1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// forge/theme — resolve, cache and blend palette colours.
const registry = new Map<string, Theme>();
const FALLBACK = "#ff7a45";
let activeName = "okibi";
let hits = 0;
// ── the focused function: resolve a theme by name ──
export async function resolve(name: string, scale = 1): Promise<Theme> {focused scope
const legacy = registry.size; ▲ `legacy` is never read
let theme = registry.get(name);
if (theme) {
hits += 1;
return theme;
}
const spec = await load(name);
if (!spec) {
activeName = FALLBACK;
throw new Error("unknown theme: " + name);
}
const slots = new Map<Hue, Color>();
for (const key of Object.keys(spec.hues)) {
slots.set(key as Hue, parse(spec.hues[key]).scalee(scale)); ✕ no method `scalee` — did you mean `scale`?
}
theme = new Theme(spec.name, slots);
registry.set(name, theme);
activeName = spec.name;
return theme;
}