@g9tm/lynxcontrols-foundation 2.5.7 → 2.5.8
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 +235 -3
- package/catalog/index.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/culture/text.d.ts +2 -0
- package/dist/culture/text.d.ts.map +1 -1
- package/dist/culture/text.js +3 -2
- package/dist/culture/text.js.map +1 -1
- package/dist/services/keys.d.ts +7 -0
- package/dist/services/keys.d.ts.map +1 -1
- package/dist/services/keys.js.map +1 -1
- package/dist/theme/appearance-kit.d.ts +148 -0
- package/dist/theme/appearance-kit.d.ts.map +1 -0
- package/dist/theme/appearance-kit.js +410 -0
- package/dist/theme/appearance-kit.js.map +1 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -0
- package/docs/api.md +29 -0
- package/package.json +1 -1
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import { g9DefaultShape } from "../tokens/shape.js";
|
|
2
|
+
import { g9BuiltInThemes, importTheme } from "./appearance.js";
|
|
3
|
+
import { formatColor, toHex, tryParseColor, withAlpha } from "./color.js";
|
|
4
|
+
import { ensureContrast, mixOklch, readableOn } from "./oklch.js";
|
|
5
|
+
const g9AppTokenNames = [
|
|
6
|
+
'hover',
|
|
7
|
+
'press',
|
|
8
|
+
'field',
|
|
9
|
+
'skeleton',
|
|
10
|
+
'accent-soft',
|
|
11
|
+
'accent-glow',
|
|
12
|
+
'accent-gradient',
|
|
13
|
+
'text-on-accent',
|
|
14
|
+
'glass',
|
|
15
|
+
'glass-border',
|
|
16
|
+
'bubble-mine',
|
|
17
|
+
'bubble-mine-text',
|
|
18
|
+
'bubble-mine-meta',
|
|
19
|
+
'bubble-other',
|
|
20
|
+
'bubble-other-text',
|
|
21
|
+
'bubble-other-border',
|
|
22
|
+
'highlight',
|
|
23
|
+
'link',
|
|
24
|
+
'selection',
|
|
25
|
+
'focus-ring',
|
|
26
|
+
'online',
|
|
27
|
+
'away',
|
|
28
|
+
'busy'
|
|
29
|
+
];
|
|
30
|
+
const css = (c)=>formatColor(c);
|
|
31
|
+
function g9AppTokens(theme, options = {}) {
|
|
32
|
+
var _p_InputBackground, _options_overrides;
|
|
33
|
+
const p = theme.palette;
|
|
34
|
+
const dark = 'dark' === theme.scheme;
|
|
35
|
+
const accent = options.accent && tryParseColor(options.accent) ? options.accent : p.Primary;
|
|
36
|
+
const own = accent === p.Primary;
|
|
37
|
+
const onAccent = own ? p.OnPrimary : readableOn(accent);
|
|
38
|
+
const surface = p.Surface;
|
|
39
|
+
const field = null != (_p_InputBackground = p.InputBackground) ? _p_InputBackground : p.SurfaceContainerLow;
|
|
40
|
+
const out = {
|
|
41
|
+
hover: css(withAlpha(p.TextPrimary, dark ? 0.08 : 0.06)),
|
|
42
|
+
press: css(withAlpha(p.TextPrimary, dark ? 0.14 : 0.1)),
|
|
43
|
+
field,
|
|
44
|
+
skeleton: p.SurfaceContainerHigh,
|
|
45
|
+
'accent-soft': css(withAlpha(accent, dark ? 0.16 : 0.11)),
|
|
46
|
+
'accent-glow': css(withAlpha(accent, dark ? 0.48 : 0.34)),
|
|
47
|
+
'accent-gradient': `linear-gradient(135deg, ${mixOklch(accent, '#ffffff', 0.2)} 0%, ${accent} 50%, ${mixOklch(accent, '#000000', 0.2)} 100%)`,
|
|
48
|
+
'text-on-accent': onAccent,
|
|
49
|
+
glass: css(withAlpha(surface, dark ? 0.6 : 0.72)),
|
|
50
|
+
'glass-border': css(withAlpha(p.OutlineVariant, 0.6)),
|
|
51
|
+
'bubble-mine': accent,
|
|
52
|
+
'bubble-mine-text': onAccent,
|
|
53
|
+
'bubble-mine-meta': css(withAlpha(onAccent, 0.76)),
|
|
54
|
+
'bubble-other': p.SurfaceContainer,
|
|
55
|
+
'bubble-other-text': p.TextPrimary,
|
|
56
|
+
'bubble-other-border': p.OutlineVariant,
|
|
57
|
+
highlight: css(withAlpha(accent, dark ? 0.22 : 0.14)),
|
|
58
|
+
link: ensureContrast(accent, surface, 4.5),
|
|
59
|
+
selection: css(withAlpha(accent, dark ? 0.34 : 0.22)),
|
|
60
|
+
'focus-ring': css(withAlpha(accent, dark ? 0.72 : 0.55)),
|
|
61
|
+
online: p.Success,
|
|
62
|
+
away: p.Warning,
|
|
63
|
+
busy: p.Error
|
|
64
|
+
};
|
|
65
|
+
for (const [name, value] of Object.entries(null != (_options_overrides = options.overrides) ? _options_overrides : {}))if (value) out[name] = value;
|
|
66
|
+
return Object.freeze(out);
|
|
67
|
+
}
|
|
68
|
+
function g9AppTokenVariables(theme, options = {}, prefix = 'g9-') {
|
|
69
|
+
const out = {};
|
|
70
|
+
for (const [name, value] of Object.entries(g9AppTokens(theme, options)))out[`--${prefix}${name}`] = value;
|
|
71
|
+
return Object.freeze(out);
|
|
72
|
+
}
|
|
73
|
+
const MAX_VALUE = 2000;
|
|
74
|
+
function g9SanitizeTokens(input, allowed) {
|
|
75
|
+
const known = new Set(allowed);
|
|
76
|
+
const result = {};
|
|
77
|
+
if (!input) return result;
|
|
78
|
+
for (const [rawName, rawValue] of Object.entries(input)){
|
|
79
|
+
var _value_match;
|
|
80
|
+
const name = rawName.replace(/^--g9-/, '');
|
|
81
|
+
if (!known.has(name) || 'string' != typeof rawValue) continue;
|
|
82
|
+
const value = rawValue.trim();
|
|
83
|
+
if (!value || value.length > MAX_VALUE) continue;
|
|
84
|
+
if (/[;{}<>]|\/\*|\\/.test(value.replace(/url\("data:image\/svg\+xml,[^"]*"\)/g, ''))) continue;
|
|
85
|
+
const urls = null != (_value_match = value.match(/url\(([^)]*)\)/g)) ? _value_match : [];
|
|
86
|
+
if (!urls.some((url)=>!/^url\(["']?data:image\//.test(url))) {
|
|
87
|
+
if (!/expression\s*\(|javascript:/i.test(value)) result[name] = value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
const g9DefaultAppearance = Object.freeze({
|
|
93
|
+
theme: 'system',
|
|
94
|
+
light: 'classic',
|
|
95
|
+
dark: 'midnight',
|
|
96
|
+
accent: null,
|
|
97
|
+
wallpaper: 'theme',
|
|
98
|
+
fontScale: 'normal',
|
|
99
|
+
effects: 'auto',
|
|
100
|
+
density: 'regular'
|
|
101
|
+
});
|
|
102
|
+
const SCALES = [
|
|
103
|
+
'small',
|
|
104
|
+
'normal',
|
|
105
|
+
'large',
|
|
106
|
+
'larger'
|
|
107
|
+
];
|
|
108
|
+
const EFFECTS = [
|
|
109
|
+
'auto',
|
|
110
|
+
'on',
|
|
111
|
+
'off'
|
|
112
|
+
];
|
|
113
|
+
const DENSITIES = [
|
|
114
|
+
'compact',
|
|
115
|
+
'regular',
|
|
116
|
+
'comfortable'
|
|
117
|
+
];
|
|
118
|
+
function g9NormalizeAppearance(raw, defaults = g9DefaultAppearance) {
|
|
119
|
+
const r = raw && 'object' == typeof raw ? raw : {};
|
|
120
|
+
const text = (v, d)=>'string' == typeof v && v.trim() ? v : d;
|
|
121
|
+
const pick = (v, list, d)=>list.includes(v) ? v : d;
|
|
122
|
+
const accent = 'string' == typeof r.accent && /^#[0-9a-f]{6}$/i.test(r.accent) ? r.accent.toLowerCase() : null;
|
|
123
|
+
return Object.freeze({
|
|
124
|
+
theme: text(r.theme, defaults.theme),
|
|
125
|
+
light: text(r.light, defaults.light),
|
|
126
|
+
dark: text(r.dark, defaults.dark),
|
|
127
|
+
accent: void 0 === r.accent ? defaults.accent : accent,
|
|
128
|
+
wallpaper: text(r.wallpaper, defaults.wallpaper),
|
|
129
|
+
fontScale: pick(r.fontScale, SCALES, defaults.fontScale),
|
|
130
|
+
effects: pick(r.effects, EFFECTS, defaults.effects),
|
|
131
|
+
density: pick(r.density, DENSITIES, defaults.density)
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const g9FontScaleFactors = Object.freeze({
|
|
135
|
+
small: 0.9,
|
|
136
|
+
normal: 1,
|
|
137
|
+
large: 1.12,
|
|
138
|
+
larger: 1.25
|
|
139
|
+
});
|
|
140
|
+
function g9ScaledType(scale, base = g9DefaultShape.type) {
|
|
141
|
+
const k = 'number' == typeof scale ? scale : g9FontScaleFactors[scale];
|
|
142
|
+
const out = {};
|
|
143
|
+
for (const [role, t] of Object.entries(base))out[role] = {
|
|
144
|
+
...t,
|
|
145
|
+
size: Math.round(t.size * k),
|
|
146
|
+
lineHeight: Math.round(t.lineHeight * k)
|
|
147
|
+
};
|
|
148
|
+
return Object.freeze(out);
|
|
149
|
+
}
|
|
150
|
+
function g9EffectsEnabled(mode, device = {}) {
|
|
151
|
+
if ('auto' !== mode) return 'on' === mode;
|
|
152
|
+
return !device.reducedMotion && !device.lowEnd;
|
|
153
|
+
}
|
|
154
|
+
function g9ActiveThemeId(settings, systemScheme) {
|
|
155
|
+
if ('system' !== settings.theme) return settings.theme;
|
|
156
|
+
return 'dark' === systemScheme ? settings.dark : settings.light;
|
|
157
|
+
}
|
|
158
|
+
function g9ThemeFromInput(input, source) {
|
|
159
|
+
if (!input || 'object' != typeof input) return null;
|
|
160
|
+
const t = input;
|
|
161
|
+
try {
|
|
162
|
+
const def = importTheme(JSON.stringify({
|
|
163
|
+
format: 'g9-theme',
|
|
164
|
+
version: 1,
|
|
165
|
+
theme: t
|
|
166
|
+
}));
|
|
167
|
+
if (!def.name || 'string' == typeof def.name && !def.name.trim()) return null;
|
|
168
|
+
return Object.freeze({
|
|
169
|
+
...def,
|
|
170
|
+
id: 'org' !== source || def.id.startsWith('org:') ? def.id : `org:${def.id}`,
|
|
171
|
+
source
|
|
172
|
+
});
|
|
173
|
+
} catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function createG9ThemeRegistry(options = {}) {
|
|
178
|
+
var _options_builtins, _options_maxPersonal, _options_personal;
|
|
179
|
+
const builtins = null != (_options_builtins = options.builtins) ? _options_builtins : g9BuiltInThemes;
|
|
180
|
+
const max = Math.max(1, null != (_options_maxPersonal = options.maxPersonal) ? _options_maxPersonal : 12);
|
|
181
|
+
let org = [];
|
|
182
|
+
let personal = (null != (_options_personal = options.personal) ? _options_personal : []).map((t)=>g9ThemeFromInput(t, 'personal')).filter((t)=>null !== t).slice(0, max);
|
|
183
|
+
const listeners = new Set();
|
|
184
|
+
let snapshot = {
|
|
185
|
+
themes: [
|
|
186
|
+
...builtins,
|
|
187
|
+
...personal
|
|
188
|
+
],
|
|
189
|
+
revision: 0
|
|
190
|
+
};
|
|
191
|
+
const rebuild = ()=>{
|
|
192
|
+
snapshot = {
|
|
193
|
+
themes: [
|
|
194
|
+
...builtins,
|
|
195
|
+
...org,
|
|
196
|
+
...personal
|
|
197
|
+
],
|
|
198
|
+
revision: snapshot.revision + 1
|
|
199
|
+
};
|
|
200
|
+
for (const l of [
|
|
201
|
+
...listeners
|
|
202
|
+
])l();
|
|
203
|
+
};
|
|
204
|
+
const find = (id)=>{
|
|
205
|
+
var _snapshot_themes_find;
|
|
206
|
+
return null != (_snapshot_themes_find = snapshot.themes.find((t)=>t.id === id)) ? _snapshot_themes_find : null;
|
|
207
|
+
};
|
|
208
|
+
return {
|
|
209
|
+
get: ()=>snapshot,
|
|
210
|
+
subscribe (listener) {
|
|
211
|
+
listeners.add(listener);
|
|
212
|
+
return ()=>listeners.delete(listener);
|
|
213
|
+
},
|
|
214
|
+
find,
|
|
215
|
+
themeOrDefault: (id)=>{
|
|
216
|
+
var _find;
|
|
217
|
+
return null != (_find = find(id)) ? _find : builtins[0];
|
|
218
|
+
},
|
|
219
|
+
setOrgThemes (inputs) {
|
|
220
|
+
org = inputs.map((i)=>g9ThemeFromInput(i, 'org')).filter((t)=>null !== t);
|
|
221
|
+
rebuild();
|
|
222
|
+
},
|
|
223
|
+
savePersonal (theme) {
|
|
224
|
+
var _options_savePersonal;
|
|
225
|
+
const own = Object.freeze({
|
|
226
|
+
...theme,
|
|
227
|
+
source: 'personal'
|
|
228
|
+
});
|
|
229
|
+
personal = [
|
|
230
|
+
own,
|
|
231
|
+
...personal.filter((t)=>t.id !== theme.id)
|
|
232
|
+
].slice(0, max);
|
|
233
|
+
null == (_options_savePersonal = options.savePersonal) || _options_savePersonal.call(options, personal);
|
|
234
|
+
rebuild();
|
|
235
|
+
},
|
|
236
|
+
removePersonal (id) {
|
|
237
|
+
var _options_savePersonal;
|
|
238
|
+
if (!personal.some((t)=>t.id === id)) return;
|
|
239
|
+
personal = personal.filter((t)=>t.id !== id);
|
|
240
|
+
null == (_options_savePersonal = options.savePersonal) || _options_savePersonal.call(options, personal);
|
|
241
|
+
rebuild();
|
|
242
|
+
},
|
|
243
|
+
personal: ()=>personal
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function g9NewPersonalThemeId(random = Math.random) {
|
|
247
|
+
let id = '';
|
|
248
|
+
for(let i = 0; i < 12; i++)id += Math.floor(36 * random()).toString(36);
|
|
249
|
+
return `me:${id}`;
|
|
250
|
+
}
|
|
251
|
+
function g9PersonalDraft(base, name, id = g9NewPersonalThemeId()) {
|
|
252
|
+
var _base_wallpaper;
|
|
253
|
+
return {
|
|
254
|
+
id,
|
|
255
|
+
name,
|
|
256
|
+
base,
|
|
257
|
+
accent: toHex(base.brand.primary),
|
|
258
|
+
surfaces: 'neutral',
|
|
259
|
+
wallpaper: null != (_base_wallpaper = base.wallpaper) ? _base_wallpaper : 'theme'
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const TINTS = {
|
|
263
|
+
cool: '#3b82f6',
|
|
264
|
+
warm: '#f59e0b'
|
|
265
|
+
};
|
|
266
|
+
const SURFACES = [
|
|
267
|
+
[
|
|
268
|
+
'Background',
|
|
269
|
+
0.07,
|
|
270
|
+
0.04
|
|
271
|
+
],
|
|
272
|
+
[
|
|
273
|
+
'BackgroundSecondary',
|
|
274
|
+
0.08,
|
|
275
|
+
0.05
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
'Surface',
|
|
279
|
+
0.09,
|
|
280
|
+
0.05
|
|
281
|
+
],
|
|
282
|
+
[
|
|
283
|
+
'SurfaceContainerLow',
|
|
284
|
+
0.09,
|
|
285
|
+
0.05
|
|
286
|
+
],
|
|
287
|
+
[
|
|
288
|
+
'SurfaceContainer',
|
|
289
|
+
0.1,
|
|
290
|
+
0.06
|
|
291
|
+
],
|
|
292
|
+
[
|
|
293
|
+
'SurfaceContainerHigh',
|
|
294
|
+
0.12,
|
|
295
|
+
0.08
|
|
296
|
+
]
|
|
297
|
+
];
|
|
298
|
+
function g9BuildPersonalTheme(draft, palettes) {
|
|
299
|
+
var _draft_scheme;
|
|
300
|
+
const accent = tryParseColor(draft.accent) ? draft.accent : draft.base.brand.primary;
|
|
301
|
+
const scheme = null != (_draft_scheme = draft.scheme) ? _draft_scheme : 'dark' === draft.base.mode ? 'dark' : 'light';
|
|
302
|
+
let overrides;
|
|
303
|
+
if ('neutral' !== draft.surfaces) {
|
|
304
|
+
const tint = 'tinted' === draft.surfaces ? accent : TINTS[draft.surfaces];
|
|
305
|
+
const of = (s)=>{
|
|
306
|
+
const o = {};
|
|
307
|
+
for (const [token, d, l] of SURFACES)o[token] = mixOklch(palettes[s][token], tint, 'dark' === s ? d : l);
|
|
308
|
+
return o;
|
|
309
|
+
};
|
|
310
|
+
overrides = {
|
|
311
|
+
light: of('light'),
|
|
312
|
+
dark: of('dark')
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const name = draft.name.trim().slice(0, 60);
|
|
316
|
+
return Object.freeze({
|
|
317
|
+
id: draft.id,
|
|
318
|
+
name: name || draft.base.name,
|
|
319
|
+
source: 'personal',
|
|
320
|
+
recipe: draft.base.recipe,
|
|
321
|
+
brand: {
|
|
322
|
+
...draft.base.brand,
|
|
323
|
+
primary: accent
|
|
324
|
+
},
|
|
325
|
+
...overrides ? {
|
|
326
|
+
overrides
|
|
327
|
+
} : {},
|
|
328
|
+
...draft.base.shape ? {
|
|
329
|
+
shape: draft.base.shape
|
|
330
|
+
} : {},
|
|
331
|
+
mode: scheme,
|
|
332
|
+
...'theme' !== draft.wallpaper ? {
|
|
333
|
+
wallpaper: draft.wallpaper
|
|
334
|
+
} : {}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function g9ThemeFileName(name) {
|
|
338
|
+
const slug = name.trim().toLowerCase().replace(/[\s!-/:-@[-`{-~،؛؟«»]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40);
|
|
339
|
+
return `${slug || 'theme'}.g9theme.json`;
|
|
340
|
+
}
|
|
341
|
+
const glow = (c, a)=>css(withAlpha(c, a));
|
|
342
|
+
const g9Wallpapers = Object.freeze([
|
|
343
|
+
{
|
|
344
|
+
id: 'none',
|
|
345
|
+
name: {
|
|
346
|
+
en: 'None',
|
|
347
|
+
fa: 'هیچ'
|
|
348
|
+
},
|
|
349
|
+
paint: (p)=>({
|
|
350
|
+
color: p.Background
|
|
351
|
+
})
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: 'aurora',
|
|
355
|
+
name: {
|
|
356
|
+
en: 'Aurora',
|
|
357
|
+
fa: 'شفق'
|
|
358
|
+
},
|
|
359
|
+
paint: (p, s)=>({
|
|
360
|
+
color: p.Background,
|
|
361
|
+
image: `radial-gradient(circle at 0% 0%, ${glow(p.Primary, 'dark' === s ? 0.18 : 0.12)} 0%, transparent 60%), radial-gradient(circle at 100% 100%, ${glow(p.Tertiary, 'dark' === s ? 0.16 : 0.1)} 0%, transparent 60%)`
|
|
362
|
+
})
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
id: 'dusk',
|
|
366
|
+
name: {
|
|
367
|
+
en: 'Dusk',
|
|
368
|
+
fa: 'غروب'
|
|
369
|
+
},
|
|
370
|
+
paint: (p, s)=>({
|
|
371
|
+
color: p.Background,
|
|
372
|
+
image: `linear-gradient(180deg, ${glow(p.Primary, 'dark' === s ? 0.12 : 0.08)} 0%, transparent 45%, ${glow(p.Secondary, 'dark' === s ? 0.1 : 0.06)} 100%)`
|
|
373
|
+
})
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
id: 'mesh',
|
|
377
|
+
name: {
|
|
378
|
+
en: 'Mesh',
|
|
379
|
+
fa: 'توری'
|
|
380
|
+
},
|
|
381
|
+
paint: (p, s)=>{
|
|
382
|
+
const k = 'dark' === s ? 1 : 0.75;
|
|
383
|
+
return {
|
|
384
|
+
color: p.Background,
|
|
385
|
+
image: [
|
|
386
|
+
`radial-gradient(circle at 15% 20%, ${glow(p.Primary, 0.14 * k)} 0%, transparent 55%)`,
|
|
387
|
+
`radial-gradient(circle at 85% 30%, ${glow(p.Tertiary, 0.14 * k)} 0%, transparent 55%)`,
|
|
388
|
+
`radial-gradient(circle at 50% 95%, ${glow(p.Secondary, 0.14 * k)} 0%, transparent 55%)`
|
|
389
|
+
].join(', ')
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
id: 'paper',
|
|
395
|
+
name: {
|
|
396
|
+
en: 'Paper',
|
|
397
|
+
fa: 'کاغذی'
|
|
398
|
+
},
|
|
399
|
+
paint: (p, s)=>({
|
|
400
|
+
color: mixOklch(p.Background, 'dark' === s ? '#000000' : '#f5ecd7', 0.25)
|
|
401
|
+
})
|
|
402
|
+
}
|
|
403
|
+
]);
|
|
404
|
+
function g9Wallpaper(id, list = g9Wallpapers) {
|
|
405
|
+
var _list_find;
|
|
406
|
+
return null != (_list_find = list.find((w)=>w.id === id)) ? _list_find : null;
|
|
407
|
+
}
|
|
408
|
+
export { createG9ThemeRegistry, g9ActiveThemeId, g9AppTokenNames, g9AppTokenVariables, g9AppTokens, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9SanitizeTokens, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers };
|
|
409
|
+
|
|
410
|
+
//# sourceMappingURL=appearance-kit.js.map
|
|
@@ -0,0 +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,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C/B,OAAO,CAACnG,GAAGmG,IAAO;gBAChB,OAAOnG,EAAE,UAAU;gBACnB,OAAO,CAAC,wBAAwB,EAAEwG,KAAKxG,EAAE,OAAO,EAAEmG,AAAM,WAANA,IAAe,OAAO,MAAM,sBAAsB,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"}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,5 +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
4
|
export { createBrandPalette, createBrandPalettes, type G9BrandColors, type G9BrandPaletteOptions } from './brand.js';
|
|
4
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';
|
|
5
6
|
export { contrastFailures, contrastReport, type G9ContrastResult, type G9ContrastRule, g9ContrastRules, } from './contrast.js';
|
|
@@ -1 +1 @@
|
|
|
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,EAC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V,UAAU,EACV,UAAU,EACV,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,aAAa,EAClB,SAAS,EACT,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,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,oBAAoB,EACzB,KAAK,eAAe,EACpB,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,eAAe,EACf,WAAW,EACX,mBAAm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AuB,EAC5B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,aAAa,EAClB,SAAS,EACT,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,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,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,5 +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
4
|
export { createBrandPalette, createBrandPalettes } from "./brand.js";
|
|
4
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";
|
|
5
6
|
export { contrastFailures, contrastReport, g9ContrastRules } from "./contrast.js";
|
package/docs/api.md
CHANGED
|
@@ -95,6 +95,7 @@ folder) explain how the pieces fit; the migration tables map every MAUI member.
|
|
|
95
95
|
| `createBrandPalette` | function | The full palette for `scheme`. Pure and deterministic: the same brand gives the same palette everywhere (app, web, server-side previews), so it can be computed at build time or on the device. |
|
|
96
96
|
| `createBrandPalettes` | function | Both schemes at once (what a theme store's `palettes` option takes). |
|
|
97
97
|
| `createDesignRegistry` | function | Creates the registry. Colour ids are `color.<Token>` (`color.Primary`); shape ids are `shape.radius.card`, `shape.height.md`, `shape.type.body.size`, `shape.touchTarget`. A change is an override layered over the app's own overrides, so a reset returns exactly to what the app painted. |
|
|
98
|
+
| `createG9ThemeRegistry` | function | Creates a theme registry. |
|
|
98
99
|
| `createHoverColor` | function | 8 % darker: the stock hover recipe. MAUI `G9ColorHelper.CreateHoverColor`. |
|
|
99
100
|
| `createPalette` | function | Validates a complete palette (every token, every value a readable colour) and returns a frozen copy in token order. |
|
|
100
101
|
| `createPressedColor` | function | 20 % darker: the stock pressed recipe. MAUI `G9ColorHelper.CreatePressedColor`. |
|
|
@@ -107,6 +108,19 @@ folder) explain how the pieces fit; the migration tables map every MAUI member.
|
|
|
107
108
|
| `fixedNeutralScale` | function | Neutrals of a fixed hue and chroma, whatever the brand (warm paper, cool steel), on the sine curve's lightness steps (ShopManager's `fixedNeutralScale`). |
|
|
108
109
|
| `formatColor` | function | Formats a colour as CSS: `#RRGGBB` when opaque, otherwise `rgba(R, G, B, A)`. Channels are rounded to the nearest byte; the alpha is printed with the fewest digits that parse back to the same float32 value, so `parseColor(formatColor(c))` reproduces the alpha exactly. |
|
|
109
110
|
| `fromOklch` | function | OKLCH → sRGB (`G9Rgba`, channels 0..1). Out-of-gamut colours keep L and H and lose chroma until they fit (binary search, 18 steps ≈ 1e-6 chroma), so a vivid brand never shifts hue when it is darkened or lightened. |
|
|
111
|
+
| `g9ActiveThemeId` | function | The theme id in force: the chosen one, or the light / dark one for the device's scheme when following it. |
|
|
112
|
+
| `g9AppTokens` | function | The app tokens for a palette and scheme: plain colours (and one gradient), never variables. |
|
|
113
|
+
| `g9AppTokenVariables` | function | The app tokens as CSS variables (`--g9-hover`…; `prefix` default `g9-`), for G9Provider's `themeExtras`. |
|
|
114
|
+
| `g9BuildPersonalTheme` | function | The theme a draft describes: the base's recipe with the draft's accent, its surfaces tinted (cool, warm, or by the accent) through overrides measured on `palettes` (the base's palettes for the accent: `recipePalettes(...)`). |
|
|
115
|
+
| `g9EffectsEnabled` | function | Whether effects (blur, glow, motion flourishes) are on. |
|
|
116
|
+
| `g9NewPersonalThemeId` | function | A fresh personal id (`me:…`). |
|
|
117
|
+
| `g9NormalizeAppearance` | function | Stored settings read back loosely: every unknown or broken field takes its default. |
|
|
118
|
+
| `g9PersonalDraft` | function | A draft starting from `base`. |
|
|
119
|
+
| `g9SanitizeTokens` | function | Only well-formed tokens of `allowed` names (a leading `--g9-` is dropped first), from a theme that came from outside (the server, a file): values that cannot break out of a declaration, and pictures only as inline `data:` images. |
|
|
120
|
+
| `g9ScaledType` | function | The type scale at a text size (sizes and line heights rounded), for G9Provider's `shape.type`. |
|
|
121
|
+
| `g9ThemeFileName` | function | A file name for a theme export (letters, digits, dashes; any script). |
|
|
122
|
+
| `g9ThemeFromInput` | function | A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. |
|
|
123
|
+
| `g9Wallpaper` | function | A wallpaper by id (from `list`, default `g9Wallpapers`), or null. |
|
|
110
124
|
| `getContrastingTextColor` | function | Black on light backgrounds (luminance above 0.5), white otherwise. MAUI `GetContrastingTextColor`. |
|
|
111
125
|
| `getContrastRatio` | function | WCAG contrast ratio, `1` to `21`. |
|
|
112
126
|
| `getLuminance` | function | WCAG relative luminance, `0` (black) to `1` (white). Alpha is ignored, as in MAUI. |
|
|
@@ -161,13 +175,19 @@ folder) explain how the pieces fit; the migration tables map every MAUI member.
|
|
|
161
175
|
| `G9ThemeMode` | enum | Which theme the user chose (MAUI `AppTheme`: `Unspecified` is `system`, follow the platform). |
|
|
162
176
|
| `g9AccentPresets` | constant | Accent colours offered by "pick a colour" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. |
|
|
163
177
|
| `g9AliasPresets` | constant | Ready-made alias maps for the four G9 apps' existing names (the migration guides start from these). |
|
|
178
|
+
| `g9AppTokenNames` | constant | The tokens an app (a messenger) adds to the library palette. |
|
|
164
179
|
| `g9BuiltInThemes` | constant | The built-in themes over the built-in recipes, one per accent preset family. |
|
|
165
180
|
| `G9Colors` | constant | Alpha recipes the G9 controls paint with (MAUI `G9Colors` constants). |
|
|
166
181
|
| `g9ContrastRules` | constant | The rules every palette must pass. |
|
|
182
|
+
| `g9DefaultAppearance` | constant | The settings of a new install. |
|
|
167
183
|
| `g9DefaultThemeSchedule` | constant | The default dark span of the scheduled mode: from 18:00 to 07:00. |
|
|
168
184
|
| `g9Easings` | constant | Named easings as cubic-bezier (Lynx reads cubic-bezier, linear, ease, ease-in, ease-out, ease-in-out). |
|
|
185
|
+
| `g9FontScaleFactors` | constant | Text size factors. |
|
|
169
186
|
| `g9TonalSteps` | constant | Steps of a tonal scale (Tailwind-like names: 50 lightest … 950 darkest). |
|
|
187
|
+
| `g9Wallpapers` | constant | Wallpapers drawn with gradients only (no pictures, no network). |
|
|
170
188
|
| `G9ColorFormatError` | class | Thrown when a string is not a colour this library can read. |
|
|
189
|
+
| `G9AppearanceSettings` | interface | What a person chose on Settings → Appearance (kept per device by the app). |
|
|
190
|
+
| `G9AppTokenOptions` | interface | Options of `g9AppTokens`. |
|
|
171
191
|
| `G9BrandColors` | interface | The colours a brand gives. Only `primary` is required; the rest are derived when missing. |
|
|
172
192
|
| `G9BrandPaletteOptions` | interface | How `createBrandPalette` builds a palette from a brand colour: grey tint, contrast target and whether the brand colour is kept as is. |
|
|
173
193
|
| `G9ContrastResult` | interface | One rule's outcome. |
|
|
@@ -178,22 +198,31 @@ folder) explain how the pieces fit; the migration tables map every MAUI member.
|
|
|
178
198
|
| `G9EnsureContrastOptions` | interface | Options of `ensureContrast`. |
|
|
179
199
|
| `G9GradientStop` | interface | A gradient stop: colour at `offset` (`0..1`). |
|
|
180
200
|
| `G9Oklch` | interface | A colour in OKLCH. `alpha` 0..1 (default 1). |
|
|
201
|
+
| `G9PersonalThemeDraft` | interface | What the personal theme editor edits. |
|
|
181
202
|
| `G9ResolvedTheme` | interface | A resolved theme: what is painted and why. Frozen. |
|
|
182
203
|
| `G9Rgba` | interface | A colour as four channels in `0..1`, stored at float32 precision exactly like MAUI `Color`. Colour arithmetic (darken, mix, contrast) runs on this shape so its results match the original helpers bit for bit; format with `formatColor` to get a CSS string back. |
|
|
183
204
|
| `G9ScaleOptions` | interface | Options of `tonalScale` and `neutralScale`. |
|
|
184
205
|
| `G9ThemeDefinition` | interface | One selectable theme. |
|
|
185
206
|
| `G9ThemeOptions` | interface | Inputs of theme resolution. |
|
|
186
207
|
| `G9ThemeRecipe` | interface | A named recipe. |
|
|
208
|
+
| `G9ThemeRegistry` | interface | Every theme: built in, the organisation's, the person's own (a store an appearance page reads). |
|
|
209
|
+
| `G9ThemeRegistryOptions` | interface | Options of `createG9ThemeRegistry`. |
|
|
210
|
+
| `G9ThemeRegistrySnapshot` | interface | The themes a person can pick, by source. |
|
|
187
211
|
| `G9ThemeSchedule` | interface | When `'scheduled'` paints dark: from `darkFrom` (hour, 0–23) to `darkTo` (exclusive), across midnight when `darkFrom > darkTo`. Default 18 → 7 (Riskara's evening theme). |
|
|
188
212
|
| `G9ThemeStore` | interface | The live theme (MAUI `G9Palette.Current` + `G9Theme`): one snapshot, replaced on every change, and listeners told once per change. Works with `useSyncExternalStore` (`subscribe` / `getSnapshot`). |
|
|
189
213
|
| `G9VariantColors` | interface | The colours a variant resolves to: fill, foreground, stroke, and whether the fill is a gradient (MAUI `G9VariantColors`). Colours are CSS strings. |
|
|
190
214
|
| `G9VariantVars` | interface | A variant painted with CSS variables: the same colours as `resolveButtonVariant`, following the theme with no script (the provider writes the variables). `gradient` names the token whose gradient a solid fill uses. |
|
|
215
|
+
| `G9Wallpaper` | interface | A chat wallpaper: layers drawn behind a thread, from the palette so it follows the theme and accent. |
|
|
216
|
+
| `G9AppTokenName` | type | The name of an app token (`hover`, `bubble-mine`…). |
|
|
191
217
|
| `G9ButtonVisualResult` | type | The colours a button finally paints, after its `baseBackgroundColor` / `textColor` escape hatches are applied over the variant (MAUI `G9Visuals.ButtonVisualResult`). Same shape as `G9VariantColors`, so a button treats both paths identically; the button itself (WP04) applies the escape hatches. |
|
|
192
218
|
| `G9Color` | type | A CSS colour string, the value type every G9 colour prop takes (plan/specs/03-API-Conventions.md §2). Use `g9Token` for a theme token reference such as `var(--g9-primary)`. |
|
|
193
219
|
| `G9ColorInput` | type | Anything the colour helpers accept: a CSS colour string or channels. |
|
|
194
220
|
| `G9ContrastRule` | type | `[foreground, background, minimum]`. 4.5 = body text (WCAG AA), 3 = large text, icons and borders that carry meaning. |
|
|
221
|
+
| `G9EffectsMode` | type | Whether effects are on, off, or decided by the device. |
|
|
195
222
|
| `G9Fill` | type | A fill: a solid colour, or a top-to-bottom linear gradient. |
|
|
223
|
+
| `G9FontScale` | type | A text size step. |
|
|
196
224
|
| `G9PaletteOverrides` | type | Some tokens replaced by CSS colours. |
|
|
225
|
+
| `G9SurfaceTone` | type | How a personal theme's surfaces are tinted. |
|
|
197
226
|
| `G9ThemeListener` | type | Listener of `G9ThemeStore`; receives the snapshot taken at notify time. |
|
|
198
227
|
| `G9ThemeSource` | type | Where a theme definition comes from: built in, the organisation's, or the person's own. |
|
|
199
228
|
| `G9TokenAliasMap` | type | App name → library token (`'TextPrimary'`) or a literal colour (`'#1B1512'`). |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/lynxcontrols-foundation",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "Pure TypeScript core: design tokens, theme model, culture (strings, digits, calendars, relative time, durations), icon model, safe execution, diagnostics, preference and capability contracts. No React, no UI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|