dsh-liquid-glass 0.4.2 → 0.5.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 CHANGED
@@ -8,7 +8,7 @@ English | [中文](README.zh.md)
8
8
 
9
9
  **Theme backgrounds for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)** — translucent surfaces with image or local video backgrounds.
10
10
 
11
- Translucent theme surfaces and scoped frosted menus over your own background image, with material presets, tint, wallpaper controls, and system accessibility response. Current version: **0.4.2**. A community plugin that reuses the host’s official controls where available.
11
+ Translucent theme surfaces and scoped frosted menus over your own background image, with material presets, tint, wallpaper controls, and system accessibility response. Current version: **0.5.0**. A community plugin that reuses the host’s official controls where available.
12
12
 
13
13
  Settings cards and list outlines retain the Host theme's border colors, including custom light and dark themes.
14
14
 
@@ -18,9 +18,9 @@ Settings cards and list outlines retain the Host theme's border colors, includin
18
18
  dsh plugin --profile web add dsh-liquid-glass
19
19
  ```
20
20
 
21
- Run the command in a terminal. In the app’s Add plugin field, enter only `dsh-liquid-glass`.
21
+ Run the command in a terminal. In the app’s Add plugin field, enter `dsh-liquid-glass@0.5.0`.
22
22
 
23
- Open **Settings → General → Theme background**, immediately below Appearance. Expand the official chevron for basic options; advanced options remain collapsed. The switch controls glass and image/video backgrounds together, retaining preferences when disabled. Restart the host after upgrading. Enter `dsh-liquid-glass@0.4.2` in the app’s plugin field, not the full terminal command.
23
+ Open **Settings → General → Theme background**, immediately below Appearance. Expand the official chevron for basic options; advanced options remain collapsed. The switch controls glass and image/video backgrounds together, retaining preferences when disabled. Restart the host after upgrading. Enter `dsh-liquid-glass@0.5.0` in the app’s plugin field, not the full terminal command.
24
24
 
25
25
  ## Screenshots
26
26
 
@@ -44,6 +44,7 @@ Captured from the actual package in official DSH 0.2.2-rc.2 Web, using original
44
44
  - **Local video backgrounds**: select MP4/WebM up to 100 MiB, with a browser-supported codec. Validated files preview immediately and are saved locally only after Save; playback loops muted; pause, resume and removal are available. Hidden pages and reduced-motion preferences pause playback. No video URLs, audio or playlists.
45
45
  - **Visual cards**: three material previews and one permanent image/video uploader, with click or drag-and-drop selection. Replace and red remove controls sit over the thumbnail; no separate filename or media-description row.
46
46
  - **Background drafts**: add, replace or remove to preview immediately; Save commits the selection. Closing settings, switching menus or collapsing the section prompts Save and leave, Discard changes or Keep editing. Discard restores the saved background.
47
+ - **Wallpaper rotation**: keep several saved image or video backgrounds in a rotation pool and cycle through them in order or at random — on every open, hourly, daily, or by time of day (morning/afternoon/evening/night). Off by default; turning it off restores the single background. Pool images share the browser's local storage budget; rotation is evaluated when the app opens.
47
48
  - **Compact defaults**: presets, transparency and background selection; tint, frost, fit and reading protection live under Advanced. Reset preserves the background and master switch.
48
49
 
49
50
  - **Theme surface transparency** through the official ThemeRuntime tokens, with a 3%–95% transparency slider.
@@ -55,6 +56,10 @@ Captured from the actual package in official DSH 0.2.2-rc.2 Web, using original
55
56
 
56
57
  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). See [0.4.0 validation](docs/v0.4.0-validation.md) for the 0.4.0 feature baseline.
57
58
 
59
+ ## Share appearance settings
60
+
61
+ Use **Export settings** and **Import settings** in the Theme background panel to share a versioned JSON file. Review the presets, rotation pool, and missing media before applying. Cancelling keeps the previous appearance. Unavailable local media is skipped and the current background is retained if the selected reference is missing. The file contains compatible wallpaper references and metadata, with local image and video bytes and URLs with query parameters excluded.
62
+
58
63
  ## Privacy and compatibility
59
64
 
60
65
  The host has no public settings leave-guard API. Unsaved-change protection uses a small adapter for the 0.2.2-rc.2 settings structure and needs regression checks after host updates.
package/README.zh.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  **[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 的主题背景插件**:调整界面通透效果,设置图片或视频背景。
10
10
 
11
- 通过官方主题接口提供表面透明化、弹出菜单模糊、自定义壁纸、质感预设、色调和系统无障碍响应。当前版本 **0.4.2**。社区插件,界面尽量复用宿主提供的官方组件。
11
+ 通过官方主题接口提供表面透明化、弹出菜单模糊、自定义壁纸、质感预设、色调和系统无障碍响应。当前版本 **0.5.0**。社区插件,界面尽量复用宿主提供的官方组件。
12
12
 
13
13
  设置卡片与列表描边保留宿主主题的边框颜色,包括自定义的浅色与深色主题。
14
14
 
@@ -18,9 +18,9 @@
18
18
  dsh plugin --profile web add dsh-liquid-glass
19
19
  ```
20
20
 
21
- 终端中运行上面的命令;如果使用应用的「添加插件」输入框,只填 `dsh-liquid-glass`。
21
+ 终端中运行上面的命令;如果使用应用的「添加插件」输入框,填写 `dsh-liquid-glass@0.5.0`。
22
22
 
23
- 入口为 **设置 → 通用 → 外观下方的「主题背景」**,默认折叠。点击官方箭头展开基础选项;高级选项再次折叠。开关同时控制透明效果和图片/视频背景,关闭不丢失偏好。升级后重启宿主。应用内安装框填写 `dsh-liquid-glass@0.4.2`,不要粘贴完整终端命令。
23
+ 入口为 **设置 → 通用 → 外观下方的「主题背景」**,默认折叠。点击官方箭头展开基础选项;高级选项再次折叠。开关同时控制透明效果和图片/视频背景,关闭不丢失偏好。升级后重启宿主。应用内安装框填写 `dsh-liquid-glass@0.5.0`,不要粘贴完整终端命令。
24
24
 
25
25
  ## 截图
26
26
 
@@ -44,6 +44,7 @@ dsh plugin --profile web add dsh-liquid-glass
44
44
  - **本地视频背景**:选择 MP4/WebM(不超过 100 MiB,需浏览器支持对应编码)验证后立即预览,点击“保存”后写入本地;静音循环,可暂停/播放、移除。页面不可见或系统启用“减少动态效果”时自动暂停。暂不支持视频 URL、声音、播放列表。
45
45
  - **卡片式选择**:三张质感预览卡片;图片和视频共用常驻上传卡片,支持点击或拖放。更换和红色移除按钮位于缩略图浮层内,不再额外显示文件名或媒体描述。
46
46
  - **背景草稿**:添加、更换和移除立即预览,点击“保存”才持久化。关闭设置、切换菜单或收起主题背景时,有未保存更改会弹出“保存并离开/放弃更改/继续编辑”;放弃会恢复已保存背景。
47
+ - **壁纸轮换**:把多张已保存的图片或视频背景放进轮换池,按顺序或随机轮换——每次打开、每小时、每天或按时段(早/午/晚/夜)。默认关闭;关闭后恢复单个背景。池内图片共用浏览器本地存储空间;轮换在每次打开应用时判断。
47
48
  - **精简默认界面**:仅展开预设、透明度和背景选择;色调、弹出菜单模糊、背景适配与阅读保护放在高级设置。恢复效果默认值保留背景和总开关。
48
49
 
49
50
  - **主题表面透明化**:经官方 ThemeRuntime token 覆盖层生效,透明度主滑块范围为 3%–95%。
@@ -55,6 +56,10 @@ dsh plugin --profile web add dsh-liquid-glass
55
56
 
56
57
  人/助手独立消息不透明度下限,以及任意宿主面板的磨砂/内侧高光,因缺少已核实的官方扩展接口而未实现。参见[本地 API 证据与验证限制](docs/v0.2.0-local-evidence.md)。0.4.0 功能基线的验证记录见 [0.4.0 验证](docs/v0.4.0-validation.md)。
57
58
 
59
+ ## 分享外观设置
60
+
61
+ 在「主题背景」面板用 **导出设置** 和 **导入设置** 分享带版本的 JSON。应用前可预览预设、轮换池和缺失的媒体。取消会保留原外观。设备上缺失的媒体会跳过,找不到所选背景时会保留当前背景。文件包含可兼容的壁纸引用和元数据,本地图片/视频内容和带查询参数的链接不会写入。
62
+
58
63
  ## 隐私与兼容性
59
64
 
60
65
  - 偏好和图片保存在当前站点的 `localStorage`,视频 Blob 保存在 IndexedDB 中;不同浏览器或站点不共享,清除站点数据会删除保存的视频;插件没有服务端组件,也不发送遥测数据。
package/lib/client.js CHANGED
@@ -108,21 +108,100 @@ window.__ModuleLoader__.load({
108
108
  return true;
109
109
  } catch { return false; }
110
110
  }
111
- function wallpaperFitsStorage(value) {
111
+ function storageFitsExcept(exceptKey, extraLength) {
112
112
  try {
113
113
  const storage = window.localStorage;
114
114
  let used = 0;
115
115
  for (let i = 0; i < storage.length; i++) {
116
116
  const key = storage.key(i);
117
- // Replacing the wallpaper frees its previous value.
118
- if (key !== KEY_WALLPAPER) used += (storage.getItem(key) || "").length;
117
+ if (key !== exceptKey) used += (storage.getItem(key) || "").length;
119
118
  }
120
119
  // Assume a typical ~5 MiB budget, estimating UTF-16 values at
121
120
  // 2 bytes per code unit. Browser quotas/accounting vary; the
122
121
  // actual write can still fail and must report that failure.
123
- return (used + value.length) * 2 <= 5 * 1024 * 1024;
122
+ return (used + extraLength) * 2 <= 5 * 1024 * 1024;
124
123
  } catch { return true; } // If estimation is unavailable, let the write decide.
125
124
  }
125
+ function wallpaperFitsStorage(value) {
126
+ // Replacing the wallpaper frees its previous value.
127
+ return storageFitsExcept(KEY_WALLPAPER, value.length);
128
+ }
129
+
130
+ //#region wallpaper rotation pool
131
+ // The pool is a localStorage record of saved backgrounds. Images keep
132
+ // their data URL in the record; videos keep only metadata and their
133
+ // Blob stays in the same IndexedDB store as the single video.
134
+ const KEY_ROTATION = "dsh-liquid-glass:rotation";
135
+ const ROTATION_ORDERS = ["sequential", "random"];
136
+ const ROTATION_TIMINGS = ["refresh", "hourly", "daily", "timeslot"];
137
+ function validRotationItem(item) {
138
+ if (!item || typeof item !== "object" || Array.isArray(item)) return false;
139
+ if (typeof item.id !== "string" || !/^[\w-]{1,80}$/.test(item.id)) return false;
140
+ if (item.kind === "image") return typeof item.url === "string" && item.url.length > 0;
141
+ if (item.kind === "video") return typeof item.name === "string";
142
+ return false;
143
+ }
144
+ function sanitizeRotation(saved) {
145
+ const r = saved && typeof saved === "object" && !Array.isArray(saved) ? saved : {};
146
+ const items = Array.isArray(r.items) ? r.items.filter(validRotationItem) : [];
147
+ return {
148
+ version: 1,
149
+ enabled: typeof r.enabled === "boolean" ? r.enabled : false,
150
+ order: enumValue(r.order, ROTATION_ORDERS, "sequential"),
151
+ timing: enumValue(r.timing, ROTATION_TIMINGS, "refresh"),
152
+ items,
153
+ index: numberValue(r.index, 0, Math.max(0, items.length - 1), 0),
154
+ lastSwitch: typeof r.lastSwitch === "number" && Number.isFinite(r.lastSwitch) && r.lastSwitch >= 0 ? r.lastSwitch : 0
155
+ };
156
+ }
157
+ function readRotation() {
158
+ try { return sanitizeRotation(JSON.parse(readStorage(KEY_ROTATION))); }
159
+ catch { return sanitizeRotation(null); }
160
+ }
161
+ function writeRotation(record) {
162
+ return writeStorage(KEY_ROTATION, JSON.stringify(record));
163
+ }
164
+ /** Morning 06–12, afternoon 12–18, evening 18–24, night 00–06. */
165
+ function timeSlotOf(date) {
166
+ const hour = date.getHours();
167
+ if (hour >= 6 && hour < 12) return "morning";
168
+ if (hour >= 12 && hour < 18) return "afternoon";
169
+ if (hour >= 18) return "evening";
170
+ return "night";
171
+ }
172
+ function rotationDue(rotation, now) {
173
+ if (!rotation.enabled || rotation.items.length < 2) return false;
174
+ if (rotation.timing === "refresh") return true;
175
+ if (rotation.timing === "hourly") return now - rotation.lastSwitch >= 60 * 60 * 1000;
176
+ if (rotation.timing === "daily") return new Date(rotation.lastSwitch).toDateString() !== new Date(now).toDateString();
177
+ if (rotation.timing === "timeslot") return timeSlotOf(new Date(rotation.lastSwitch)) !== timeSlotOf(new Date(now));
178
+ return false;
179
+ }
180
+ function nextRotationIndex(rotation) {
181
+ const n = rotation.items.length;
182
+ if (n === 0) return -1;
183
+ if (n === 1) return 0;
184
+ if (rotation.order === "random") {
185
+ const next = Math.floor(Math.random() * n);
186
+ return next === rotation.index ? (next + 1) % n : next;
187
+ }
188
+ return (rotation.index + 1) % n;
189
+ }
190
+ /** Pool entry for the currently saved background, or null when there is none. */
191
+ function currentBackgroundItem() {
192
+ const video = readVideo();
193
+ if (video) return { id: video.id, kind: "video", name: video.name };
194
+ const url = readWallpaper();
195
+ if (url) return { id: window.crypto.randomUUID(), kind: "image", url };
196
+ return null;
197
+ }
198
+ /** A pooled video Blob stays in IndexedDB until its pool entry is removed. */
199
+ function deleteVideoIfUnpooled(id) {
200
+ if (!id) return;
201
+ if (readRotation().items.some((item) => item.kind === "video" && item.id === id)) return;
202
+ void videoRecord("delete", id).catch(() => {});
203
+ }
204
+ //#endregion
126
205
  const readGlassOn = () => {
127
206
  const raw = readStorage(KEY_GLASS);
128
207
  if (raw === null) return DEFAULT_GLASS_ON;
@@ -140,6 +219,144 @@ window.__ModuleLoader__.load({
140
219
  const currentVideoSelection = () => previewSelection ? (previewSelection.kind === "video" ? { ...previewSelection.meta, file: previewSelection.file } : null) : readVideo();
141
220
  //#endregion
142
221
 
222
+ //#region appearance transfer
223
+ const TRANSFER_SCHEMA = "dsh-liquid-glass-appearance";
224
+ const TRANSFER_LIMIT = 512 * 1024;
225
+ const transferId = value => typeof value === "string" && /^[\w-]{1,80}$/.test(value);
226
+ const isRecord = value => value !== null && typeof value === "object" && !Array.isArray(value);
227
+ const transferError = error => ({ error: `transfer.${error}` });
228
+
229
+ function shareableImageUrl(value) {
230
+ if (typeof value !== "string" || value.length > 4096) return false;
231
+ try {
232
+ const url = new URL(value);
233
+ return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
234
+ } catch { return false; }
235
+ }
236
+
237
+ function imageReference(url, id) {
238
+ const identity = id ? { id } : {};
239
+ return shareableImageUrl(url) ? { ...identity, kind: "image", url } : { ...identity, kind: "local-image" };
240
+ }
241
+
242
+ function videoReference(video) {
243
+ return { kind: "video", id: video.id, name: video.name.slice(0, 256) };
244
+ }
245
+
246
+ function transferProfile(profile) {
247
+ return { alpha: Math.max(0.05, Math.min(0.97, profile.alpha)), options: sanitizeOptions(profile.options) };
248
+ }
249
+
250
+ function exportAppearance() {
251
+ const rotation = readRotation();
252
+ const saved = readProfiles();
253
+ const profile = { alpha: readAlpha(), options: readOptions() };
254
+ const profiles = saved ? { separate: saved.separate, light: transferProfile(saved.light), dark: transferProfile(saved.dark) }
255
+ : { separate: false, light: profile, dark: profile };
256
+ const video = readVideo();
257
+ const wallpaperUrl = readWallpaper();
258
+ const wallpaper = video ? videoReference(video) : wallpaperUrl
259
+ ? imageReference(wallpaperUrl, rotation.items.find(item => item.kind === "image" && item.url === wallpaperUrl)?.id)
260
+ : null;
261
+ const items = rotation.items.map(item => item.kind === "video" ? videoReference(item) : imageReference(item.url, item.id));
262
+ return JSON.stringify({
263
+ schema: TRANSFER_SCHEMA, version: 1, enabled: readGlassOn(), profiles,
264
+ videoPaused: readStorage(KEY_VIDEO_PAUSED) === "on", wallpaper,
265
+ rotation: { enabled: rotation.enabled, order: rotation.order, timing: rotation.timing, items }
266
+ }, null, 2);
267
+ }
268
+
269
+ function validTransferProfile(value) {
270
+ if (!isRecord(value) || !Number.isFinite(value.alpha) || value.alpha < 0.05 || value.alpha > 0.97 || !isRecord(value.options)) return false;
271
+ const canonical = sanitizeOptions(value.options);
272
+ return Object.keys(canonical).every(key => canonical[key] === value.options[key]);
273
+ }
274
+
275
+ function validMediaReference(value, needsId = false) {
276
+ if (!isRecord(value) || ((needsId || value.id !== undefined) && !transferId(value.id))) return false;
277
+ if (value.kind === "image") return shareableImageUrl(value.url);
278
+ if (value.kind === "local-image") return value.url === undefined;
279
+ return value.kind === "video" && transferId(value.id) && typeof value.name === "string" && value.name.length <= 256;
280
+ }
281
+
282
+ function validateAppearanceTransfer(value) {
283
+ if (!isRecord(value) || value.schema !== TRANSFER_SCHEMA) return transferError("invalid");
284
+ if (value.version !== 1) return transferError("version");
285
+ const { profiles, rotation, wallpaper } = value;
286
+ if (typeof value.enabled !== "boolean" || typeof value.videoPaused !== "boolean"
287
+ || !isRecord(profiles) || typeof profiles.separate !== "boolean" || !validTransferProfile(profiles.light) || !validTransferProfile(profiles.dark)
288
+ || (wallpaper !== null && !validMediaReference(wallpaper))
289
+ || !isRecord(rotation) || typeof rotation.enabled !== "boolean" || !ROTATION_ORDERS.includes(rotation.order)
290
+ || !ROTATION_TIMINGS.includes(rotation.timing) || !Array.isArray(rotation.items)
291
+ || !rotation.items.every(item => validMediaReference(item, true))
292
+ || new Set(rotation.items.map(item => item.id)).size !== rotation.items.length) return transferError("invalid");
293
+ return { config: value };
294
+ }
295
+
296
+ async function resolveTransferMedia(config) {
297
+ const saved = readRotation().items;
298
+ const wallpaper = readWallpaper();
299
+ const activeVideo = readVideo();
300
+ const localVideos = new Map(saved.filter(item => item.kind === "video").map(item => [item.id, item]));
301
+ if (activeVideo) localVideos.set(activeVideo.id, activeVideo);
302
+ const localImages = new Map(saved.filter(item => item.kind === "image").map(item => [item.id, item]));
303
+ const resolvedVideos = new Map();
304
+ const resolve = async (reference, primary) => {
305
+ if (reference === null) return null;
306
+ if (reference.kind === "image") return { kind: "image", id: reference.id, url: reference.url };
307
+ if (reference.kind === "local-image") {
308
+ const local = localImages.get(reference.id);
309
+ if (local) return local;
310
+ if (primary && !reference.id && wallpaper && !shareableImageUrl(wallpaper)) return { kind: "image", url: wallpaper };
311
+ return undefined;
312
+ }
313
+ const local = localVideos.get(reference.id);
314
+ if (!local || local.name.slice(0, 256) !== reference.name) return undefined;
315
+ if (!resolvedVideos.has(local.id)) {
316
+ resolvedVideos.set(local.id, videoRecord("get", local.id).catch(() => null));
317
+ }
318
+ return await resolvedVideos.get(local.id) ? { kind: "video", id: local.id, name: local.name } : undefined;
319
+ };
320
+ const selected = await resolve(config.wallpaper, true);
321
+ const entries = await Promise.all(config.rotation.items.map(item => resolve(item, false)));
322
+ const items = entries.filter(Boolean);
323
+ return { selected, items, missing: (selected === undefined ? 1 : 0) + entries.length - items.length };
324
+ }
325
+
326
+ async function previewAppearanceImport(source) {
327
+ if (typeof source !== "string") return transferError("invalid");
328
+ if (new Blob([source]).size > TRANSFER_LIMIT) return transferError("tooLarge");
329
+ let parsed;
330
+ try { parsed = JSON.parse(source); } catch { return transferError("invalid"); }
331
+ const result = validateAppearanceTransfer(parsed);
332
+ if (result.error) return result;
333
+ const { missing } = await resolveTransferMedia(result.config);
334
+ return { ...result, missing };
335
+ }
336
+
337
+ function applySavedAppearance(changes, render) {
338
+ let prior;
339
+ try {
340
+ prior = new Map(changes.map(([key]) => [key, window.localStorage.getItem(key)]));
341
+ } catch { return transferError("applyFailed"); }
342
+ const written = [];
343
+ try {
344
+ for (const [key, value] of changes) {
345
+ if (value === prior.get(key)) continue;
346
+ if (!writeStorage(key, value)) throw new Error("appearance storage");
347
+ written.push(key);
348
+ }
349
+ render();
350
+ return {};
351
+ } catch {
352
+ let restored = true;
353
+ for (const key of written.reverse()) if (!writeStorage(key, prior.get(key))) restored = false;
354
+ try { render(); } catch { restored = false; }
355
+ return transferError(restored ? "applyFailed" : "restoreFailed");
356
+ }
357
+ }
358
+ //#endregion
359
+
143
360
  //#region color utils
144
361
  function hexToRgb(hex) {
145
362
  const m = /^#?([0-9a-f]{6})$/i.exec(String(hex).trim());
@@ -156,6 +373,24 @@ window.__ModuleLoader__.load({
156
373
 
157
374
  //#region locale
158
375
  const zh = {
376
+ "transfer.title": "外观设置备份",
377
+ "transfer.export": "导出设置",
378
+ "transfer.import": "导入设置",
379
+ "transfer.shareHint": "仅分享设置和壁纸引用。文件不包含本地图片、视频或带参数的私有链接。",
380
+ "transfer.preview": "预览导入",
381
+ "transfer.previewHint": "确认后替换当前外观设置。设备上不存在的壁纸引用将跳过。",
382
+ "transfer.cancel": "取消",
383
+ "transfer.apply": "应用设置",
384
+ "transfer.missing": "无法找到的媒体引用",
385
+ "transfer.downloadStarted": "已开始下载。",
386
+ "transfer.applied": "外观设置已应用。",
387
+ "transfer.exportFailed": "无法导出设置。",
388
+ "transfer.invalid": "文件不是有效的外观设置。",
389
+ "transfer.version": "不支持该设置文件版本。",
390
+ "transfer.tooLarge": "设置文件超过 512 KiB。",
391
+ "transfer.applyFailed": "无法应用设置。",
392
+ "transfer.restoreFailed": "无法完整恢复之前的设置,请检查浏览器存储。",
393
+ "transfer.conflict": "设置在导入期间发生变化,请重新预览。",
159
394
  "wallpaper.saveLeave": "保存并离开",
160
395
  "wallpaper.discard": "放弃更改",
161
396
  "wallpaper.keepEditing": "继续编辑",
@@ -234,8 +469,45 @@ window.__ModuleLoader__.load({
234
469
  "wallpaper.tooLarge": "GIF 超出本浏览器的预计剩余存储空间,请缩小文件后重试",
235
470
  "wallpaper.saveFailed": "背景图保存失败,请释放浏览器存储空间或检查存储权限后重试",
236
471
  "wallpaper.checking": "校验中…",
472
+ "rotation.title": "壁纸轮换",
473
+ "rotation.enable": "启用壁纸轮换",
474
+ "rotation.hint": "按顺序或随机轮换池中的背景;关闭后恢复单个背景。轮换在每次打开应用时判断。",
475
+ "rotation.order": "轮换顺序",
476
+ "rotation.sequential": "顺序",
477
+ "rotation.random": "随机",
478
+ "rotation.timing": "切换时机",
479
+ "rotation.refresh": "每次打开",
480
+ "rotation.hourly": "每小时",
481
+ "rotation.daily": "每天",
482
+ "rotation.timeslot": "按时段",
483
+ "rotation.next": "下一张",
484
+ "rotation.addCurrent": "添加当前背景",
485
+ "rotation.empty": "池子是空的:先保存一张背景,再把它加进来。",
486
+ "rotation.remove": "移除",
487
+ "rotation.image": "图片",
488
+ "rotation.video": "视频",
489
+ "rotation.tooLarge": "池子已满:该背景超出浏览器预计剩余存储空间。",
490
+ "rotation.saveFailed": "轮换设置保存失败,请检查浏览器存储空间或权限。",
237
491
  };
238
492
  const en = {
493
+ "transfer.title": "Appearance backup",
494
+ "transfer.export": "Export settings",
495
+ "transfer.import": "Import settings",
496
+ "transfer.shareHint": "Share settings and wallpaper references. Local image and video data and links with private parameters are excluded.",
497
+ "transfer.preview": "Preview import",
498
+ "transfer.previewHint": "Confirm to replace the current appearance settings. Wallpaper references missing on this device are skipped.",
499
+ "transfer.cancel": "Cancel",
500
+ "transfer.apply": "Apply settings",
501
+ "transfer.missing": "Missing media references",
502
+ "transfer.downloadStarted": "Download started.",
503
+ "transfer.applied": "Appearance settings applied.",
504
+ "transfer.exportFailed": "Unable to export settings.",
505
+ "transfer.invalid": "Invalid appearance settings file.",
506
+ "transfer.version": "Unsupported settings file version.",
507
+ "transfer.tooLarge": "Settings file exceeds 512 KiB.",
508
+ "transfer.applyFailed": "Settings could not be applied.",
509
+ "transfer.restoreFailed": "Previous settings could not be fully restored. Check browser storage.",
510
+ "transfer.conflict": "Settings changed during import. Preview the file again.",
239
511
  "wallpaper.saveLeave": "Save and leave",
240
512
  "wallpaper.discard": "Discard changes",
241
513
  "wallpaper.keepEditing": "Keep editing",
@@ -314,6 +586,25 @@ window.__ModuleLoader__.load({
314
586
  "wallpaper.tooLarge": "This GIF exceeds the estimated remaining browser storage. Please use a smaller file.",
315
587
  "wallpaper.saveFailed": "Background could not be saved. Free browser storage or check storage permissions and retry.",
316
588
  "wallpaper.checking": "Checking…",
589
+ "rotation.title": "Wallpaper rotation",
590
+ "rotation.enable": "Rotate wallpapers",
591
+ "rotation.hint": "Cycle through the pool in order or at random. Turning it off restores the single background. Rotation is evaluated when the app opens.",
592
+ "rotation.order": "Rotation order",
593
+ "rotation.sequential": "In order",
594
+ "rotation.random": "Random",
595
+ "rotation.timing": "Switch when",
596
+ "rotation.refresh": "On every open",
597
+ "rotation.hourly": "Every hour",
598
+ "rotation.daily": "Every day",
599
+ "rotation.timeslot": "By time of day",
600
+ "rotation.next": "Next wallpaper",
601
+ "rotation.addCurrent": "Add current background",
602
+ "rotation.empty": "The pool is empty. Save a background first, then add it here.",
603
+ "rotation.remove": "Remove",
604
+ "rotation.image": "Image",
605
+ "rotation.video": "Video",
606
+ "rotation.tooLarge": "The pool is full: this background exceeds the estimated remaining browser storage.",
607
+ "rotation.saveFailed": "Rotation settings could not be saved. Check browser storage space or permissions.",
317
608
  };
318
609
  //#endregion
319
610
 
@@ -656,10 +947,11 @@ window.__ModuleLoader__.load({
656
947
  settingsError: false,
657
948
  shortcutStatus: "unavailable",
658
949
  video: null,
950
+ rotation: null,
659
951
  revision: -1
660
952
  }),
661
953
  actions: {
662
- sync: (d, on, alpha, wallpaper, revision, options, accessibility, settingsError, shortcutStatus, video) => {
954
+ sync: (d, on, alpha, wallpaper, revision, options, accessibility, settingsError, shortcutStatus, video, rotation) => {
663
955
  if (revision <= d.revision) return;
664
956
  d.on = on;
665
957
  d.alpha = alpha;
@@ -670,6 +962,7 @@ window.__ModuleLoader__.load({
670
962
  d.settingsError = settingsError;
671
963
  d.shortcutStatus = shortcutStatus;
672
964
  d.video = video;
965
+ d.rotation = rotation;
673
966
  }
674
967
  }
675
968
  });
@@ -904,7 +1197,118 @@ window.__ModuleLoader__.load({
904
1197
  style: { background: "transparent", padding: 0, minWidth: "20px", width: "20px", height: "20px", ...(gutter ? { position: "absolute", left: "-22px", top: 0 } : {}) },
905
1198
  icon: h(open ? UI.IconChevronDownOutlineRegular : UI.IconChevronRightOutlineRegular, { size: 12 }) });
906
1199
  }
907
- function GlassRow({ t, useStore, setGlass, setAlpha, setWallpaper, setOption, setPreset, resetAppearance, setVideo, setVideoPaused, previewBackground, setSeparateAppearance }) {
1200
+ function RotationVideoThumbnail({ item, t }) {
1201
+ const [src, setSrc] = _react.useState("");
1202
+ _react.useEffect(() => {
1203
+ let cancelled = false, url = "";
1204
+ setSrc("");
1205
+ void videoRecord("get", item.id).then(file => {
1206
+ if (cancelled || !file) return;
1207
+ url = window.URL.createObjectURL(file);
1208
+ setSrc(url);
1209
+ }).catch(() => {});
1210
+ return () => { cancelled = true; if (url) window.URL.revokeObjectURL(url); };
1211
+ }, [item.id]);
1212
+ return src
1213
+ ? h("video", { src, muted: true, playsInline: true, preload: "metadata", style: { width: "64px", height: "40px", objectFit: "cover", borderRadius: "6px", flexShrink: 0 } })
1214
+ : h("div", { style: { width: "64px", height: "40px", borderRadius: "6px", background: "var(--dsw-alias-bg-layer-1)", display: "flex", alignItems: "center", justifyContent: "center", fontSize: "12px", flexShrink: 0 }, children: t("rotation.video") });
1215
+ }
1216
+ function RotationSection({ rotation, wallpaper, video, setRotationEnabled, setRotationOrder, setRotationTiming, addCurrentToRotation, removeRotationItem, nextRotation, t }) {
1217
+ const [error, setError] = _react.useState("");
1218
+ if (!rotation) return null;
1219
+ const hasBackground = !!(video?.meta || wallpaper);
1220
+ const currentInPool = hasBackground && rotation.items.some((item) => item.kind === "video" ? item.id === video?.meta?.id : item.url === wallpaper);
1221
+ const add = () => {
1222
+ const result = addCurrentToRotation();
1223
+ setError(result === true ? "" : t(result === "tooLarge" ? "rotation.tooLarge" : "rotation.saveFailed"));
1224
+ };
1225
+ const remove = (id) => { if (removeRotationItem(id)) setError(""); else setError(t("rotation.saveFailed")); };
1226
+ const advance = () => { if (nextRotation()) setError(""); else setError(t("rotation.saveFailed")); };
1227
+ return h("div", { style: styles.stack, children: [
1228
+ h("div", { style: styles.sectionLabel, children: t("rotation.title") }),
1229
+ h(Check, { label: t("rotation.enable"), checked: rotation.enabled, onChange: (value) => { if (setRotationEnabled(value)) setError(""); else setError(t("rotation.saveFailed")); } }),
1230
+ h("div", { style: styles.hint, children: t("rotation.hint") }),
1231
+ rotation.enabled && h(Choices, { label: t("rotation.order"), value: rotation.order, values: ROTATION_ORDERS, onChange: (value) => { if (!setRotationOrder(value)) setError(t("rotation.saveFailed")); }, t, prefix: "rotation" }),
1232
+ rotation.enabled && h(Choices, { label: t("rotation.timing"), value: rotation.timing, values: ROTATION_TIMINGS, onChange: (value) => { if (!setRotationTiming(value)) setError(t("rotation.saveFailed")); }, t, prefix: "rotation" }),
1233
+ h("div", { style: styles.row, children: [
1234
+ rotation.enabled && h(UI.Button, { size: "sm", disabled: rotation.items.length < 2, onClick: advance, children: t("rotation.next") }),
1235
+ h(UI.Button, { size: "sm", disabled: !hasBackground || currentInPool, onClick: add, children: t("rotation.addCurrent") })] }),
1236
+ rotation.items.length === 0
1237
+ ? h("div", { style: styles.hint, children: t("rotation.empty") })
1238
+ : h("div", { style: styles.stack, children: rotation.items.map((item) => h("div", { key: item.id, style: styles.row, children: [
1239
+ item.kind === "image"
1240
+ ? h("img", { src: item.url, alt: t("wallpaper.imagePreview"), style: { width: "64px", height: "40px", objectFit: "cover", borderRadius: "6px", flexShrink: 0 } })
1241
+ : h(RotationVideoThumbnail, { item, t }),
1242
+ h("span", { style: { ...styles.hint, flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item.kind === "video" ? item.name : (/^https?:\/\//i.test(item.url) ? item.url : t("rotation.image")) }),
1243
+ h(UI.Button, { size: "sm", variant: "ghost", onClick: () => remove(item.id), children: t("rotation.remove") })] })) }),
1244
+ error && h("div", { role: "alert", style: styles.dirtyHint, children: error })] });
1245
+ }
1246
+ function TransferSection({ t, exportAppearance, previewAppearanceImport, importAppearance }) {
1247
+ const input = _react.useRef(null);
1248
+ const [preview, setPreview] = _react.useState(null);
1249
+ const [status, setStatus] = _react.useState(null);
1250
+ const [busy, setBusy] = _react.useState(false);
1251
+ const cancel = () => { if (!busy) setPreview(null); };
1252
+
1253
+ const download = () => {
1254
+ try {
1255
+ const blob = new Blob([exportAppearance()], { type: "application/json" });
1256
+ if (blob.size > TRANSFER_LIMIT) { setStatus(transferError("tooLarge")); return; }
1257
+ const url = window.URL.createObjectURL(blob);
1258
+ const link = document.createElement("a");
1259
+ link.href = url;
1260
+ link.download = "appearance.dsh-theme.json";
1261
+ try { link.click(); } finally { setTimeout(() => window.URL.revokeObjectURL(url), 0); }
1262
+ setStatus({ message: "transfer.downloadStarted" });
1263
+ } catch { setStatus(transferError("exportFailed")); }
1264
+ };
1265
+
1266
+ const choose = async event => {
1267
+ const file = event.target.files?.[0];
1268
+ event.target.value = "";
1269
+ if (!file || busy) return;
1270
+ setStatus(null);
1271
+ setBusy(true);
1272
+ try {
1273
+ const result = file.size > TRANSFER_LIMIT ? transferError("tooLarge") : await previewAppearanceImport(await file.text());
1274
+ if (result.error) setStatus(result);
1275
+ else setPreview(result);
1276
+ } catch { setStatus(transferError("invalid")); }
1277
+ finally { setBusy(false); }
1278
+ };
1279
+
1280
+ const confirm = async () => {
1281
+ if (!preview || busy) return;
1282
+ setBusy(true);
1283
+ try {
1284
+ const result = await importAppearance(preview.config);
1285
+ setStatus(result.error ? result : { message: "transfer.applied" });
1286
+ setPreview(null);
1287
+ } catch { setStatus(transferError("applyFailed")); }
1288
+ finally { setBusy(false); }
1289
+ };
1290
+
1291
+ return h("div", { style: styles.stack, children: [
1292
+ h("div", { style: styles.sectionLabel, children: t("transfer.title") }),
1293
+ h("div", { style: styles.hint, children: t("transfer.shareHint") }),
1294
+ h("div", { style: styles.row, children: [
1295
+ h(UI.Button, { size: "sm", disabled: busy, onClick: download, children: t("transfer.export") }),
1296
+ h(UI.Button, { size: "sm", disabled: busy, onClick: () => input.current?.click(), children: t("transfer.import") })] }),
1297
+ h("input", { type: "file", ref: input, style: { display: "none" }, accept: ".json,application/json", disabled: busy, onChange: choose }),
1298
+ status && h("div", { role: status.error ? "alert" : "status", style: status.error ? styles.dirtyHint : styles.hint, children: t(status.error ?? status.message) }),
1299
+ h(UI.Modal, { open: preview !== null, title: t("transfer.preview"), description: t("transfer.previewHint"),
1300
+ closeLabel: t("transfer.cancel"), onClose: cancel, footer: [
1301
+ h(UI.Button, { disabled: busy, onClick: cancel, children: t("transfer.cancel") }),
1302
+ h(UI.Button, { disabled: busy, variant: "primary", onClick: confirm, children: t("transfer.apply") })
1303
+ ], children: preview && h("ul", { children: [
1304
+ h("li", { children: `${t("glass.presets")}: ${t(`glass.${preview.config.profiles.light.options.preset}`)} / ${t(`glass.${preview.config.profiles.dark.options.preset}`)}` }),
1305
+ h("li", { children: `${t("rotation.title")}: ${preview.config.rotation.items.length}` }),
1306
+ preview.missing > 0 && h("li", { children: `${t("transfer.missing")}: ${preview.missing}` })
1307
+ ] }) })
1308
+ ] });
1309
+ }
1310
+
1311
+ function GlassRow({ t, useStore, setGlass, setAlpha, setWallpaper, setOption, setPreset, resetAppearance, setVideo, setVideoPaused, previewBackground, setSeparateAppearance, setRotationEnabled, setRotationOrder, setRotationTiming, addCurrentToRotation, removeRotationItem, nextRotation, exportAppearance, previewAppearanceImport, importAppearance }) {
908
1312
  const on = useStore(s => s.on);
909
1313
  const alpha = useStore(s => s.alpha);
910
1314
  const wallpaper = useStore(s => s.wallpaper);
@@ -913,6 +1317,7 @@ window.__ModuleLoader__.load({
913
1317
  const accessibility = useStore(s => s.accessibility);
914
1318
  const settingsError = useStore(s => s.settingsError);
915
1319
  const shortcutStatus = useStore(s => s.shortcutStatus);
1320
+ const rotation = useStore(s => s.rotation);
916
1321
  const [open, setOpen] = _react.useState(false);
917
1322
  const [advanced, setAdvanced] = _react.useState(false);
918
1323
 
@@ -943,6 +1348,8 @@ window.__ModuleLoader__.load({
943
1348
  h("div", { style: styles.sectionLabel, children: t("wallpaper.title") }),
944
1349
  h(WallpaperSection, { url: video?.meta ? null : wallpaper, onApply: setWallpaper, onVideo: setVideo, previewBackground, setVideoPaused, video, t }),
945
1350
  video?.error && h("div", { role: "alert", style: styles.dirtyHint, children: t(video.error) }),
1351
+ h(TransferSection, { t, exportAppearance, previewAppearanceImport, importAppearance }),
1352
+ h(RotationSection, { rotation, wallpaper, video, setRotationEnabled, setRotationOrder, setRotationTiming, addCurrentToRotation, removeRotationItem, nextRotation, t }),
946
1353
  h("div", { style: styles.row, children: [
947
1354
  h("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
948
1355
  h(Expander, { label: t("row.advanced"), open: advanced, controls: `${id}-advanced`, onClick: () => setAdvanced(!advanced) }),
@@ -987,7 +1394,41 @@ window.__ModuleLoader__.load({
987
1394
  const sync = () => {
988
1395
  revision += 1;
989
1396
  const material = appearance();
990
- bound?.sync(readGlassOn(), material.alpha, readWallpaper(), revision, material, accessibilityActive, settingsError, shortcutStatus, { meta: readVideo(), status: videoStatus, error: videoSaveError || videoPlaybackError, saving: videoSaving, reducedMotion, still: material.videoMode === "still" });
1397
+ bound?.sync(readGlassOn(), material.alpha, readWallpaper(), revision, material, accessibilityActive, settingsError, shortcutStatus, { meta: readVideo(), status: videoStatus, error: videoSaveError || videoPlaybackError, saving: videoSaving, reducedMotion, still: material.videoMode === "still" }, readRotation());
1398
+ };
1399
+
1400
+ /** Commit one pool entry as the saved background (storage only). */
1401
+ const commitBackground = (item) => {
1402
+ if (item.kind === "image") {
1403
+ const previous = readWallpaper();
1404
+ const oldVideo = readVideo();
1405
+ if (!writeStorage(KEY_WALLPAPER, item.url)) return false;
1406
+ if (!writeStorage(KEY_VIDEO, null)) { writeStorage(KEY_WALLPAPER, previous); return false; }
1407
+ videoSaveError = ""; previewSelection = null;
1408
+ deleteVideoIfUnpooled(oldVideo?.id);
1409
+ return true;
1410
+ }
1411
+ const previousVideo = readVideo();
1412
+ if (!writeStorage(KEY_VIDEO, JSON.stringify({ id: item.id, name: item.name }))) return false;
1413
+ if (!writeStorage(KEY_WALLPAPER, null)) {
1414
+ writeStorage(KEY_VIDEO, previousVideo ? JSON.stringify(previousVideo) : null);
1415
+ return false;
1416
+ }
1417
+ videoSaveError = ""; previewSelection = null;
1418
+ deleteVideoIfUnpooled(previousVideo?.id);
1419
+ return true;
1420
+ };
1421
+ // Rotation is evaluated when the app opens. No background timer:
1422
+ // a live switch could discard an unsaved background draft, and
1423
+ // hourly/daily/time-of-day switches are all covered on next open.
1424
+ const rotateOnBoot = () => {
1425
+ if (!active) return;
1426
+ const rotation = readRotation();
1427
+ if (!rotationDue(rotation, Date.now())) return;
1428
+ const nextIndex = nextRotationIndex(rotation);
1429
+ if (nextIndex < 0) return;
1430
+ if (!commitBackground(rotation.items[nextIndex])) return;
1431
+ writeRotation({ ...rotation, index: nextIndex, lastSwitch: Date.now() });
991
1432
  };
992
1433
 
993
1434
  notifyVideo = () => { if (active) sync(); };
@@ -1032,6 +1473,7 @@ window.__ModuleLoader__.load({
1032
1473
  teardownWallpaper();
1033
1474
  };
1034
1475
  stopRuntime = stop;
1476
+ rotateOnBoot();
1035
1477
  applyWallpaper();
1036
1478
  applyGlass(ctx);
1037
1479
  sync();
@@ -1121,6 +1563,32 @@ window.__ModuleLoader__.load({
1121
1563
  bound = actions;
1122
1564
  sync();
1123
1565
  return {
1566
+ exportAppearance,
1567
+ previewAppearanceImport,
1568
+ importAppearance: async (input) => {
1569
+ const result = validateAppearanceTransfer(input);
1570
+ if (result.error) return result;
1571
+ if (!active || videoSaving || previewSelection) return transferError("conflict");
1572
+ const baseRevision = revision;
1573
+ const { config } = result;
1574
+ const { selected, items } = await resolveTransferMedia(config);
1575
+ if (!active || videoSaving || previewSelection || baseRevision !== revision) return transferError("conflict");
1576
+ const { profiles, rotation } = config;
1577
+ const nextProfiles = { version: 1, separate: profiles.separate, light: transferProfile(profiles.light), dark: transferProfile(profiles.dark) };
1578
+ const nextRotation = { version: 1, enabled: rotation.enabled && items.length > 1, order: rotation.order, timing: rotation.timing,
1579
+ items, index: Math.max(0, items.findIndex(item => item.id === selected?.id)), lastSwitch: Date.now() };
1580
+ const changes = [
1581
+ [KEY_GLASS, config.enabled ? "on" : "off"],
1582
+ [KEY_APPEARANCES, JSON.stringify(nextProfiles)],
1583
+ [KEY_VIDEO_PAUSED, config.videoPaused ? "on" : null],
1584
+ [KEY_ROTATION, JSON.stringify(nextRotation)]
1585
+ ];
1586
+ if (selected !== undefined) {
1587
+ changes.push([KEY_WALLPAPER, selected?.kind === "image" ? selected.url : null],
1588
+ [KEY_VIDEO, selected?.kind === "video" ? JSON.stringify({ id: selected.id, name: selected.name }) : null]);
1589
+ }
1590
+ return applySavedAppearance(changes, () => { applyGlass(ctx); applyWallpaper(); sync(); });
1591
+ },
1124
1592
  setSeparateAppearance: (separate) => {
1125
1593
  if (!active || typeof separate !== "boolean") return false;
1126
1594
  if ((readProfiles()?.separate === true) === separate) return true;
@@ -1177,7 +1645,7 @@ window.__ModuleLoader__.load({
1177
1645
  if (!writeStorage(KEY_VIDEO, JSON.stringify({ id, name: file.name }))) throw new Error("video.storage");
1178
1646
  previewSelection = null;
1179
1647
  applyWallpaper();
1180
- if (previous) void videoRecord("delete", previous.id).catch(() => {});
1648
+ deleteVideoIfUnpooled(previous?.id);
1181
1649
  return true;
1182
1650
  } catch (error) {
1183
1651
  if (id && readVideo()?.id !== id) void videoRecord("delete", id).catch(() => {});
@@ -1192,6 +1660,71 @@ window.__ModuleLoader__.load({
1192
1660
  return !settingsError;
1193
1661
  },
1194
1662
 
1663
+ setRotationEnabled: (enabled) => {
1664
+ if (!active || typeof enabled !== "boolean") return false;
1665
+ const rotation = readRotation();
1666
+ let next = { ...rotation, enabled, lastSwitch: enabled ? Date.now() : rotation.lastSwitch };
1667
+ if (enabled) {
1668
+ const current = currentBackgroundItem();
1669
+ const match = current ? next.items.findIndex((item) => item.kind === current.kind && (item.kind === "video" ? item.id === current.id : item.url === current.url)) : -1;
1670
+ if (match >= 0) next = { ...next, index: match };
1671
+ else if (next.items.length === 0 && current && (current.kind === "video" || storageFitsExcept(KEY_ROTATION, JSON.stringify({ ...next, items: [current] }).length))) {
1672
+ // First enable seeds the pool with the saved background.
1673
+ next = { ...next, items: [current], index: 0 };
1674
+ }
1675
+ }
1676
+ if (!writeRotation(next)) return false;
1677
+ sync(); return true;
1678
+ },
1679
+ setRotationOrder: (order) => {
1680
+ if (!active || !ROTATION_ORDERS.includes(order)) return false;
1681
+ if (!writeRotation({ ...readRotation(), order })) return false;
1682
+ sync(); return true;
1683
+ },
1684
+ setRotationTiming: (timing) => {
1685
+ if (!active || !ROTATION_TIMINGS.includes(timing)) return false;
1686
+ if (!writeRotation({ ...readRotation(), timing })) return false;
1687
+ sync(); return true;
1688
+ },
1689
+ addCurrentToRotation: () => {
1690
+ if (!active) return "saveFailed";
1691
+ const rotation = readRotation();
1692
+ const current = currentBackgroundItem();
1693
+ if (!current) return "saveFailed";
1694
+ const match = rotation.items.findIndex((item) => item.kind === current.kind && (item.kind === "video" ? item.id === current.id : item.url === current.url));
1695
+ if (match >= 0) {
1696
+ if (!writeRotation({ ...rotation, index: match })) return "saveFailed";
1697
+ sync(); return true;
1698
+ }
1699
+ const next = { ...rotation, items: [...rotation.items, current], index: rotation.items.length };
1700
+ if (current.kind === "image" && !storageFitsExcept(KEY_ROTATION, JSON.stringify(next).length)) return "tooLarge";
1701
+ if (!writeRotation(next)) return "saveFailed";
1702
+ sync(); return true;
1703
+ },
1704
+ removeRotationItem: (id) => {
1705
+ if (!active || typeof id !== "string") return false;
1706
+ const rotation = readRotation();
1707
+ const item = rotation.items.find((entry) => entry.id === id);
1708
+ if (!item) return false;
1709
+ const items = rotation.items.filter((entry) => entry.id !== id);
1710
+ if (!writeRotation({ ...rotation, items, index: Math.min(rotation.index, Math.max(0, items.length - 1)) })) return false;
1711
+ if (item.kind === "video" && readVideo()?.id !== item.id) void videoRecord("delete", item.id).catch(() => {});
1712
+ sync(); return true;
1713
+ },
1714
+ nextRotation: () => {
1715
+ if (!active) return false;
1716
+ const rotation = readRotation();
1717
+ if (!rotation.enabled || rotation.items.length < 2) return false;
1718
+ const nextIndex = nextRotationIndex(rotation);
1719
+ if (nextIndex < 0) return false;
1720
+ const item = rotation.items[nextIndex];
1721
+ if (!commitBackground(item)) return false;
1722
+ writeRotation({ ...rotation, index: nextIndex, lastSwitch: Date.now() });
1723
+ applyWallpaper();
1724
+ sync();
1725
+ return true;
1726
+ },
1727
+
1195
1728
  setWallpaper: (url) => {
1196
1729
  selectionRevision++;
1197
1730
  const previous = readWallpaper();
@@ -1199,7 +1732,7 @@ window.__ModuleLoader__.load({
1199
1732
  if (!writeStorage(KEY_WALLPAPER, url)) return false;
1200
1733
  if (!writeStorage(KEY_VIDEO, null)) { writeStorage(KEY_WALLPAPER, previous); return false; }
1201
1734
  videoSaveError = ""; previewSelection = null;
1202
- if (oldVideo) void videoRecord("delete", oldVideo.id).catch(() => {}); // Noncritical orphan cleanup; selection already committed.
1735
+ deleteVideoIfUnpooled(oldVideo?.id); // Noncritical orphan cleanup; selection already committed.
1203
1736
  applyWallpaper();
1204
1737
  sync();
1205
1738
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-liquid-glass",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Theme backgrounds for DeepSeek Harness: native-style collapsible settings, translucent surfaces, and local image/video wallpapers. 主题背景:官方风格折叠设置、通透界面与本地图片/视频背景。",
5
5
  "license": "MIT",
6
6
  "author": "Ultroncn",