@adea-ai/themes 0.6.0 → 0.6.1
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/README.md +5 -0
- package/dist/derive.d.ts +9 -0
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +55 -0
- package/dist/derive.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/derive.ts +63 -0
- package/src/index.ts +2 -1
package/README.md
CHANGED
|
@@ -91,6 +91,11 @@ terminal.options.theme = toXtermTheme(theme)
|
|
|
91
91
|
const highlighter = await createHighlighter({ themes: [toShikiTheme(theme)], langs: [...] })
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
`syntaxRolesHex(theme)` keeps comments at the catalogue's intentionally quiet default.
|
|
95
|
+
For editor palettes where comments and diff markers are small content text,
|
|
96
|
+
`editorRolesHex(theme)` returns the editor roles with every rounded hex value checked
|
|
97
|
+
against a 4.5:1 contrast floor. The source syntax palette remains unchanged.
|
|
98
|
+
|
|
94
99
|
Every exported theme value is an `oklch()` string, which means the browser does the
|
|
95
100
|
colour work and a consumer can compose — `color-mix(in oklch, var(--adea-accent),
|
|
96
101
|
transparent 20%)` — and get a predictable result. The adapters that need hex (xterm,
|
package/dist/derive.d.ts
CHANGED
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
import type { AdeaTheme } from './schema.js';
|
|
32
32
|
/** The syntax roles, matching the names Shiki's theme contract expects. */
|
|
33
33
|
export type SyntaxRole = 'keyword' | 'string' | 'number' | 'comment' | 'function' | 'variable' | 'type' | 'tag' | 'attribute' | 'operator' | 'heading' | 'link' | 'constant' | 'punctuation' | 'diffAdd' | 'diffDelete' | 'diffHunk' | 'searchMatch';
|
|
34
|
+
/** Roles in the product's editor palette, which are all read as small text. */
|
|
35
|
+
export type EditorRole = Exclude<SyntaxRole, 'constant' | 'punctuation'>;
|
|
34
36
|
/**
|
|
35
37
|
* The syntax palette for a theme, as OKLCH strings.
|
|
36
38
|
*
|
|
@@ -45,6 +47,13 @@ export declare function syntaxRoles(theme: AdeaTheme, options?: {
|
|
|
45
47
|
}): Record<SyntaxRole, string>;
|
|
46
48
|
/** The syntax palette as hex, for engines that cannot evaluate `oklch()`. */
|
|
47
49
|
export declare function syntaxRolesHex(theme: AdeaTheme): Record<SyntaxRole, string>;
|
|
50
|
+
/**
|
|
51
|
+
* The hex role set for code editors, where comments and diffs are rendered as
|
|
52
|
+
* content text rather than decorative syntax. The quiet syntax API stays at its
|
|
53
|
+
* palette-selected comment level; this projection explicitly holds every editor
|
|
54
|
+
* role to WCAG AA on the canvas.
|
|
55
|
+
*/
|
|
56
|
+
export declare function editorRolesHex(theme: AdeaTheme): Record<EditorRole, string>;
|
|
48
57
|
/**
|
|
49
58
|
* The categorical chart series, derived from the ANSI hues.
|
|
50
59
|
*
|
package/dist/derive.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAI5C,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,UAAU,GACV,UAAU,GACV,MAAM,GACN,KAAK,GACL,WAAW,GACX,UAAU,GACV,SAAS,GACT,MAAM,GACN,UAAU,GACV,aAAa,GACb,SAAS,GACT,YAAY,GACZ,UAAU,GACV,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAA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wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAS3E;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAG9E"}
|
package/dist/derive.js
CHANGED
|
@@ -29,6 +29,24 @@
|
|
|
29
29
|
* palettes today.
|
|
30
30
|
*/
|
|
31
31
|
import { contrastRatio, formatOklch, mix, oklchToHex, parseColor, repairContrast } from './oklch.js';
|
|
32
|
+
const EDITOR_ROLES = [
|
|
33
|
+
'keyword',
|
|
34
|
+
'string',
|
|
35
|
+
'number',
|
|
36
|
+
'comment',
|
|
37
|
+
'function',
|
|
38
|
+
'variable',
|
|
39
|
+
'type',
|
|
40
|
+
'tag',
|
|
41
|
+
'attribute',
|
|
42
|
+
'operator',
|
|
43
|
+
'heading',
|
|
44
|
+
'link',
|
|
45
|
+
'diffAdd',
|
|
46
|
+
'diffDelete',
|
|
47
|
+
'diffHunk',
|
|
48
|
+
'searchMatch',
|
|
49
|
+
];
|
|
32
50
|
/** Which ANSI role each syntax role is read from, and why. */
|
|
33
51
|
const SYNTAX_SOURCE = Object.freeze({
|
|
34
52
|
// Magenta is the slot palettes spend on the most distinctive hue they have, and
|
|
@@ -101,6 +119,43 @@ export function syntaxRolesHex(theme) {
|
|
|
101
119
|
return [role, parsed ? oklchToHex(parsed) : value];
|
|
102
120
|
}));
|
|
103
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* The hex role set for code editors, where comments and diffs are rendered as
|
|
124
|
+
* content text rather than decorative syntax. The quiet syntax API stays at its
|
|
125
|
+
* palette-selected comment level; this projection explicitly holds every editor
|
|
126
|
+
* role to WCAG AA on the canvas.
|
|
127
|
+
*/
|
|
128
|
+
export function editorRolesHex(theme) {
|
|
129
|
+
const roles = syntaxRolesHex(theme);
|
|
130
|
+
const background = parseColor(theme.colors.background);
|
|
131
|
+
if (!background)
|
|
132
|
+
throw new Error(`theme ${theme.id} has no valid editor background`);
|
|
133
|
+
return Object.fromEntries(EDITOR_ROLES.map((role) => {
|
|
134
|
+
const source = parseColor(roles[role]);
|
|
135
|
+
if (!source)
|
|
136
|
+
throw new Error(`theme ${theme.id} has no valid editor.${role}`);
|
|
137
|
+
const initial = oklchToHex(source);
|
|
138
|
+
const renderedInitial = parseColor(initial);
|
|
139
|
+
if (renderedInitial && contrastRatio(renderedInitial, background) >= 4.5 - 1e-9) {
|
|
140
|
+
return [role, initial];
|
|
141
|
+
}
|
|
142
|
+
// Repair against the exact role the editor receives. A repair at precisely
|
|
143
|
+
// 4.5:1 in OKLCH can round to a hex value just below that floor, so advance
|
|
144
|
+
// the requested threshold by the smallest measured step until the encoded
|
|
145
|
+
// value itself clears 4.5:1. No source palette value or hue is rewritten.
|
|
146
|
+
for (let margin = 0.001; margin <= 0.05; margin += 0.001) {
|
|
147
|
+
const repaired = repairContrast(source, background, 4.5 + margin);
|
|
148
|
+
if (!repaired.satisfied)
|
|
149
|
+
continue;
|
|
150
|
+
const candidate = oklchToHex(repaired.color);
|
|
151
|
+
const renderedCandidate = parseColor(candidate);
|
|
152
|
+
if (renderedCandidate && contrastRatio(renderedCandidate, background) >= 4.5 - 1e-9) {
|
|
153
|
+
return [role, candidate];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
throw new Error(`cannot encode editor.${role} for ${theme.id} above 4.5:1 contrast`);
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
104
159
|
/**
|
|
105
160
|
* The categorical chart series, derived from the ANSI hues.
|
|
106
161
|
*
|
package/dist/derive.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,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;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgB,EAAE,IAAgB;IACjE,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACtD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACtD,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAA;IAEvE,MAAM,IAAI,GACR,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAA;IAC9F,OAAO,WAAW,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,KAAgB,EAAE,IAAgB;IACpE,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,OAAO,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAA;AAC9D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,8 +53,8 @@ export type { AnsiInvariant, ContrastFinding, Pairing } from './validate.js';
|
|
|
53
53
|
export { REQUIRED_PAIRINGS, STATUS_PAIRINGS, checkAnsiRamp, formatFindings, validateCatalogue, validateTheme, } from './validate.js';
|
|
54
54
|
export type { NormalizationFinding, NormalizedTheme, ThemeSourceSpec } from './normalize.js';
|
|
55
55
|
export { CONTRAST_FLOORS, normalizeTheme } from './normalize.js';
|
|
56
|
-
export type { StatusRole, SyntaxRole } from './derive.js';
|
|
57
|
-
export { CHART_SERIES, STATUS_ROLES, chartSeries, statusForeground, statusForegroundHex, syntaxRoles, syntaxRolesHex, tint, } from './derive.js';
|
|
56
|
+
export type { EditorRole, StatusRole, SyntaxRole } from './derive.js';
|
|
57
|
+
export { CHART_SERIES, STATUS_ROLES, chartSeries, editorRolesHex, statusForeground, statusForegroundHex, syntaxRoles, syntaxRolesHex, tint, } from './derive.js';
|
|
58
58
|
export type { Base24Palette, Base24Scheme, Base24Slot } from './adapters/base24.js';
|
|
59
59
|
export { BASE24_SLOTS, BASE24_SLOT_MEANING, BASE24_TO_ANSI, Base24ParseError, formatBase24Scheme, parseBase24Palette, parseBase24Scheme, toBase24, } from './adapters/base24.js';
|
|
60
60
|
export type { XtermTheme } from './adapters/xterm.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,YAAY,EACV,QAAQ,EACR,SAAS,EACT,eAAe,EACf,eAAe,EACf,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEzD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,aAAa,EACb,QA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7B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE9F,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEjE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export { DEFAULT_THEME_IDS, getBase24Scheme, getTheme, hasTheme, resolveTheme, t
|
|
|
49
49
|
export { contrastRatio, deltaEok, formatOklch, gamutMap, hexToOklch, inGamut, mix, oklchToHex, parseColor, parseOklch, relativeLuminance, repairContrast, shiftLightness, } from './oklch.js';
|
|
50
50
|
export { REQUIRED_PAIRINGS, STATUS_PAIRINGS, checkAnsiRamp, formatFindings, validateCatalogue, validateTheme, } from './validate.js';
|
|
51
51
|
export { CONTRAST_FLOORS, normalizeTheme } from './normalize.js';
|
|
52
|
-
export { CHART_SERIES, STATUS_ROLES, chartSeries, statusForeground, statusForegroundHex, syntaxRoles, syntaxRolesHex, tint, } from './derive.js';
|
|
52
|
+
export { CHART_SERIES, STATUS_ROLES, chartSeries, editorRolesHex, statusForeground, statusForegroundHex, syntaxRoles, syntaxRolesHex, tint, } from './derive.js';
|
|
53
53
|
export { BASE24_SLOTS, BASE24_SLOT_MEANING, BASE24_TO_ANSI, Base24ParseError, formatBase24Scheme, parseBase24Palette, parseBase24Scheme, toBase24, } from './adapters/base24.js';
|
|
54
54
|
export { toXtermTheme } from './adapters/xterm.js';
|
|
55
55
|
export { catalogueCss, cssVariableName, themeCss, themeCssVariables } from './adapters/css.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAgBH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGzD,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAA;AAErB,8EAA8E;AAC9E,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,aAAa,EACb,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,OAAO,GACR,MAAM,gBAAgB,CAAA;AAIvB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,UAAU,EACV,OAAO,EACP,GAAG,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAA;AAInB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,eAAe,CAAA;AAItB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIhE,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,IAAI,GACL,MAAM,aAAa,CAAA;AAIpB,OAAO,EACL,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BAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,eAAe,CAAA;AAItB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIhE,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,IAAI,GACL,MAAM,aAAa,CAAA;AAIpB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG9F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGxD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEjE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
package/package.json
CHANGED
package/src/derive.ts
CHANGED
|
@@ -54,6 +54,28 @@ export type SyntaxRole =
|
|
|
54
54
|
| 'diffHunk'
|
|
55
55
|
| 'searchMatch'
|
|
56
56
|
|
|
57
|
+
/** Roles in the product's editor palette, which are all read as small text. */
|
|
58
|
+
export type EditorRole = Exclude<SyntaxRole, 'constant' | 'punctuation'>
|
|
59
|
+
|
|
60
|
+
const EDITOR_ROLES = [
|
|
61
|
+
'keyword',
|
|
62
|
+
'string',
|
|
63
|
+
'number',
|
|
64
|
+
'comment',
|
|
65
|
+
'function',
|
|
66
|
+
'variable',
|
|
67
|
+
'type',
|
|
68
|
+
'tag',
|
|
69
|
+
'attribute',
|
|
70
|
+
'operator',
|
|
71
|
+
'heading',
|
|
72
|
+
'link',
|
|
73
|
+
'diffAdd',
|
|
74
|
+
'diffDelete',
|
|
75
|
+
'diffHunk',
|
|
76
|
+
'searchMatch',
|
|
77
|
+
] as const satisfies readonly EditorRole[]
|
|
78
|
+
|
|
57
79
|
/** Which ANSI role each syntax role is read from, and why. */
|
|
58
80
|
const SYNTAX_SOURCE: Readonly<Record<SyntaxRole, keyof AdeaTheme['ansi']>> = Object.freeze({
|
|
59
81
|
// Magenta is the slot palettes spend on the most distinctive hue they have, and
|
|
@@ -140,6 +162,47 @@ export function syntaxRolesHex(theme: AdeaTheme): Record<SyntaxRole, string> {
|
|
|
140
162
|
) as Record<SyntaxRole, string>
|
|
141
163
|
}
|
|
142
164
|
|
|
165
|
+
/**
|
|
166
|
+
* The hex role set for code editors, where comments and diffs are rendered as
|
|
167
|
+
* content text rather than decorative syntax. The quiet syntax API stays at its
|
|
168
|
+
* palette-selected comment level; this projection explicitly holds every editor
|
|
169
|
+
* role to WCAG AA on the canvas.
|
|
170
|
+
*/
|
|
171
|
+
export function editorRolesHex(theme: AdeaTheme): Record<EditorRole, string> {
|
|
172
|
+
const roles = syntaxRolesHex(theme)
|
|
173
|
+
const background = parseColor(theme.colors.background)
|
|
174
|
+
if (!background) throw new Error(`theme ${theme.id} has no valid editor background`)
|
|
175
|
+
|
|
176
|
+
return Object.fromEntries(
|
|
177
|
+
EDITOR_ROLES.map((role) => {
|
|
178
|
+
const source = parseColor(roles[role])
|
|
179
|
+
if (!source) throw new Error(`theme ${theme.id} has no valid editor.${role}`)
|
|
180
|
+
|
|
181
|
+
const initial = oklchToHex(source)
|
|
182
|
+
const renderedInitial = parseColor(initial)
|
|
183
|
+
if (renderedInitial && contrastRatio(renderedInitial, background) >= 4.5 - 1e-9) {
|
|
184
|
+
return [role, initial]
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Repair against the exact role the editor receives. A repair at precisely
|
|
188
|
+
// 4.5:1 in OKLCH can round to a hex value just below that floor, so advance
|
|
189
|
+
// the requested threshold by the smallest measured step until the encoded
|
|
190
|
+
// value itself clears 4.5:1. No source palette value or hue is rewritten.
|
|
191
|
+
for (let margin = 0.001; margin <= 0.05; margin += 0.001) {
|
|
192
|
+
const repaired = repairContrast(source, background, 4.5 + margin)
|
|
193
|
+
if (!repaired.satisfied) continue
|
|
194
|
+
const candidate = oklchToHex(repaired.color)
|
|
195
|
+
const renderedCandidate = parseColor(candidate)
|
|
196
|
+
if (renderedCandidate && contrastRatio(renderedCandidate, background) >= 4.5 - 1e-9) {
|
|
197
|
+
return [role, candidate]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
throw new Error(`cannot encode editor.${role} for ${theme.id} above 4.5:1 contrast`)
|
|
202
|
+
})
|
|
203
|
+
) as Record<EditorRole, string>
|
|
204
|
+
}
|
|
205
|
+
|
|
143
206
|
/**
|
|
144
207
|
* The categorical chart series, derived from the ANSI hues.
|
|
145
208
|
*
|
package/src/index.ts
CHANGED
|
@@ -123,11 +123,12 @@ export type { NormalizationFinding, NormalizedTheme, ThemeSourceSpec } from './n
|
|
|
123
123
|
export { CONTRAST_FLOORS, normalizeTheme } from './normalize.js'
|
|
124
124
|
|
|
125
125
|
/* --- Derived colours --------------------------------------------------- */
|
|
126
|
-
export type { StatusRole, SyntaxRole } from './derive.js'
|
|
126
|
+
export type { EditorRole, StatusRole, SyntaxRole } from './derive.js'
|
|
127
127
|
export {
|
|
128
128
|
CHART_SERIES,
|
|
129
129
|
STATUS_ROLES,
|
|
130
130
|
chartSeries,
|
|
131
|
+
editorRolesHex,
|
|
131
132
|
statusForeground,
|
|
132
133
|
statusForegroundHex,
|
|
133
134
|
syntaxRoles,
|