dsh-liquid-glass 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 dsh-liquid-glass contributors
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,33 @@
1
+ # dsh-liquid-glass
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ **Liquid glass for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)** — one toggle, and the whole interface turns to glass.
6
+
7
+ Translucency built for DeepSeek Harness: the page base, cards, panels and chat bubbles all go see-through over your own background image, with a single slider for exactly how much glass you want. Nothing else — the best tools are the simple ones.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ dsh plugin --profile web add dsh-liquid-glass
13
+ ```
14
+
15
+ Open **Settings → General** — a **Liquid Glass** row appears. It is ON by default; restart once after install.
16
+
17
+ ## What you get
18
+
19
+ - **Full-shell transparency**: every surface the shell paints — page base, cards, panels, sidebar, chat bubbles, code blocks — goes translucent through the official ThemeRuntime token-override layer. Neutral white on the light scheme, near-black on dark.
20
+ - **One master transparency slider** (3%–95%): higher values reveal more of the background.
21
+ - **Full-page custom background**: upload a local image (auto-compressed for localStorage) or paste a URL. It spans the whole page behind the glass.
22
+
23
+ ## Uninstall
24
+
25
+ ```sh
26
+ dsh plugin --profile web remove dsh-liquid-glass
27
+ ```
28
+
29
+ Preferences live in this browser's localStorage and are left behind harmlessly.
30
+
31
+ ## License
32
+
33
+ MIT
package/README.zh.md ADDED
@@ -0,0 +1,33 @@
1
+ # dsh-liquid-glass
2
+
3
+ [English](README.md) | 中文
4
+
5
+ **[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 的液态玻璃**——点一下,整个界面通透起来。
6
+
7
+ 为 DeepSeek Harness 而生的透明质感:页面底层、卡片、面板、聊天气泡全部化为半透玻璃,衬上你选的背景图。透明度一个滑块随心调,背景图想换就换。除此之外什么都没有——好用的东西,本就该这么简单。
8
+
9
+ ## 安装
10
+
11
+ ```sh
12
+ dsh plugin --profile web add dsh-liquid-glass
13
+ ```
14
+
15
+ 打开 **设置 → 通用**,出现「液态玻璃」设置行。默认开启;装完重启一次。
16
+
17
+ ## 功能
18
+
19
+ - **全界面透明化**:页面底层、卡片、面板、侧栏、聊天气泡、代码块——所有表面经官方 ThemeRuntime token 覆盖层变成半透明。亮色方案用中性白,暗色用近黑。
20
+ - **一个透明度主滑块**(3%–95%):越大越透,背景越清晰。
21
+ - **全页自定义背景**:本地上传(自动压缩)或粘贴 URL,铺满整个页面,衬在玻璃之下。
22
+
23
+ ## 卸载
24
+
25
+ ```sh
26
+ dsh plugin --profile web remove dsh-liquid-glass
27
+ ```
28
+
29
+ 偏好保存在本浏览器 localStorage,卸载后无害残留。
30
+
31
+ ## 许可证
32
+
33
+ MIT
@@ -0,0 +1,6 @@
1
+ # dsh-liquid-glass profile patch layer: one loader entry for the plugin
2
+ # package. The browser half is picked up by dsh-client-modules through the
3
+ # package's dsh.client declaration, exactly like the shipped ui-* packages.
4
+ - insert:
5
+ - id: liquid-glass
6
+ name: 'dsh-liquid-glass'
package/lib/client.js ADDED
@@ -0,0 +1,692 @@
1
+ // dsh-liquid-glass — browser half (client plugin bundle).
2
+ //
3
+ // Loaded by dsh-client-modules at /plugins/dsh-liquid-glass/client.js and
4
+ // executed through the vendored cordis Loader's lazy-CJS module table
5
+ // (window.__ModuleLoader__.load). The factory body is plain CJS with require()
6
+ // resolved against the shell's module table — the same shape the shipped ui-*
7
+ // packages emit.
8
+ //
9
+ // What this plugin is (0.1.0): exactly two things, done well —
10
+ // 1. Liquid glass: the whole shell goes translucent (every surface token,
11
+ // including the page base) behind one master transparency slider.
12
+ // 2. A full-page custom wallpaper behind everything.
13
+ // No theme catalog, no accent colors, no packs. Preferences persist in
14
+ // localStorage, the correct boundary for third-party visual preferences (the
15
+ // Host settings wire only exposes an allowlisted namespace set to browser
16
+ // clients).
17
+ window.__ModuleLoader__.load({
18
+ id: "dsh-liquid-glass",
19
+ factory: (require) => {
20
+ var module = { exports: {} };
21
+ var exports = module.exports;
22
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
23
+ let jsx = require("react/jsx-runtime");
24
+ let _react = require("react");
25
+ let _runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
26
+
27
+
28
+ //#region constants & storage
29
+ const SETTINGS_NS = "settings.liquid-glass";
30
+ const KEY_GLASS = "dsh-liquid-glass:glass";
31
+ const KEY_ALPHA = "dsh-liquid-glass:glass-alpha";
32
+ const KEY_WALLPAPER = "dsh-liquid-glass:wallpaper";
33
+ const DEFAULT_ALPHA = 0.62;
34
+ const GLASS_SOURCE = "dsh-liquid-glass:glass";
35
+ const GLASS_CSS_ID = "dsh-liquid-glass-glass-css";
36
+ /** Glass defaults to ON: transparency is the whole point of the plugin. */
37
+ const DEFAULT_GLASS_ON = true;
38
+
39
+ function readStorage(key) {
40
+ try { return window.localStorage.getItem(key); } catch { return null; }
41
+ }
42
+ function writeStorage(key, value) {
43
+ try {
44
+ if (value === null || value === void 0) window.localStorage.removeItem(key);
45
+ else window.localStorage.setItem(key, value);
46
+ } catch { /* quota exceeded — ignore */ }
47
+ }
48
+ const readGlassOn = () => {
49
+ const raw = readStorage(KEY_GLASS);
50
+ if (raw === null) return DEFAULT_GLASS_ON;
51
+ return raw === "on";
52
+ };
53
+ const readAlpha = () => {
54
+ const raw = readStorage(KEY_ALPHA);
55
+ if (raw === null) return DEFAULT_ALPHA;
56
+ const n = Number(raw);
57
+ return Number.isFinite(n) && n > 0 ? Math.min(0.95, Math.max(0.3, n)) : DEFAULT_ALPHA;
58
+ };
59
+ const readWallpaper = () => readStorage(KEY_WALLPAPER);
60
+ //#endregion
61
+
62
+ //#region color utils
63
+ function hexToRgb(hex) {
64
+ const m = /^#?([0-9a-f]{6})$/i.exec(String(hex).trim());
65
+ if (!m) return null;
66
+ const n = parseInt(m[1], 16);
67
+ return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };
68
+ }
69
+ function toRgba(hex, alpha) {
70
+ const rgb = hexToRgb(hex);
71
+ if (!rgb) return hex;
72
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
73
+ }
74
+ //#endregion
75
+
76
+ //#region locale
77
+ const zh = {
78
+ "row.title": "液态玻璃",
79
+ "row.subtitle": "由 Liquid Glass 提供 · 全界面透明化 + 自定义背景图",
80
+ "glass.toggle": "启用玻璃质感",
81
+ "glass.alpha": "透明度",
82
+ "glass.hint": "透明度越大越透,背景越清晰。",
83
+ "wallpaper.title": "背景图",
84
+ "wallpaper.choose": "选择图片…",
85
+ "wallpaper.upload": "点击上传背景图",
86
+ "wallpaper.formats": "支持 JPG / PNG / WebP / GIF",
87
+ "wallpaper.badType": "仅支持 JPG / PNG / WebP / GIF 格式的图片",
88
+ "wallpaper.urlPlaceholder": "或粘贴图片 URL",
89
+ "wallpaper.remove": "移除背景",
90
+ "wallpaper.replace": "更换背景",
91
+ "wallpaper.previewHint": "点击图片全屏预览",
92
+ "wallpaper.save": "保存",
93
+ "wallpaper.unsaved": "有未保存的更改",
94
+ "wallpaper.badUrl": "图片链接加载失败,请检查后重试",
95
+ "wallpaper.checking": "校验中…",
96
+ "wallpaper.hint": "背景铺满整个页面,保存在本浏览器;过大的图片会自动压缩。"
97
+ };
98
+ const en = {
99
+ "row.title": "Liquid Glass",
100
+ "row.subtitle": "Powered by Liquid Glass · full-shell transparency + custom background",
101
+ "glass.toggle": "Enable glassmorphism",
102
+ "glass.alpha": "Opacity",
103
+ "glass.hint": "Higher transparency reveals more of the background.",
104
+ "wallpaper.title": "Background",
105
+ "wallpaper.choose": "Choose image…",
106
+ "wallpaper.upload": "Click to upload a background",
107
+ "wallpaper.formats": "JPG / PNG / WebP / GIF",
108
+ "wallpaper.badType": "Only JPG / PNG / WebP / GIF images are supported",
109
+ "wallpaper.urlPlaceholder": "…or paste an image URL",
110
+ "wallpaper.remove": "Remove background",
111
+ "wallpaper.replace": "Replace",
112
+ "wallpaper.previewHint": "Click image to preview fullscreen",
113
+ "wallpaper.save": "Save",
114
+ "wallpaper.unsaved": "Unsaved changes",
115
+ "wallpaper.badUrl": "Image failed to load from this URL. Please check and retry.",
116
+ "wallpaper.checking": "Checking…",
117
+ "wallpaper.hint": "The background spans the whole page and stays in this browser; large images are compressed automatically."
118
+ };
119
+ //#endregion
120
+
121
+ //#region wallpaper layer (full-page background)
122
+ let wallpaperEl = null;
123
+
124
+ function applyWallpaper() {
125
+ const url = readWallpaper();
126
+ if (url === null) {
127
+ wallpaperEl?.remove();
128
+ wallpaperEl = null;
129
+ return;
130
+ }
131
+ if (wallpaperEl === null || !document.body.contains(wallpaperEl)) {
132
+ wallpaperEl = document.createElement("div");
133
+ wallpaperEl.style.cssText = "position:fixed;inset:0;z-index:-1;pointer-events:none;background-size:cover;background-position:center;background-repeat:no-repeat;";
134
+ document.body.prepend(wallpaperEl);
135
+ }
136
+ wallpaperEl.style.backgroundImage = `url("${url}")`;
137
+ }
138
+
139
+ function teardownWallpaper() {
140
+ wallpaperEl?.remove();
141
+ wallpaperEl = null;
142
+ }
143
+
144
+ /** Downscale an image to a JPEG data URL (localStorage quota friendly). */
145
+ function compressImage(image, maxSide, quality) {
146
+ const scale = Math.min(1, maxSide / Math.max(image.width, image.height));
147
+ const canvas = document.createElement("canvas");
148
+ canvas.width = Math.max(1, Math.round(image.width * scale));
149
+ canvas.height = Math.max(1, Math.round(image.height * scale));
150
+ const context = canvas.getContext("2d");
151
+ context.drawImage(image, 0, 0, canvas.width, canvas.height);
152
+ return canvas.toDataURL("image/jpeg", quality);
153
+ }
154
+ //#endregion
155
+
156
+ //#region liquid glass layer
157
+ /**
158
+ * Every surface token the shell paints, page base included, goes
159
+ * translucent so the wallpaper shows through everywhere. Neutral white
160
+ * on light scheme, near-black on dark — the classic frosted-glass recipe.
161
+ */
162
+ const GLASS_TOKENS = [
163
+ "--dsw-alias-bg-base",
164
+ "--dsw-alias-bg-layer-1",
165
+ "--dsw-alias-bg-layer-2",
166
+ "--dsw-alias-bg-layer-3",
167
+ "--dsw-alias-bg-overlay",
168
+ "--dsw-specific-sidebar-fill",
169
+ "--dsw-alias-markdown-code-block",
170
+ "--dsw-alias-markdown-inline-code"
171
+ ];
172
+ const LIGHT_SURFACE = "#ffffff";
173
+ const DARK_SURFACE = "#151517";
174
+
175
+ let glassDispose = null;
176
+
177
+ function glassCss() {
178
+ // Transparency only — no backdrop-filter. It created containing-block
179
+ // side effects that broke the settings dialog, and its value did not
180
+ // justify the complexity. The glass look comes from the translucent
181
+ // surface tokens plus the neutralized body background.
182
+ return [
183
+ "/* dsh-liquid-glass liquid glass */",
184
+ "body{background-color:transparent !important;}",
185
+ "body > *{background-color:transparent !important;}"
186
+ ].join("\n");
187
+ }
188
+
189
+ let applyingGlass = false;
190
+
191
+ function applyGlass(ctx) {
192
+ if (applyingGlass) return;
193
+ applyingGlass = true;
194
+ try { applyGlassInner(ctx); } finally { applyingGlass = false; }
195
+ }
196
+
197
+ function applyGlassInner(ctx) {
198
+ teardownGlass();
199
+ if (!readGlassOn()) return;
200
+ const alpha = readAlpha();
201
+ const overrides = {};
202
+ for (const key of GLASS_TOKENS) {
203
+ overrides[key] = {
204
+ light: toRgba(LIGHT_SURFACE, alpha),
205
+ dark: toRgba(DARK_SURFACE, alpha)
206
+ };
207
+ }
208
+ glassDispose = ctx.theme.overrideTokens(GLASS_SOURCE, overrides);
209
+ const style = document.createElement("style");
210
+ style.id = GLASS_CSS_ID;
211
+ style.setAttribute("data-plugin-css", "dsh-liquid-glass");
212
+ style.textContent = glassCss();
213
+ document.head.appendChild(style);
214
+ }
215
+
216
+ function teardownGlass() {
217
+ glassDispose?.();
218
+ glassDispose = null;
219
+ document.getElementById(GLASS_CSS_ID)?.remove();
220
+ }
221
+ //#endregion
222
+
223
+ //#region store
224
+ function createGlassStore() {
225
+ return (0, _runtime_client.defineStore)({
226
+ init: () => ({
227
+ on: DEFAULT_GLASS_ON,
228
+ alpha: DEFAULT_ALPHA,
229
+ wallpaper: null,
230
+ revision: -1
231
+ }),
232
+ actions: {
233
+ sync: (d, on, alpha, wallpaper, revision) => {
234
+ if (revision <= d.revision) return;
235
+ d.on = on;
236
+ d.alpha = alpha;
237
+ d.wallpaper = wallpaper;
238
+ d.revision = revision;
239
+ }
240
+ }
241
+ });
242
+ }
243
+ //#endregion
244
+
245
+ //#region styles
246
+ const styles = {
247
+ group: {
248
+ borderBottom: "1px solid var(--dsw-alias-border-l2)",
249
+ display: "flex",
250
+ flexDirection: "column",
251
+ gap: "10px",
252
+ padding: "16px 0"
253
+ },
254
+ title: { color: "var(--dsw-alias-label-primary)", fontSize: "14px", fontWeight: 400, lineHeight: "22px" },
255
+ subtitle: { color: "var(--dsw-alias-label-tertiary)", fontSize: "12px", lineHeight: "18px" },
256
+ hint: { color: "var(--dsw-alias-label-tertiary)", fontSize: "12px", lineHeight: "18px" },
257
+ sectionLabel: { color: "var(--dsw-alias-label-secondary)", fontSize: "12px", lineHeight: "18px", marginTop: "4px" },
258
+ row: { display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" },
259
+ sliderRow: { display: "flex", alignItems: "center", gap: "10px" },
260
+ sliderLabel: { color: "var(--dsw-alias-label-secondary)", fontSize: "12px", width: "72px", flexShrink: 0 },
261
+ slider: { flex: 1, minWidth: "120px" },
262
+ sliderValue: { color: "var(--dsw-alias-label-tertiary)", fontSize: "12px", width: "40px", textAlign: "right" },
263
+ button: {
264
+ padding: "5px 12px",
265
+ borderRadius: "8px",
266
+ border: "1px solid var(--dsw-alias-border-l2)",
267
+ background: "var(--dsw-alias-bg-layer-1)",
268
+ color: "var(--dsw-alias-label-primary)",
269
+ fontSize: "12px",
270
+ cursor: "pointer",
271
+ font: "inherit"
272
+ },
273
+ textInput: {
274
+ flex: 1,
275
+ minWidth: "180px",
276
+ padding: "5px 10px",
277
+ borderRadius: "8px",
278
+ border: "1px solid var(--dsw-alias-border-l2)",
279
+ background: "var(--dsw-alias-bg-layer-1)",
280
+ color: "var(--dsw-alias-label-primary)",
281
+ fontSize: "12px",
282
+ font: "inherit",
283
+ boxSizing: "border-box"
284
+ },
285
+ checkLabel: { display: "flex", alignItems: "center", gap: "6px", cursor: "pointer", color: "var(--dsw-alias-label-primary)", fontSize: "12px" },
286
+ headerRow: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "10px" },
287
+ previewWrap: {
288
+ position: "relative",
289
+ borderRadius: "10px",
290
+ overflow: "hidden",
291
+ border: "1px solid var(--dsw-alias-border-l1)",
292
+ width: "140px",
293
+ aspectRatio: "16 / 9",
294
+ background: "var(--dsw-alias-bg-layer-1)",
295
+ flexShrink: 0,
296
+ cursor: "zoom-in"
297
+ },
298
+ previewImage: {
299
+ position: "absolute",
300
+ inset: 0,
301
+ backgroundSize: "cover",
302
+ backgroundPosition: "center",
303
+ backgroundRepeat: "no-repeat"
304
+ },
305
+ actionRow: { display: "flex", gap: "8px", marginTop: "6px" },
306
+ actionButton: {
307
+ padding: "4px 10px",
308
+ borderRadius: "8px",
309
+ border: "1px solid var(--dsw-alias-border-l2)",
310
+ background: "transparent",
311
+ color: "var(--dsw-alias-label-secondary)",
312
+ fontSize: "12px",
313
+ lineHeight: "18px",
314
+ cursor: "pointer",
315
+ font: "inherit"
316
+ },
317
+ actionButtonDanger: {
318
+ padding: "4px 10px",
319
+ borderRadius: "8px",
320
+ border: "1px solid rgba(229, 72, 77, 0.45)",
321
+ background: "transparent",
322
+ color: "#e5484d",
323
+ fontSize: "12px",
324
+ lineHeight: "18px",
325
+ cursor: "pointer",
326
+ font: "inherit"
327
+ },
328
+ buttonColumn: { display: "flex", flexDirection: "column", gap: "6px", justifyContent: "flex-start" },
329
+ uploadBox: {
330
+ width: "200px",
331
+ aspectRatio: "16 / 9",
332
+ borderRadius: "10px",
333
+ border: "1.5px dashed var(--dsw-alias-border-l2)",
334
+ background: "var(--dsw-alias-bg-layer-1)",
335
+ display: "flex",
336
+ flexDirection: "column",
337
+ alignItems: "center",
338
+ justifyContent: "center",
339
+ gap: "4px",
340
+ cursor: "pointer",
341
+ font: "inherit",
342
+ padding: 0
343
+ },
344
+ uploadPlus: { fontSize: "22px", lineHeight: "1", color: "var(--dsw-alias-label-tertiary)" },
345
+ uploadText: { fontSize: "12px", color: "var(--dsw-alias-label-tertiary)" },
346
+ saveButton: {
347
+ padding: "4px 10px",
348
+ borderRadius: "8px",
349
+ border: "none",
350
+ background: "#4d6bfe",
351
+ color: "#ffffff",
352
+ fontSize: "12px",
353
+ lineHeight: "18px",
354
+ cursor: "pointer",
355
+ font: "inherit"
356
+ },
357
+ saveButtonDisabled: {
358
+ padding: "4px 10px",
359
+ borderRadius: "8px",
360
+ border: "none",
361
+ background: "var(--dsw-alias-bg-layer-2)",
362
+ color: "var(--dsw-alias-label-tertiary)",
363
+ fontSize: "12px",
364
+ lineHeight: "18px",
365
+ cursor: "default",
366
+ font: "inherit"
367
+ },
368
+ dirtyHint: { color: "#e5484d", fontSize: "12px", lineHeight: "18px" },
369
+ lightboxOverlay: {
370
+ position: "fixed",
371
+ inset: 0,
372
+ background: "rgba(0, 0, 0, 0.85)",
373
+ zIndex: 99999,
374
+ display: "flex",
375
+ alignItems: "center",
376
+ justifyContent: "center",
377
+ cursor: "zoom-out"
378
+ },
379
+ lightboxImage: {
380
+ maxWidth: "92vw",
381
+ maxHeight: "92vh",
382
+ objectFit: "contain",
383
+ borderRadius: "8px",
384
+ boxShadow: "0 8px 64px rgba(0, 0, 0, 0.5)"
385
+ }
386
+ };
387
+
388
+ function Slider({ label, value, min, max, step, format, onChange }) {
389
+ return (0, jsx.jsxs)("div", {
390
+ style: styles.sliderRow,
391
+ children: [
392
+ (0, jsx.jsx)("span", { style: styles.sliderLabel, children: label }),
393
+ (0, jsx.jsx)("input", { type: "range", min, max, step, value, style: styles.slider, onChange: (e) => onChange(Number(e.target.value)) }),
394
+ (0, jsx.jsx)("span", { style: styles.sliderValue, children: format(value) })
395
+ ]
396
+ });
397
+ }
398
+ //#endregion
399
+
400
+ //#region component
401
+ /** Toggle switch, plain inline styles. */
402
+ function Toggle({ checked, onChange }) {
403
+ return (0, jsx.jsx)("button", {
404
+ type: "button",
405
+ role: "switch",
406
+ "aria-checked": checked,
407
+ onClick: () => onChange(!checked),
408
+ style: {
409
+ width: "40px",
410
+ height: "22px",
411
+ borderRadius: "11px",
412
+ border: "none",
413
+ background: checked ? "var(--dsw-alias-brand-primary)" : "var(--dsw-alias-bg-layer-3)",
414
+ border: checked ? "1px solid transparent" : "1px solid var(--dsw-alias-border-l2)",
415
+ position: "relative",
416
+ cursor: "pointer",
417
+ padding: 0,
418
+ flexShrink: 0,
419
+ transition: "background 0.2s",
420
+ font: "inherit",
421
+ boxSizing: "border-box"
422
+ },
423
+ children: (0, jsx.jsx)("span", {
424
+ style: {
425
+ position: "absolute",
426
+ top: "2px",
427
+ left: checked ? "20px" : "2px",
428
+ width: "18px",
429
+ height: "18px",
430
+ borderRadius: "50%",
431
+ background: "#ffffff",
432
+ boxShadow: "0 1px 3px rgba(0, 0, 0, 0.3)",
433
+ transition: "left 0.2s"
434
+ }
435
+ })
436
+ });
437
+ }
438
+
439
+ /** Read a picked image file, compress it, and hand back a data URL. */
440
+ const ACCEPTED_IMAGE_TYPES = /^image\/(jpeg|png|webp|gif)$/;
441
+
442
+ function pickImageFile(file, onReady, onError) {
443
+ if (!file) return;
444
+ if (!ACCEPTED_IMAGE_TYPES.test(file.type)) {
445
+ onError?.(file.type || "unknown");
446
+ return;
447
+ }
448
+ const reader = new FileReader();
449
+ reader.onload = () => {
450
+ const img = new Image();
451
+ img.onload = () => onReady(compressImage(img, 1920, 0.85));
452
+ img.src = String(reader.result);
453
+ };
454
+ reader.readAsDataURL(file);
455
+ }
456
+
457
+ /**
458
+ * Wallpaper preview card: shows the full image, and on hover reveals a
459
+ * dimmed overlay with Replace / Remove actions — the standard image
460
+ * picker pattern. Replacing via URL stays available in the row below.
461
+ */
462
+ function WallpaperSection({ url, onApply, t }) {
463
+ const draftState = _react.useState(url);
464
+ const draft = draftState[0];
465
+ const setDraft = draftState[1];
466
+ const urlTextState = _react.useState(typeof url === "string" && /^https?:/i.test(url) ? url : "");
467
+ const urlText = urlTextState[0];
468
+ const setUrlText = urlTextState[1];
469
+ const lightboxState = _react.useState(false);
470
+ const lightbox = lightboxState[0];
471
+ const setLightbox = lightboxState[1];
472
+ const checkingState = _react.useState(false);
473
+ const checking = checkingState[0];
474
+ const setChecking = checkingState[1];
475
+ const errorState = _react.useState("");
476
+ const error = errorState[0];
477
+ const setError = errorState[1];
478
+ const fileRef = _react.useRef(null);
479
+ // Re-sync the draft whenever the applied wallpaper changes externally.
480
+ _react.useEffect(() => {
481
+ setDraft(url);
482
+ setUrlText(typeof url === "string" && /^https?:/i.test(url) ? url : "");
483
+ setError("");
484
+ }, [url]);
485
+ _react.useEffect(() => {
486
+ if (!lightbox) return void 0;
487
+ const onKey = (e) => { if (e.key === "Escape") setLightbox(false); };
488
+ window.addEventListener("keydown", onKey);
489
+ return () => window.removeEventListener("keydown", onKey);
490
+ }, [lightbox]);
491
+ const dirty = draft !== url;
492
+ const handleSave = () => {
493
+ if (!dirty || checking) return;
494
+ setError("");
495
+ // Local data-URLs always load; remote URLs get a load pre-check so
496
+ // a bad link is rejected with a hint instead of a blank wallpaper.
497
+ if (draft && /^https?:/i.test(draft)) {
498
+ setChecking(true);
499
+ const probe = new Image();
500
+ probe.onload = () => { setChecking(false); onApply(draft); };
501
+ probe.onerror = () => { setChecking(false); setError(t("wallpaper.badUrl")); };
502
+ probe.src = draft;
503
+ } else {
504
+ onApply(draft);
505
+ }
506
+ };
507
+ const saveButton = (0, jsx.jsx)("button", {
508
+ type: "button",
509
+ style: dirty && !checking ? styles.saveButton : styles.saveButtonDisabled,
510
+ disabled: !dirty || checking,
511
+ onClick: handleSave,
512
+ children: checking ? t("wallpaper.checking") : t("wallpaper.save")
513
+ });
514
+ return (0, jsx.jsxs)("div", {
515
+ children: [
516
+ (0, jsx.jsxs)("div", {
517
+ style: { display: "flex", alignItems: "flex-start", gap: "10px" },
518
+ children: [
519
+ draft !== null && (0, jsx.jsx)("div", {
520
+ style: styles.previewWrap,
521
+ title: t("wallpaper.previewHint"),
522
+ onClick: () => setLightbox(true),
523
+ children: (0, jsx.jsx)("div", { style: { ...styles.previewImage, backgroundImage: `url("${draft}")` } })
524
+ }),
525
+ draft === null && (0, jsx.jsxs)("button", {
526
+ type: "button",
527
+ style: styles.uploadBox,
528
+ onClick: () => fileRef.current?.click(),
529
+ children: [
530
+ (0, jsx.jsx)("span", { style: styles.uploadPlus, children: "+" }),
531
+ (0, jsx.jsx)("span", { style: styles.uploadText, children: t("wallpaper.upload") }),
532
+ (0, jsx.jsx)("span", { style: styles.uploadText, children: t("wallpaper.formats") })
533
+ ]
534
+ }),
535
+ draft !== null && (0, jsx.jsxs)("div", {
536
+ style: styles.buttonColumn,
537
+ children: [
538
+ (0, jsx.jsx)("button", {
539
+ type: "button",
540
+ style: styles.actionButton,
541
+ onClick: () => fileRef.current?.click(),
542
+ children: t("wallpaper.replace")
543
+ }),
544
+ (0, jsx.jsx)("button", {
545
+ type: "button",
546
+ style: styles.actionButtonDanger,
547
+ onClick: () => { setDraft(null); setUrlText(""); setError(""); },
548
+ children: t("wallpaper.remove")
549
+ })
550
+ ]
551
+ })
552
+ ]
553
+ }),
554
+ (0, jsx.jsx)("input", {
555
+ ref: fileRef,
556
+ type: "file",
557
+ accept: "image/jpeg,image/png,image/webp,image/gif",
558
+ style: { display: "none" },
559
+ onChange: (e) => {
560
+ pickImageFile(
561
+ e.target.files?.[0],
562
+ (dataUrl) => { setDraft(dataUrl); setUrlText(""); setError(""); },
563
+ () => setError(t("wallpaper.badType"))
564
+ );
565
+ e.target.value = "";
566
+ }
567
+ }),
568
+ (0, jsx.jsxs)("div", {
569
+ style: { display: "flex", gap: "8px", marginTop: "6px", alignItems: "center" },
570
+ children: [
571
+ (0, jsx.jsx)("input", {
572
+ style: styles.textInput,
573
+ placeholder: t("wallpaper.urlPlaceholder"),
574
+ value: urlText,
575
+ onChange: (e) => {
576
+ const value = e.target.value;
577
+ setUrlText(value);
578
+ setError("");
579
+ setDraft(value.trim() === "" ? null : value.trim());
580
+ }
581
+ }),
582
+ saveButton
583
+ ]
584
+ }),
585
+ error !== "" && (0, jsx.jsx)("div", { style: styles.dirtyHint, children: error }),
586
+ error === "" && dirty && (0, jsx.jsx)("div", { style: styles.dirtyHint, children: t("wallpaper.unsaved") }),
587
+ lightbox && (0, jsx.jsx)("div", {
588
+ style: styles.lightboxOverlay,
589
+ onClick: () => setLightbox(false),
590
+ children: (0, jsx.jsx)("img", { src: draft, style: styles.lightboxImage, alt: "" })
591
+ })
592
+ ]
593
+ });
594
+ }
595
+
596
+ /** The single settings row: glass toggle, sliders, background picker. */
597
+ function GlassRow({ t, useStore, setGlass, setAlpha, setWallpaper }) {
598
+ const on = useStore((s) => s.on);
599
+ const alpha = useStore((s) => s.alpha);
600
+ const wallpaper = useStore((s) => s.wallpaper);
601
+ return (0, jsx.jsxs)("div", {
602
+ style: styles.group,
603
+ children: [
604
+ (0, jsx.jsxs)("div", {
605
+ style: styles.headerRow,
606
+ children: [
607
+ (0, jsx.jsx)("div", { style: styles.title, children: t("row.title") }),
608
+ (0, jsx.jsx)(Toggle, { checked: on, onChange: (v) => setGlass(v) })
609
+ ]
610
+ }),
611
+ 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 }),
613
+ on && (0, jsx.jsx)("div", { style: styles.hint, children: t("glass.hint") }),
614
+ on && (0, jsx.jsx)("div", { style: styles.sectionLabel, children: t("wallpaper.title") }),
615
+ on && (0, jsx.jsx)(WallpaperSection, {
616
+ url: wallpaper,
617
+ onApply: (value) => setWallpaper(value),
618
+ t
619
+ }),
620
+ on && (0, jsx.jsx)("div", { style: styles.hint, children: t("wallpaper.hint") })
621
+ ]
622
+ });
623
+ }
624
+ //#endregion
625
+
626
+ //#region plugin body
627
+ const inject = ["slots", "locale", "theme"];
628
+
629
+ function apply(ctx) {
630
+ const store = createGlassStore();
631
+ let bound;
632
+ let revision = 0;
633
+ const sync = () => {
634
+ revision += 1;
635
+ bound?.sync(readGlassOn(), readAlpha(), readWallpaper(), revision);
636
+ };
637
+
638
+ applyWallpaper();
639
+ applyGlass(ctx);
640
+ sync();
641
+
642
+ // A ThemeRuntime rebuild can drop our override layer; re-apply on
643
+ // every theme change event. Surfaces are neutral per scheme, so no
644
+ // re-tinting is needed here.
645
+ ctx.on("theme/change", () => {
646
+ if (readGlassOn()) applyGlass(ctx);
647
+ });
648
+
649
+ ctx.effect(() => () => { teardownGlass(); teardownWallpaper(); }, "liquid-glass: cleanup");
650
+ ctx.effect(() => ctx.locale.register(SETTINGS_NS, { zh, en }), "liquid-glass: dictionaries");
651
+
652
+ const injected = (actions) => {
653
+ bound = actions;
654
+ sync();
655
+ return {
656
+ setGlass: (on) => {
657
+ writeStorage(KEY_GLASS, on ? "on" : "off");
658
+ applyGlass(ctx);
659
+ sync();
660
+ },
661
+ setAlpha: (percent) => {
662
+ // UI speaks "transparency %" (bigger = more see-through);
663
+ // the surface token alpha is the inverse (1 - t/100).
664
+ const alpha = Math.min(0.95, Math.max(0.05, 1 - percent / 100));
665
+ writeStorage(KEY_ALPHA, String(alpha));
666
+ applyGlass(ctx);
667
+ sync();
668
+ },
669
+ setWallpaper: (url) => {
670
+ writeStorage(KEY_WALLPAPER, url);
671
+ applyWallpaper();
672
+ sync();
673
+ }
674
+ };
675
+ };
676
+ const slotResult = ctx.slots.inject("settings.general.item", () => ctx.slots.register({
677
+ name: "settings.general.item",
678
+ id: "liquid-glass",
679
+ order: 20,
680
+ store,
681
+ locale: SETTINGS_NS,
682
+ inject: injected
683
+ }, GlassRow));
684
+ }
685
+ //#endregion
686
+
687
+ exports.SETTINGS_NS = SETTINGS_NS;
688
+ exports.apply = apply;
689
+ exports.inject = inject;
690
+ return module.exports;
691
+ }
692
+ });
package/lib/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * dsh-liquid-glass — host half.
3
+ *
4
+ * Intentionally a no-op loader entry: the whole feature lives in the browser
5
+ * half (`./client`), which dsh-client-modules picks up through the package's
6
+ * `dsh.client` declaration. All preferences persist in localStorage because
7
+ * the Host settings wire only exposes an allowlisted set of namespaces to
8
+ * browser clients, so a third-party namespace would answer
9
+ * `settings-not-exposed`; visual preferences belong to the browser anyway.
10
+ */
11
+
12
+ /** Host loader entry for the browser implementation exported from `./client`. */
13
+ export function apply() {}
@@ -0,0 +1,3 @@
1
+ export declare const SETTINGS_NS: string;
2
+ export declare function apply(ctx: unknown): void;
3
+ export declare const inject: string[];
@@ -0,0 +1,2 @@
1
+ /** Host loader entry — intentionally a no-op; the feature lives in `./client`. */
2
+ export declare function apply(): void;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "dsh-liquid-glass",
3
+ "version": "0.1.0",
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
+ "license": "MIT",
6
+ "author": "Ultronen",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Ultronen/dsh-liquid-glass.git"
10
+ },
11
+ "homepage": "https://github.com/Ultronen/dsh-liquid-glass",
12
+ "bugs": {
13
+ "url": "https://github.com/Ultronen/dsh-liquid-glass/issues"
14
+ },
15
+ "keywords": [
16
+ "deepseek-harness",
17
+ "dsh",
18
+ "dsh-plugin",
19
+ "theme",
20
+ "skin",
21
+ "wallpaper",
22
+ "web-ui"
23
+ ],
24
+ "type": "module",
25
+ "main": "lib/index.js",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./lib/types/index.d.ts",
29
+ "default": "./lib/index.js"
30
+ },
31
+ "./client": {
32
+ "types": "./lib/types/client/index.d.ts",
33
+ "default": "./lib/client.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "lib/index.js",
39
+ "lib/client.js",
40
+ "lib/types",
41
+ "cordis.patch.yml"
42
+ ],
43
+ "dsh": {
44
+ "bundle": {
45
+ "patch": "./cordis.patch.yml"
46
+ },
47
+ "client": {
48
+ "inject": [
49
+ "@deepseek-ai/dsh-client-runtime",
50
+ "@deepseek-ai/dsh-client-locale",
51
+ "@deepseek-ai/dsh-client-ui-theme"
52
+ ],
53
+ "platform": "web",
54
+ "immediately": true
55
+ }
56
+ },
57
+ "peerDependencies": {
58
+ "react": "^18.2.0",
59
+ "@deepseek-ai/cordis": "^4.0.1"
60
+ }
61
+ }