Skip to content

Commit 964458d

Browse files
committed
align windows community theme contract
1 parent 7724e6d commit 964458d

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

windows/scripts/injector.mjs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -535,24 +535,17 @@ export async function loadTheme(themeDir) {
535535
throw new Error("Theme image cannot escape through a link or junction");
536536
}
537537
const art = raw.art && typeof raw.art === "object" && !Array.isArray(raw.art) ? raw.art : {};
538-
const palette = raw.palette && typeof raw.palette === "object" && !Array.isArray(raw.palette)
539-
? raw.palette : {};
540538
const rawColors = raw.colors && typeof raw.colors === "object" && !Array.isArray(raw.colors)
541539
? raw.colors : null;
542540
const colorKeys = [
543541
"background", "panel", "panelAlt", "accent", "accentAlt", "secondary",
544542
"highlight", "text", "muted", "line",
545543
];
546-
const paletteAccent = typeof palette.accent === "string" && palette.accent.trim()
547-
? palette.accent.trim() : "";
548-
if (paletteAccent && !/^(?:#[\da-f]{3,8}|(?:rgb|hsl|oklch|oklab)\([^;{}]{1,96}\))$/i.test(paletteAccent)) {
549-
throw new Error("palette.accent is not a supported CSS color");
550-
}
551544
const colors = {
552545
background: normalizeThemeColor(rawColors?.background, "#071116"),
553546
panel: normalizeThemeColor(rawColors?.panel, "#0b1a20"),
554547
panelAlt: normalizeThemeColor(rawColors?.panelAlt, "#10272c"),
555-
accent: normalizeThemeColor(rawColors?.accent, normalizeThemeColor(paletteAccent, "#7cff46")),
548+
accent: normalizeThemeColor(rawColors?.accent, "#7cff46"),
556549
accentAlt: normalizeThemeColor(rawColors?.accentAlt, "#b8ff3d"),
557550
secondary: normalizeThemeColor(rawColors?.secondary, "#36d7e8"),
558551
highlight: normalizeThemeColor(rawColors?.highlight, "#642a8c"),
@@ -577,14 +570,10 @@ export async function loadTheme(themeDir) {
577570
safeArea: normalizedChoice(art.safeArea, "art.safeArea", THEME_CHOICES.safeArea, "auto"),
578571
taskMode: normalizedChoice(art.taskMode, "art.taskMode", THEME_CHOICES.taskMode, "auto"),
579572
},
580-
colorMode: rawColors ? "explicit" : (paletteAccent ? "explicit" : "auto"),
581-
explicitColorKeys: rawColors
582-
? colorKeys.filter((key) => Object.hasOwn(rawColors, key))
583-
: (paletteAccent ? ["accent"] : []),
573+
colorMode: rawColors ? "explicit" : "auto",
574+
explicitColorKeys: rawColors ? colorKeys.filter((key) => Object.hasOwn(rawColors, key)) : [],
584575
colors,
585-
palette: {},
586576
};
587-
if (paletteAccent) theme.palette.accent = paletteAccent;
588577
const [themeStat, imageStat, safeCss] = await Promise.all([
589578
fs.stat(themePath),
590579
fs.stat(realImagePath),
@@ -1740,6 +1729,10 @@ if (path.resolve(process.argv[1] || "") === path.resolve(scriptPath)) {
17401729
payloadBytes: Buffer.byteLength(loaded.payload),
17411730
themeId: loaded.theme.id,
17421731
appearance: loaded.theme.appearance,
1732+
colorMode: loaded.theme.colorMode,
1733+
explicitColorKeys: loaded.theme.explicitColorKeys,
1734+
hasColors: !!loaded.theme.colors && typeof loaded.theme.colors === "object",
1735+
hasPalette: Object.hasOwn(loaded.theme, "palette"),
17431736
art: loaded.theme.art,
17441737
artMetadata: loaded.theme.artMetadata ?? null,
17451738
safeCssStatus: loaded.safeCssStatus,

windows/tests/run-tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,12 @@ try {
14131413
$managedPayloadTest = Invoke-DreamSkinNative -FilePath $node.Path -ArgumentList @(
14141414
(Join-Path $Root 'scripts\injector.mjs'), '--check-payload', '--theme-dir', $themePaths.Active)
14151415
if ($managedPayloadTest.ExitCode -ne 0) { throw 'Managed theme payload validation failed.' }
1416+
$managedPayload = ($managedPayloadTest.Output -join "`n") | ConvertFrom-Json
1417+
if (-not $managedPayload.pass -or $managedPayload.hasPalette -or -not $managedPayload.hasColors -or
1418+
$managedPayload.colorMode -notin @('auto', 'explicit') -or
1419+
$managedPayload.explicitColorKeys -isnot [array]) {
1420+
throw 'Windows payload drifted from the shared community theme contract.'
1421+
}
14161422
$oversizedPayloadTest = Invoke-DreamSkinNative -FilePath $node.Path -ArgumentList @(
14171423
(Join-Path $Root 'scripts\injector.mjs'), '--check-payload', '--theme-dir', $oversizedTheme)
14181424
if ($oversizedPayloadTest.ExitCode -eq 0) { throw 'Node injector accepted an image over the 10 MB limit.' }

0 commit comments

Comments
 (0)