An open-source, self-hosted system for apps built with web technologies.
Persist configurable Surface theme settings
zohayrslilehab363a8b63e0
diff --git a/scripts/verify-theme.mjs b/scripts/verify-theme.mjsindex 53eae98..787214b 100644--- a/scripts/verify-theme.mjs+++ b/scripts/verify-theme.mjs@@ -14,10 +14,27 @@ const expected = {saturation: 1.8,brightness: 1.06,opacity: 0.12+ },+ surface: {+ color: "#f5f4ee",+ grain: 0.1,+ animation: 0,+ backdrop: 0,+ opacity: 1}}assert.deepEqual(themeSchema.parse({}), expected)+assert.deepEqual(themeSchema.parse({ surface: { color: "black", grain: 0.9, animation: 16, backdrop: 24, opacity: 0 } }).surface, {+ color: "black",+ grain: 0.9,+ animation: 16,+ backdrop: 24,+ opacity: 0+})+assert.throws(() => themeSchema.parse({ surface: { grain: 1.01 } }))+assert.throws(() => themeSchema.parse({ surface: { animation: 17 } }))+assert.throws(() => themeSchema.parse({ surface: { backdrop: 25 } }))const store = new Keyv()const manager = await ThemeManager.open(store)diff --git a/source/server/core/theme-manager.ts b/source/server/core/theme-manager.tsindex 9aa8a6f..cf56244 100644--- a/source/server/core/theme-manager.ts+++ b/source/server/core/theme-manager.ts@@ -17,7 +17,14 @@ export const themeSchema: z.ZodType<ThemeProperties> = z.strictObject({saturation: bounded(themeLimits.glass.saturation).default(standardTheme.glass.saturation),brightness: bounded(themeLimits.glass.brightness).default(standardTheme.glass.brightness),opacity: bounded(themeLimits.glass.opacity).default(standardTheme.glass.opacity)- }).default(standardTheme.glass)+ }).default(standardTheme.glass),+ surface: z.strictObject({+ color: z.string().min(1).default(standardTheme.surface.color),+ grain: bounded(themeLimits.surface.grain).default(standardTheme.surface.grain),+ animation: bounded(themeLimits.surface.animation).default(standardTheme.surface.animation),+ backdrop: bounded(themeLimits.surface.backdrop).default(standardTheme.surface.backdrop),+ opacity: bounded(themeLimits.surface.opacity).default(standardTheme.surface.opacity)+ }).default(standardTheme.surface)})/** Durable, authoritative Theme state owned by the server core. */