@g9tm/lynxcontrols-foundation 2.5.9 → 2.5.11
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/catalog/catalog.json +218 -10
- package/catalog/index.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/theme/appearance-kit.d.ts +33 -10
- package/dist/theme/appearance-kit.d.ts.map +1 -1
- package/dist/theme/appearance-kit.js +64 -25
- package/dist/theme/appearance-kit.js.map +1 -1
- package/dist/theme/appearance.d.ts +6 -1
- package/dist/theme/appearance.d.ts.map +1 -1
- package/dist/theme/appearance.js +21 -3
- package/dist/theme/appearance.js.map +1 -1
- package/dist/theme/index.d.ts +3 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +2 -1
- package/dist/theme/sanitize.d.ts +7 -0
- package/dist/theme/sanitize.d.ts.map +1 -0
- package/dist/theme/sanitize.js +22 -0
- package/dist/theme/sanitize.js.map +1 -0
- package/dist/theme/theme.d.ts +12 -0
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +13 -2
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/token-themes.d.ts +114 -0
- package/dist/theme/token-themes.d.ts.map +1 -0
- package/dist/theme/token-themes.js +568 -0
- package/dist/theme/token-themes.js.map +1 -0
- package/dist/tokens/index.d.ts +1 -1
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/root.d.ts +8 -0
- package/dist/tokens/root.d.ts.map +1 -1
- package/dist/tokens/root.js +9 -2
- package/dist/tokens/root.js.map +1 -1
- package/docs/api.md +29 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme/appearance-kit.js","sources":["../../src/theme/appearance-kit.ts"],"sourcesContent":["// The appearance kit (2.5.8, from G9Hub item 42): what an app's Settings → Appearance needs over the theme engine —\n// the tokens a messenger adds to a palette (hover / press, fields and skeletons, the accent's soft wash and glow,\n// glass, chat bubbles, presence colours), each derived from the palette so every theme and accent drives them; the\n// person's settings (theme, light and dark themes when following the device, accent, wallpaper, text size, effects,\n// density); a theme registry (built in, the organisation's from the server, the person's own on the device); a\n// personal theme built from a base theme, an accent and a surface tone; wallpapers; and a token sanitizer for themes\n// that come from outside. Pure: the app persists the settings and the personal themes.\nimport type { G9ColorToken, G9PaletteValues } from '../tokens/generated/palettes';\nimport { type G9Density, type G9TypeRole, type G9TypeRoleName, g9DefaultShape } from '../tokens/shape';\nimport { type G9ThemeDefinition, g9BuiltInThemes, importTheme } from './appearance';\nimport { formatColor, toHex, tryParseColor, withAlpha } from './color';\nimport { ensureContrast, mixOklch, readableOn } from './oklch';\nimport type { G9ColorScheme } from './theme';\n\n// ------------------------------------------------------------------------------------------------ the app tokens\n\n/** The tokens an app (a messenger) adds to the library palette. */\nexport const g9AppTokenNames = [\n 'hover',\n 'press',\n 'field',\n 'skeleton',\n 'accent-soft',\n 'accent-glow',\n 'accent-gradient',\n 'text-on-accent',\n 'glass',\n 'glass-border',\n 'bubble-mine',\n 'bubble-mine-text',\n 'bubble-mine-meta',\n 'bubble-other',\n 'bubble-other-text',\n 'bubble-other-border',\n 'highlight',\n 'link',\n 'selection',\n 'focus-ring',\n 'online',\n 'away',\n 'busy',\n] as const;\n\n/** The name of an app token (`hover`, `bubble-mine`…). */\nexport type G9AppTokenName = (typeof g9AppTokenNames)[number];\n\n/** Options of {@link g9AppTokens}. */\nexport interface G9AppTokenOptions {\n /** The person's accent (`#rrggbb`) over the theme's primary; null / invalid: the theme's own. */\n readonly accent?: string | null;\n /** Values the app (or a theme) sets itself. */\n readonly overrides?: Partial<Record<G9AppTokenName, string>>;\n}\n\nconst css = (c: Parameters<typeof formatColor>[0]) => formatColor(c);\n\n/** The app tokens for a palette and scheme: plain colours (and one gradient), never variables. */\nexport function g9AppTokens(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n): Readonly<Record<G9AppTokenName, string>> {\n const p = theme.palette;\n const dark = theme.scheme === 'dark';\n const accent = options.accent && tryParseColor(options.accent) ? options.accent : p.Primary;\n const own = accent === p.Primary;\n const onAccent = own ? p.OnPrimary : readableOn(accent);\n const surface = p.Surface;\n const field = (p as Partial<Record<string, string>>).InputBackground ?? p.SurfaceContainerLow;\n const out: Record<G9AppTokenName, string> = {\n hover: css(withAlpha(p.TextPrimary, dark ? 0.08 : 0.06)),\n press: css(withAlpha(p.TextPrimary, dark ? 0.14 : 0.1)),\n field,\n skeleton: p.SurfaceContainerHigh,\n 'accent-soft': css(withAlpha(accent, dark ? 0.16 : 0.11)),\n 'accent-glow': css(withAlpha(accent, dark ? 0.48 : 0.34)),\n 'accent-gradient': `linear-gradient(135deg, ${mixOklch(accent, '#ffffff', 0.2)} 0%, ${accent} 50%, ${mixOklch(accent, '#000000', 0.2)} 100%)`,\n 'text-on-accent': onAccent,\n glass: css(withAlpha(surface, dark ? 0.6 : 0.72)),\n 'glass-border': css(withAlpha(p.OutlineVariant, 0.6)),\n 'bubble-mine': accent,\n 'bubble-mine-text': onAccent,\n 'bubble-mine-meta': css(withAlpha(onAccent, 0.76)),\n 'bubble-other': p.SurfaceContainer,\n 'bubble-other-text': p.TextPrimary,\n 'bubble-other-border': p.OutlineVariant,\n highlight: css(withAlpha(accent, dark ? 0.22 : 0.14)),\n link: ensureContrast(accent, surface, 4.5),\n selection: css(withAlpha(accent, dark ? 0.34 : 0.22)),\n 'focus-ring': css(withAlpha(accent, dark ? 0.72 : 0.55)),\n online: p.Success,\n away: p.Warning,\n busy: p.Error,\n };\n for (const [name, value] of Object.entries(options.overrides ?? {})) if (value) out[name as G9AppTokenName] = value;\n return Object.freeze(out);\n}\n\n/** The app tokens as CSS variables (`--g9-hover`…; `prefix` default `g9-`), for G9Provider's `themeExtras`. */\nexport function g9AppTokenVariables(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n prefix = 'g9-',\n): Readonly<Record<string, string>> {\n const out: Record<string, string> = {};\n for (const [name, value] of Object.entries(g9AppTokens(theme, options))) out[`--${prefix}${name}`] = value;\n return Object.freeze(out);\n}\n\n// ------------------------------------------------------------------------------------------------ the sanitizer\n\nconst MAX_VALUE = 2000;\n\n/**\n * Only well-formed tokens of `allowed` names (a leading `--g9-` is dropped first), from a theme that came from outside\n * (the server, a file): values that cannot break out of a declaration, and pictures only as inline `data:` images.\n */\nexport function g9SanitizeTokens(\n input: Readonly<Record<string, unknown>> | null | undefined,\n allowed: readonly string[],\n): Record<string, string> {\n const known = new Set(allowed);\n const result: Record<string, string> = {};\n if (!input) return result;\n for (const [rawName, rawValue] of Object.entries(input)) {\n const name = rawName.replace(/^--g9-/, '');\n if (!known.has(name) || typeof rawValue !== 'string') continue;\n const value = rawValue.trim();\n if (!value || value.length > MAX_VALUE) continue;\n if (/[;{}<>]|\\/\\*|\\\\/.test(value.replace(/url\\(\"data:image\\/svg\\+xml,[^\"]*\"\\)/g, ''))) continue;\n const urls = value.match(/url\\(([^)]*)\\)/g) ?? [];\n if (urls.some((url) => !/^url\\([\"']?data:image\\//.test(url))) continue;\n if (/expression\\s*\\(|javascript:/i.test(value)) continue;\n result[name] = value;\n }\n return result;\n}\n\n// ------------------------------------------------------------------------------------------------ the settings\n\n/** A text size step. */\nexport type G9FontScale = 'small' | 'normal' | 'large' | 'larger';\n/** Whether effects are on, off, or decided by the device. */\nexport type G9EffectsMode = 'auto' | 'on' | 'off';\n\n/** What a person chose on Settings → Appearance (kept per device by the app). */\nexport interface G9AppearanceSettings {\n /** A theme id, or `system`: follow the device between `light` and `dark`. */\n readonly theme: string;\n readonly light: string;\n readonly dark: string;\n /** `#rrggbb`, or null for the theme's own. */\n readonly accent: string | null;\n /** A wallpaper id; `theme` keeps the theme's own. */\n readonly wallpaper: string;\n readonly fontScale: G9FontScale;\n /** `auto`: off on low-end devices and when the system asks for reduced motion. */\n readonly effects: G9EffectsMode;\n readonly density: G9Density;\n}\n\n/** The settings of a new install. */\nexport const g9DefaultAppearance: G9AppearanceSettings = Object.freeze({\n theme: 'system',\n light: 'classic',\n dark: 'midnight',\n accent: null,\n wallpaper: 'theme',\n fontScale: 'normal',\n effects: 'auto',\n density: 'regular',\n});\n\nconst SCALES: readonly G9FontScale[] = ['small', 'normal', 'large', 'larger'];\nconst EFFECTS: readonly G9EffectsMode[] = ['auto', 'on', 'off'];\nconst DENSITIES: readonly G9Density[] = ['compact', 'regular', 'comfortable'];\n\n/** Stored settings read back loosely: every unknown or broken field takes its default. */\nexport function g9NormalizeAppearance(\n raw: unknown,\n defaults: G9AppearanceSettings = g9DefaultAppearance,\n): G9AppearanceSettings {\n const r = (raw && typeof raw === 'object' ? raw : {}) as Partial<Record<keyof G9AppearanceSettings, unknown>>;\n const text = (v: unknown, d: string) => (typeof v === 'string' && v.trim() ? v : d);\n const pick = <T extends string>(v: unknown, list: readonly T[], d: T) => (list.includes(v as T) ? (v as T) : d);\n const accent = typeof r.accent === 'string' && /^#[0-9a-f]{6}$/i.test(r.accent) ? r.accent.toLowerCase() : null;\n return Object.freeze({\n theme: text(r.theme, defaults.theme),\n light: text(r.light, defaults.light),\n dark: text(r.dark, defaults.dark),\n accent: r.accent === undefined ? defaults.accent : accent,\n wallpaper: text(r.wallpaper, defaults.wallpaper),\n fontScale: pick(r.fontScale, SCALES, defaults.fontScale),\n effects: pick(r.effects, EFFECTS, defaults.effects),\n density: pick(r.density, DENSITIES, defaults.density),\n });\n}\n\n/** Text size factors. */\nexport const g9FontScaleFactors: Readonly<Record<G9FontScale, number>> = Object.freeze({\n small: 0.9,\n normal: 1,\n large: 1.12,\n larger: 1.25,\n});\n\n/** The type scale at a text size (sizes and line heights rounded), for G9Provider's `shape.type`. */\nexport function g9ScaledType(\n scale: G9FontScale | number,\n base: { readonly [K in G9TypeRoleName]: G9TypeRole } = g9DefaultShape.type,\n): { readonly [K in G9TypeRoleName]: G9TypeRole } {\n const k = typeof scale === 'number' ? scale : g9FontScaleFactors[scale];\n const out = {} as Record<G9TypeRoleName, G9TypeRole>;\n for (const [role, t] of Object.entries(base) as [G9TypeRoleName, G9TypeRole][])\n out[role] = { ...t, size: Math.round(t.size * k), lineHeight: Math.round(t.lineHeight * k) };\n return Object.freeze(out);\n}\n\n/** Whether effects (blur, glow, motion flourishes) are on. */\nexport function g9EffectsEnabled(\n mode: G9EffectsMode,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): boolean {\n if (mode !== 'auto') return mode === 'on';\n return !device.reducedMotion && !device.lowEnd;\n}\n\n/** The theme id in force: the chosen one, or the light / dark one for the device's scheme when following it. */\nexport function g9ActiveThemeId(settings: G9AppearanceSettings, systemScheme: G9ColorScheme): string {\n if (settings.theme !== 'system') return settings.theme;\n return systemScheme === 'dark' ? settings.dark : settings.light;\n}\n\n// ------------------------------------------------------------------------------------------------ the registry\n\n/** The themes a person can pick, by source. */\nexport interface G9ThemeRegistrySnapshot {\n readonly themes: readonly G9ThemeDefinition[];\n readonly revision: number;\n}\n\n/** Options of {@link createG9ThemeRegistry}. */\nexport interface G9ThemeRegistryOptions {\n /** Default {@link g9BuiltInThemes}. */\n readonly builtins?: readonly G9ThemeDefinition[];\n /** The person's own themes as the app stored them (read before the first paint). */\n readonly personal?: readonly G9ThemeDefinition[];\n /** Saves the personal list (the device's preferences). */\n readonly savePersonal?: (themes: readonly G9ThemeDefinition[]) => void;\n /** The most personal themes kept. Default 12. */\n readonly maxPersonal?: number;\n}\n\n/** Every theme: built in, the organisation's, the person's own (a store an appearance page reads). */\nexport interface G9ThemeRegistry {\n get(): G9ThemeRegistrySnapshot;\n subscribe(listener: () => void): () => void;\n /** A theme by id, or null. */\n find(id: string): G9ThemeDefinition | null;\n /** A theme by id; one that disappeared (an admin deleted it) falls back to the first built-in theme. */\n themeOrDefault(id: string): G9ThemeDefinition;\n /** Replaces the organisation's themes (from the server; each read loosely, broken ones dropped). */\n setOrgThemes(inputs: readonly unknown[]): void;\n /** Adds or replaces a personal theme (the newest first; past the limit the oldest go). */\n savePersonal(theme: G9ThemeDefinition): void;\n removePersonal(id: string): void;\n readonly personal: () => readonly G9ThemeDefinition[];\n}\n\n/** A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. */\nexport function g9ThemeFromInput(input: unknown, source: G9ThemeDefinition['source']): G9ThemeDefinition | null {\n if (!input || typeof input !== 'object') return null;\n const t = input as Partial<G9ThemeDefinition>;\n try {\n const def = importTheme(JSON.stringify({ format: 'g9-theme', version: 1, theme: t }));\n if (!def.name || (typeof def.name === 'string' && !def.name.trim())) return null;\n return Object.freeze({\n ...def,\n id: source === 'org' && !def.id.startsWith('org:') ? `org:${def.id}` : def.id,\n source,\n });\n } catch {\n return null;\n }\n}\n\n/** Creates a theme registry. */\nexport function createG9ThemeRegistry(options: G9ThemeRegistryOptions = {}): G9ThemeRegistry {\n const builtins = options.builtins ?? g9BuiltInThemes;\n const max = Math.max(1, options.maxPersonal ?? 12);\n let org: G9ThemeDefinition[] = [];\n let personal: G9ThemeDefinition[] = (options.personal ?? [])\n .map((t) => g9ThemeFromInput(t, 'personal'))\n .filter((t): t is G9ThemeDefinition => t !== null)\n .slice(0, max);\n const listeners = new Set<() => void>();\n let snapshot: G9ThemeRegistrySnapshot = { themes: [...builtins, ...personal], revision: 0 };\n const rebuild = () => {\n snapshot = { themes: [...builtins, ...org, ...personal], revision: snapshot.revision + 1 };\n for (const l of [...listeners]) l();\n };\n const find = (id: string) => snapshot.themes.find((t) => t.id === id) ?? null;\n return {\n get: () => snapshot,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n find,\n themeOrDefault: (id) => find(id) ?? (builtins[0] as G9ThemeDefinition),\n setOrgThemes(inputs) {\n org = inputs.map((i) => g9ThemeFromInput(i, 'org')).filter((t): t is G9ThemeDefinition => t !== null);\n rebuild();\n },\n savePersonal(theme) {\n const own = Object.freeze({ ...theme, source: 'personal' as const });\n personal = [own, ...personal.filter((t) => t.id !== theme.id)].slice(0, max);\n options.savePersonal?.(personal);\n rebuild();\n },\n removePersonal(id) {\n if (!personal.some((t) => t.id === id)) return;\n personal = personal.filter((t) => t.id !== id);\n options.savePersonal?.(personal);\n rebuild();\n },\n personal: () => personal,\n };\n}\n\n// ------------------------------------------------------------------------------------------------ personal themes\n\n/** How a personal theme's surfaces are tinted. */\nexport type G9SurfaceTone = 'neutral' | 'cool' | 'warm' | 'tinted';\n\n/** What the personal theme editor edits. */\nexport interface G9PersonalThemeDraft {\n readonly id: string;\n readonly name: string;\n /** The theme it starts from. */\n readonly base: G9ThemeDefinition;\n /** `#rrggbb`. */\n readonly accent: string;\n readonly surfaces: G9SurfaceTone;\n /** A wallpaper id, or `theme`. */\n readonly wallpaper: string;\n /** Light or dark (default the base's own mode, else light). */\n readonly scheme?: G9ColorScheme;\n}\n\n/** A fresh personal id (`me:…`). */\nexport function g9NewPersonalThemeId(random: () => number = Math.random): string {\n let id = '';\n for (let i = 0; i < 12; i++) id += Math.floor(random() * 36).toString(36);\n return `me:${id}`;\n}\n\n/** A draft starting from `base`. */\nexport function g9PersonalDraft(\n base: G9ThemeDefinition,\n name: string,\n id: string = g9NewPersonalThemeId(),\n): G9PersonalThemeDraft {\n return {\n id,\n name,\n base,\n accent: toHex(base.brand.primary),\n surfaces: 'neutral',\n wallpaper: base.wallpaper ?? 'theme',\n };\n}\n\nconst TINTS: Readonly<Record<'cool' | 'warm', string>> = { cool: '#3b82f6', warm: '#f59e0b' };\nconst SURFACES: readonly [G9ColorToken, number, number][] = [\n // token, tint in dark, tint in light (fractions)\n ['Background', 0.07, 0.04],\n ['BackgroundSecondary', 0.08, 0.05],\n ['Surface', 0.09, 0.05],\n ['SurfaceContainerLow', 0.09, 0.05],\n ['SurfaceContainer', 0.1, 0.06],\n ['SurfaceContainerHigh', 0.12, 0.08],\n];\n\n/**\n * The theme a draft describes: the base's recipe with the draft's accent, its surfaces tinted (cool, warm, or by the\n * accent) through overrides measured on `palettes` (the base's palettes for the accent: `recipePalettes(...)`).\n */\nexport function g9BuildPersonalTheme(\n draft: G9PersonalThemeDraft,\n palettes: { readonly light: G9PaletteValues; readonly dark: G9PaletteValues },\n): G9ThemeDefinition {\n const accent = tryParseColor(draft.accent) ? draft.accent : draft.base.brand.primary;\n const scheme: G9ColorScheme = draft.scheme ?? (draft.base.mode === 'dark' ? 'dark' : 'light');\n let overrides: G9ThemeDefinition['overrides'];\n if (draft.surfaces !== 'neutral') {\n const tint = draft.surfaces === 'tinted' ? accent : TINTS[draft.surfaces];\n const of = (s: G9ColorScheme) => {\n const o: Partial<Record<G9ColorToken, string>> = {};\n for (const [token, d, l] of SURFACES) o[token] = mixOklch(palettes[s][token], tint, s === 'dark' ? d : l);\n return o;\n };\n overrides = { light: of('light'), dark: of('dark') };\n }\n const name = draft.name.trim().slice(0, 60);\n return Object.freeze({\n id: draft.id,\n name: name || draft.base.name,\n source: 'personal' as const,\n recipe: draft.base.recipe,\n brand: { ...draft.base.brand, primary: accent },\n ...(overrides ? { overrides } : {}),\n ...(draft.base.shape ? { shape: draft.base.shape } : {}),\n mode: scheme,\n ...(draft.wallpaper !== 'theme' ? { wallpaper: draft.wallpaper } : {}),\n });\n}\n\n/** A file name for a theme export (letters, digits, dashes; any script). */\nexport function g9ThemeFileName(name: string): string {\n const slug = name\n .trim()\n .toLowerCase()\n .replace(/[\\s!-/:-@[-`{-~،؛؟«»]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40);\n return `${slug || 'theme'}.g9theme.json`;\n}\n\n// ------------------------------------------------------------------------------------------------ wallpapers\n\n/** A chat wallpaper: layers drawn behind a thread, from the palette so it follows the theme and accent. */\nexport interface G9Wallpaper {\n readonly id: string;\n readonly name: Readonly<Record<string, string>>;\n /** The background for a palette and scheme: a colour and optional gradient layers (Lynx `background-image`). */\n paint(palette: G9PaletteValues, scheme: G9ColorScheme): { readonly color: string; readonly image?: string };\n}\n\nconst glow = (c: string, a: number) => css(withAlpha(c, a));\n\n/** Wallpapers drawn with gradients only (no pictures, no network). */\nexport const g9Wallpapers: readonly G9Wallpaper[] = Object.freeze([\n { id: 'none', name: { en: 'None', fa: 'هیچ' }, paint: (p) => ({ color: p.Background }) },\n {\n id: 'aurora',\n name: { en: 'Aurora', fa: 'شفق' },\n paint: (p, s) => ({\n color: p.Background,\n image: `radial-gradient(circle at 0% 0%, ${glow(p.Primary, s === 'dark' ? 0.18 : 0.12)} 0%, transparent 60%), radial-gradient(circle at 100% 100%, ${glow(p.Tertiary, s === 'dark' ? 0.16 : 0.1)} 0%, transparent 60%)`,\n }),\n },\n {\n id: 'dusk',\n name: { en: 'Dusk', fa: 'غروب' },\n paint: (p, s) => ({\n color: p.Background,\n image: `linear-gradient(180deg, ${glow(p.Primary, s === 'dark' ? 0.12 : 0.08)} 0%, transparent 45%, ${glow(p.Secondary, s === 'dark' ? 0.1 : 0.06)} 100%)`,\n }),\n },\n {\n id: 'mesh',\n name: { en: 'Mesh', fa: 'توری' },\n paint: (p, s) => {\n const k = s === 'dark' ? 1 : 0.75;\n return {\n color: p.Background,\n image: [\n `radial-gradient(circle at 15% 20%, ${glow(p.Primary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 85% 30%, ${glow(p.Tertiary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 50% 95%, ${glow(p.Secondary, 0.14 * k)} 0%, transparent 55%)`,\n ].join(', '),\n };\n },\n },\n {\n id: 'paper',\n name: { en: 'Paper', fa: 'کاغذی' },\n paint: (p, s) => ({ color: mixOklch(p.Background, s === 'dark' ? '#000000' : '#f5ecd7', 0.25) }),\n },\n] satisfies G9Wallpaper[]);\n\n/** A wallpaper by id (from `list`, default {@link g9Wallpapers}), or null. */\nexport function g9Wallpaper(id: string, list: readonly G9Wallpaper[] = g9Wallpapers): G9Wallpaper | null {\n return list.find((w) => w.id === id) ?? null;\n}\n"],"names":["g9AppTokenNames","css","c","formatColor","g9AppTokens","theme","options","_p_InputBackground","_options_overrides","p","dark","accent","tryParseColor","own","onAccent","readableOn","surface","field","out","withAlpha","mixOklch","ensureContrast","name","value","Object","g9AppTokenVariables","prefix","MAX_VALUE","g9SanitizeTokens","input","allowed","known","Set","result","rawName","rawValue","_value_match","urls","url","g9DefaultAppearance","SCALES","EFFECTS","DENSITIES","g9NormalizeAppearance","raw","defaults","r","text","v","d","pick","list","undefined","g9FontScaleFactors","g9ScaledType","scale","base","g9DefaultShape","k","role","t","Math","g9EffectsEnabled","mode","device","g9ActiveThemeId","settings","systemScheme","g9ThemeFromInput","source","def","importTheme","JSON","createG9ThemeRegistry","_options_builtins","_options_maxPersonal","_options_personal","builtins","g9BuiltInThemes","max","org","personal","listeners","snapshot","rebuild","l","find","id","_snapshot_themes_find","listener","_find","inputs","i","g9NewPersonalThemeId","random","g9PersonalDraft","_base_wallpaper","toHex","TINTS","SURFACES","g9BuildPersonalTheme","draft","palettes","_draft_scheme","scheme","overrides","tint","of","s","o","token","g9ThemeFileName","slug","glow","a","g9Wallpapers","g9Wallpaper","_list_find","w"],"mappings":";;;;AAiBO,MAAMA,kBAAkB;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAaD,MAAMC,MAAM,CAACC,IAAyCC,YAAYD;AAG3D,SAASE,YACdC,KAA4E,EAC5EC,UAA6B,CAAC,CAAC;QAQjBC,oBA0B6BC;IAhC3C,MAAMC,IAAIJ,MAAM,OAAO;IACvB,MAAMK,OAAOL,AAAiB,WAAjBA,MAAM,MAAM;IACzB,MAAMM,SAASL,QAAQ,MAAM,IAAIM,cAAcN,QAAQ,MAAM,IAAIA,QAAQ,MAAM,GAAGG,EAAE,OAAO;IAC3F,MAAMI,MAAMF,WAAWF,EAAE,OAAO;IAChC,MAAMK,WAAWD,MAAMJ,EAAE,SAAS,GAAGM,WAAWJ;IAChD,MAAMK,UAAUP,EAAE,OAAO;IACzB,MAAMQ,QAAQ,QAAA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,EAAEK,KAAKxG,EAAE,SAAS,EAAEmG,AAAM,WAANA,IAAe,MAAM,MAAM,MAAM,CAAC;YAC5J;IACF;IACA;QACE,IAAI;QACJ,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAO;QAC/B,OAAO,CAACnG,GAAGmG;YACT,MAAMlD,IAAIkD,AAAM,WAANA,IAAe,IAAI;YAC7B,OAAO;gBACL,OAAOnG,EAAE,UAAU;gBACnB,OAAO;oBACL,CAAC,mCAAmC,EAAEwG,KAAKxG,EAAE,OAAO,EAAE,OAAOiD,GAAG,qBAAqB,CAAC;oBACtF,CAAC,mCAAmC,EAAEuD,KAAKxG,EAAE,QAAQ,EAAE,OAAOiD,GAAG,qBAAqB,CAAC;oBACvF,CAAC,mCAAmC,EAAEuD,KAAKxG,EAAE,SAAS,EAAE,OAAOiD,GAAG,qBAAqB,CAAC;iBACzF,CAAC,IAAI,CAAC;YACT;QACF;IACF;IACA;QACE,IAAI;QACJ,MAAM;YAAE,IAAI;YAAS,IAAI;QAAQ;QACjC,OAAO,CAACjD,GAAGmG,IAAO;gBAAE,OAAOxF,SAASX,EAAE,UAAU,EAAEmG,AAAM,WAANA,IAAe,YAAY,WAAW;YAAM;IAChG;CACD;AAGM,SAASQ,YAAY7B,EAAU,EAAEpC,OAA+BgE,YAAY;QAC1EE;IAAP,OAAO,QAAAA,CAAAA,aAAAA,KAAK,IAAI,CAAC,CAACC,IAAMA,EAAE,EAAE,KAAK/B,GAAE,IAA5B8B,aAAiC;AAC1C"}
|
|
1
|
+
{"version":3,"file":"theme/appearance-kit.js","sources":["../../src/theme/appearance-kit.ts"],"sourcesContent":["// The appearance kit (2.5.8, from G9Hub item 42): what an app's Settings → Appearance needs over the theme engine —\n// the tokens a messenger adds to a palette (hover / press, fields and skeletons, the accent's soft wash and glow,\n// glass, chat bubbles, presence colours), each derived from the palette so every theme and accent drives them; the\n// person's settings (theme, light and dark themes when following the device, accent, wallpaper, text size, effects,\n// density); a theme registry (built in, the organisation's from the server, the person's own on the device); a\n// personal theme built from a base theme, an accent and a surface tone; wallpapers; and a token sanitizer for themes\n// that come from outside. Pure: the app persists the settings and the personal themes.\nimport type { G9ColorToken, G9PaletteValues } from '../tokens/generated/palettes';\nimport { type G9Density, type G9TypeRole, type G9TypeRoleName, g9DefaultShape } from '../tokens/shape';\nimport { type G9ThemeDefinition, g9BuiltInThemes, importTheme } from './appearance';\nimport { formatColor, toHex, tryParseColor, withAlpha } from './color';\nimport { ensureContrast, mixOklch, readableOn } from './oklch';\nimport type { G9ColorScheme } from './theme';\nimport {\n type G9EffectsReason,\n type G9TokenTheme,\n type G9TokenThemeOptions,\n g9IsTokenTheme,\n g9ThemeFromTokens,\n g9ThemeTokenNames,\n} from './token-themes';\n\n// ------------------------------------------------------------------------------------------------ the app tokens\n\n/** The tokens an app (a messenger) adds to the library palette. */\nexport const g9AppTokenNames = [\n 'hover',\n 'press',\n 'field',\n 'skeleton',\n 'accent-soft',\n 'accent-glow',\n 'accent-gradient',\n 'text-on-accent',\n 'glass',\n 'glass-border',\n 'bubble-mine',\n 'bubble-mine-text',\n 'bubble-mine-meta',\n 'bubble-other',\n 'bubble-other-text',\n 'bubble-other-border',\n 'highlight',\n 'link',\n 'selection',\n 'focus-ring',\n 'online',\n 'away',\n 'busy',\n] as const;\n\n/** The name of an app token (`hover`, `bubble-mine`…). */\nexport type G9AppTokenName = (typeof g9AppTokenNames)[number];\n\n/** Every app token name the library knows: its own and a token theme's (2.5.10), for a sanitizer or an editor. */\nexport const g9AllAppTokenNames: readonly string[] = Object.freeze([\n ...new Set<string>([...g9AppTokenNames, ...g9ThemeTokenNames]),\n]);\n\n/** Options of {@link g9AppTokens}. */\nexport interface G9AppTokenOptions {\n /** The person's accent (`#rrggbb`) over the theme's primary; null / invalid: the theme's own. */\n readonly accent?: string | null;\n /** Values the app (or a theme) sets itself. */\n readonly overrides?: Partial<Record<G9AppTokenName, string>>;\n}\n\nconst css = (c: Parameters<typeof formatColor>[0]) => formatColor(c);\n\n/** The app tokens for a palette and scheme: plain colours (and one gradient), never variables. */\nexport function g9AppTokens(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n): Readonly<Record<G9AppTokenName, string>> {\n const p = theme.palette;\n const dark = theme.scheme === 'dark';\n const accent = options.accent && tryParseColor(options.accent) ? options.accent : p.Primary;\n const own = accent === p.Primary;\n const onAccent = own ? p.OnPrimary : readableOn(accent);\n const surface = p.Surface;\n const field = (p as Partial<Record<string, string>>).InputBackground ?? p.SurfaceContainerLow;\n const out: Record<G9AppTokenName, string> = {\n hover: css(withAlpha(p.TextPrimary, dark ? 0.08 : 0.06)),\n press: css(withAlpha(p.TextPrimary, dark ? 0.14 : 0.1)),\n field,\n skeleton: p.SurfaceContainerHigh,\n 'accent-soft': css(withAlpha(accent, dark ? 0.16 : 0.11)),\n 'accent-glow': css(withAlpha(accent, dark ? 0.48 : 0.34)),\n 'accent-gradient': `linear-gradient(135deg, ${mixOklch(accent, '#ffffff', 0.2)} 0%, ${accent} 50%, ${mixOklch(accent, '#000000', 0.2)} 100%)`,\n 'text-on-accent': onAccent,\n glass: css(withAlpha(surface, dark ? 0.6 : 0.72)),\n 'glass-border': css(withAlpha(p.OutlineVariant, 0.6)),\n 'bubble-mine': accent,\n 'bubble-mine-text': onAccent,\n 'bubble-mine-meta': css(withAlpha(onAccent, 0.76)),\n 'bubble-other': p.SurfaceContainer,\n 'bubble-other-text': p.TextPrimary,\n 'bubble-other-border': p.OutlineVariant,\n highlight: css(withAlpha(accent, dark ? 0.22 : 0.14)),\n link: ensureContrast(accent, surface, 4.5),\n selection: css(withAlpha(accent, dark ? 0.34 : 0.22)),\n 'focus-ring': css(withAlpha(accent, dark ? 0.72 : 0.55)),\n online: p.Success,\n away: p.Warning,\n busy: p.Error,\n };\n for (const [name, value] of Object.entries(options.overrides ?? {})) if (value) out[name as G9AppTokenName] = value;\n return Object.freeze(out);\n}\n\n/** The app tokens as CSS variables (`--g9-hover`…; `prefix` default `g9-`), for G9Provider's `themeExtras`. */\nexport function g9AppTokenVariables(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n prefix = 'g9-',\n): Readonly<Record<string, string>> {\n const out: Record<string, string> = {};\n for (const [name, value] of Object.entries(g9AppTokens(theme, options))) out[`--${prefix}${name}`] = value;\n return Object.freeze(out);\n}\n\n// ------------------------------------------------------------------------------------------------ the sanitizer\n\nexport { g9SanitizeTokens } from './sanitize';\n\n// ------------------------------------------------------------------------------------------------ the settings\n\n/** A text size step. */\nexport type G9FontScale = 'small' | 'normal' | 'large' | 'larger';\n/** Whether effects are on, off, or decided by the device. */\nexport type G9EffectsMode = 'auto' | 'on' | 'off';\n\n/** What a person chose on Settings → Appearance (kept per device by the app). */\nexport interface G9AppearanceSettings {\n /** A theme id, or `system`: follow the device between `light` and `dark`. */\n readonly theme: string;\n readonly light: string;\n readonly dark: string;\n /** `#rrggbb`, or null for the theme's own. */\n readonly accent: string | null;\n /** A wallpaper id; `theme` keeps the theme's own. */\n readonly wallpaper: string;\n readonly fontScale: G9FontScale;\n /** `auto`: off on low-end devices and when the system asks for reduced motion. */\n readonly effects: G9EffectsMode;\n readonly density: G9Density;\n}\n\n/** The settings of a new install. */\nexport const g9DefaultAppearance: G9AppearanceSettings = Object.freeze({\n theme: 'system',\n light: 'classic',\n dark: 'midnight',\n accent: null,\n wallpaper: 'theme',\n fontScale: 'normal',\n effects: 'auto',\n density: 'regular',\n});\n\nconst SCALES: readonly G9FontScale[] = ['small', 'normal', 'large', 'larger'];\nconst EFFECTS: readonly G9EffectsMode[] = ['auto', 'on', 'off'];\nconst DENSITIES: readonly G9Density[] = ['compact', 'regular', 'comfortable'];\n\n/** Stored settings read back loosely: every unknown or broken field takes its default. */\nexport function g9NormalizeAppearance(\n raw: unknown,\n defaults: G9AppearanceSettings = g9DefaultAppearance,\n): G9AppearanceSettings {\n const r = (raw && typeof raw === 'object' ? raw : {}) as Partial<Record<keyof G9AppearanceSettings, unknown>>;\n const text = (v: unknown, d: string) => (typeof v === 'string' && v.trim() ? v : d);\n const pick = <T extends string>(v: unknown, list: readonly T[], d: T) => (list.includes(v as T) ? (v as T) : d);\n const accent = typeof r.accent === 'string' && /^#[0-9a-f]{6}$/i.test(r.accent) ? r.accent.toLowerCase() : null;\n return Object.freeze({\n theme: text(r.theme, defaults.theme),\n light: text(r.light, defaults.light),\n dark: text(r.dark, defaults.dark),\n accent: r.accent === undefined ? defaults.accent : accent,\n wallpaper: text(r.wallpaper, defaults.wallpaper),\n fontScale: pick(r.fontScale, SCALES, defaults.fontScale),\n effects: pick(r.effects, EFFECTS, defaults.effects),\n density: pick(r.density, DENSITIES, defaults.density),\n });\n}\n\n/** Text size factors. */\nexport const g9FontScaleFactors: Readonly<Record<G9FontScale, number>> = Object.freeze({\n small: 0.9,\n normal: 1,\n large: 1.12,\n larger: 1.25,\n});\n\n/** The type scale at a text size (sizes and line heights rounded), for G9Provider's `shape.type`. */\nexport function g9ScaledType(\n scale: G9FontScale | number,\n base: { readonly [K in G9TypeRoleName]: G9TypeRole } = g9DefaultShape.type,\n): { readonly [K in G9TypeRoleName]: G9TypeRole } {\n const k = typeof scale === 'number' ? scale : g9FontScaleFactors[scale];\n const out = {} as Record<G9TypeRoleName, G9TypeRole>;\n for (const [role, t] of Object.entries(base) as [G9TypeRoleName, G9TypeRole][])\n out[role] = { ...t, size: Math.round(t.size * k), lineHeight: Math.round(t.lineHeight * k) };\n return Object.freeze(out);\n}\n\n/** Whether effects (blur, glow, motion flourishes) are on. */\nexport function g9EffectsEnabled(\n mode: G9EffectsMode,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): boolean {\n if (mode !== 'auto') return mode === 'on';\n return !device.reducedMotion && !device.lowEnd;\n}\n\n/**\n * Whether effects are on and, when they are off, why (2.5.10): the person turned them off (`setting`), or `auto` on a\n * low-end device (`lowEnd`) or a system that asks for less motion (`reducedMotion`).\n */\nexport function g9EffectsState(\n mode: G9EffectsMode,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): { readonly enabled: boolean; readonly reason: G9EffectsReason } {\n if (mode === 'on') return { enabled: true, reason: null };\n if (mode === 'off') return { enabled: false, reason: 'setting' };\n if (device.lowEnd) return { enabled: false, reason: 'lowEnd' };\n if (device.reducedMotion) return { enabled: false, reason: 'reducedMotion' };\n return { enabled: true, reason: null };\n}\n\n/**\n * The classes an app's root takes for the appearance in force (2.5.10, G9Hub's root classes): `g9-scheme-dark`,\n * `g9-density-compact`, `g9-effects-off`, `g9-effects-off--low-end` / `--reduced-motion`, `g9-text-large`.\n */\nexport function g9AppearanceClasses(\n settings: G9AppearanceSettings,\n scheme: G9ColorScheme,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): string[] {\n const effects = g9EffectsState(settings.effects, device);\n const out = [`g9-scheme-${scheme}`, `g9-density-${settings.density}`, `g9-text-${settings.fontScale}`];\n out.push(effects.enabled ? 'g9-effects-on' : 'g9-effects-off');\n if (effects.reason === 'lowEnd') out.push('g9-effects-off--low-end');\n if (effects.reason === 'reducedMotion') out.push('g9-effects-off--reduced-motion');\n return out;\n}\n\n/** The theme id in force: the chosen one, or the light / dark one for the device's scheme when following it. */\nexport function g9ActiveThemeId(settings: G9AppearanceSettings, systemScheme: G9ColorScheme): string {\n if (settings.theme !== 'system') return settings.theme;\n return systemScheme === 'dark' ? settings.dark : settings.light;\n}\n\n// ------------------------------------------------------------------------------------------------ the registry\n\n/** The themes a person can pick, by source. */\nexport interface G9ThemeRegistrySnapshot {\n readonly themes: readonly G9ThemeDefinition[];\n readonly revision: number;\n}\n\n/** Options of {@link createG9ThemeRegistry}. */\nexport interface G9ThemeRegistryOptions {\n /** Default {@link g9BuiltInThemes}. Token themes (`{ id, name, scheme, tokens }`, 2.5.10) are read as they come. */\n readonly builtins?: readonly (G9ThemeDefinition | G9TokenTheme)[];\n /** How token themes are read (2.5.10: the scheme defaults an organisation theme falls back to). */\n readonly tokenThemes?: G9TokenThemeOptions;\n /** The person's own themes as the app stored them (read before the first paint). */\n readonly personal?: readonly G9ThemeDefinition[];\n /** Saves the personal list (the device's preferences). */\n readonly savePersonal?: (themes: readonly G9ThemeDefinition[]) => void;\n /** The most personal themes kept. Default 12. */\n readonly maxPersonal?: number;\n}\n\n/** Every theme: built in, the organisation's, the person's own (a store an appearance page reads). */\nexport interface G9ThemeRegistry {\n get(): G9ThemeRegistrySnapshot;\n subscribe(listener: () => void): () => void;\n /** A theme by id, or null. */\n find(id: string): G9ThemeDefinition | null;\n /** A theme by id; one that disappeared (an admin deleted it) falls back to the first built-in theme. */\n themeOrDefault(id: string): G9ThemeDefinition;\n /** Replaces the organisation's themes (from the server; each read loosely, broken ones dropped). */\n setOrgThemes(inputs: readonly unknown[]): void;\n /** Adds or replaces a personal theme (the newest first; past the limit the oldest go). */\n savePersonal(theme: G9ThemeDefinition): void;\n removePersonal(id: string): void;\n readonly personal: () => readonly G9ThemeDefinition[];\n}\n\n/**\n * A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. A token\n * theme (`{ id, name, scheme, tokens }`, G9Hub's format; 2.5.10) is read with {@link g9ThemeFromTokens}.\n */\nexport function g9ThemeFromInput(\n input: unknown,\n source: G9ThemeDefinition['source'],\n tokenThemes: G9TokenThemeOptions = {},\n): G9ThemeDefinition | null {\n if (!input || typeof input !== 'object') return null;\n if (g9IsTokenTheme(input)) {\n if (typeof input.name !== 'string' && (typeof input.name !== 'object' || input.name === null)) return null;\n if (typeof input.name === 'string' && !input.name.trim()) return null;\n const def = g9ThemeFromTokens(input, { ...tokenThemes, source });\n return Object.freeze({ ...def, id: source === 'org' && !def.id.startsWith('org:') ? `org:${def.id}` : def.id });\n }\n const t = input as Partial<G9ThemeDefinition>;\n try {\n const def = importTheme(JSON.stringify({ format: 'g9-theme', version: 1, theme: t }));\n if (!def.name || (typeof def.name === 'string' && !def.name.trim())) return null;\n return Object.freeze({\n ...def,\n id: source === 'org' && !def.id.startsWith('org:') ? `org:${def.id}` : def.id,\n source,\n });\n } catch {\n return null;\n }\n}\n\n/** Creates a theme registry. */\nexport function createG9ThemeRegistry(options: G9ThemeRegistryOptions = {}): G9ThemeRegistry {\n const builtins: readonly G9ThemeDefinition[] = (options.builtins ?? g9BuiltInThemes).map((t) =>\n g9IsTokenTheme(t) ? g9ThemeFromTokens(t, { ...options.tokenThemes, source: 'builtin' }) : t,\n );\n const max = Math.max(1, options.maxPersonal ?? 12);\n let org: G9ThemeDefinition[] = [];\n let personal: G9ThemeDefinition[] = (options.personal ?? [])\n .map((t) => g9ThemeFromInput(t, 'personal', options.tokenThemes))\n .filter((t): t is G9ThemeDefinition => t !== null)\n .slice(0, max);\n const listeners = new Set<() => void>();\n let snapshot: G9ThemeRegistrySnapshot = { themes: [...builtins, ...personal], revision: 0 };\n const rebuild = () => {\n snapshot = { themes: [...builtins, ...org, ...personal], revision: snapshot.revision + 1 };\n for (const l of [...listeners]) l();\n };\n const find = (id: string) => snapshot.themes.find((t) => t.id === id) ?? null;\n return {\n get: () => snapshot,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n find,\n themeOrDefault: (id) => find(id) ?? (builtins[0] as G9ThemeDefinition),\n setOrgThemes(inputs) {\n org = inputs\n .map((i) => g9ThemeFromInput(i, 'org', options.tokenThemes))\n .filter((t): t is G9ThemeDefinition => t !== null);\n rebuild();\n },\n savePersonal(theme) {\n const own = Object.freeze({ ...theme, source: 'personal' as const });\n personal = [own, ...personal.filter((t) => t.id !== theme.id)].slice(0, max);\n options.savePersonal?.(personal);\n rebuild();\n },\n removePersonal(id) {\n if (!personal.some((t) => t.id === id)) return;\n personal = personal.filter((t) => t.id !== id);\n options.savePersonal?.(personal);\n rebuild();\n },\n personal: () => personal,\n };\n}\n\n// ------------------------------------------------------------------------------------------------ personal themes\n\n/** How a personal theme's surfaces are tinted. */\nexport type G9SurfaceTone = 'neutral' | 'cool' | 'warm' | 'tinted';\n\n/** What the personal theme editor edits. */\nexport interface G9PersonalThemeDraft {\n readonly id: string;\n readonly name: string;\n /** The theme it starts from. */\n readonly base: G9ThemeDefinition;\n /** `#rrggbb`. */\n readonly accent: string;\n readonly surfaces: G9SurfaceTone;\n /** A wallpaper id, or `theme`. */\n readonly wallpaper: string;\n /** Light or dark (default the base's own mode, else light). */\n readonly scheme?: G9ColorScheme;\n}\n\n/** A fresh personal id (`me:…`). */\nexport function g9NewPersonalThemeId(random: () => number = Math.random): string {\n let id = '';\n for (let i = 0; i < 12; i++) id += Math.floor(random() * 36).toString(36);\n return `me:${id}`;\n}\n\n/** A draft starting from `base`. */\nexport function g9PersonalDraft(\n base: G9ThemeDefinition,\n name: string,\n id: string = g9NewPersonalThemeId(),\n): G9PersonalThemeDraft {\n return {\n id,\n name,\n base,\n accent: toHex(base.brand.primary),\n surfaces: 'neutral',\n wallpaper: base.wallpaper ?? 'theme',\n };\n}\n\nconst TINTS: Readonly<Record<'cool' | 'warm', string>> = { cool: '#3b82f6', warm: '#f59e0b' };\nconst SURFACES: readonly [G9ColorToken, number, number][] = [\n // token, tint in dark, tint in light (fractions)\n ['Background', 0.07, 0.04],\n ['BackgroundSecondary', 0.08, 0.05],\n ['Surface', 0.09, 0.05],\n ['SurfaceContainerLow', 0.09, 0.05],\n ['SurfaceContainer', 0.1, 0.06],\n ['SurfaceContainerHigh', 0.12, 0.08],\n];\n\n/**\n * The theme a draft describes: the base's recipe with the draft's accent, its surfaces tinted (cool, warm, or by the\n * accent) through overrides measured on `palettes` (the base's palettes for the accent: `recipePalettes(...)`).\n */\nexport function g9BuildPersonalTheme(\n draft: G9PersonalThemeDraft,\n palettes: { readonly light: G9PaletteValues; readonly dark: G9PaletteValues },\n): G9ThemeDefinition {\n const accent = tryParseColor(draft.accent) ? draft.accent : draft.base.brand.primary;\n const scheme: G9ColorScheme = draft.scheme ?? (draft.base.mode === 'dark' ? 'dark' : 'light');\n let overrides: G9ThemeDefinition['overrides'];\n if (draft.surfaces !== 'neutral') {\n const tint = draft.surfaces === 'tinted' ? accent : TINTS[draft.surfaces];\n const of = (s: G9ColorScheme) => {\n const o: Partial<Record<G9ColorToken, string>> = {};\n for (const [token, d, l] of SURFACES) o[token] = mixOklch(palettes[s][token], tint, s === 'dark' ? d : l);\n return o;\n };\n overrides = { light: of('light'), dark: of('dark') };\n }\n const name = draft.name.trim().slice(0, 60);\n return Object.freeze({\n id: draft.id,\n name: name || draft.base.name,\n source: 'personal' as const,\n recipe: draft.base.recipe,\n brand: { ...draft.base.brand, primary: accent },\n ...(overrides ? { overrides } : {}),\n ...(draft.base.shape ? { shape: draft.base.shape } : {}),\n mode: scheme,\n ...(draft.wallpaper !== 'theme' ? { wallpaper: draft.wallpaper } : {}),\n });\n}\n\n// What is not a letter, a mark or a digit (the web's class, \\p{L}\\p{M}\\p{N}; 2.5.11). Lynx has no Unicode property\n// escapes, so the class is spelled out: white space, ASCII and Latin-1 punctuation and symbols, the general\n// punctuation, currency, arrows, mathematical, technical, box, geometric and miscellaneous symbols and dingbats\n// (★ ☆ ✓ …), CJK punctuation, the Arabic script's own punctuation, and every astral character (emoji) — letters,\n// marks and digits of any script stay.\nconst NOT_WORD = /[\\s!-/:-@[-`{-~ -¿×÷ -₠-℀-⅏←-⯿⸀- -〿،؛؟٪-٭۔︐-!-/:-@\\ud800-\\udfff]+/g;\n\n/** A file name for a theme export (letters, marks and digits of any script, dashes). */\nexport function g9ThemeFileName(name: string): string {\n const slug = name\n .trim()\n .toLowerCase()\n .replace(NOT_WORD, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40);\n return `${slug || 'theme'}.g9theme.json`;\n}\n\n// ------------------------------------------------------------------------------------------------ wallpapers\n\n/** A chat wallpaper: layers drawn behind a thread, from the palette so it follows the theme and accent. */\nexport interface G9Wallpaper {\n readonly id: string;\n readonly name: Readonly<Record<string, string>>;\n /** The background for a palette and scheme: a colour and optional gradient layers (Lynx `background-image`). */\n paint(palette: G9PaletteValues, scheme: G9ColorScheme): { readonly color: string; readonly image?: string };\n}\n\nconst glow = (c: string, a: number) => css(withAlpha(c, a));\n\n/** Wallpapers drawn with gradients only (no pictures, no network). */\nexport const g9Wallpapers: readonly G9Wallpaper[] = Object.freeze([\n { id: 'none', name: { en: 'None', fa: 'هیچ' }, paint: (p) => ({ color: p.Background }) },\n {\n id: 'aurora',\n name: { en: 'Aurora', fa: 'شفق' },\n paint: (p, s) => ({\n color: p.Background,\n image: `radial-gradient(circle at 0% 0%, ${glow(p.Primary, s === 'dark' ? 0.18 : 0.12)} 0%, transparent 60%), radial-gradient(circle at 100% 100%, ${glow(p.Tertiary, s === 'dark' ? 0.16 : 0.1)} 0%, transparent 60%)`,\n }),\n },\n {\n id: 'dusk',\n name: { en: 'Dusk', fa: 'غروب' },\n paint: (p, s) => ({\n color: p.Background,\n image: `linear-gradient(180deg, ${glow(p.Primary, s === 'dark' ? 0.12 : 0.08)} 0%, transparent 45%, ${glow(p.Secondary, s === 'dark' ? 0.1 : 0.06)} 100%)`,\n }),\n },\n {\n id: 'mesh',\n name: { en: 'Mesh', fa: 'توری' },\n paint: (p, s) => {\n const k = s === 'dark' ? 1 : 0.75;\n return {\n color: p.Background,\n image: [\n `radial-gradient(circle at 15% 20%, ${glow(p.Primary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 85% 30%, ${glow(p.Tertiary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 50% 95%, ${glow(p.Secondary, 0.14 * k)} 0%, transparent 55%)`,\n ].join(', '),\n };\n },\n },\n {\n id: 'paper',\n name: { en: 'Paper', fa: 'کاغذی' },\n paint: (p, s) => ({ color: mixOklch(p.Background, s === 'dark' ? '#000000' : '#f5ecd7', 0.25) }),\n },\n] satisfies G9Wallpaper[]);\n\n/** A wallpaper by id (from `list`, default {@link g9Wallpapers}), or null. */\nexport function g9Wallpaper(id: string, list: readonly G9Wallpaper[] = g9Wallpapers): G9Wallpaper | null {\n return list.find((w) => w.id === id) ?? null;\n}\n"],"names":["g9AppTokenNames","g9AllAppTokenNames","Object","Set","g9ThemeTokenNames","css","c","formatColor","g9AppTokens","theme","options","_p_InputBackground","_options_overrides","p","dark","accent","tryParseColor","own","onAccent","readableOn","surface","field","out","withAlpha","mixOklch","ensureContrast","name","value","g9AppTokenVariables","prefix","g9DefaultAppearance","SCALES","EFFECTS","DENSITIES","g9NormalizeAppearance","raw","defaults","r","text","v","d","pick","list","undefined","g9FontScaleFactors","g9ScaledType","scale","base","g9DefaultShape","k","role","t","Math","g9EffectsEnabled","mode","device","g9EffectsState","g9AppearanceClasses","settings","scheme","effects","g9ActiveThemeId","systemScheme","g9ThemeFromInput","input","source","tokenThemes","g9IsTokenTheme","def","g9ThemeFromTokens","importTheme","JSON","createG9ThemeRegistry","_options_builtins","_options_maxPersonal","_options_personal","builtins","g9BuiltInThemes","max","org","personal","listeners","snapshot","rebuild","l","find","id","_snapshot_themes_find","listener","_find","inputs","i","g9NewPersonalThemeId","random","g9PersonalDraft","_base_wallpaper","toHex","TINTS","SURFACES","g9BuildPersonalTheme","draft","palettes","_draft_scheme","overrides","tint","of","s","o","token","NOT_WORD","g9ThemeFileName","slug","glow","a","g9Wallpapers","g9Wallpaper","_list_find","w"],"mappings":";;;;;AAyBO,MAAMA,kBAAkB;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAMM,MAAMC,qBAAwCC,OAAO,MAAM,CAAC;OAC9D,IAAIC,IAAY;WAAIH;WAAoBI;KAAkB;CAC9D;AAUD,MAAMC,MAAM,CAACC,IAAyCC,YAAYD;AAG3D,SAASE,YACdC,KAA4E,EAC5EC,UAA6B,CAAC,CAAC;QAQjBC,oBA0B6BC;IAhC3C,MAAMC,IAAIJ,MAAM,OAAO;IACvB,MAAMK,OAAOL,AAAiB,WAAjBA,MAAM,MAAM;IACzB,MAAMM,SAASL,QAAQ,MAAM,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AI;QAAO;QAC/B,OAAO,CAAC7F,GAAG6F;YACT,MAAMzD,IAAIyD,AAAM,WAANA,IAAe,IAAI;YAC7B,OAAO;gBACL,OAAO7F,EAAE,UAAU;gBACnB,OAAO;oBACL,CAAC,mCAAmC,EAAEmG,KAAKnG,EAAE,OAAO,EAAE,OAAOoC,GAAG,qBAAqB,CAAC;oBACtF,CAAC,mCAAmC,EAAE+D,KAAKnG,EAAE,QAAQ,EAAE,OAAOoC,GAAG,qBAAqB,CAAC;oBACvF,CAAC,mCAAmC,EAAE+D,KAAKnG,EAAE,SAAS,EAAE,OAAOoC,GAAG,qBAAqB,CAAC;iBACzF,CAAC,IAAI,CAAC;YACT;QACF;IACF;IACA;QACE,IAAI;QACJ,MAAM;YAAE,IAAI;YAAS,IAAI;QAAQ;QACjC,OAAO,CAACpC,GAAG6F,IAAO;gBAAE,OAAOlF,SAASX,EAAE,UAAU,EAAE6F,AAAM,WAANA,IAAe,YAAY,WAAW;YAAM;IAChG;CACD;AAGM,SAASS,YAAY7B,EAAU,EAAE5C,OAA+BwE,YAAY;QAC1EE;IAAP,OAAO,QAAAA,CAAAA,aAAAA,KAAK,IAAI,CAAC,CAACC,IAAMA,EAAE,EAAE,KAAK/B,GAAE,IAA5B8B,aAAiC;AAC1C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { G9ColorToken } from '../tokens/generated/palettes.js';
|
|
2
2
|
import { type G9ShapeSet } from '../tokens/shape.js';
|
|
3
3
|
import type { G9BrandColors } from './brand.js';
|
|
4
|
-
import { type G9ColorScheme, type G9PaletteOverrides, type G9ResolvedTheme, type G9ThemeMode, type G9ThemeStore } from './theme.js';
|
|
4
|
+
import { type G9ColorScheme, type G9PaletteOverrides, type G9ResolvedTheme, type G9SchemeAppTokens, type G9ThemeMode, type G9ThemeStore } from './theme.js';
|
|
5
5
|
/** Where a theme definition comes from: built in, the organisation's, or the person's own. */
|
|
6
6
|
export type G9ThemeSource = 'builtin' | 'org' | 'personal';
|
|
7
7
|
/** One selectable theme. */
|
|
@@ -22,6 +22,11 @@ export interface G9ThemeDefinition {
|
|
|
22
22
|
readonly mode?: G9ThemeMode;
|
|
23
23
|
/** An app-defined wallpaper key. */
|
|
24
24
|
readonly wallpaper?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The theme's app tokens per scheme (2.5.10): `--g9-<name>` values beside the palette — a token theme's every token
|
|
27
|
+
* (`bubble-mine` gradient, glass, wallpaper, shadows, radii, motion), kept through the registry, export and import.
|
|
28
|
+
*/
|
|
29
|
+
readonly appTokens?: G9SchemeAppTokens;
|
|
25
30
|
}
|
|
26
31
|
/** Accent colours offered by "pick a colour" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */
|
|
27
32
|
export declare const g9AccentPresets: ReadonlyArray<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../src/theme/appearance.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../src/theme/appearance.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,SAAS,CAAC;AAEjB,8FAA8F;AAC9F,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,KAAK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AE,aAAuB,GAAG,eAAe,CAMjH;AAWD,mEAAmE;AACnE,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,iBAAiB,CA+C3E;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,SAAS,iBAAiB,EAgCxB,CAAC;AAEjC,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,GAAI,OAAO,iBAAiB,KAAG,SAAS,YAAY,EAG5D,CAAC"}
|
package/dist/theme/appearance.js
CHANGED
|
@@ -2,6 +2,7 @@ import { G9Error } from "../errors.js";
|
|
|
2
2
|
import { resolveShape } from "../tokens/shape.js";
|
|
3
3
|
import { tryParseColor } from "./color.js";
|
|
4
4
|
import { recipePalettes } from "./recipe.js";
|
|
5
|
+
import { g9SanitizeTokens } from "./sanitize.js";
|
|
5
6
|
import { lazyPalettes } from "./theme.js";
|
|
6
7
|
const g9AccentPresets = Object.freeze([
|
|
7
8
|
{
|
|
@@ -109,10 +110,12 @@ function applyThemeDefinition(store, theme) {
|
|
|
109
110
|
}) : palette;
|
|
110
111
|
store.beginBatch();
|
|
111
112
|
try {
|
|
113
|
+
var _store_setAppTokens;
|
|
112
114
|
store.setPalettes(lazyPalettes((scheme)=>{
|
|
113
115
|
var _theme_overrides;
|
|
114
116
|
return layer(base[scheme], null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides[scheme]);
|
|
115
117
|
}));
|
|
118
|
+
null == (_store_setAppTokens = store.setAppTokens) || _store_setAppTokens.call(store, theme.appTokens);
|
|
116
119
|
if (theme.mode) store.setMode(theme.mode);
|
|
117
120
|
} finally{
|
|
118
121
|
store.endBatch();
|
|
@@ -120,18 +123,22 @@ function applyThemeDefinition(store, theme) {
|
|
|
120
123
|
return resolveShape(theme.shape);
|
|
121
124
|
}
|
|
122
125
|
function previewThemeDefinition(theme, scheme = 'light') {
|
|
123
|
-
var _theme_overrides;
|
|
126
|
+
var _theme_overrides, _theme_appTokens;
|
|
124
127
|
const base = recipePalettes(theme.recipe, theme.brand)[scheme];
|
|
125
128
|
const over = null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides[scheme];
|
|
126
129
|
const palette = over ? Object.freeze({
|
|
127
130
|
...base,
|
|
128
131
|
...stripUndefined(over)
|
|
129
132
|
}) : base;
|
|
133
|
+
const appTokens = null == (_theme_appTokens = theme.appTokens) ? void 0 : _theme_appTokens[scheme];
|
|
130
134
|
return Object.freeze({
|
|
131
135
|
mode: scheme,
|
|
132
136
|
systemScheme: scheme,
|
|
133
137
|
scheme,
|
|
134
|
-
palette
|
|
138
|
+
palette,
|
|
139
|
+
...appTokens ? {
|
|
140
|
+
appTokens
|
|
141
|
+
} : {}
|
|
135
142
|
});
|
|
136
143
|
}
|
|
137
144
|
function stripUndefined(o) {
|
|
@@ -174,10 +181,21 @@ function importTheme(json, newId) {
|
|
|
174
181
|
if (null == (_t_shape = t.shape) ? void 0 : _t_shape.radii) {
|
|
175
182
|
for (const [key, value] of Object.entries(t.shape.radii))if ('number' != typeof value || value < 0 || value > 999) throw new G9Error('theme-import', `Radius "${key}" is not a number 0–999.`);
|
|
176
183
|
}
|
|
184
|
+
const appTokens = t.appTokens ? {
|
|
185
|
+
...t.appTokens.light ? {
|
|
186
|
+
light: Object.freeze(g9SanitizeTokens(t.appTokens.light))
|
|
187
|
+
} : {},
|
|
188
|
+
...t.appTokens.dark ? {
|
|
189
|
+
dark: Object.freeze(g9SanitizeTokens(t.appTokens.dark))
|
|
190
|
+
} : {}
|
|
191
|
+
} : void 0;
|
|
177
192
|
return Object.freeze({
|
|
178
193
|
...t,
|
|
179
194
|
id: null != newId ? newId : t.id,
|
|
180
|
-
source: 'personal'
|
|
195
|
+
source: 'personal',
|
|
196
|
+
...appTokens ? {
|
|
197
|
+
appTokens
|
|
198
|
+
} : {}
|
|
181
199
|
});
|
|
182
200
|
}
|
|
183
201
|
const g9BuiltInThemes = Object.freeze([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme/appearance.js","sources":["../../src/theme/appearance.ts"],"sourcesContent":["// Appearance: the themes a person can pick (built-in, the organisation's, their own), each a recipe + brand + optional\n// designer overrides and shape, applied to the theme store in one batch. Personal themes travel as versioned JSON\n// (export / import, G9Hub's PersonalThemeSheet). Pure: the app persists the choice and the personal list.\nimport { G9Error } from '../errors';\nimport type { G9ColorToken } from '../tokens/generated/palettes';\nimport { type G9ShapeSet, resolveShape } from '../tokens/shape';\nimport type { G9BrandColors } from './brand';\nimport { tryParseColor } from './color';\nimport { recipePalettes } from './recipe';\nimport {\n type G9ColorScheme,\n type G9PaletteOverrides,\n type G9ResolvedTheme,\n type G9ThemeMode,\n type G9ThemeStore,\n lazyPalettes,\n} from './theme';\n\n/** Where a theme definition comes from: built in, the organisation's, or the person's own. */\nexport type G9ThemeSource = 'builtin' | 'org' | 'personal';\n\n/** One selectable theme. */\nexport interface G9ThemeDefinition {\n readonly id: string;\n /** Display name, one string or per language. */\n readonly name: string | Readonly<Record<string, string>>;\n readonly source: G9ThemeSource;\n readonly recipe: string;\n readonly brand: G9BrandColors;\n /** Designer overrides on top of the recipe, per scheme. */\n readonly overrides?: { readonly light?: G9PaletteOverrides; readonly dark?: G9PaletteOverrides };\n readonly shape?: Partial<G9ShapeSet>;\n /** A mode this theme forces (`'dark'` for a night theme); otherwise the user's mode stays. */\n readonly mode?: G9ThemeMode;\n /** An app-defined wallpaper key. */\n readonly wallpaper?: string;\n}\n\n/** Accent colours offered by \"pick a colour\" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */\nexport const g9AccentPresets: ReadonlyArray<{\n readonly id: string;\n readonly color: string;\n readonly name: Readonly<Record<string, string>>;\n}> = Object.freeze([\n { id: 'emerald', color: '#349D57', name: { en: 'Emerald', fa: 'زمردی' } },\n { id: 'teal', color: '#01A890', name: { en: 'Teal', fa: 'فیروزهای' } },\n { id: 'ocean', color: '#2B6FB3', name: { en: 'Ocean', fa: 'اقیانوسی' } },\n { id: 'indigo', color: '#4F55D8', name: { en: 'Indigo', fa: 'نیلی' } },\n { id: 'violet', color: '#7B5EA7', name: { en: 'Violet', fa: 'بنفش' } },\n { id: 'rose', color: '#D0457A', name: { en: 'Rose', fa: 'گلی' } },\n { id: 'terracotta', color: '#C2552D', name: { en: 'Terracotta', fa: 'آجری' } },\n { id: 'amber', color: '#B7791F', name: { en: 'Amber', fa: 'کهربایی' } },\n { id: 'olive', color: '#6B7A2A', name: { en: 'Olive', fa: 'زیتونی' } },\n { id: 'slate', color: '#4A5A6A', name: { en: 'Slate', fa: 'سنگی' } },\n { id: 'graphite', color: '#2F3437', name: { en: 'Graphite', fa: 'گرافیتی' } },\n { id: 'saffron', color: '#E0A100', name: { en: 'Saffron', fa: 'زعفرانی' } },\n]);\n\n/**\n * Paints `theme` into `store` (one notification): the recipe's palettes for its brand, the designer overrides layered\n * per scheme, the forced mode if any. Returns the theme's resolved shape for the provider's CSS variables.\n */\nexport function applyThemeDefinition(store: G9ThemeStore, theme: G9ThemeDefinition): G9ShapeSet {\n const base = recipePalettes(theme.recipe, theme.brand);\n const layer = (palette: typeof base.light, over?: G9PaletteOverrides) =>\n over ? (Object.freeze({ ...palette, ...stripUndefined(over) }) as typeof palette) : palette;\n store.beginBatch();\n try {\n // each scheme built when the store first paints it (the dark one waits for dark mode)\n store.setPalettes(lazyPalettes((scheme) => layer(base[scheme], theme.overrides?.[scheme])));\n if (theme.mode) store.setMode(theme.mode);\n } finally {\n store.endBatch();\n }\n return resolveShape(theme.shape);\n}\n\n/**\n * A theme definition resolved for one scheme without touching any store: what `G9ThemePreviewCard` shows (a theme\n * picker's cards, an editor's draft). Only the asked scheme's palette is built (palettes are cached by recipe and\n * brand, so showing the same card again costs nothing).\n */\nexport function previewThemeDefinition(theme: G9ThemeDefinition, scheme: G9ColorScheme = 'light'): G9ResolvedTheme {\n const base = recipePalettes(theme.recipe, theme.brand)[scheme];\n const over = theme.overrides?.[scheme];\n const palette = over ? (Object.freeze({ ...base, ...stripUndefined(over) }) as typeof base) : base;\n return Object.freeze({ mode: scheme, systemScheme: scheme, scheme, palette });\n}\n\nfunction stripUndefined(o: G9PaletteOverrides): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(o)) if (v !== undefined) out[k] = v;\n return out;\n}\n\nconst FORMAT = 'g9-theme';\nconst VERSION = 1;\n\n/** A theme as portable JSON (personal themes, sharing, backup). */\nexport function exportTheme(theme: G9ThemeDefinition): string {\n return JSON.stringify({ format: FORMAT, version: VERSION, theme: { ...theme, source: 'personal' } });\n}\n\n/**\n * Reads exported JSON back, checking every colour and the shape's numbers; the result is always a personal theme with\n * a fresh id when `newId` is given (an import never overwrites a built-in).\n * @throws {G9Error} `theme-import` with the reason.\n */\nexport function importTheme(json: string, newId?: string): G9ThemeDefinition {\n let data: unknown;\n try {\n data = JSON.parse(json);\n } catch {\n throw new G9Error('theme-import', 'Not a theme file (not JSON).');\n }\n const d = data as { format?: unknown; version?: unknown; theme?: Partial<G9ThemeDefinition> };\n if (d?.format !== FORMAT) throw new G9Error('theme-import', 'Not a G9 theme file.');\n if (typeof d.version !== 'number' || d.version > VERSION)\n throw new G9Error(\n 'theme-import',\n `Theme file version ${String(d.version)} is newer than this app reads (${VERSION}).`,\n );\n const t = d.theme;\n if (!t || typeof t.id !== 'string' || typeof t.recipe !== 'string' || !t.brand || typeof t.brand !== 'object') {\n throw new G9Error('theme-import', 'The theme lacks an id, a recipe or a brand.');\n }\n const colours: [string, unknown][] = [\n ...Object.entries(t.brand),\n ...Object.entries(t.overrides?.light ?? {}),\n ...Object.entries(t.overrides?.dark ?? {}),\n ];\n for (const [key, value] of colours) {\n if (value !== undefined && (typeof value !== 'string' || !tryParseColor(value))) {\n throw new G9Error('theme-import', `\"${key}\" is not a colour: ${JSON.stringify(value)}.`);\n }\n }\n if (t.shape?.radii) {\n for (const [key, value] of Object.entries(t.shape.radii)) {\n if (typeof value !== 'number' || value < 0 || value > 999)\n throw new G9Error('theme-import', `Radius \"${key}\" is not a number 0–999.`);\n }\n }\n return Object.freeze({ ...(t as G9ThemeDefinition), id: newId ?? t.id, source: 'personal' as const });\n}\n\n/** The built-in themes over the built-in recipes, one per accent preset family. */\nexport const g9BuiltInThemes: readonly G9ThemeDefinition[] = Object.freeze([\n {\n id: 'classic',\n name: { en: 'Classic', fa: 'کلاسیک' },\n source: 'builtin',\n recipe: 'stock',\n brand: { primary: '#349D57' },\n },\n {\n id: 'tonal',\n name: { en: 'Tonal', fa: 'همرنگ' },\n source: 'builtin',\n recipe: 'tonal',\n brand: { primary: '#2B6FB3' },\n },\n { id: 'calm', name: { en: 'Calm', fa: 'آرام' }, source: 'builtin', recipe: 'neutral', brand: { primary: '#4A5A6A' } },\n { id: 'vivid', name: { en: 'Vivid', fa: 'شاد' }, source: 'builtin', recipe: 'tinted', brand: { primary: '#D0457A' } },\n {\n id: 'midnight',\n name: { en: 'Midnight', fa: 'نیمهشب' },\n source: 'builtin',\n recipe: 'midnight',\n brand: { primary: '#01C6AC' },\n mode: 'dark',\n },\n {\n id: 'accessible',\n name: { en: 'High contrast', fa: 'کنتراست بالا' },\n source: 'builtin',\n recipe: 'contrast',\n brand: { primary: '#1F5FA8' },\n },\n] satisfies G9ThemeDefinition[]);\n\n/** A theme's display name in `language` (falls back to English, then any). */\nexport function themeName(theme: G9ThemeDefinition, language: string): string {\n if (typeof theme.name === 'string') return theme.name;\n return theme.name[language] ?? theme.name.en ?? Object.values(theme.name)[0] ?? theme.id;\n}\n\n/** Tokens a theme overrides (for a \"what is changed\" list in a theme editor). */\nexport const overriddenTokens = (theme: G9ThemeDefinition): readonly G9ColorToken[] =>\n [\n ...new Set([...Object.keys(theme.overrides?.light ?? {}), ...Object.keys(theme.overrides?.dark ?? {})]),\n ] as G9ColorToken[];\n"],"names":["g9AccentPresets","Object","applyThemeDefinition","store","theme","base","recipePalettes","layer","palette","over","stripUndefined","lazyPalettes","scheme","_theme_overrides","resolveShape","previewThemeDefinition","o","out","k","v","undefined","FORMAT","VERSION","exportTheme","JSON","importTheme","json","newId","_t_overrides","_t_overrides1","_t_shape","data","G9Error","d","String","t","colours","key","value","tryParseColor","g9BuiltInThemes","themeName","language","_ref","overriddenTokens","_theme_overrides1","Set"],"mappings":";;;;;AAuCO,MAAMA,kBAIRC,OAAO,MAAM,CAAC;IACjB;QAAE,IAAI;QAAW,OAAO;QAAW,MAAM;YAAE,IAAI;YAAW,IAAI;QAAQ;IAAE;IACxE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAY;IAAE;IACtE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAW;IAAE;IACvE;QAAE,IAAI;QAAU,OAAO;QAAW,MAAM;YAAE,IAAI;YAAU,IAAI;QAAO;IAAE;IACrE;QAAE,IAAI;QAAU,OAAO;QAAW,MAAM;YAAE,IAAI;YAAU,IAAI;QAAO;IAAE;IACrE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAM;IAAE;IAChE;QAAE,IAAI;QAAc,OAAO;QAAW,MAAM;YAAE,IAAI;YAAc,IAAI;QAAO;IAAE;IAC7E;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAU;IAAE;IACtE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAS;IAAE;IACrE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAO;IAAE;IACnE;QAAE,IAAI;QAAY,OAAO;QAAW,MAAM;YAAE,IAAI;YAAY,IAA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;YAAE,IAAI;YAAS,IAAI;QAAM;QAAG,QAAQ;QAAW,QAAQ;QAAU,OAAO;YAAE,SAAS;QAAU;IAAE;IACpH;QACE,IAAI;QACJ,MAAM;YAAE,IAAI;YAAY,IAAI;QAAU;QACtC,QAAQ;QACR,QAAQ;QACR,OAAO;YAAE,SAAS;QAAU;QAC5B,MAAM;IACR;IACA;QACE,IAAI;QACJ,MAAM;YAAE,IAAI;YAAiB,IAAI;QAAe;QAChD,QAAQ;QACR,QAAQ;QACR,OAAO;YAAE,SAAS;QAAU;IAC9B;CACD;AAGM,SAASwC,UAAUrC,KAAwB,EAAEsC,QAAgB;QAE3DC,MAAAA,OAAAA;IADP,IAAI,AAAsB,YAAtB,OAAOvC,MAAM,IAAI,EAAe,OAAOA,MAAM,IAAI;IACrD,OAAO,QAAAuC,CAAAA,OAAAA,QAAAA,CAAAA,QAAAA,QAAAA,CAAAA,uBAAAA,MAAM,IAAI,CAACD,SAAS,AAAD,IAAnBC,uBAAwBvC,MAAM,IAAI,CAAC,EAAE,AAAD,IAApCuC,QAAyC1C,OAAO,MAAM,CAACG,MAAM,IAAI,CAAC,CAAC,EAAE,AAAD,IAApEuC,OAAyEvC,MAAM,EAAE;AAC1F;AAGO,MAAMwC,mBAAmB,CAACxC;;QAEFS,kBAA8CgC;WAD3E;WACK,IAAIC,IAAI;eAAI7C,OAAO,IAAI,CAAC,QAAD,gBAACY,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,iBAAiB,KAAK,AAAD,IAAC,OAAI,CAAC;eAAOZ,OAAO,IAAI,CAAC,QAAD,iBAAC4C,CAAAA,oBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,kBAAiB,IAAI,AAAD,IAAC,QAAI,CAAC;SAAG;KACvG"}
|
|
1
|
+
{"version":3,"file":"theme/appearance.js","sources":["../../src/theme/appearance.ts"],"sourcesContent":["// Appearance: the themes a person can pick (built-in, the organisation's, their own), each a recipe + brand + optional\n// designer overrides and shape, applied to the theme store in one batch. Personal themes travel as versioned JSON\n// (export / import, G9Hub's PersonalThemeSheet). Pure: the app persists the choice and the personal list.\nimport { G9Error } from '../errors';\nimport type { G9ColorToken } from '../tokens/generated/palettes';\nimport { type G9ShapeSet, resolveShape } from '../tokens/shape';\nimport type { G9BrandColors } from './brand';\nimport { tryParseColor } from './color';\nimport { recipePalettes } from './recipe';\nimport { g9SanitizeTokens } from './sanitize';\nimport {\n type G9ColorScheme,\n type G9PaletteOverrides,\n type G9ResolvedTheme,\n type G9SchemeAppTokens,\n type G9ThemeMode,\n type G9ThemeStore,\n lazyPalettes,\n} from './theme';\n\n/** Where a theme definition comes from: built in, the organisation's, or the person's own. */\nexport type G9ThemeSource = 'builtin' | 'org' | 'personal';\n\n/** One selectable theme. */\nexport interface G9ThemeDefinition {\n readonly id: string;\n /** Display name, one string or per language. */\n readonly name: string | Readonly<Record<string, string>>;\n readonly source: G9ThemeSource;\n readonly recipe: string;\n readonly brand: G9BrandColors;\n /** Designer overrides on top of the recipe, per scheme. */\n readonly overrides?: { readonly light?: G9PaletteOverrides; readonly dark?: G9PaletteOverrides };\n readonly shape?: Partial<G9ShapeSet>;\n /** A mode this theme forces (`'dark'` for a night theme); otherwise the user's mode stays. */\n readonly mode?: G9ThemeMode;\n /** An app-defined wallpaper key. */\n readonly wallpaper?: string;\n /**\n * The theme's app tokens per scheme (2.5.10): `--g9-<name>` values beside the palette — a token theme's every token\n * (`bubble-mine` gradient, glass, wallpaper, shadows, radii, motion), kept through the registry, export and import.\n */\n readonly appTokens?: G9SchemeAppTokens;\n}\n\n/** Accent colours offered by \"pick a colour\" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */\nexport const g9AccentPresets: ReadonlyArray<{\n readonly id: string;\n readonly color: string;\n readonly name: Readonly<Record<string, string>>;\n}> = Object.freeze([\n { id: 'emerald', color: '#349D57', name: { en: 'Emerald', fa: 'زمردی' } },\n { id: 'teal', color: '#01A890', name: { en: 'Teal', fa: 'فیروزهای' } },\n { id: 'ocean', color: '#2B6FB3', name: { en: 'Ocean', fa: 'اقیانوسی' } },\n { id: 'indigo', color: '#4F55D8', name: { en: 'Indigo', fa: 'نیلی' } },\n { id: 'violet', color: '#7B5EA7', name: { en: 'Violet', fa: 'بنفش' } },\n { id: 'rose', color: '#D0457A', name: { en: 'Rose', fa: 'گلی' } },\n { id: 'terracotta', color: '#C2552D', name: { en: 'Terracotta', fa: 'آجری' } },\n { id: 'amber', color: '#B7791F', name: { en: 'Amber', fa: 'کهربایی' } },\n { id: 'olive', color: '#6B7A2A', name: { en: 'Olive', fa: 'زیتونی' } },\n { id: 'slate', color: '#4A5A6A', name: { en: 'Slate', fa: 'سنگی' } },\n { id: 'graphite', color: '#2F3437', name: { en: 'Graphite', fa: 'گرافیتی' } },\n { id: 'saffron', color: '#E0A100', name: { en: 'Saffron', fa: 'زعفرانی' } },\n]);\n\n/**\n * Paints `theme` into `store` (one notification): the recipe's palettes for its brand, the designer overrides layered\n * per scheme, the forced mode if any. Returns the theme's resolved shape for the provider's CSS variables.\n */\nexport function applyThemeDefinition(store: G9ThemeStore, theme: G9ThemeDefinition): G9ShapeSet {\n const base = recipePalettes(theme.recipe, theme.brand);\n const layer = (palette: typeof base.light, over?: G9PaletteOverrides) =>\n over ? (Object.freeze({ ...palette, ...stripUndefined(over) }) as typeof palette) : palette;\n store.beginBatch();\n try {\n // each scheme built when the store first paints it (the dark one waits for dark mode)\n store.setPalettes(lazyPalettes((scheme) => layer(base[scheme], theme.overrides?.[scheme])));\n store.setAppTokens?.(theme.appTokens);\n if (theme.mode) store.setMode(theme.mode);\n } finally {\n store.endBatch();\n }\n return resolveShape(theme.shape);\n}\n\n/**\n * A theme definition resolved for one scheme without touching any store: what `G9ThemePreviewCard` shows (a theme\n * picker's cards, an editor's draft). Only the asked scheme's palette is built (palettes are cached by recipe and\n * brand, so showing the same card again costs nothing).\n */\nexport function previewThemeDefinition(theme: G9ThemeDefinition, scheme: G9ColorScheme = 'light'): G9ResolvedTheme {\n const base = recipePalettes(theme.recipe, theme.brand)[scheme];\n const over = theme.overrides?.[scheme];\n const palette = over ? (Object.freeze({ ...base, ...stripUndefined(over) }) as typeof base) : base;\n const appTokens = theme.appTokens?.[scheme];\n return Object.freeze({ mode: scheme, systemScheme: scheme, scheme, palette, ...(appTokens ? { appTokens } : {}) });\n}\n\nfunction stripUndefined(o: G9PaletteOverrides): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(o)) if (v !== undefined) out[k] = v;\n return out;\n}\n\nconst FORMAT = 'g9-theme';\nconst VERSION = 1;\n\n/** A theme as portable JSON (personal themes, sharing, backup). */\nexport function exportTheme(theme: G9ThemeDefinition): string {\n return JSON.stringify({ format: FORMAT, version: VERSION, theme: { ...theme, source: 'personal' } });\n}\n\n/**\n * Reads exported JSON back, checking every colour and the shape's numbers; the result is always a personal theme with\n * a fresh id when `newId` is given (an import never overwrites a built-in).\n * @throws {G9Error} `theme-import` with the reason.\n */\nexport function importTheme(json: string, newId?: string): G9ThemeDefinition {\n let data: unknown;\n try {\n data = JSON.parse(json);\n } catch {\n throw new G9Error('theme-import', 'Not a theme file (not JSON).');\n }\n const d = data as { format?: unknown; version?: unknown; theme?: Partial<G9ThemeDefinition> };\n if (d?.format !== FORMAT) throw new G9Error('theme-import', 'Not a G9 theme file.');\n if (typeof d.version !== 'number' || d.version > VERSION)\n throw new G9Error(\n 'theme-import',\n `Theme file version ${String(d.version)} is newer than this app reads (${VERSION}).`,\n );\n const t = d.theme;\n if (!t || typeof t.id !== 'string' || typeof t.recipe !== 'string' || !t.brand || typeof t.brand !== 'object') {\n throw new G9Error('theme-import', 'The theme lacks an id, a recipe or a brand.');\n }\n const colours: [string, unknown][] = [\n ...Object.entries(t.brand),\n ...Object.entries(t.overrides?.light ?? {}),\n ...Object.entries(t.overrides?.dark ?? {}),\n ];\n for (const [key, value] of colours) {\n if (value !== undefined && (typeof value !== 'string' || !tryParseColor(value))) {\n throw new G9Error('theme-import', `\"${key}\" is not a colour: ${JSON.stringify(value)}.`);\n }\n }\n if (t.shape?.radii) {\n for (const [key, value] of Object.entries(t.shape.radii)) {\n if (typeof value !== 'number' || value < 0 || value > 999)\n throw new G9Error('theme-import', `Radius \"${key}\" is not a number 0–999.`);\n }\n }\n // app tokens are CSS values, not colours: each kept only when it is a safe declaration value\n const appTokens = t.appTokens\n ? {\n ...(t.appTokens.light ? { light: Object.freeze(g9SanitizeTokens(t.appTokens.light)) } : {}),\n ...(t.appTokens.dark ? { dark: Object.freeze(g9SanitizeTokens(t.appTokens.dark)) } : {}),\n }\n : undefined;\n return Object.freeze({\n ...(t as G9ThemeDefinition),\n id: newId ?? t.id,\n source: 'personal' as const,\n ...(appTokens ? { appTokens } : {}),\n });\n}\n\n/** The built-in themes over the built-in recipes, one per accent preset family. */\nexport const g9BuiltInThemes: readonly G9ThemeDefinition[] = Object.freeze([\n {\n id: 'classic',\n name: { en: 'Classic', fa: 'کلاسیک' },\n source: 'builtin',\n recipe: 'stock',\n brand: { primary: '#349D57' },\n },\n {\n id: 'tonal',\n name: { en: 'Tonal', fa: 'همرنگ' },\n source: 'builtin',\n recipe: 'tonal',\n brand: { primary: '#2B6FB3' },\n },\n { id: 'calm', name: { en: 'Calm', fa: 'آرام' }, source: 'builtin', recipe: 'neutral', brand: { primary: '#4A5A6A' } },\n { id: 'vivid', name: { en: 'Vivid', fa: 'شاد' }, source: 'builtin', recipe: 'tinted', brand: { primary: '#D0457A' } },\n {\n id: 'midnight',\n name: { en: 'Midnight', fa: 'نیمهشب' },\n source: 'builtin',\n recipe: 'midnight',\n brand: { primary: '#01C6AC' },\n mode: 'dark',\n },\n {\n id: 'accessible',\n name: { en: 'High contrast', fa: 'کنتراست بالا' },\n source: 'builtin',\n recipe: 'contrast',\n brand: { primary: '#1F5FA8' },\n },\n] satisfies G9ThemeDefinition[]);\n\n/** A theme's display name in `language` (falls back to English, then any). */\nexport function themeName(theme: G9ThemeDefinition, language: string): string {\n if (typeof theme.name === 'string') return theme.name;\n return theme.name[language] ?? theme.name.en ?? Object.values(theme.name)[0] ?? theme.id;\n}\n\n/** Tokens a theme overrides (for a \"what is changed\" list in a theme editor). */\nexport const overriddenTokens = (theme: G9ThemeDefinition): readonly G9ColorToken[] =>\n [\n ...new Set([...Object.keys(theme.overrides?.light ?? {}), ...Object.keys(theme.overrides?.dark ?? {})]),\n ] as G9ColorToken[];\n"],"names":["g9AccentPresets","Object","applyThemeDefinition","store","theme","base","recipePalettes","layer","palette","over","stripUndefined","lazyPalettes","scheme","_theme_overrides","resolveShape","previewThemeDefinition","_theme_appTokens","appTokens","o","out","k","v","undefined","FORMAT","VERSION","exportTheme","JSON","importTheme","json","newId","_t_overrides","_t_overrides1","_t_shape","data","G9Error","d","String","t","colours","key","value","tryParseColor","g9SanitizeTokens","g9BuiltInThemes","themeName","language","_ref","overriddenTokens","_theme_overrides1","Set"],"mappings":";;;;;;AA8CO,MAAMA,kBAIRC,OAAO,MAAM,CAAC;IACjB;QAAE,IAAI;QAAW,OAAO;QAAW,MAAM;YAAE,IAAI;YAAW,IAAI;QAAQ;IAAE;IACxE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAY;IAAE;IACtE;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YAAS,IAAI;QAAW;IAAE;IACvE;QAAE,IAAI;QAAU,OAAO;QAAW,MAAM;YAAE,IAAI;YAAU,IAAI;QAAO;IAAE;IACrE;QAAE,IAAI;QAAU,OAAO;QAAW,MAAM;YAAE,IAAI;YAAU,IAAI;QAAO;IAAE;IACrE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAM;IAAE;IAChE;QAAE,IAAI;QAAc,OAAO;QAAW,MAAM;YAAE,IAAI;YAAc,IAAI;QAAO;IAAE;IAC7E;QAAE,IAAI;QAAS,OAAO;QAAW,MAAM;YAAE,IAAI;YA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SAAS2C,UAAUxC,KAAwB,EAAEyC,QAAgB;QAE3DC,MAAAA,OAAAA;IADP,IAAI,AAAsB,YAAtB,OAAO1C,MAAM,IAAI,EAAe,OAAOA,MAAM,IAAI;IACrD,OAAO,QAAA0C,CAAAA,OAAAA,QAAAA,CAAAA,QAAAA,QAAAA,CAAAA,uBAAAA,MAAM,IAAI,CAACD,SAAS,AAAD,IAAnBC,uBAAwB1C,MAAM,IAAI,CAAC,EAAE,AAAD,IAApC0C,QAAyC7C,OAAO,MAAM,CAACG,MAAM,IAAI,CAAC,CAAC,EAAE,AAAD,IAApE0C,OAAyE1C,MAAM,EAAE;AAC1F;AAGO,MAAM2C,mBAAmB,CAAC3C;;QAEFS,kBAA8CmC;WAD3E;WACK,IAAIC,IAAI;eAAIhD,OAAO,IAAI,CAAC,QAAD,gBAACY,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,iBAAiB,KAAK,AAAD,IAAC,OAAI,CAAC;eAAOZ,OAAO,IAAI,CAAC,QAAD,iBAAC+C,CAAAA,oBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,kBAAiB,IAAI,AAAD,IAAC,QAAI,CAAC;SAAG;KACvG"}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { aliasCssVariables, aliasPalette, type G9TokenAliasMap, g9AliasPresets } from './aliases.js';
|
|
2
2
|
export { applyThemeDefinition, exportTheme, type G9ThemeDefinition, type G9ThemeSource, g9AccentPresets, g9BuiltInThemes, importTheme, overriddenTokens, previewThemeDefinition, themeName, } from './appearance.js';
|
|
3
|
-
export { createG9ThemeRegistry, type G9AppearanceSettings, type G9AppTokenName, type G9AppTokenOptions, type G9EffectsMode, type G9FontScale, type G9PersonalThemeDraft, type G9SurfaceTone, type G9ThemeRegistry, type G9ThemeRegistryOptions, type G9ThemeRegistrySnapshot, type G9Wallpaper, g9ActiveThemeId, g9AppTokenNames, g9AppTokens, g9AppTokenVariables, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9SanitizeTokens, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers, } from './appearance-kit.js';
|
|
3
|
+
export { createG9ThemeRegistry, type G9AppearanceSettings, type G9AppTokenName, type G9AppTokenOptions, type G9EffectsMode, type G9FontScale, type G9PersonalThemeDraft, type G9SurfaceTone, type G9ThemeRegistry, type G9ThemeRegistryOptions, type G9ThemeRegistrySnapshot, type G9Wallpaper, g9ActiveThemeId, g9AllAppTokenNames, g9AppearanceClasses, g9AppTokenNames, g9AppTokens, g9AppTokenVariables, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9EffectsState, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9SanitizeTokens, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers, } from './appearance-kit.js';
|
|
4
4
|
export { createBrandPalette, createBrandPalettes, type G9BrandColors, type G9BrandPaletteOptions } from './brand.js';
|
|
5
5
|
export { applyAlpha, createBorderColor, createHoverColor, createPressedColor, darken, formatColor, type G9Color, G9ColorFormatError, type G9ColorInput, type G9Rgba, getContrastingTextColor, getContrastRatio, getLuminance, lighten, meetsWcagAA, meetsWcagAAA, mix, parseColor, parseMauiColor, rgba, toHex, toRgba, tryParseColor, withAlpha, withOpacity, } from './color.js';
|
|
6
6
|
export { contrastFailures, contrastReport, type G9ContrastResult, type G9ContrastRule, g9ContrastRules, } from './contrast.js';
|
|
@@ -9,6 +9,7 @@ export { g9Easings, lightnessOf, parseCssColor, resolveColorFunctions, resolveCs
|
|
|
9
9
|
export { createDesignRegistry, type G9DesignRegistry, type G9DesignRegistryOptions, type G9DesignToken, } from './design.js';
|
|
10
10
|
export { chartPalette, colorDistance, ensureContrast, fixedNeutralScale, fromOklch, type G9EnsureContrastOptions, type G9Oklch, type G9ScaleOptions, type G9TonalScale, type G9TonalStep, g9TonalSteps, interpolateStops, isInSrgbGamut, mixOklch, nearestTonalStep, neutralScale, oklchToHex, readableOn, tonalScale, toOklch, } from './oklch.js';
|
|
11
11
|
export { brandRecipe, designedRecipe, type G9ThemeRecipe, getRecipe, listRecipes, recipePalettes, registerRecipe, } from './recipe.js';
|
|
12
|
-
export { createPalette, createThemeStore, G9ColorScheme, type G9CustomPalettes, type G9PaletteOverrides, type G9ResolvedTheme, type G9ThemeListener, G9ThemeMode, type G9ThemeOptions, type G9ThemeSchedule, type G9ThemeStore, g9DefaultThemeSchedule, isScheduledDark, resolveColorScheme, resolveTheme, stockPalette, } from './theme.js';
|
|
12
|
+
export { createPalette, createThemeStore, G9ColorScheme, type G9CustomPalettes, type G9PaletteOverrides, type G9ResolvedTheme, type G9SchemeAppTokens, type G9ThemeListener, G9ThemeMode, type G9ThemeOptions, type G9ThemeSchedule, type G9ThemeStore, g9DefaultThemeSchedule, isScheduledDark, resolveColorScheme, resolveTheme, stockPalette, } from './theme.js';
|
|
13
|
+
export { type G9BackgroundStyle, type G9CssWallpaper, type G9EffectsReason, type G9ThemeTokenName, type G9ThemeTokens, type G9TokenPersonalDraft, type G9TokenTheme, type G9TokenThemeOptions, g9AccentTokens, g9BackgroundStyle, g9BuildTokenPersonalTheme, g9IsTokenTheme, g9ResolveThemeTokens, g9SubstituteTokens, g9ThemeBaseTokens, g9ThemeFromTokens, g9ThemeTokenGroups, g9ThemeTokenNames, g9TokenForPalette, g9TokenValueValid, resolveColorMix, } from './token-themes.js';
|
|
13
14
|
export { type G9ButtonVisualResult, type G9VariantColors, type G9VariantVars, hasSwatch, resolveButtonVariant, resolveButtonVariantVars, resolveProgressColor, resolveProgressColorVar, } from './variants.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.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,KAAK,aAAa,EAClB,SAAS,EACT,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAClG,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAClH,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,KAAK,OAAO,EACZ,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,MAAM,E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AiB,EACtB,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,SAAS,EACT,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
|
package/dist/theme/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { aliasCssVariables, aliasPalette, g9AliasPresets } from "./aliases.js";
|
|
2
2
|
export { applyThemeDefinition, exportTheme, g9AccentPresets, g9BuiltInThemes, importTheme, overriddenTokens, previewThemeDefinition, themeName } from "./appearance.js";
|
|
3
|
-
export { createG9ThemeRegistry, g9ActiveThemeId, g9AppTokenNames, g9AppTokenVariables, g9AppTokens, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9SanitizeTokens, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers } from "./appearance-kit.js";
|
|
3
|
+
export { createG9ThemeRegistry, g9ActiveThemeId, g9AllAppTokenNames, g9AppTokenNames, g9AppTokenVariables, g9AppTokens, g9AppearanceClasses, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9EffectsState, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9SanitizeTokens, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers } from "./appearance-kit.js";
|
|
4
4
|
export { createBrandPalette, createBrandPalettes } from "./brand.js";
|
|
5
5
|
export { G9ColorFormatError, applyAlpha, createBorderColor, createHoverColor, createPressedColor, darken, formatColor, getContrastRatio, getContrastingTextColor, getLuminance, lighten, meetsWcagAA, meetsWcagAAA, mix, parseColor, parseMauiColor, rgba, toHex, toRgba, tryParseColor, withAlpha, withOpacity } from "./color.js";
|
|
6
6
|
export { contrastFailures, contrastReport, g9ContrastRules } from "./contrast.js";
|
|
@@ -10,4 +10,5 @@ export { createDesignRegistry } from "./design.js";
|
|
|
10
10
|
export { chartPalette, colorDistance, ensureContrast, fixedNeutralScale, fromOklch, g9TonalSteps, interpolateStops, isInSrgbGamut, mixOklch, nearestTonalStep, neutralScale, oklchToHex, readableOn, toOklch, tonalScale } from "./oklch.js";
|
|
11
11
|
export { brandRecipe, designedRecipe, getRecipe, listRecipes, recipePalettes, registerRecipe } from "./recipe.js";
|
|
12
12
|
export { G9ColorScheme, G9ThemeMode, createPalette, createThemeStore, g9DefaultThemeSchedule, isScheduledDark, resolveColorScheme, resolveTheme, stockPalette } from "./theme.js";
|
|
13
|
+
export { g9AccentTokens, g9BackgroundStyle, g9BuildTokenPersonalTheme, g9IsTokenTheme, g9ResolveThemeTokens, g9SubstituteTokens, g9ThemeBaseTokens, g9ThemeFromTokens, g9ThemeTokenGroups, g9ThemeTokenNames, g9TokenForPalette, g9TokenValueValid, resolveColorMix } from "./token-themes.js";
|
|
13
14
|
export { hasSwatch, resolveButtonVariant, resolveButtonVariantVars, resolveProgressColor, resolveProgressColorVar } from "./variants.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Only well-formed tokens of `allowed` names (a leading `--g9-` is dropped first; without `allowed`, any lower-case
|
|
3
|
+
* token name), from a theme that came from outside (the server, a file): values that cannot break out of a
|
|
4
|
+
* declaration, and pictures only as inline `data:` images.
|
|
5
|
+
*/
|
|
6
|
+
export declare function g9SanitizeTokens(input: Readonly<Record<string, unknown>> | null | undefined, allowed?: readonly string[]): Record<string, string>;
|
|
7
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/theme/sanitize.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3D,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBxB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const MAX_VALUE = 2000;
|
|
2
|
+
function g9SanitizeTokens(input, allowed) {
|
|
3
|
+
const known = allowed ? new Set(allowed) : null;
|
|
4
|
+
const result = {};
|
|
5
|
+
if (!input) return result;
|
|
6
|
+
for (const [rawName, rawValue] of Object.entries(input)){
|
|
7
|
+
var _value_match;
|
|
8
|
+
const name = rawName.replace(/^--g9-/, '');
|
|
9
|
+
if ((known ? !known.has(name) : !/^[a-z][a-z0-9-]*$/.test(name)) || 'string' != typeof rawValue) continue;
|
|
10
|
+
const value = rawValue.trim();
|
|
11
|
+
if (!value || value.length > MAX_VALUE) continue;
|
|
12
|
+
if (/[;{}<>]|\/\*|\\/.test(value.replace(/url\("data:image\/svg\+xml,[^"]*"\)/g, ''))) continue;
|
|
13
|
+
const urls = null != (_value_match = value.match(/url\(([^)]*)\)/g)) ? _value_match : [];
|
|
14
|
+
if (!urls.some((url)=>!/^url\(["']?data:image\//.test(url))) {
|
|
15
|
+
if (!/expression\s*\(|javascript:/i.test(value)) result[name] = value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
export { g9SanitizeTokens };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=sanitize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme/sanitize.js","sources":["../../src/theme/sanitize.ts"],"sourcesContent":["// The token sanitizer (2.5.8, moved here in 2.5.10 so the token themes and the appearance kit share it).\n\nconst MAX_VALUE = 2000;\n\n/**\n * Only well-formed tokens of `allowed` names (a leading `--g9-` is dropped first; without `allowed`, any lower-case\n * token name), from a theme that came from outside (the server, a file): values that cannot break out of a\n * declaration, and pictures only as inline `data:` images.\n */\nexport function g9SanitizeTokens(\n input: Readonly<Record<string, unknown>> | null | undefined,\n allowed?: readonly string[],\n): Record<string, string> {\n const known = allowed ? new Set(allowed) : null;\n const result: Record<string, string> = {};\n if (!input) return result;\n for (const [rawName, rawValue] of Object.entries(input)) {\n const name = rawName.replace(/^--g9-/, '');\n if ((known ? !known.has(name) : !/^[a-z][a-z0-9-]*$/.test(name)) || typeof rawValue !== 'string') continue;\n const value = rawValue.trim();\n if (!value || value.length > MAX_VALUE) continue;\n if (/[;{}<>]|\\/\\*|\\\\/.test(value.replace(/url\\(\"data:image\\/svg\\+xml,[^\"]*\"\\)/g, ''))) continue;\n const urls = value.match(/url\\(([^)]*)\\)/g) ?? [];\n if (urls.some((url) => !/^url\\([\"']?data:image\\//.test(url))) continue;\n if (/expression\\s*\\(|javascript:/i.test(value)) continue;\n result[name] = value;\n }\n return result;\n}\n"],"names":["MAX_VALUE","g9SanitizeTokens","input","allowed","known","Set","result","rawName","rawValue","Object","_value_match","name","value","urls","url"],"mappings":"AAEA,MAAMA,YAAY;AAOX,SAASC,iBACdC,KAA2D,EAC3DC,OAA2B;IAE3B,MAAMC,QAAQD,UAAU,IAAIE,IAAIF,WAAW;IAC3C,MAAMG,SAAiC,CAAC;IACxC,IAAI,CAACJ,OAAO,OAAOI;IACnB,KAAK,MAAM,CAACC,SAASC,SAAS,IAAIC,OAAO,OAAO,CAACP,OAAQ;YAM1CQ;QALb,MAAMC,OAAOJ,QAAQ,OAAO,CAAC,UAAU;QACvC,IAAKH,AAAAA,CAAAA,QAAQ,CAACA,MAAM,GAAG,CAACO,QAAQ,CAAC,oBAAoB,IAAI,CAACA,KAAI,KAAM,AAAoB,YAApB,OAAOH,UAAuB;QAClG,MAAMI,QAAQJ,SAAS,IAAI;QAC3B,IAAI,CAACI,SAASA,MAAM,MAAM,GAAGZ,WAAW;QACxC,IAAI,kBAAkB,IAAI,CAACY,MAAM,OAAO,CAAC,wCAAwC,MAAM;QACvF,MAAMC,OAAO,QAAAH,CAAAA,eAAAA,MAAM,KAAK,CAAC,kBAAiB,IAA7BA,eAAkC,EAAE;QACjD,KAAIG,KAAK,IAAI,CAAC,CAACC,MAAQ,CAAC,0BAA0B,IAAI,CAACA,OACvD;YAAA,KAAI,+BAA+B,IAAI,CAACF,QACxCN,MAAM,CAACK,KAAK,GAAGC;QADyC;IAE1D;IACA,OAAON;AACT"}
|
package/dist/theme/theme.d.ts
CHANGED
|
@@ -56,6 +56,16 @@ export interface G9ResolvedTheme {
|
|
|
56
56
|
readonly systemScheme: G9ColorScheme;
|
|
57
57
|
readonly scheme: G9ColorScheme;
|
|
58
58
|
readonly palette: G9PaletteValues;
|
|
59
|
+
/**
|
|
60
|
+
* The theme's app tokens for this scheme (2.5.10: a token theme's `--g9-<name>` values — bubbles, glass, wallpaper,
|
|
61
|
+
* depth, radii, motion), written by G9Provider beside the palette. Absent when the theme sets none.
|
|
62
|
+
*/
|
|
63
|
+
readonly appTokens?: Readonly<Record<string, string>>;
|
|
64
|
+
}
|
|
65
|
+
/** App tokens per scheme (2.5.10; {@link G9ResolvedTheme.appTokens}). */
|
|
66
|
+
export interface G9SchemeAppTokens {
|
|
67
|
+
readonly light?: Readonly<Record<string, string>>;
|
|
68
|
+
readonly dark?: Readonly<Record<string, string>>;
|
|
59
69
|
}
|
|
60
70
|
/**
|
|
61
71
|
* `'light'`/`'dark'` pick that scheme; `'system'` follows `systemScheme` (MAUI `G9Theme.ApplyCurrent`);
|
|
@@ -105,6 +115,8 @@ export interface G9ThemeStore {
|
|
|
105
115
|
* designer's change on the running app that never touches the app's own palettes or overrides.
|
|
106
116
|
*/
|
|
107
117
|
setDesignOverrides(overrides: G9PaletteOverrides | undefined): void;
|
|
118
|
+
/** A theme's app tokens per scheme (2.5.10), or none. Optional: stores written before 2.5.10 lack it. */
|
|
119
|
+
setAppTokens?(tokens: G9SchemeAppTokens | undefined): void;
|
|
108
120
|
/** The local hour (0–23), for the `'scheduled'` mode; repaints only when it crosses the schedule. */
|
|
109
121
|
setHour(hour: number): void;
|
|
110
122
|
/** The dark span of the `'scheduled'` mode. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EAIrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,SAAS,CAAC;AAEnD,oGAAoG;AACpG,eAAO,MAAM,WAAW;;;;;CAAsF,CAAC;AAC/G,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wEAAwE;AACxE,eAAO,MAAM,sBAAsB,EAAE,eAA4D,CAAC;AAElG,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,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IAChG,QAAQ,IAAI,IAAI,CAAC;CAClB;AAsCD,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,cAAmB,GAAG,YAAY,CAkH3E"}
|
package/dist/theme/theme.js
CHANGED
|
@@ -109,6 +109,7 @@ function samePalette(a, b) {
|
|
|
109
109
|
return g9ColorTokens.every((token)=>a[token] === b[token]);
|
|
110
110
|
}
|
|
111
111
|
function resolveState(state) {
|
|
112
|
+
var _state_appTokens;
|
|
112
113
|
const { palettes, overrides } = state;
|
|
113
114
|
const next = resolveTheme({
|
|
114
115
|
mode: state.mode,
|
|
@@ -126,10 +127,15 @@ function resolveState(state) {
|
|
|
126
127
|
...next,
|
|
127
128
|
palette: Object.freeze(theme_layer(state.applied, overrides))
|
|
128
129
|
}) : next;
|
|
129
|
-
|
|
130
|
+
const designed = state.design ? Object.freeze({
|
|
130
131
|
...painted,
|
|
131
132
|
palette: Object.freeze(theme_layer(painted.palette, state.design))
|
|
132
133
|
}) : painted;
|
|
134
|
+
const tokens = null == (_state_appTokens = state.appTokens) ? void 0 : _state_appTokens[designed.scheme];
|
|
135
|
+
return tokens ? Object.freeze({
|
|
136
|
+
...designed,
|
|
137
|
+
appTokens: tokens
|
|
138
|
+
}) : designed;
|
|
133
139
|
}
|
|
134
140
|
function createThemeStore(options = {}) {
|
|
135
141
|
var _options_mode, _options_systemScheme, _options_hour, _options_schedule;
|
|
@@ -155,7 +161,7 @@ function createThemeStore(options = {}) {
|
|
|
155
161
|
};
|
|
156
162
|
const next = resolveState(nextState);
|
|
157
163
|
state = nextState;
|
|
158
|
-
const changed = next.mode !== snapshot.mode || next.systemScheme !== snapshot.systemScheme || next.scheme !== snapshot.scheme || !samePalette(next.palette, snapshot.palette);
|
|
164
|
+
const changed = next.mode !== snapshot.mode || next.systemScheme !== snapshot.systemScheme || next.scheme !== snapshot.scheme || next.appTokens !== snapshot.appTokens || !samePalette(next.palette, snapshot.palette);
|
|
159
165
|
if (changed) snapshot = next;
|
|
160
166
|
flush();
|
|
161
167
|
}
|
|
@@ -224,6 +230,11 @@ function createThemeStore(options = {}) {
|
|
|
224
230
|
design
|
|
225
231
|
});
|
|
226
232
|
},
|
|
233
|
+
setAppTokens (appTokens) {
|
|
234
|
+
commit({
|
|
235
|
+
appTokens
|
|
236
|
+
});
|
|
237
|
+
},
|
|
227
238
|
setHour (hour) {
|
|
228
239
|
if (!Number.isInteger(hour) || hour < 0 || hour > 23) throw new G9Error('theme-invalid-hour', `${hour} is not an hour (0–23).`);
|
|
229
240
|
const before = isScheduledDark(state.hour, state.schedule);
|