dsh-background-by-model 0.7.4 → 0.7.5
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 +11 -1
- package/CHANGELOG.zh.md +11 -1
- package/README.md +20 -23
- package/README.zh.md +20 -23
- package/lib/client.js +201 -40
- package/lib/client.js.map +1 -1
- package/lib/index.js +46 -14
- package/package.json +4 -2
package/lib/index.js
CHANGED
|
@@ -76,18 +76,22 @@ function defaultRotation() {
|
|
|
76
76
|
* `sidebar` sidebar (`--dsw-specific-sidebar-fill`)
|
|
77
77
|
* `card` cards/panels (`--dsw-alias-bg-layer-1/2/3`, `--dsw-specific-menu`
|
|
78
78
|
* and its 0.1.7 alias `--dsw-menu-surface-fill`)
|
|
79
|
+
* `code` code blocks, banner included (`--dsw-alias-markdown-code-block`,
|
|
80
|
+
* `--dsw-alias-markdown-code-block-banner`)
|
|
79
81
|
* `input` input/control surfaces (`--dsw-specific-input-major`)
|
|
80
82
|
*/
|
|
81
83
|
const PART_OPACITY_KEYS = [
|
|
82
84
|
"bg",
|
|
83
85
|
"sidebar",
|
|
84
86
|
"card",
|
|
87
|
+
"code",
|
|
85
88
|
"input"
|
|
86
89
|
];
|
|
87
90
|
const DEFAULT_PART_OPACITIES = {
|
|
88
91
|
bg: .85,
|
|
89
92
|
sidebar: .93,
|
|
90
93
|
card: 1,
|
|
94
|
+
code: 1,
|
|
91
95
|
input: 1
|
|
92
96
|
};
|
|
93
97
|
/**
|
|
@@ -185,7 +189,9 @@ function hexToHsl(hex) {
|
|
|
185
189
|
*
|
|
186
190
|
* Holidays default to `fill` rather than a rule's `fit`: these are full-bleed
|
|
187
191
|
* festival wallpapers, and `fit` would letterbox them on every aspect ratio the
|
|
188
|
-
* art was not cut for.
|
|
192
|
+
* art was not cut for. The mode now lives on the IMAGE (see `BgImage.bgMode`), so
|
|
193
|
+
* that default is written there — and `fill` is what a holiday's read-back
|
|
194
|
+
* sanitizer refuses to lose (see `normalizeHolidayRule`).
|
|
189
195
|
*/
|
|
190
196
|
function defaultHolidayRule(def) {
|
|
191
197
|
const color = hexToHsl(def.color);
|
|
@@ -193,13 +199,13 @@ function defaultHolidayRule(def) {
|
|
|
193
199
|
id: def.id,
|
|
194
200
|
images: [{
|
|
195
201
|
slot: def.slot,
|
|
202
|
+
bgMode: "fill",
|
|
196
203
|
bgState: { ...DEFAULT_BG_STATE },
|
|
197
204
|
color
|
|
198
205
|
}],
|
|
199
206
|
match: "",
|
|
200
207
|
enabled: true,
|
|
201
208
|
color,
|
|
202
|
-
bgMode: "fill",
|
|
203
209
|
wallpaperOpacity: 1,
|
|
204
210
|
blur: 0,
|
|
205
211
|
rotate: defaultRotation()
|
|
@@ -308,12 +314,21 @@ function normalizeTransition(raw, legacyMs) {
|
|
|
308
314
|
* same as absent: an entry with `color: null` is an image the user explicitly set
|
|
309
315
|
* to "follow the system theme", and re-inheriting the rule's color over that
|
|
310
316
|
* would undo a deliberate choice on every load.
|
|
317
|
+
*
|
|
318
|
+
* `inheritMode` is the same one-shot lift for the layout mode, and it is the
|
|
319
|
+
* caller's to resolve because the two callers answer differently: a user rule
|
|
320
|
+
* passes the mode its config carried at the RULE level (a schema-5 config, where
|
|
321
|
+
* 适应/填充 was one choice for the whole rotation), a holiday passes `fill` (its
|
|
322
|
+
* own default, which is not up for the lift to change). An entry that HAS a
|
|
323
|
+
* `bgMode` key keeps it — including one that has just been set to a value equal
|
|
324
|
+
* to the default, which is a decision and not an absence.
|
|
311
325
|
*/
|
|
312
|
-
function normalizeImage(raw, inherit = null) {
|
|
326
|
+
function normalizeImage(raw, inherit = null, inheritMode = "fit") {
|
|
313
327
|
const i = raw ?? {};
|
|
314
328
|
if (typeof i.slot !== "string" || !SLOT_RE.test(i.slot)) return null;
|
|
315
329
|
return {
|
|
316
330
|
slot: i.slot,
|
|
331
|
+
bgMode: BG_MODES.includes(i.bgMode) ? i.bgMode : inheritMode,
|
|
317
332
|
bgState: normalizeBgState(i.bgState),
|
|
318
333
|
color: hasOwn(i, "color") ? normalizeHsl(i.color) : inherit
|
|
319
334
|
};
|
|
@@ -333,6 +348,14 @@ function normalizeImage(raw, inherit = null) {
|
|
|
333
348
|
* it as well: it is not a default for its images at paint time any more, but it
|
|
334
349
|
* is still what the rule paints once its last picture is gone.
|
|
335
350
|
*
|
|
351
|
+
* The layout mode makes the same trip in the other direction, and this is the
|
|
352
|
+
* last release that has to: a config written before 0.8 keeps `bgMode` at the RULE
|
|
353
|
+
* level, where one value covered every picture of a rotation, so it is read here
|
|
354
|
+
* once and handed to each image as its inherited mode. What the user chose
|
|
355
|
+
* therefore survives the move the same way it survived the color's — the mode is
|
|
356
|
+
* not reset to the default on upgrade, and the field it used to live on is simply
|
|
357
|
+
* not written back.
|
|
358
|
+
*
|
|
336
359
|
* An EMPTY list is a legitimate rule, not a broken one: removing a rule's last
|
|
337
360
|
* picture has to be expressible, and forcing an entry back in is what produced a
|
|
338
361
|
* phantom blank image that took slot 1 and could never be deleted again (the next
|
|
@@ -347,11 +370,12 @@ function normalizeRule(raw) {
|
|
|
347
370
|
const id = typeof r.id === "string" && r.id !== "" ? r.id : null;
|
|
348
371
|
if (id === null) return null;
|
|
349
372
|
const color = normalizeHsl(r.color);
|
|
373
|
+
const mode = BG_MODES.includes(r.bgMode) ? r.bgMode : "fit";
|
|
350
374
|
const images = [];
|
|
351
375
|
const seen = /* @__PURE__ */ new Set();
|
|
352
376
|
const hadList = Array.isArray(r.images);
|
|
353
377
|
if (hadList) for (const entry of r.images) {
|
|
354
|
-
const image = normalizeImage(entry, color);
|
|
378
|
+
const image = normalizeImage(entry, color, mode);
|
|
355
379
|
if (image === null || seen.has(image.slot)) continue;
|
|
356
380
|
seen.add(image.slot);
|
|
357
381
|
images.push(image);
|
|
@@ -359,21 +383,22 @@ function normalizeRule(raw) {
|
|
|
359
383
|
const legacySlot = typeof r.slot === "string" && SLOT_RE.test(r.slot) ? r.slot : null;
|
|
360
384
|
if (images.length === 0 && legacySlot !== null) images.push({
|
|
361
385
|
slot: legacySlot,
|
|
386
|
+
bgMode: mode,
|
|
362
387
|
bgState: normalizeBgState(r.bgState),
|
|
363
388
|
color
|
|
364
389
|
});
|
|
365
390
|
if (images.length === 0 && !hadList) return null;
|
|
366
|
-
const
|
|
391
|
+
const rotate = normalizeRotation(r.rotate);
|
|
392
|
+
if (images.length < 2) rotate.enabled = false;
|
|
367
393
|
return {
|
|
368
394
|
id,
|
|
369
395
|
images,
|
|
370
396
|
match: typeof r.match === "string" ? r.match : "",
|
|
371
397
|
enabled: r.enabled !== false,
|
|
372
398
|
color,
|
|
373
|
-
bgMode: mode,
|
|
374
399
|
wallpaperOpacity: clamp01(r.wallpaperOpacity, 1),
|
|
375
400
|
blur: clamp(r.blur, 0, 60, 0),
|
|
376
|
-
rotate
|
|
401
|
+
rotate
|
|
377
402
|
};
|
|
378
403
|
}
|
|
379
404
|
/**
|
|
@@ -384,9 +409,12 @@ function normalizeRule(raw) {
|
|
|
384
409
|
* its bytes, and its theme color is a fixed part of what that holiday looks like —
|
|
385
410
|
* so a stale or hand-edited value would either orphan the wallpaper, point the
|
|
386
411
|
* holiday at a rule's image, or paint a festival in a color it does not have.
|
|
387
|
-
* Everything else is sanitized exactly like a rule's field — except
|
|
388
|
-
*
|
|
389
|
-
*
|
|
412
|
+
* Everything else is sanitized exactly like a rule's field — except three things
|
|
413
|
+
* that stay the definition's own: the image list and the rotation (so a festival
|
|
414
|
+
* can never be swapped or cycled), and the layout mode, which is the definition's
|
|
415
|
+
* `fill` for the same reason the color is its own — full-bleed art letterboxed by
|
|
416
|
+
* a stale `fit` is the one thing this feature must not do, and the mode is not
|
|
417
|
+
* editable for a holiday anywhere in the panel.
|
|
390
418
|
*/
|
|
391
419
|
function normalizeHolidayRule(def, raw) {
|
|
392
420
|
const r = raw ?? {};
|
|
@@ -394,11 +422,11 @@ function normalizeHolidayRule(def, raw) {
|
|
|
394
422
|
return {
|
|
395
423
|
...base,
|
|
396
424
|
enabled: r.enabled !== false,
|
|
397
|
-
bgMode: BG_MODES.includes(r.bgMode) ? r.bgMode : base.bgMode,
|
|
398
425
|
wallpaperOpacity: clamp01(r.wallpaperOpacity, base.wallpaperOpacity),
|
|
399
426
|
blur: clamp(r.blur, 0, 60, base.blur),
|
|
400
427
|
images: base.images.map((image) => ({
|
|
401
428
|
slot: image.slot,
|
|
429
|
+
bgMode: image.bgMode,
|
|
402
430
|
bgState: normalizeBgState(r.images?.[0]?.bgState ?? r.bgState),
|
|
403
431
|
color: image.color
|
|
404
432
|
}))
|
|
@@ -517,12 +545,12 @@ async function migrateLegacy(raw) {
|
|
|
517
545
|
id: "m1",
|
|
518
546
|
images: [{
|
|
519
547
|
slot: "m1",
|
|
548
|
+
bgMode: typeof r.bgMode === "string" ? r.bgMode : "fit",
|
|
520
549
|
bgState: r.bgState ?? {}
|
|
521
550
|
}],
|
|
522
551
|
match: "",
|
|
523
552
|
enabled: true,
|
|
524
553
|
color: Array.isArray(r.color) ? r.color : null,
|
|
525
|
-
bgMode: typeof r.bgMode === "string" ? r.bgMode : "fit",
|
|
526
554
|
wallpaperOpacity: typeof r.wallpaperOpacity === "number" ? r.wallpaperOpacity : 1,
|
|
527
555
|
blur: typeof r.blur === "number" ? r.blur : 0
|
|
528
556
|
}],
|
|
@@ -564,7 +592,11 @@ const LEGACY_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
564
592
|
"blur",
|
|
565
593
|
"bgState"
|
|
566
594
|
]);
|
|
567
|
-
const LEGACY_RULE_KEYS = /* @__PURE__ */ new Set([
|
|
595
|
+
const LEGACY_RULE_KEYS = /* @__PURE__ */ new Set([
|
|
596
|
+
"slot",
|
|
597
|
+
"bgState",
|
|
598
|
+
"bgMode"
|
|
599
|
+
]);
|
|
568
600
|
const LEGACY_NESTED_KEYS = /* @__PURE__ */ new Set(["rules[].rotate.fadeMs"]);
|
|
569
601
|
const warnedConfigKeys = /* @__PURE__ */ new Set();
|
|
570
602
|
function warnUnknownConfigKeys(raw, normalized) {
|
|
@@ -818,7 +850,7 @@ async function handleRpcMethod(ctx, endpoint, payload) {
|
|
|
818
850
|
value: {
|
|
819
851
|
config: await readConfig(),
|
|
820
852
|
slots: await listSlots(),
|
|
821
|
-
schema:
|
|
853
|
+
schema: 6
|
|
822
854
|
}
|
|
823
855
|
};
|
|
824
856
|
case "writeConfig": return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-background-by-model",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Appearance plugin for DeepSeek Harness: an ordered list of model rules, each carrying its own wallpapers — every image with its own framing and theme color — plus layout mode, opacity and blur; the background follows the model you switch to, and a rule can rotate through several images on its own rhythm.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -60,9 +60,11 @@
|
|
|
60
60
|
"check:rotation": "node scripts/rotation-check.ts",
|
|
61
61
|
"check:transition": "node scripts/transition-check.ts",
|
|
62
62
|
"check:repaint": "node scripts/repaint-check.ts",
|
|
63
|
+
"check:code-plate": "node scripts/code-plate-check.ts",
|
|
64
|
+
"check:image-mode": "node scripts/image-mode-check.ts",
|
|
63
65
|
"check:ui": "node scripts/ui-strings-check.ts",
|
|
64
66
|
"check:node": "node scripts/node-half-check.mjs",
|
|
65
|
-
"test": "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/ui-strings-check.ts && node scripts/node-half-check.mjs"
|
|
67
|
+
"test": "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/ui-strings-check.ts && node scripts/node-half-check.mjs"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@deepseek-ai/dsh-home-paths": "^0.1.0-rc.6",
|