dsh-background-by-model 0.7.5 → 0.7.7
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/CHANGELOG.md +25 -1
- package/CHANGELOG.zh.md +25 -1
- package/README.md +58 -26
- package/README.zh.md +58 -26
- package/lib/client.js +1252 -559
- package/lib/index.js +472 -33
- package/package.json +4 -6
- package/example_img/rule-editor.webp +0 -0
- package/example_img/wallpaper-deepseek.webp +0 -0
- package/example_img/wallpaper-kimi.webp +0 -0
- package/holiday/mid-autumn.webp +0 -0
- package/holiday/national-day.webp +0 -0
- package/lib/client.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
> The full release history lives here; the two most recent releases (v0.7.
|
|
3
|
+
> The full release history lives here; the two most recent releases (v0.7.7 / v0.7.6) are also listed in [README.md](./README.md#recent-optimizations).
|
|
4
|
+
|
|
5
|
+
## v0.7.7
|
|
6
|
+
|
|
7
|
+
- **A fresh install starts on the author's own profile, and it needs no network** — the shipped defaults on the Interface tab now ARE the numbers the recommended profile carries (`preset/theme-config.json` in the [assets repository](https://github.com/HarmlessFunny/assets)): main background `0%`, left panel `10%`, right panel `45%`, cards `100%`, code `81%`, inputs `88%` with `60 px` of blur, settings `100%`, conversation text `35%`, trajectory `73%`, every other blur `0`. So the panel is worth looking at before a single byte is fetched, and the profile's one click adds rules and pictures instead of changing the numbers underneath them. Every one of those values used to be chosen per key for **safety** rather than for looks — `bg` at 0.85 so the host surface stayed visible under the wallpaper, `code` fully opaque because "a code block is read, not looked through", `input` blur at 0 because a blur costs a compositor layer — which is why a new install opened on a pale approximation of the host rather than on a configuration anyone would actually run. Two consequences are named rather than discovered later: the main background starts at `0%`, so with no wallpaper yet the window is the host's own canvas (the palette and its ink are unaffected — they come from the theme colour, not from this alpha), and `check:code-plate` now pins the profile's `81%` instead of "defaults to opaque". The constants live in `src/schema.ts` under a note saying they are copied from a live data directory, so changing the profile's numbers means moving them together; the README's Interface section says the same.
|
|
8
|
+
|
|
9
|
+
- **`rightbarOpacity` keeps its "never owned" state while a fresh install starts owned** — the preview panel's `null` means "follow `opacities.bg`", and that is not a theoretical state: **every** release so far has written it, because a panel the user never dragged is persisted as an explicit `null`. The new sanitizer (`normalizeRightbarOpacity`) therefore reads `null` back as itself and hands the shipped `45%` only to a key that is not there at all. Treating `null` as "missing" would have silently repainted the preview panel of every existing configuration whose panel was following the main background — exactly the kind of silent migration the config shape's versioning exists to prevent. A fresh install starts owned at `45%`; `null` is now reachable only by hand, since the UI has never had a control that goes back to it.
|
|
10
|
+
|
|
11
|
+
- **The festival switch ships OFF** — a first install paints what the model rules say and nothing else, and the single switch on the Config page is how the feature is asked for. It shipped ON before, on the argument that the point of the feature is that the background changes by itself on the day; that is the right answer for a configuration somebody has already chosen — which is why the recommended profile still turns it **ON** — but not for a plugin that has just been installed and has no wallpaper of its own yet, where the first thing a new user would see on 中秋节 is a festival picture nobody asked for. The sanitizer is now "a real boolean is honoured, anything else takes the shipped default" rather than "only an explicit `false` turns it off": the absent field of a config written before the feature existed, and junk from a hand-edit, both mean OFF. The per-holiday switches inside the block are untouched — they are details of a feature that is already switched on, not the switch itself.
|
|
12
|
+
|
|
13
|
+
- **The percentage pill in each Interface card is gone** — the number was already on the slider row directly below it, so the card head is the icon and the name again and `.dab-part-badge` goes with it, stylesheet rule included.
|
|
14
|
+
|
|
15
|
+
- **Gates** — `pnpm test` is still nine checks; the defaults above moved `check:code-plate` (the code plate ships on the profile's `81%`) and `check:node`, whose new assertions are written **by value** so that a constant changed without the profile — or the profile changed without the constants — fails a check instead of drifting out of step: the appearance numbers a config with no file at all comes up with, an explicit `null` preview panel reading back as itself, a number of its own surviving, a hand-edit that is not a number landing on the shipped `45%`, and the festival switch through both booleans and a non-boolean.
|
|
16
|
+
|
|
17
|
+
## v0.7.6
|
|
18
|
+
|
|
19
|
+
- **The rules page turns from a stack of self-growing cards into one tab strip and one editor** — the report was "如果规则多且不收起的话会拉的很长". Every rule used to be a card that expanded itself, so the page was as tall as the sum of the cards and only got shorter once the user collapsed them by hand. Now **every rule is a tab and exactly one editor is mounted**: `ModelBgPage` holds the selection (`selId`), `RuleCard` no longer owns an open/collapsed state and is always rendered — it is the tab panel. The page height is therefore a function of one card plus the strip, whatever the rule count. The tabs carry what only the card head used to show: the number, a thumbnail of the rule's first image, the match string, and the two states worth knowing without opening the rule — whether it is the one in use, and whether it rotates or is switched off. The strip scrolls sideways rather than wrapping, for the same reason as above (a wrapped strip hands the page height straight back to the rule count), and the tabs are a fixed 34px with an elided match label, so switching rules cannot reflow the row. **The `+` and the "which rule" menu sit OUTSIDE the scroller**, as icon tiles at its right edge: inside, the only control that can ADD a rule scrolled away from the end of a long list. The strip's scrollbar now declares the host's own `--dsw-scrollbar-*` block (5px, rounded, layer-2 tint, no stepper arrows) instead of the platform's thick arrowed default sitting next to the panel's slim vertical one; every selector is scoped to a `dab-` class because this stylesheet is injected into the host page and a bare webkit-scrollbar selector would restyle the whole harness. **The match tester moved to the profile page** — it answers a question about the configuration as a whole ("which rule does this model land on?"), is read once rather than consulted while editing a rule, and on the rules page it pushed the strip a whole card down; the host-stale notice went with it, since that is also about config writes as a whole. The two decisions behind the strip are pure and now live in `src/client/rules-view.ts` (which rule the editor shows, and where a deletion lands — its neighbour, never rule 1), pinned by the new `check:rules`, which also pins the page structure the layout rests on: one editor drawn, no old stacked container, no per-card open state, a strip that can neither wrap nor grow, and its scrollbar block staying scoped. Also, the page description loses its `max-width:56ch`, which left it wrapping early with dead space beside it while the cards below ran the full width.
|
|
20
|
+
|
|
21
|
+
- **The rotation card's controls were reshuffled, at your request** — four changes, all explicit asks ("'一小时'删掉,'切换模型时也换一张'放到'随机'旁边,'下一张、正在显示...'放到外面'轮换这组图'旁边,常驻" and "把多图轮换板块放到主题色板块之下,把图二元素删掉"). **The manual step is always there**: the Next button and the "On screen 2 / 3" readout beside it used to be gated behind `rotatable && enabled`, so they vanished together with the rotation switch — and that readout is the only place on the card that says which picture is showing. The button now sits in the switch row, outside both the rotation panel and that test, so it is present for every rule state, enabled whenever the ACTIVE rule has two or more pictures (which is exactly `rotateNow`'s own test — it gates on the active rule and on `nextIndex`, never on `rotate.enabled`); below two pictures it is disabled and the readout is omitted rather than printing "0 / 0". **"Also step on a model switch" joined the order row**, beside In order / Shuffle: all three answer "when does a picture change", and the row without it read as the whole story of when the rotation steps. **"1 hour" is gone** from the dwell-time presets — five chips now (10 s / 30 s / 1 min / 5 min / 30 min) plus the custom field, which still takes 3600 s like any other value in the 5 s – 24 h clamp. **"图二元素" — the row of eight fixed preset swatches — is deleted**: the wheel, the numeric inputs, Extract from this image, the eyedropper and Follow system theme all stay; the row was a shortcut into the same setter the wheel drives. It was the only reader of three things, which went with it: the `PALETTE` table in `state.ts`, the `.dab-swatches` / `.dab-swatch` rules in `ui.css.ts`, and the `.dab-swatch:focus-visible` entry in the shared outline group; `.dab-swatch-title` and `.dab-swatch-lg` merely share the prefix and are untouched. **The whole rotation block moved into the second column**, below the theme colour and the wallpaper sliders: it used to sit between the image strip and the layout mode, which is the same place in the wide two-column card but the worst place in the collapsed one (below ~760px, `.dab-rule-cols`), where the tallest block of the card — a titled switch, a bordered panel with three rows inside it — landed between the pictures and the colour controls that edit them. Nothing inside the block changed; it is the same JSX, moved. Both READMEs lose the swatch row ("an inspiration palette" / 「灵感色板」), "1 h" from the dwell-time list, and now say where the manual step lives.
|
|
22
|
+
|
|
23
|
+
- **The festival art stops shipping in the package: it is fetched on the day, and cached by asset** — the two holiday wallpapers (228 KB + 500 KB) were two thirds of the entire tarball, for a picture that is looked at one day a year, and they were the one thing in the package that is a picture rather than code — with their binary history kept in `.git` forever besides. They now live in the project's own [`HarmlessFunny/assets`](https://github.com/HarmlessFunny/assets) repository (beside the README screenshots, in a directory that is marked separately), and the node half downloads, validates and caches one on the first read of the day, under `~/.dsh/.dsh-background-by-model-data/holiday-cache/`. **The reference is pinned to a commit, never a branch**: runtime art has to be immutable — a branch reference would let a later reshuffle of the documentation screenshots silently kill a shipped feature on a day nobody is watching, with nothing in the log — and jsDelivr caches a commit reference forever, which is exactly what a file that never changes wants. **Two mirrors**: `cdn.jsdelivr.net` first (reachable from networks where `raw.githubusercontent.com` is not), raw as the fallback, both pointing at the same revision so a fallback cannot mix versions. **A failed download is a normal state, not an error path**: with both mirrors down the holiday simply does not take over and the model rules keep painting — the "does this slot actually have bytes" gate in `pickHoliday` was written for exactly this. **A cache entry is validated, not trusted**: a cached file that is not an image is treated as a miss and overwritten by the next download, because a process killed mid-write would otherwise break that holiday permanently with no way back short of deleting a file the user does not know exists; the write goes through a temp name and a rename, so a half-written file can never be read. **Neither invariant moved an inch**: the cache is keyed by ASSET name (`mid-autumn.webp`), deliberately outside the slot namespace, so `writeImage` still refuses a holiday slot and the store still never holds a `modelbg-h-*` file. `globalThis.fetch` is replaced by a stub throughout `check:node`, so the suite neither needs a CDN to be up nor asserts today's byte count of a file it does not own; the new assertions cover: loading the plugin and reading the config fetch nothing, one cold read is enough, the second read comes off disk with no transfer, two simultaneous cold reads share one transfer, a dead first mirror falls through, a failed fetch caches nothing, a mirror answering 200 with HTML is rejected, a corrupt cache entry is re-downloaded, and both mirrors serve the same commit.
|
|
24
|
+
|
|
25
|
+
- **A recommended profile, installed in one click** — the Config page gained a third card that downloads the author's own configuration from the same [`HarmlessFunny/assets`](https://github.com/HarmlessFunny/assets) repository and writes it in place of yours. **It is hosted in the store's own shape**: `preset/preset.json` (the shape gate), `preset/theme-config.json` (6.5 KB of readable JSON) and `preset/modelbg-<slot>` (one raw file per slot). It was first written as a single theme file with every wallpaper inlined as base64 — 2.9 MB where 99.8% of the bytes were a picture, which is not a document anyone can hand-edit, since changing one rule's `match` string means finding it inside one line of several hundred thousand characters. That is why the format was changed: editing the config is now editing 6.5 KB of JSON on GitHub, replacing a wallpaper is replacing a file, and publishing the whole thing is a `cp` out of `~/.dsh/.dsh-background-by-model-data/`. On the node side a new `fetchPresetConfig` (fetch the manifest and the config, run the SHARED sanitizer on this side, then derive which files to ask for) and `fetchPresetImage` (one file by slot, magic-byte checked, returned as a data URL) replace the old single-document `fetchPreset`, both reusing the general `fetchAsset` the previous release split out of the festival-art downloader. **The request set is derived from the config rather than from a second manifest**, so adding a wallpaper is adding a rule entry and a file with nothing to keep in sync — which also means an untrusted config decides how many times this process goes to the network, so every slot name is checked against `SLOT_RE` (in `normalizeImage`) and the count is capped besides. **The two holiday slots a config legally names are dropped rather than requested**: `holidays.items` always carries `h-midautumn` / `h-nationalday`, no `modelbg-h-*` file can ever exist (a hard assertion added by the previous release), and asking for one would fail the whole feature on a file the plugin itself guarantees is not there. The client fetches **one file per request**, four of them in flight at a time — measured at 8.3 s sequential against 4.8 s concurrent for the real profile, since what is being paid is per-request latency over HTTP/2 — showing `3/7` on the button; each file therefore gets its own mirror fallback and its own validation. **One missing wallpaper fails the whole attempt and names the slot** — a profile that quietly arrived short a picture is precisely the silent failure that pinning the festival art to a commit exists to prevent, and naming it is what keeps a branch reference acceptable here. It still lands through the same `applyThemeFile` a hand-picked file goes through (assembled on the client into the shape `exportTheme` writes), so the version gate, the sanitizer and the wipe are one path; `preset.json` is what lets the version gate fire before a single wallpaper is requested. It remains the only destructive action in the panel: the download happens before the question (so the confirmation can state what is actually in hand), the wipe happens only after the download succeeds (an unreachable CDN must not cost the user their configuration on the way to a profile that never arrived), a host too old to write this shape is refused before anything is deleted, `holiday-cache/` is untouched, and nothing is cached to disk. `check:node`'s stub grew a "serve a whole directory by file name, a name it does not hold is a 404" mode, covering: the manifest and config fetched in order and sanitized on arrival, the request set derived from the rules with the holiday slot dropped, one request per wallpaper with its type sniffed rather than trusted from a header, a fallback to raw for a single file, a named wallpaper the host does not have being an error rather than a short profile, the two refusals that happen before any request at all (a holiday slot, a malformed slot name), a manifest version that is not a number, a profile written for a newer shape refused before anything is fetched, a config that is not JSON, one that is a JSON array, one naming more images than the cap, and a mirror announcing an oversized body.
|
|
26
|
+
|
|
27
|
+
- **The published package drops from 1.1 MB to about 220 kB** — besides the two festival pictures above, two other things were taking up room that the people downloading this plugin should not be paying for. **The documentation screenshots moved out**: `example_img/` (three webp files, 220 KB) now lives in the same assets repository under `dsh-background-by-model/`, and both READMEs reference it by absolute jsDelivr URL — the screenshots were put into `files` in the first place so the images on the npm page would not break, and an absolute URL does that too without putting binaries in the tarball or their history in `.git`. `screenshots.json` is deleted: nothing in the whole DSH installation or `~/.dsh` consumes it. **`lib/client.js.map` is no longer published**: it is a source map for the browser bundle, 624 KB, useless to anyone installing the package, and it stays in the repository (anyone debugging should be debugging a local build anyway). Ten files, about 220 kB packed / 690 kB unpacked, against thirteen files and 1.1 MB / 2.0 MB before. (Both figures are deliberately approximate — this entry and the two READMEs are themselves part of the number, so they nudge it every time they are edited. What the number says is the point: after the pictures left, the tarball is code and documentation and very little else.)
|
|
4
28
|
|
|
5
29
|
## v0.7.5
|
|
6
30
|
|
package/CHANGELOG.zh.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
-
> 这里保留完整的历史记录;最近两个版本(v0.7.
|
|
3
|
+
> 这里保留完整的历史记录;最近两个版本(v0.7.7 / v0.7.6)同时列在 [README.zh.md](./README.zh.md#近期优化) 里。
|
|
4
|
+
|
|
5
|
+
## v0.7.7
|
|
6
|
+
|
|
7
|
+
- **新装出来就是作者本人那套外观,而且不用联网** —— 「界面」页的出厂默认值现在**就是**推荐配置里那套数字([assets 仓库](https://github.com/HarmlessFunny/assets)里的 `preset/theme-config.json`):主背景 `0%`、左侧栏 `10%`、右侧栏 `45%`、卡片 `100%`、代码块 `81%`、输入框与控件 `88%` 外加 `60 px` 模糊、设置面板 `100%`、对话文本框 `35%`、轨迹页 `73%`、其余模糊全 `0`。于是第一次装上、一个字节都还没下,界面就已经值得看;而推荐配置那一下点击加进来的是规则和图片,不是把底下的数字换掉。这些数字此前**每一个都是按「安全」而不是按「好看」逐项挑的** —— `bg` 取 0.85 是为了让宿主表面在壁纸之下仍然可见,`code` 全不透明是因为「代码块是拿来读的、不是拿来看穿的」,`input` 模糊取 0 是因为一层模糊要付一个合成层的代价 —— 这就是为什么以前新装打开的是一个「宿主的苍白近似」,而不是任何人真会用的配置。两个后果是写明的、不是等着以后被发现的:主背景从 `0%` 起步,所以还没有壁纸时窗口就是宿主自己的画布(配色与墨色不受影响,它们来自主题色而不是这个 alpha);而 `check:code-plate` 现在钉住的是配置里的 `81%`,不再是「默认不透明」。这些常量住在 `src/schema.ts`,旁边就写着它们是从真实数据目录抄出来的那一份,所以改推荐配置的数字就得把两边一起搬;README 的「界面」一节说的是同一件事。
|
|
8
|
+
|
|
9
|
+
- **`rightbarOpacity` 保留了它「从未被拥有」的状态,而新装出来是已被拥有的** —— 预览栏的 `null` 意思是「跟随 `opacities.bg`」,而它不是一个理论状态:此前**每一个**版本都写过它 —— 用户从没拖过的那一栏,落盘就是显式的 `null`。所以新的净化器(`normalizeRightbarOpacity`)把 `null` 读回成它自己,只有「这个键根本不在」才拿到出厂的 `45%`。把 `null` 当成「缺失」,会把每一份「预览栏正跟着主背景」的既有配置悄悄重画 —— 而这正是这套配置形状做版本号要防的那种静默迁移。新装从 `45%` 起步、是已被拥有的;`null` 现在只剩下手写可达,因为界面从来就没有一个能回到它的控件。
|
|
10
|
+
|
|
11
|
+
- **节日开关出厂是关的** —— 第一次装上只画模型规则说的东西,别的什么都不画;「配置」页那一个开关才是「要这个功能」的表达方式。它此前是开的,理由是「这个功能的意义就在于到日子背景自己换」;那个理由对于一份**已经被人选定的**配置是对的 —— 所以推荐配置仍然把它**打开** —— 但对于一个刚装上、自己还没有任何壁纸的插件不对:中秋当天,新用户看到的第一样东西会是一张没人要的节日图。净化规则也从「只有显式的 `false` 才关掉」改成「真正的布尔值算数,其它一律取出厂默认」:功能出现之前写下的配置里那个缺失的字段、以及手改出来的垃圾值,现在都意味着关。块内每个节日各自那个开关没动 —— 那是一个已经打开的功能内部的细节,不是这个开关本身。
|
|
12
|
+
|
|
13
|
+
- **「界面」页每张卡片上那个百分比胶囊删掉了** —— 那个数字本来就在它正下方的滑块行上,于是卡头又只剩图标和名字,`.dab-part-badge` 连同它的样式规则一起走。
|
|
14
|
+
|
|
15
|
+
- **门禁** —— `pnpm test` 仍是九道;上面这些默认值动到的是 `check:code-plate`(代码块出厂走配置的 `81%`)与 `check:node`,后者的新断言是**按值**写死的,所以「改了常量没改配置、或改了配置没改常量」会直接让一道校验失败,而不是慢慢漂开:完全没有配置文件时读出来的那套外观数字、显式 `null` 的预览栏读回成它自己、它自己的数字被保留、非数字的手改值落回出厂的 `45%`,以及节日开关两个布尔方向加一个非布尔值。
|
|
16
|
+
|
|
17
|
+
## v0.7.6
|
|
18
|
+
|
|
19
|
+
- **规则页从一摞会自己长大的卡片变成一条选项卡 + 一个编辑器** —— 报告是「这个界面如果规则多且不收起的话会拉的很长」。此前每条规则是一张自展开的卡片,页面的高度等于所有卡片之和,只有用户手动一张张收起才会缩短。现在**每条规则是一个选项卡,页面上只挂载一个编辑器**:`ModelBgPage` 持有选中项(`selId`),`RuleCard` 不再拥有开合状态、永远渲染,它就是那个面板。于是页面高度只跟「一张卡片 + 一条选项卡」有关,与规则条数无关。选项卡把原本只在卡头上才看得到的东西搬了上来 —— 序号、首图缩略图、匹配串,以及两条不用展开就该知道的状态(它是不是当前生效的那条、它在轮换还是被关掉了);条子横向滚动而不是换行,理由和上面一样:一换行就把高度还给了规则条数,而且选项卡固定 34px、匹配串省略号截断,所以切换规则不会让整行抖动。**「+」和「切换哪条规则」这两个动作挪到了滚动区之外**,作为图标贴在条子右端:放在里面时,一个长列表里**唯一能新增规则**的控件会被滚走。条子的滚动条现在也用宿主自己那套 `--dsw-scrollbar-*`(5px、圆角、layer-2 染色、无步进箭头),此前它在面板那条细竖向滚动条旁边显示的是平台默认的粗浅色带箭头版本;选择器全部限定在 `dab-` 类上,因为这个样式表是注入宿主页面的,一个裸的 webkit-scrollbar 选择器会把整个 harness 一起改掉。**匹配测试器搬到了「资料」页** —— 它回答的是「这个模型落在哪条规则上」这个关于整份配置的问题,读一次就够,不是编辑某条规则时要反复看的东西,而在规则页上它把选项卡整整推下去一张卡片的高度;宿主过期的提示一起走了,因为那同样关乎整份配置的写入。选项卡背后那两个判定是纯的,现在住在 `src/client/rules-view.ts`(编辑器显示哪条规则、删除之后落在哪条 —— 落在邻居上,永远不是规则 1),由新的 `check:rules` 钉住,它同时还钉住布局所依赖的页面结构:只画一个编辑器、没有旧的堆叠容器、没有逐卡片的开合状态、条子既不换行也不长高、滚动条样式块仍然被限定住。另外页面描述去掉了 `max-width:56ch` —— 它让那段话提前换行、在旁边留出一块死空间,而下面的卡片是跑满宽度的。
|
|
20
|
+
|
|
21
|
+
- **轮换卡片的控件按你的要求重新排了一遍** —— 四处改动,都是明确的请求(「'一小时'删掉,'切换模型时也换一张'放到'随机'旁边,'下一张、正在显示...'放到外面'轮换这组图'旁边,常驻」「把多图轮换板块放到主题色板块之下,把图二元素删掉」)。**常驻的手动换图**:此前「下一张」按钮和它旁边那句「正在显示第 2 / 3 张」被关在 `rotatable && enabled` 的判定里,于是它们会跟着轮换开关一起消失 —— 而那句读数正是这张卡片上**唯一**说明当前是哪张图的地方。现在按钮住在「轮换这组图」那一行的外侧,对所有规则状态都在,判据只有一条:当前生效的规则有两张以上图就可用(这正是 `rotateNow` 自己的判据,它只问生效规则和 `nextIndex`,从来不问 `rotate.enabled`);不足两张时按钮禁用、读数整句省略而不是印一个「0 / 0」。**「切换模型时也换一张」挪到顺序那一行**,和「顺序」「随机」并排:三者都在回答「什么时候换」,缺了它的那一行读起来像是把话说完了。**「1 小时」从停留时长预设里删掉**,剩五个(10 秒 / 30 秒 / 1 分 / 5 分 / 30 分)加自定义输入 —— 自定义输入照旧接受 3600 秒,5 秒到 24 小时的夹紧范围没变。**「图二元素」—— 那排八个固定预设色板 —— 删掉了**:滚轮、数值输入、从本图提取、吸管、跟随系统主题都还在,那一排只是通往同一个 setter 的快捷方式。它是 `state.ts` 里的 `PALETTE` 表、`ui.css.ts` 里的 `.dab-swatches` / `.dab-swatch` 规则(以及共享描边分组里的 `.dab-swatch:focus-visible`)唯一的读者,这些跟着它一起走了;`.dab-swatch-title` 和 `.dab-swatch-lg` 只是名字前缀相同,未受影响。**整个轮换块移到了第二列**,在主题色和壁纸滑块之下:它此前夹在胶片条和布局模式之间,在宽版两列卡片里是同一个位置,但在折叠成单列的窄版(`~760px` 以下,`.dab-rule-cols`)里,它是卡片里最高的一块 —— 一个带标题的开关、一个内部三行的带框面板 —— 正好落在图片和编辑图片的颜色控件中间。块内部一个字段都没动,就是同一段 JSX 挪了位置。两份 README 里描述那排色板的地方(「灵感色板」/ "an inspiration palette")、停留时长列表里的「1 小时」、以及手动换图的位置都相应改了。
|
|
22
|
+
|
|
23
|
+
- **节日画不再随包发布:当天按需下载、按素材名缓存** —— 两张节日壁纸(228 KB + 500 KB)此前打进包里,占了整个 tarball 的三分之二 —— 为了一张一年只被看一天的画,而且是包里唯一属于「图片」而不是「代码」的东西,还要把它的二进制历史永久留在 `.git` 里。现在它们托管在项目自己的 [`HarmlessFunny/assets`](https://github.com/HarmlessFunny/assets) 仓库(和 README 截图放在一起,但目录分开标注),节点半边在节日当天第一次读取时下载、校验、写进 `~/.dsh/.dsh-background-by-model-data/holiday-cache/`。**引用钉死在 commit 上,不是分支**:运行时素材必须是不可变的 —— 分支引用意味着以后整理一次文档截图,就能让一个已经发布的功能在某个没人盯着的那天静默失效、日志里什么都不说;而 jsDelivr 对 commit 引用永久缓存,正是一个永不改变的文件想要的。**两个镜像**:`cdn.jsdelivr.net` 主用(在 `raw.githubusercontent.com` 不通的网络里也能到),raw 兜底,两个都指向同一个 revision,所以回退不可能混版本。**下载失败不是一个异常路径,而是一个正常状态**:两个镜像都不通,这个节日今天就不接管,模型规则继续画 —— `pickHoliday` 那道「槽位里到底有没有字节」的闸门本来就是为这个写的。**缓存条目会被校验而不是被信任**:不是图片的缓存文件按未命中处理并在下次下载时覆盖,否则一个写到一半被杀掉的进程会让这个节日永久报废,而用户根本不知道有那个文件存在;写入走临时名 + rename,读到一半的文件不可能被看见。**两条不变量一个字都没改**:缓存按**素材名**(`mid-autumn.webp`)命名,刻意放在槽位命名空间之外,所以 `writeImage` 照旧拒绝节日槽位、数据目录里照旧永远不会出现 `modelbg-h-*`。`globalThis.fetch` 在 `check:node` 里被整体替换成桩,测试因此不依赖任何 CDN 是活的,也不去断言一个不属于自己的文件今天有多少字节;新增的断言覆盖:加载插件和读配置不发起任何下载、冷读一次就够、第二次读盘不再传输、两次并发冷读共用一次传输、第一个镜像死了会回退、失败的抓取什么都不缓存、镜像返回 200 但内容是 HTML 会被拒绝、损坏的缓存会被重新下载、两个镜像指向同一个 commit。
|
|
24
|
+
|
|
25
|
+
- **一键装上「推荐配置」** —— 「配置」页多了第三张卡,从同一个 [`HarmlessFunny/assets`](https://github.com/HarmlessFunny/assets) 仓库下载作者本人正在用的那套配置并就地覆盖你的。**它托管在数据目录自己的形状里**:`preset/preset.json`(形状闸门)、`preset/theme-config.json`(6.5 KB 可读 JSON)和 `preset/modelbg-<slot>`(每个槽位一个原始文件)。第一版是单个主题文件、所有壁纸内联成 base64,2.9 MB 里 99.8% 是图片 —— 在几十万字符的一行里找一个 `match` 字符串不是任何人能做的手改,格式就是为这个改的;换过来之后,改配置是在 GitHub 上编辑 6.5 KB 的 JSON,换壁纸是替换一个文件,发布是从 `~/.dsh/.dsh-background-by-model-data/` 里 `cp` 一下。node 半边新增 `fetchPresetConfig`(取 manifest 与 config、在**这一侧**跑共享 sanitizer、再从这个配置推导出要请求哪些文件)与 `fetchPresetImage`(按槽位取一个文件,魔数校验后返回 data URL),旧的单文档 `fetchPreset` 删掉;`fetchHolidayAsset` 上一版拆出的通用 `fetchAsset` 被两者复用。**请求清单从配置推导,而不是来自第二份清单**:加一张壁纸就是在 config 里加一条并放进同名文件;反过来说,一份不受信任的配置决定了这个进程会去网络几次,所以每个槽位名都要过 `SLOT_RE`(在 `normalizeImage` 里),数量另有上限。**config 里合法存在的两个节日槽位会被剔掉而不是去请求** —— `holidays.items` 里必然有 `h-midautumn` / `h-nationalday`,而数据目录里永远不可能有 `modelbg-h-*` 文件(上一版刚加的硬断言),照单去请求会让整个功能在一份插件自己保证不存在的文件上失败。客户端**一个文件一个请求**地取、同时最多四路 —— 实测同一份配置顺序取 8.3 秒、并发取 4.8 秒,因为付的是 HTTP/2 上的每请求延迟 —— 按钮上显示 `3/7`;每个文件因此有自己的镜像回退与自己的校验。**少一张就整体失败并报出是哪个槽位**:一份悄悄少了图的配置恰恰是「节日素材钉死 commit」那条契约要防的静默失效,把它报出来才让分支引用在这里站得住。落地仍然走本地文件那条 `applyThemeFile`(在客户端组装成 `exportTheme` 写出的形状),所以版本闸门、sanitizer、清空都还是同一条路;`preset.json` 让版本闸门在请求第一张壁纸之前就能生效。它仍然是这个面板里唯一会销毁东西的操作:下载在**提问之前**(确认框因此能如实说出手里有什么),清空在**下载成功之后**(CDN 不通不该让你在等一份永远没来的配置的路上先弄丢自己的配置),一个旧到写不了这套形状的宿主在删除任何东西之前就被拒绝,`holiday-cache/` 不碰,配置也从不落盘缓存。`check:node` 的桩新增了「按文件名供应一整个目录、缺名就是 404」这一档,覆盖:manifest 与 config 按序取且当场 sanitize、请求清单由规则推导且节日槽位被剔掉、一张壁纸一个请求且类型是嗅出来的、对单个文件回落到 raw、config 点名而托管处没有的文件是一个错误、节日槽位与畸形槽位名在任何请求之前就被拒绝、manifest 版本不是数字、写给更新形状的配置在请求第一张壁纸之前被拒绝、config 不是 JSON / 是数组 / 图片数超限、以及镜像谎报超长。
|
|
26
|
+
|
|
27
|
+
- **发布包从 1.1 MB 瘦到约 220 kB** —— 除了上面那两张节日画,另外两样东西也在占地方,而且都不该由下载这个插件的人来付。**文档截图搬走了**:`example_img/`(三个 webp,220 KB)移到同一个 assets 仓库的 `dsh-background-by-model/` 目录下,两份 README 改用 jsDelivr 绝对地址引用 —— 这个插件此前专门把截图放进 `files` 是为了让 npm 页面上的图不裂,而绝对地址同样做得到,还不用把二进制塞进包里、更不用写进 `.git` 的历史。`screenshots.json` 删掉了:翻遍整个 DSH 安装目录和 `~/.dsh` 都没有任何消费方。**`lib/client.js.map` 不再发布**:它是给浏览器 bundle 用的源码映射,624 KB,对装包的人没有用处,仓库里仍然保留(要调试本地构建的人本来就该对着本地构建调)。10 个文件、约 220 kB packed / 690 kB unpacked,此前是 13 个文件、1.1 MB / 2.0 MB。(这两组数字刻意写成约数 —— 这条记录和两份 README 本身就是这个数字的一部分,每改一次就把它推高一点。这个数字想说的是:图片搬走之后,包里剩下的确实只有代码和文档。)
|
|
4
28
|
|
|
5
29
|
## v0.7.5
|
|
6
30
|
|
package/README.md
CHANGED
|
@@ -49,19 +49,19 @@ Notes:
|
|
|
49
49
|
One interface, one config — only the current model differs:
|
|
50
50
|
|
|
51
51
|
<p align="center">
|
|
52
|
-
<img src="
|
|
52
|
+
<img src="https://cdn.jsdelivr.net/gh/HarmlessFunny/assets@main/dsh-background-by-model/wallpaper-deepseek.webp" alt="Appearance under DeepSeek" width="880">
|
|
53
53
|
<br/>
|
|
54
54
|
<em>DeepSeek V4.1 Flash · matched the rule whose match string contains <code>deepseek</code>: a light wallpaper with a matching theme color</em>
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
57
|
<p align="center">
|
|
58
|
-
<img src="
|
|
58
|
+
<img src="https://cdn.jsdelivr.net/gh/HarmlessFunny/assets@main/dsh-background-by-model/wallpaper-kimi.webp" alt="Appearance under Kimi" width="880">
|
|
59
59
|
<br/>
|
|
60
60
|
<em>Kimi K2.7 Code · matched the rule containing <code>kimi</code>: a dark wallpaper, a dark theme, and the whole interface reskinned with it</em>
|
|
61
61
|
</p>
|
|
62
62
|
|
|
63
63
|
<p align="center">
|
|
64
|
-
<img src="
|
|
64
|
+
<img src="https://cdn.jsdelivr.net/gh/HarmlessFunny/assets@main/dsh-background-by-model/rule-editor.webp" alt="One rule's editor" width="660">
|
|
65
65
|
<br/>
|
|
66
66
|
<em>One rule on the Model Background tab · the wallpaper, its opacity and its blur belong to the rule; the layout mode, the framing and the theme color (wheel / HSL / RGB / extract from this image / pick from image) belong to the image it is editing</em>
|
|
67
67
|
</p>
|
|
@@ -78,7 +78,7 @@ One interface, one config — only the current model differs:
|
|
|
78
78
|
- **Live Match Readout** — The top of the Model Background tab shows the current state, e.g. `Current model deepseek-flash → matched · Rule 1`, so you can verify a rule on the spot. If the current model can't be detected, a hint is shown instead.
|
|
79
79
|
- **Per-rule Appearance** — Every rule owns its wallpapers, opacity and blur, and **every image owns its layout mode, its framing and its theme color**. Nothing is shared globally except the Interface tab.
|
|
80
80
|
- **Several Images per Rule** — A rule holds an ordered set of images, shown as a filmstrip: add several at once (file picker, drag & drop, or a list of URLs, one per line), reorder them, promote one to first, **replace one in place** (which keeps its position in the rotation), or remove them one by one. The image a rule paints when nothing rotates is its **first**. Removing the last image simply leaves the rule empty — and empty is not the same as off: while the rule keeps a theme color of its own it still matches, still serves as the fallback, and paints the interface instead of a wallpaper; only a rule with neither (a freshly added one) is skipped by matching. So an emptied rule is a visible, reversible state rather than one you get stuck in. While it holds no picture the filmstrip is hidden and the big preview tile **is** the upload button, so there is exactly one obvious place to add one.
|
|
81
|
-
- **Import / Export** — Export every rule **including all of its images** to a `dsh-background-by-model-theme.json` (format version 6, images inlined as base64) and restore it anywhere. Files written by earlier releases still import: each rule's single image is lifted into its image list, a color written before per-image colors is lifted onto every image that has none, a layout mode written when it was the rule's is lifted onto each of its images, and a file written before the [switch effect](#switch-effect-global) gets that setting's shipped default — so an older theme file restores its look unchanged.
|
|
81
|
+
- **Import / Export** — Export every rule **including all of its images** to a `dsh-background-by-model-theme.json` (format version 6, images inlined as base64) and restore it anywhere. Files written by earlier releases still import: each rule's single image is lifted into its image list, a color written before per-image colors is lifted onto every image that has none, a layout mode written when it was the rule's is lifted onto each of its images, and a file written before the [switch effect](#switch-effect-global) gets that setting's shipped default — so an older theme file restores its look unchanged. The same document can also be **downloaded from the project's asset host** instead of picked from disk — see [Recommended profile](#recommended-profile) — with one difference, which is that it empties the store before it writes.
|
|
82
82
|
- **File-based Persistence** — All settings and images are stored on the filesystem under `~/.dsh/.dsh-background-by-model-data/`, not `localStorage`.
|
|
83
83
|
- **Automatic Migration** — Old single-wallpaper configs are upgraded in place on first read, and so is a layout mode that used to live on the rule. See the [v0.3.0 entry in CHANGELOG.md](./CHANGELOG.md#v030).
|
|
84
84
|
- **Bilingual** — Full Chinese / English UI with automatic locale detection.
|
|
@@ -89,11 +89,11 @@ One interface, one config — only the current model differs:
|
|
|
89
89
|
Per rule, and **off by default** — cycling spends real bandwidth, memory and battery, so nothing turns it on for you.
|
|
90
90
|
|
|
91
91
|
- **Enable it per rule** — the switch appears in the rule card and only becomes usable once the rule holds two or more images.
|
|
92
|
-
- **Dwell time** — 10 s / 30 s / 1 min / 5 min / 30 min
|
|
92
|
+
- **Dwell time** — 10 s / 30 s / 1 min / 5 min / 30 min, or any custom value in seconds (clamped to 5 s – 24 h).
|
|
93
93
|
- **Order** — **In order** walks the list top-down and wraps around; **Shuffle** picks uniformly among every image *except* the one on screen, so a tick never looks like it was missed.
|
|
94
94
|
- **Also step on a model switch** — an optional second trigger: every time the model changes and lands on that rule, it steps once. That is the whole feature for a rule meant to show "a different picture every time" without any timer running.
|
|
95
95
|
- **Only the active rule rotates** — one timer for the whole plugin, aimed at whichever rule the current model resolved to. It stops while the tab is hidden and resumes on a fresh interval; a single-image rule (and every [holiday](#holiday-backgrounds)) never schedules anything.
|
|
96
|
-
- **Next image** — steps the wallpaper immediately, for when you want to check the set.
|
|
96
|
+
- **Next image** — steps the wallpaper immediately, for when you want to check the set. It sits with the rotation switch (beside *which image is on screen*) and works whether or not the timer is running.
|
|
97
97
|
- **What follows a switch is the rule — except everything that belongs to the picture** — opacity and blur belong to the rule and stay put. The **layout mode**, the **framing** and the **theme color** belong to the image, so a rotation can letterbox a tall screenshot and fill the landscape photo next to it, and can move through a green picture, a red one and a system-themed one with the interface palette following the wallpaper. The cross-fade between two images is the same one a model switch already used.
|
|
98
98
|
- **Layout mode, framing and color are per image** — 适应/填充 decides how *this* picture meets the viewport, a crop and an accent belong to it too, so each image keeps its own while sharing the rule's opacity and blur. The filmstrip marks the images that carry a color of their own, and the color controls always say which image they are editing.
|
|
99
99
|
- **Only the images it needs are loaded** — boot reads each rule's first image; the rest stream in when a card is expanded or when the rotation is about to need one. Ten images per rule therefore do not mean ten wallpapers transferred before the first frame.
|
|
@@ -113,21 +113,21 @@ What a wallpaper **change** looks like. It lives on the **Config** page, it is t
|
|
|
113
113
|
|
|
114
114
|
### Holiday backgrounds
|
|
115
115
|
|
|
116
|
-
A small one, not a settings block: **one switch on the Config page and nothing else**. It
|
|
116
|
+
A small one, not a settings block: **one switch on the Config page and nothing else**. It ships **off** — turn it on and on the day the background changes by itself and changes back the next morning. (The [recommended profile](#recommended-profile) below turns it on for you.)
|
|
117
117
|
|
|
118
118
|
- **How it behaves** — On 中秋节 and 国庆节 the wallpaper switches to that holiday's own image, with that holiday's own fixed theme color (中秋 `#384A77`, 国庆 `#FFF6EB`). The next day, the model rules take over again.
|
|
119
119
|
- **Mid-Autumn Festival** — 农历八月十五, the day itself. It moves every year (2024-09-17, 2025-10-06, 2026-09-25, 2027-09-15 …), so it is resolved from the Chinese calendar at runtime, in **Asia/Shanghai** — the lunar day turns over at Beijing midnight, not yours.
|
|
120
120
|
- **National Day** — October 1–7.
|
|
121
121
|
- **Mid-Autumn wins the overlap** — the two do collide (2025-10-06 was both); the single precise day is the better answer.
|
|
122
122
|
- **A holiday with no image falls through** to the model rules rather than blanking the wallpaper.
|
|
123
|
-
- **
|
|
124
|
-
- **Neither the art nor the palette is swappable, by design** — an easter egg that asks to be configured is not an easter egg. A holiday slot is read-only: a file dropped into `modelbg-h-midautumn` / `modelbg-h-nationalday` is ignored by every read, and the plugin refuses to write, fetch into or delete those slots. The theme colors are constants in the holiday definition and are forced on every read — on the holiday **and on its image**, since a theme color lives on the image now — so a hand-edited `color` in `theme-config.json` cannot repaint a festival either. Its layout mode is the definition's **Fill** for the same reason (the art is full-bleed, and a stale `fit` would letterbox it), while the **framing** next to it stays yours. Theme exports therefore carry your rules only.
|
|
125
|
-
- **Turning it
|
|
123
|
+
- **The art is downloaded, not shipped** — a compressed wallpaper per holiday (228 KB and 500 KB at native resolution, against 8.37 MB of source art), hosted in the project's [assets repository](https://github.com/HarmlessFunny/assets) rather than in the package: they were two thirds of the tarball for a picture that is looked at one day a year. The download is gated on the **calendar**, so a profile that is not on a holiday fetches nothing at all, and the first read on the day caches the file under `holiday-cache/` — every boot after that, and every year after that, is answered from disk and needs no network. The reference is pinned to a **commit**, never a branch, so reshuffling the repository's screenshots cannot break a shipped festival; a `jsDelivr` mirror is tried first and `raw.githubusercontent.com` second, and if both are unreachable the holiday simply does not take over — the model rules keep painting.
|
|
124
|
+
- **Neither the art nor the palette is swappable, by design** — an easter egg that asks to be configured is not an easter egg. A holiday slot is read-only: a file dropped into `modelbg-h-midautumn` / `modelbg-h-nationalday` is ignored by every read, and the plugin refuses to write, fetch into or delete those slots. The download lands in `holiday-cache/`, keyed by asset name and never by slot, so the store still never holds a `modelbg-h-*` file. The theme colors are constants in the holiday definition and are forced on every read — on the holiday **and on its image**, since a theme color lives on the image now — so a hand-edited `color` in `theme-config.json` cannot repaint a festival either. Its layout mode is the definition's **Fill** for the same reason (the art is full-bleed, and a stale `fit` would letterbox it), while the **framing** next to it stays yours. Theme exports therefore carry your rules only.
|
|
125
|
+
- **Turning it on** — the switch on the Config page, or `"holidays": { "enabled": true }` in the same file. Only a real `true` counts: the feature is on because a configuration says so, not because nothing has been said. The per-holiday switches inside it (中秋 / 国庆) are a different thing and still default to on — they are details of a feature that is already switched on.
|
|
126
126
|
|
|
127
127
|
### Per-rule and per-image settings
|
|
128
128
|
|
|
129
129
|
- **Wallpaper** — Give a rule one or more images; each image is its own file. The filmstrip picks which one you are editing, and the "first" one is what the rule paints when no rotation is running. A rule may also hold **no** image: it then paints no wallpaper, but as long as it has a theme color of its own it still matches and still serves as the fallback (painting the interface alone), and only with neither is it skipped by matching until you give it something.
|
|
130
|
-
- **Theme Color** — HSL wheel plus numeric input
|
|
130
|
+
- **Theme Color** — HSL wheel plus numeric input, with **Extract from this image** and an **eyedropper**. **The color belongs to the image**: those controls edit the one selected in the filmstrip, the strip shows which images already carry a color of their own, and an image that has none follows the system theme rather than inheriting its rule's. A rule with **no image at all** has only its own color left to edit — and that is exactly what such a rule paints. Generates the full CSS design-token set in real time. Following the system theme hands the palette back to the host while the wallpaper and the Interface-tab opacity/blur sliders keep working — the surface colors are read back from the host's own tokens and re-emitted with your alpha, so the wallpaper is never buried under an opaque plate.
|
|
131
131
|
- **Layout Mode** — Fit / Fill / Stretch / Tile / Center, and it is stored **per image**: a rotation can letterbox one picture and fill the next. On a rule that holds no picture the row is disabled (there is nothing to lay out) rather than hidden, so the card shows what becomes editable once you add one.
|
|
132
132
|
- **Framing** — Drag to pan and scroll to zoom inside a viewport-proportional editor; **only editable in Fit mode**, and the committed framing stays consistent across window resizes and cross-monitor moves. Stored per image.
|
|
133
133
|
- **Background Opacity** — `0–100%` for the rule's wallpaper layer.
|
|
@@ -135,10 +135,37 @@ A small one, not a settings block: **one switch on the Config page and nothing e
|
|
|
135
135
|
|
|
136
136
|
### Global settings (Interface tab)
|
|
137
137
|
|
|
138
|
+
- **What a fresh install starts on** — the shipped numbers **are the author's own profile**, i.e. the Interface numbers the [recommended profile](#recommended-profile) carries, so a first run already looks like that without downloading anything: main background `0%`, left panel `10%`, right panel `45%`, cards & panels `100%`, code blocks `81%`, input & controls `88%` with `60 px` of blur, settings panel `100%`, conversation text `35%`, trajectory `73%`, and every other blur `0`. The two are kept in step by hand — the profile is published straight out of a live data directory, so changing its numbers means moving these constants with them. (The two settings this tab does not own are deliberately *not* copied from the profile: the [festival switch](#holiday-backgrounds) ships off, and the [switch duration](#switch-effect-global) keeps the 320 ms cross-fade — the profile uses its 3000 ms maximum.)
|
|
138
139
|
- **Per-part Interface Opacity** — Independent sliders for the main background, left panel, right panel, cards & panels (including the dropdowns and menus around the dialog), the input & controls (composer box, Cordis panel), plus the settings panel and the conversation text box. Independent of the theme color: a rule with no color keeps every one of these sliders live.
|
|
139
140
|
- **Per-part Interface Blur** — Frosted-glass `backdrop-filter` blur (`0–60 px`) for each interface part, including a real backdrop on the composer and Cordis panel via stable host selectors.
|
|
140
141
|
- **Conversation & Trajectory** — The message list is wrapped in a translucent card automatically, and the trajectory page gets whole-page opacity & blur controls, letting the wallpaper shine through the content.
|
|
141
|
-
- **Right Panel** — The column that slides in from the right when you open a file now has a card of its own: its opacity follows **Main background**
|
|
142
|
+
- **Right Panel** — The column that slides in from the right when you open a file now has a card of its own: this card owns its opacity from the first drag, and until then it follows **Main background** — the state a config written while that was the shipped default is in, since a fresh install already owns the panel at the profile's `45%` — and its blur stacks on top of the main-background blur. While closed it takes no space and costs nothing.
|
|
143
|
+
|
|
144
|
+
### Recommended profile
|
|
145
|
+
|
|
146
|
+
The Config tab's first card downloads the author's own configuration — rules, wallpapers and interface settings — from the project's [assets repository](https://github.com/HarmlessFunny/assets) and installs it in one click.
|
|
147
|
+
|
|
148
|
+
**Every Interface number in it is what the plugin already ships with** — each opacity, blur and tint alpha in `theme-config.json` is the number a fresh install starts on (see [Global settings](#global-settings-interface-tab)) — so on a new install this button adds the rules and the pictures. Two settings it brings that a fresh install does not have are outside that tab: the [festival switch](#holiday-backgrounds), which ships off and this profile turns on, and the [switch duration](#switch-effect-global), which the profile sets to its 3000 ms maximum where the shipped default is the 320 ms cross-fade every earlier release used. On a store whose sliders you have already moved, adopting it resets those too: it is a whole configuration, not a patch.
|
|
149
|
+
|
|
150
|
+
**It is hosted in the store's own shape**, not as one bundled document:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
preset/
|
|
154
|
+
├── preset.json the shape gate — {"version": 6}
|
|
155
|
+
├── theme-config.json the rules and the interface settings (6.5 KB)
|
|
156
|
+
└── modelbg-m1 … modelbg-m7 each wallpaper as its raw bytes
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
So it is editable where it lives: the config is a few kilobytes of readable JSON that can be edited on GitHub directly, and replacing one wallpaper is replacing one file. It also makes publishing it a `cp` out of `~/.dsh/.dsh-background-by-model-data/`. The plugin fetches the manifest and the config, derives the file list from `rules[].images[].slot` — there is no manifest of images to keep in sync — and then fetches the wallpapers **one request each, up to four in flight**, showing the count on the button while it runs.
|
|
160
|
+
|
|
161
|
+
It is the only action in the panel that **destroys** something, and it is built around that:
|
|
162
|
+
|
|
163
|
+
- **You are asked second, not first.** The download happens before the confirmation, so the question can say what is actually in hand — *7 rules · 7 wallpapers · 2.9 MB* — instead of asking about a file that may never arrive. If the download fails, nothing has happened yet.
|
|
164
|
+
- **One missing wallpaper fails the whole thing**, and says which. A profile that quietly arrived without a picture — because a file was renamed where it is hosted — would be exactly the silent failure that pinning the festival art to a commit exists to prevent; naming the file keeps that failure loud, which is what makes a branch reference acceptable here.
|
|
165
|
+
- **The store is emptied before the profile is written.** `nextSlot` allocates slots as `m1`, `m2`, … — a counter, not a random token — so a downloaded profile and the store it lands in collide on those names as a matter of course. "Replace everything with this" is only true if the everything is genuinely gone, and this is also why there is no undo.
|
|
166
|
+
- **The wipe runs after the download, never before it.** An unreachable CDN must not cost you your configuration on the way to a profile that never arrived — which matters more now that the download is several transfers rather than one.
|
|
167
|
+
- **The festival art is not touched.** `holiday-cache/` is downloaded art that belongs to no slot; it is not part of anybody's configuration, and re-fetching it would be a network round trip for nothing. The config *does* name the two holiday slots (they are part of any config), and they are dropped from the request set rather than asked for: no `modelbg-h-*` file can exist.
|
|
168
|
+
- **It is referenced by branch, unlike the festival art's commit** — and for the opposite reason. A profile fails *loudly* (you are looking at the button when it happens) where a holiday fails silently, so pinning would buy nothing and would cost a plugin release for every correction to one JSON file. The risk that is real — a profile written for a config shape this build cannot read — is what `preset.json` is for: it is refused before a single wallpaper is requested, and long before anything is deleted.
|
|
142
169
|
|
|
143
170
|
## Settings
|
|
144
171
|
|
|
@@ -148,7 +175,7 @@ Settings → **Theme** now has three tabs:
|
|
|
148
175
|
| --- | --- | --- |
|
|
149
176
|
| **Interface** | Global, shared by every model | Opacity & blur for the main background, left panel, right panel, cards & panels, input & controls, settings panel, conversation text box and trajectory page |
|
|
150
177
|
| **Model Background** | Per rule, per image | The ordered rule list, the live match readout, and each rule's images (filmstrip), **per-image layout mode, framing and theme color**, plus the rule's opacity, blur and [rotation](#image-rotation) |
|
|
151
|
-
| **Config** | — | The global [switch effect](#switch-effect-global),
|
|
178
|
+
| **Config** | — | The global [switch effect](#switch-effect-global), the whole rule set as a file — [recommended profile](#recommended-profile), import and export (`dsh-background-by-model-theme.json`) — plus the single [holiday background](#holiday-backgrounds) switch |
|
|
152
179
|
|
|
153
180
|
The old **Color** tab is gone — the theme color is now a property of each rule. The old **Background** tab became **Model Background**.
|
|
154
181
|
|
|
@@ -160,7 +187,7 @@ Data directory: `~/.dsh/.dsh-background-by-model-data/` (Windows: `C:\Users\<you
|
|
|
160
187
|
| --- | --- |
|
|
161
188
|
| `theme-config.json` | The rule list (each rule with its image list and rotation) plus the global Interface settings, the global switch effect and the holiday overrides |
|
|
162
189
|
| `modelbg-<slot>` | One image, stored as raw bytes without a file extension — one file per image, so a rule with three images owns three slots |
|
|
163
|
-
| `
|
|
190
|
+
| `holiday-cache/<asset>` | Festival art downloaded from the CDN, one file per holiday (`mid-autumn.webp`, `national-day.webp`). Keyed by **asset name**, deliberately outside the slot namespace — a holiday slot still never holds a file, which is what keeps it read-only. Delete a file here and it is simply re-downloaded the next time that holiday is in force |
|
|
164
191
|
|
|
165
192
|
## Installation
|
|
166
193
|
|
|
@@ -212,14 +239,17 @@ To mount a working copy into a profile instead, add it to the profile's `package
|
|
|
212
239
|
|
|
213
240
|
After changing anything under `src/`, run `pnpm run bundle` again — the mounted profile loads `lib/`, so edits do not take effect until the bundle is rebuilt.
|
|
214
241
|
|
|
215
|
-
`pnpm test` builds, typechecks and runs
|
|
242
|
+
`pnpm test` builds, typechecks and runs nine checks (`tsdown && tsc -p tsconfig.json && node scripts/holiday-check.ts && node scripts/rotation-check.ts && node scripts/transition-check.ts && node scripts/repaint-check.ts && node scripts/code-plate-check.ts && node scripts/image-mode-check.ts && node scripts/rules-view-check.ts && node scripts/ui-strings-check.ts && node scripts/node-half-check.mjs`). None of them needs a dependency, a transformer or a browser, and each can be run alone with `pnpm check:holiday` / `pnpm check:rotation` / `pnpm check:transition` / `pnpm check:repaint` / `pnpm check:code-plate` / `pnpm check:image-mode` / `pnpm check:rules` / `pnpm check:ui` / `pnpm check:node`:
|
|
216
243
|
|
|
217
244
|
- **`check:holiday`** — the two holiday windows against known dates, the Beijing day boundary (23:59 vs 00:01), leap eighth months across 1900–2100, and the four gates `pickHoliday` applies before a holiday is allowed to take over the background.
|
|
218
245
|
- **`check:rotation`** — the rotation's decisions (`nextIndex` / `isRotating`): no walking off the end of a list, shuffle never repeating the image already on screen (across the whole support of the roll), and "rotating" never claimed for a rule with nothing to rotate.
|
|
219
246
|
- **`check:transition`** — the switch effect's decisions (`resolveFadeMs` / `transitionPlan`), which live in `src/client/transition.ts` and are the ones that fail without a sound: that the shipped default still produces **exactly** the transition string earlier releases wrote (`opacity 320ms ease`, opacity only — an unchanged property must not be put on the transition list), that `Instant`, a `0` duration, a `0` unified duration and a non-numeric duration each mean a hard cut, that reduced motion vetoes rather than shortens, that every effect starts somewhere other than where it ends (the "I picked the new effect and nothing happened" failure), and that every effect lands fully visible and **unscaled** — a zoom that never resets would crop every later wallpaper.
|
|
220
247
|
- **`check:repaint`** — the decision that says whether an edit has to repaint the interface (`shouldRepaint`), including the case that kept failing in the field: an edit that **creates** the winner (a rule's first picture, its first or auto-extracted color) must repaint even though the edited rule was not the active one yet. It also fails if any of the write paths in `src/client/index.tsx` stops asking — so re-introducing the old `id === activeRuleId` test breaks the build's checks instead of the user's next upload — and if a rotation step stops re-emitting the interface palette (a theme color belongs to the image, so a step changes it).
|
|
248
|
+
- **`check:code-plate`** — the code block's plate: that the surface tokens it reads are declared on **both** `:root` and `body` (a `var()` is substituted where it is *declared*, so a root-level consumer otherwise reads the host's colour and not the palette's), that the light branch emits the banner instead of borrowing the host's near-white, and that each of the two surfaces reads its **own** plugin variable — one shared variable would let the banner's write paint the plate too.
|
|
249
|
+
- **`check:image-mode`** — the 0.7.5 lift of the layout mode onto the image and, more to the point, the **wiring**: which image a control edits and which image the render layer reads. A mis-wired read does not throw, it just makes every picture in a rotation look the same.
|
|
250
|
+
- **`check:rules`** — the two decisions behind the tab strip, which are pure and live in `src/client/rules-view.ts` (which rule the editor shows, and where a deletion lands — its neighbour, never rule 1), plus the page structure the layout rests on: one editor drawn, no stacked per-card container, no per-card open state, a strip that can neither wrap nor grow, and its scrollbar block staying scoped to the plugin's own classes.
|
|
221
251
|
- **`check:ui`** — every `t('…')` key exists in both dictionaries, both dictionaries carry the same key set, every `dab-…` class has a rule in the stylesheet, and no dictionary entry has gone unreferenced.
|
|
222
|
-
- **`check:node`** — the built node half driven through its real RPC handler with `DSH_HOME` redirected to a throwaway directory: the holiday block through the shared sanitizer
|
|
252
|
+
- **`check:node`** — the built node half driven through its real RPC handler with `DSH_HOME` redirected to a throwaway directory, and `globalThis.fetch` replaced by a stub — the festival art lives on a CDN now, and this suite must not depend on one being up, nor assert today's bytes of a file it does not own. It covers: the holiday block through the shared sanitizer; nothing fetched merely for loading the plugin or reading the config; the art fetched on demand and cached under `holiday-cache/` keyed by **asset** rather than slot; a second read answered from disk with no second transfer; two simultaneous cold reads sharing one transfer; a dead first mirror falling through to the second with both mirrors pinned to the same commit; every mirror down yielding "no bytes" rather than a throw, with nothing cached from a failed fetch; a mirror answering 200 with a non-image rejected rather than cached; a corrupt cache entry discarded and re-downloaded; a holiday slot refusing writes, deletes and URL fetches while a file dropped into it is ignored and no `modelbg-h-*` file is ever written; an ordinary rule slot still writing, listing and deleting; a hand-edited config unable to redirect a holiday at another rule's image; the per-image color shape — the read-time lift in both directions (an absent key inherits the rule's color, an explicit `null` does not), independent colors through the file, and a `null` written as a key rather than omitted; and the global switch effect — the shipped default for a config that predates it, a chosen effect/easing/unified duration surviving the round trip, hostile values falling back while an absurd duration clamps, a `0` duration kept rather than defaulted, and drift inside `transition` reported instead of silently dropped. The recommended profile is covered end to end from the node half's side: the manifest and the config fetched in that order and sanitized on arrival, the request set DERIVED from the rules with the holiday slots dropped from it, one request per wallpaper with the bytes sniffed rather than trusted from a header, a dead jsDelivr falling through to raw for a single file, and every way it can fail reported as a value rather than a throw — every mirror down, a mirror answering 500, a 200 carrying HTML, a manifest whose version is not a number, a profile written for a newer shape refused before a single wallpaper is asked for, a config that is not JSON, a config that is a JSON array, a config naming more images than the cap, and a mirror announcing an oversized body; plus the strict half (a named wallpaper the host does not have is an error, not a short profile), the two naming refusals that happen before any request at all (a holiday slot, and a slot name that is not a slot), and the reset: the config and every rule image gone, `holiday-cache/` untouched, a read afterwards yielding a fresh config rather than an error, and the profile then writing into the emptied store.
|
|
223
253
|
|
|
224
254
|
## FAQ
|
|
225
255
|
|
|
@@ -270,20 +300,22 @@ Two things can hold it, and both are on the card: the effect is **Instant**, or
|
|
|
270
300
|
|
|
271
301
|
## Recent Optimizations
|
|
272
302
|
|
|
273
|
-
> Only the two most recent releases are listed here; older ones (v0.7.
|
|
303
|
+
> Only the two most recent releases are listed here; older ones (v0.7.5 and earlier) live in [CHANGELOG.md](./CHANGELOG.md).
|
|
304
|
+
|
|
305
|
+
### v0.7.7
|
|
274
306
|
|
|
275
|
-
|
|
307
|
+
- **A fresh install starts on the author's own profile, with nothing to download** — the shipped Interface numbers are now the ones the [recommended profile](#recommended-profile) carries: main background `0%`, left panel `10%`, right panel `45%`, code plate `81%`, inputs `88%` with `60 px` of blur, conversation text `35%`, trajectory `73%`. The plugin therefore looks right before a byte is fetched, and the profile's one click adds pictures rather than changing the look underneath them. Every one of those numbers used to be picked per key for **safety** rather than for looks — `bg` 0.85 so the host surface stayed visible under it, `code` fully opaque because a code block is read rather than looked through, `input` blur 0 because blur costs a compositor layer — which is why a new install opened on a pale approximation of the host instead of on a configuration anyone would run. The preview panel is the one field that needed care: `null` ("never dragged, so follow the main background") is preserved as itself rather than read as a missing key, because every release so far has **written** it — a panel the user never dragged sits on disk as an explicit `null`, and taking that for "missing" would have repainted the panel in every existing configuration.
|
|
308
|
+
- **The festival switch ships off** — a first run paints what the model rules say and nothing else; the switch on the Config page is how the feature is asked for, and the recommended profile turns it on, which is the difference between a chosen configuration and a fresh one. Only a real boolean counts now: an absent field, or a hand-edit that is not `true`/`false`, takes the shipped default instead of the old "anything but `false` means on".
|
|
309
|
+
- **The percentage pill in each Interface card is gone** — the number was already on the slider row below it, so the card head is the icon and the name again.
|
|
276
310
|
|
|
277
|
-
|
|
278
|
-
- **The fade only animates what the palette in force writes (a fix)** — "有时候切换背景时(图上为浅色切换为浅色),白色色块会渐变为黑色色块…白色渐变完黑色后立马切到白色", with the white value measured as `237, 243, 254`. That number is the answer: `#edf3fe` = `--dsw-static-deepseek-50`, which is what the host's light scheme paints `--dsw-specific-bubble` with — the user message bubble — and its dark-scheme value is `#2c2c2e`. The fade had registered that name because it asks for the **dark** branch's token list (the superset) and hands the whole thing to the `:root` and `body` scopes, while the light branch writes only 35 of those 80 names: the other 45 (the bubble, the settings dropdown fills, the tip/tooltip/toast surfaces, the code-block header segments, the status colours) still belong to the **host**, and the plugin is what makes the host switch schemes for a moment — it disposes and re-registers its theme on every colour change, and the host's disposer resets the preference to `system`, which on a dark desktop paints the host's dark palette until that call finishes. With the reported 3000 ms switch, one frame of it became a three-second ramp. A scope's token is now emitted only when the palette in force writes it (the registrations still cover all 80 names, so the dark palette is unchanged), and a skin whose colour scheme already holds is not rebuilt at all. Measured on the reported palette: `body`'s transition list goes 80 → 35 names, the bubble and the dropdown fill are out of it, and `--dsw-alias-bg-base`, `--dsw-alias-bg-layer-2` and the code plate stay in.
|
|
279
|
-
- **The code block follows the palette, and its plate has an opacity of its own (a fix)** — "代码块背景有点问题": dark green ink on a near-black plate inside a **light** interface. The host's shiki sheet declares `--shiki-background: var(--dsw-alias-markdown-code-block)` on `:root`, while the token was declared on `body` only, so the root element had nothing to read but the fade registration's `initial-value` — the host's own colour, sampled once. The palette rule is emitted for `:root` too, `:root` joins the fade scopes, the plate and its banner are palette tints again, and a new **`code`** part drives both surfaces, each through its own variable, defaulting to opaque.
|
|
280
|
-
- **Four small ones** — the rotation switch no longer stays "on" when deleting images leaves fewer than two (the panel disables the switch there, so it could not be turned off either; `normalizeRule` enforces the same invariant for imports), "切换时长" is printed once instead of twice, and the profile footer's package name and the brand tile link to the repository, with `check:ui` comparing that one address against `package.json`.
|
|
281
|
-
- **Gates** — `pnpm test` is now **eight** checks: `check:code-plate` and `check:image-mode` join the suite, `check:rotation` gained the switch-and-count invariant, `check:ui` the repository-link agreement, `check:transition` the fade-ownership rule and `check:repaint` the two lines that arm the fade.
|
|
311
|
+
### v0.7.6
|
|
282
312
|
|
|
283
|
-
|
|
313
|
+
- **The rules page turns from a stack of self-growing cards into one tab strip and one editor** — every rule used to be a card that expanded itself, so the page was as tall as the sum of the cards and only got shorter once the user collapsed them by hand. Now every rule is a tab and exactly one editor is mounted, so the height is a function of one card plus the strip, whatever the rule count. The tabs carry what only the card head used to show (the number, a thumbnail of the first image, the match string, and whether the rule is the one in use and whether it rotates); the strip scrolls sideways rather than wrapping, at a fixed 34px with an elided match label, so switching rules cannot reflow the row. **The `+` and the "which rule" menu sit outside the scroller** — inside it, the only control that can add a rule scrolled away from the end of a long list. The match tester moved to the profile page: it answers a question about the configuration as a whole, and on the rules page it pushed the strip a whole card down. The two decisions behind the strip are pure functions now (`src/client/rules-view.ts`), pinned by the new `check:rules`, which also pins the page structure the layout rests on.
|
|
314
|
+
- **The rotation card's controls were reshuffled, at your request** — the Next button and the "On screen 2 / 3" readout moved outside the rotation panel and are **always there**: that readout is the only place on the card that says which picture is showing, and it used to vanish together with the rotation switch. The only test left is `rotateNow`'s own — the active rule has two or more pictures — and below that the button is disabled and the readout is omitted rather than printing "0 / 0". **"Also step on a model switch" joined the order row** (all three answer "when does a picture change"); **"1 hour" is gone** from the dwell-time presets (the custom field still takes 3600 s); **the row of eight fixed preset swatches is deleted** (the wheel, the numeric inputs, Extract from this image, the eyedropper and Follow system theme all stay — the row was a shortcut into the same setter); and **the whole rotation block moved into the second column**, below the theme colour, where in the collapsed single-column card it used to be the tallest block on the card, sitting between the pictures and the colour controls that edit them.
|
|
315
|
+
- **The festival art stops shipping in the package: fetched on the day, cached by asset** — the two holiday wallpapers (228 KB + 500 KB) were two thirds of the entire tarball, for a picture looked at one day a year, with their binary history kept in `.git` forever on top of that. They now live in the project's own [`HarmlessFunny/assets`](https://github.com/HarmlessFunny/assets): the download is gated on the **calendar**, so a profile that is not on a holiday fetches nothing at all, and the first read on the day caches the file under `holiday-cache/` — every boot after that, and every year after that, comes off disk. The reference is **pinned to a commit, never a branch** — runtime art has to be immutable, or a later reshuffle of the documentation screenshots could silently kill a shipped feature on a day nobody is watching — with jsDelivr first and raw second, and with both mirrors unreachable the holiday simply does not take over and the model rules keep painting (the "does this slot actually have bytes" gate was written for exactly that). The cache is keyed by **asset** name and sits deliberately outside the slot namespace, so neither "a holiday slot is read-only" nor "the store never holds a `modelbg-h-*` file" moved an inch; a cache entry is **validated**, and one that is not an image is treated as a miss and re-downloaded. `globalThis.fetch` is replaced by a stub throughout `check:node`, so the suite does not need a CDN to be up.
|
|
316
|
+
- **A recommended profile you can install in one click** — the Config tab gained a third card that downloads the author's own configuration from the same assets repository and writes it in place of yours (see [Recommended profile](#recommended-profile)). **It is hosted in the store's own shape** — a `preset.json` shape gate, a readable `theme-config.json`, and one raw file per slot — which is what makes it editable where it lives: the config is 6.5 KB of JSON you can edit on GitHub, replacing a wallpaper is replacing a file, and publishing it is a `cp` out of the data directory. It was first written as a single theme file with every wallpaper inlined as base64, at 2.9 MB where 99.8% of the bytes were a picture; that is not a thing anyone can hand-edit, and the format was changed for exactly that reason. The plugin fetches the manifest and the config, derives the file list from `rules[].images[].slot` (no second place to keep in sync), and fetches the wallpapers one request each, four at a time — showing `3/7` on the button while it runs — so each file gets its own mirror fallback and its own validation. Applied through the same `applyThemeFile` a hand-picked file goes through, assembled on the client into the shape `exportTheme` writes; it is the only action in the panel that destroys anything, so it is the only one that asks, and the download happens **before** the question so the confirmation can state what is actually in hand (7 rules · 7 wallpapers · 2.9 MB). **The store is emptied first, deliberately:** `nextSlot` hands slots out as `m1`, `m2`, … — a counter, not a random token — so a downloaded profile and the store it lands in collide on those names as a matter of course, and "replace everything with this" is only true if the everything is actually gone; that is also why there is no undo. The wipe runs **after** the download and never before it, because an unreachable CDN must not cost the user their configuration on the way to a profile that never arrived, and a host too old to write this build's config shape is refused before anything is deleted. **One missing wallpaper fails the whole attempt and names the file** — a profile that quietly arrived short a picture is precisely the silent failure that pinning the festival art to a commit exists to prevent, so the loud failure is what makes a branch reference acceptable here; the two holiday slots a config legally names are dropped from the request set rather than asked for, since the store can never hold a `modelbg-h-*` file. `holiday-cache/` is left alone, and nothing about the profile is written to the store or cached to disk — the whole point of the button is to fetch what is there *now*.
|
|
317
|
+
- **The published package drops from 1.1 MB to about 220 kB** — the documentation screenshots (`example_img/`, three webp files, 220 KB) moved into the same assets repository and both READMEs reference them by absolute jsDelivr URL (an absolute URL keeps the images on the npm page unbroken just as well, without putting binaries in the tarball or their history in `.git`); `screenshots.json`, which nothing consumes, is deleted; and `lib/client.js.map` (a 624 KB source map, useless to anyone installing the package) is no longer published, though it stays in the repository. Thirteen files became ten.
|
|
284
318
|
|
|
285
|
-
- **The controls inside the dialog change colour on the wallpaper's clock instead of jumping when it finishes (a fix)** — on a theme-colour change the holiday switch's fill and the active **Slide in** / **Standard** chips held the **previous** colour for the whole switch and took the new one only once the background had finished: a three-second change that reads as "the interface ignores it, then hard-cuts at the end". The cause was this plugin's own doing: the fade armed the **full token list** on three elements, two of which (the settings dialog and the trajectory root) only **re-declare** the three layer tokens and inherit the rest. A transition on an *inherited* token targets the value that element saw when the fade was armed — still the old one, because the ancestor is itself interpolating — so it becomes a damped copy of the animation and drags its whole subtree behind it (measured: 113/255 of the way at t = 1500 ms on a 1200 ms transition, against frame-for-frame for a consumer with no transition of its own). The transition list is now per scope, and a scope only ever gets the tokens it declares.
|
|
286
|
-
- **The surfaces painted from a colour of the plugin's own fade too now (a fix)** — the settings dialog's plate, the file-preview panel and the Cordis panel are not painted from a registered alias token but from a variable the plugin owns and writes inline on `<html>`, and an unregistered variable cannot interpolate at all: they snapped in one frame while every surface around them faded. A fade scope can now name a **standard property** (`background-color`), and each paint rule and its fade now share one selector constant so the two halves cannot drift apart. Measured over the real emitted CSS, one 3000 ms `ease` change: the plate, the right panel and the Cordis surface already read their **final** colour at the first sample and never moved, while all five surfaces now sit at exactly the same fraction of the way — 80.2% at t = 1500 ms, which is `ease(0.5)`.
|
|
287
319
|
|
|
288
320
|
## Star History
|
|
289
321
|
|