@taprootio/espalier 7.2.0 → 7.3.0

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/custom-elements.json +4621 -15535
  3. package/dist/badge/esp-badge.d.ts +7 -0
  4. package/dist/badge/esp-badge.js +11 -5
  5. package/dist/breadcrumbs/breadcrumb-separators.d.ts +4 -0
  6. package/dist/breadcrumbs/breadcrumb-separators.js +1 -0
  7. package/dist/breadcrumbs/esp-breadcrumb.d.ts +13 -14
  8. package/dist/breadcrumbs/esp-breadcrumb.js +6 -7
  9. package/dist/breadcrumbs/esp-breadcrumbs.d.ts +16 -9
  10. package/dist/breadcrumbs/esp-breadcrumbs.js +9 -6
  11. package/dist/cli/theme-check.js +2 -2
  12. package/dist/font-picker/esp-font-picker.d.ts +11 -14
  13. package/dist/font-picker/esp-font-picker.js +5 -5
  14. package/dist/footer/esp-footer-link-group.js +1 -1
  15. package/dist/footer/esp-footer.d.ts +5 -0
  16. package/dist/footer/esp-footer.js +10 -4
  17. package/dist/header/esp-header-button.js +3 -3
  18. package/dist/header/esp-header.js +9 -9
  19. package/dist/index.d.ts +3 -2
  20. package/dist/index.js +1 -1
  21. package/dist/pickers/esp-picker-item.js +1 -1
  22. package/dist/root/esp-root.d.ts +8 -1
  23. package/dist/root/esp-root.js +47 -10
  24. package/dist/root/helpers/compute-semantic-properties.js +1 -1
  25. package/dist/root/helpers/compute-theme-properties.js +1 -1
  26. package/dist/root/helpers/data-companion-properties.js +1 -1
  27. package/dist/root/helpers/lightness-ramp-properties.js +1 -1
  28. package/dist/shared/blockquote-styles.d.ts +3 -0
  29. package/dist/shared/blockquote-styles.js +4 -4
  30. package/dist/shared/color-engine.js +1 -1
  31. package/dist/shared/component-property-compiler.js +1 -0
  32. package/dist/shared/component-property-diagnostics.js +1 -0
  33. package/dist/shared/component-property-normalizer.js +1 -0
  34. package/dist/shared/component-property-resets.js +1 -0
  35. package/dist/shared/document-sprite.js +1 -1
  36. package/dist/shared/esp-element-base.d.ts +3 -0
  37. package/dist/shared/esp-element-base.js +3 -3
  38. package/dist/shared/font-helpers.d.ts +3 -3
  39. package/dist/shared/font-helpers.js +1 -1
  40. package/dist/shared/font-plan.d.ts +1 -1
  41. package/dist/shared/governing-root.d.ts +24 -0
  42. package/dist/shared/governing-root.js +1 -0
  43. package/dist/shared/intent-values.js +1 -1
  44. package/dist/shared/paint-fit.js +1 -1
  45. package/dist/shared/public-token-catalog.generated.js +1 -0
  46. package/dist/shared/root-event-subscription.d.ts +11 -0
  47. package/dist/shared/scoped-style-declarations.js +1 -0
  48. package/dist/shared/semantic-color-names.d.ts +16 -0
  49. package/dist/shared/semantic-color-names.js +1 -0
  50. package/dist/shared/settable-component-properties.js +1 -0
  51. package/dist/shared/theme-core.d.ts +808 -0
  52. package/dist/shared/theme-core.js +1 -0
  53. package/dist/shared/theme-fit-report.d.ts +30 -4
  54. package/dist/shared/theme-fit-report.js +1 -1
  55. package/dist/shared/theme-mapping-grammar.d.ts +16 -0
  56. package/dist/shared/theme-mapping-grammar.js +1 -0
  57. package/dist/shared/theme-properties.d.ts +3 -1
  58. package/dist/shared/theme-properties.js +1 -1
  59. package/dist/shared/theme-validation.d.ts +52 -0
  60. package/dist/shared/theme-validation.js +1 -0
  61. package/dist/shared/theme.d.ts +4 -876
  62. package/dist/shared/theme.js +1 -1
  63. package/dist/shared/token-pairings.d.ts +1 -1
  64. package/dist/testing/observe-paint.iife.js +1 -1
  65. package/espalier.css-data.json +62 -2
  66. package/espalier.token-manifest.json +5724 -29
  67. package/package.json +5 -1
@@ -1,878 +1,6 @@
1
- /**
2
- * @module theme
3
- *
4
- * Data-layer for the Espalier theming system.
5
- *
6
- * Defines the {@link EspalierTheme} interface, default light and dark
7
- * themes, and utilities for encoding, decoding, merging, and
8
- * validating theme objects.
9
- *
10
- * A theme encapsulates **every** tuneable parameter of the design
11
- * system — from the OKLCH seed color to spacing ratios, lightness
12
- * curves, chroma clamps, and semantic color mappings. Two theme
13
- * objects (`light-theme` and `dark-theme`) are passed to `<esp-root>`
14
- * as Base64-encoded JSON attributes; the active `scheme` attribute
15
- * selects which one is applied.
16
- *
17
- * @example
18
- * ```ts
19
- * import {
20
- * DEFAULT_LIGHT_THEME,
21
- * mergeTheme,
22
- * parseTheme,
23
- * validateTheme,
24
- * } from './theme.js';
25
- *
26
- * const result = validateTheme(atob(JSON.stringify({ seedColor: 'oklch(0.6 0.2 30)' })));
27
- * if (result.valid) {
28
- * const partial = parseTheme(myBase64String)!;
29
- * const theme = mergeTheme(DEFAULT_LIGHT_THEME, partial);
30
- * }
31
- * ```
32
- */
33
- import { type DataPalette, type DataRamps, type PartialDataRamps } from "./data-colors.js";
1
+ /** Public compatibility entry for the theme data model, codec and validation. */
2
+ export { ANCHOR_SLUG_PATTERN, COLOR_SOURCES, DEFAULT_BODY_FONT_FAMILY, DEFAULT_DARK_LIGHTNESS, DEFAULT_DARK_THEME, DEFAULT_LIGHT_LIGHTNESS, DEFAULT_LIGHT_THEME, DEFAULT_MONOSPACE_FONT_FAMILY, DEFAULT_SEMANTIC_MAPPINGS, LIGHTNESS_KEYS, NESTED_THEME_KEYS, ROLE_DERIVED_INK, ROLE_DERIVED_SURFACE, ROLE_NAMES, ROLE_PAIRED_INK, ROLE_TOKEN_PLAN, SEMANTIC_COLOR_NAMES, STATUS_COLOR_SOURCES, TOKEN_PAIRINGS, VARIANT_COLOR_SOURCES, buildTaprootDarkTheme, buildTaprootLightTheme, compileRoles, encodeTheme, explicitMappingTokens, isLightnessKey, isObjectRecord, isSemanticColorName, layerThemes, mergePartials, mergeTheme, parseAnchorSource, parseTheme, resolveAnchorColor, resolveContextTheme, resolveDataColorSource, resolveLightnessReference, roleInkProvenance, semanticToCSS, toneReferenceName, } from "./theme-core.js";
3
+ export type { AnchorReference, ChromaRange, ColorSource, ComponentProperties, ComponentPropertyValue, EspalierTheme, LightnessKey, LightnessMap, LightnessReference, MappingSource, PartialTheme, PartialThemeAnchor, PartialThemeAnchors, PartialThemeContexts, PartialThemeTones, RoleBinding, RoleName, RoleSlotName, SemanticColorName, SemanticMapping, SemanticMappings, StatusColorSource, ThemeAnchor, ThemeAnchorSlots, ThemeAnchors, ThemeContext, ThemeContexts, ThemeIntents, ThemeRoles, ThemeTones, ToneReference, VariantColorSource, } from "./theme-core.js";
4
+ export { validateComponentProperties, validateTheme, validateThemePair, type ComponentPropertyFinding, type ThemeValidationResult, } from "./theme-validation.js";
34
5
  export { isTallHeaderPaint } from "../header/is-tall-header-paint.js";
35
- export { TOKEN_PAIRINGS } from "./token-pairings.js";
36
6
  export { AA_LARGE_RATIO, AA_NON_TEXT_RATIO, AA_TEXT_RATIO, wcagRatio } from "./wcag-contrast.js";
37
- /** A key in the lightness ramp. Each maps to a perceptual role. */
38
- export type LightnessKey = "surface" | "raised1" | "raised2" | "raised3" | "raised4" | "accent" | "muted" | "text" | "border" | "ink" | "shadow";
39
- /** Lightness values (0–1) for every ramp position. */
40
- export type LightnessMap = Record<LightnessKey, number>;
41
- /** A named, opt-in lightness value outside the engine-owned ramp. */
42
- export type ToneReference = `tone:${string}`;
43
- /** A built-in ramp stop or an explicitly declared custom tone. */
44
- export type LightnessReference = LightnessKey | ToneReference;
45
- /** Named custom lightness values. They are inert until a mapping references one. */
46
- export type ThemeTones = Record<string, number>;
47
- /** Tone declarations while partial themes are being layered. */
48
- export type PartialThemeTones = Record<string, number | undefined>;
49
- /**
50
- * A geometric color-theory variant **or** a fixed status family.
51
- *
52
- * Geometric variants are derived by rotating the seed hue; the status
53
- * families (`danger`, `success`, `warning`, `info`) use fixed hue
54
- * angles from `semanticHues` — or a theme's `intents` override, which
55
- * retunes a family with a declared absolute color (ESP0172).
56
- */
57
- export type ColorSource = "primary" | "analogous-left" | "analogous-right" | "complementary" | "split-complementary-left" | "split-complementary-right" | "triadic-left" | "triadic-right" | "danger" | "success" | "warning" | "info";
58
- /**
59
- * Non-primary color sources — the eleven variants that can carry
60
- * independent chroma overrides.
61
- *
62
- * Primary is excluded because its chroma is always the seed
63
- * color's chroma.
64
- */
65
- export type VariantColorSource = Exclude<ColorSource, "primary">;
66
- /**
67
- * The fixed-meaning status families (ADR-004): the colors
68
- * `intent="danger|success|warning|info"` and the same-named mapping
69
- * sources resolve to. A theme may retune each with `intents`.
70
- */
71
- export type StatusColorSource = "danger" | "success" | "warning" | "info";
72
- /**
73
- * Status-family color overrides, by family (ESP0172). Values are an
74
- * `anchor:<name>[.<slot>]` reference or a supported color form
75
- * (`#rrggbb`, `#rgb`, `rgb()`, `hsl()`, `oklch()`); see
76
- * {@link EspalierTheme.intents}.
77
- */
78
- export type ThemeIntents = Partial<Record<StatusColorSource, string>>;
79
- /**
80
- * The object form of an anchor: a required base `color` plus named
81
- * sub-slots — per-family variants the way designers already specify
82
- * them (`rose.text` for the deepened rose that may carry copy).
83
- */
84
- export type ThemeAnchorSlots = {
85
- color: string;
86
- } & Record<string, string>;
87
- /**
88
- * A named brand color in a **resolved** theme.
89
- *
90
- * Either a color string, or the slot object — which always carries its
91
- * base `color`, because a partial that names only slots refines an
92
- * anchor rather than replacing it. Like `seedColor`, this type states
93
- * the contract `validateTheme` enforces: a theme assembled from an
94
- * unvalidated partial that never declared a base color reports an error
95
- * there, and degrades to the seed at runtime.
96
- *
97
- * Every value accepts any CSS color form (ESP0161) and is normalized to
98
- * OKLCH at the merge boundary.
99
- */
100
- export type ThemeAnchor = string | ThemeAnchorSlots;
101
- /**
102
- * A named brand color in a **partial** theme, where an object form may
103
- * name slots alone — `{ rose: { hover: "#88404c" } }` refines the rose
104
- * anchor a base theme already declared.
105
- */
106
- export type PartialThemeAnchor = string | Record<string, string>;
107
- /** Anchors as they appear in a partial theme. */
108
- export type PartialThemeAnchors = Record<string, PartialThemeAnchor>;
109
- /**
110
- * Named brand colors, keyed by slug.
111
- *
112
- * Anchors are free-standing color sources for semantic mappings —
113
- * `source: "anchor:<name>"` — so a multi-color brand is declared as the
114
- * swatches the designer handed over instead of being bent through hue
115
- * geometry and per-token chroma clamps. See ADR-015.
116
- */
117
- export type ThemeAnchors = Record<string, ThemeAnchor>;
118
- /**
119
- * A semantic mapping's color source: a geometric or status family from
120
- * {@link ColorSource}, or a declared anchor — `anchor:<name>` for its
121
- * base color, `anchor:<name>.<slot>` for a sub-slot.
122
- *
123
- * An anchor source contributes its own hue **and chroma**; lightness
124
- * comes from the mapping's built-in stop or custom tone, and APCA
125
- * enforcement applies unchanged. Anchors are absolute sources rather
126
- * than seed rotations — a brand color is a color, not a relationship
127
- * to the seed — so they hold steady while contexts rebind roles around
128
- * them and intents replace the filled-action source.
129
- */
130
- export type MappingSource = ColorSource | `anchor:${string}`;
131
- /** Anchor names and slot names share one slug grammar. */
132
- export declare const ANCHOR_SLUG_PATTERN: RegExp;
133
- /** A parsed `anchor:` mapping source. */
134
- export interface AnchorReference {
135
- name: string;
136
- slot?: string;
137
- }
138
- /**
139
- * Parse an `anchor:` mapping source into its reference, or return
140
- * `null` for anything that is not anchor syntax at all. (A reference
141
- * with an invalid or undeclared name parses fine here — declaration
142
- * checks belong to validateTheme and resolution.)
143
- */
144
- export declare function parseAnchorSource(source: string): AnchorReference | null;
145
- /**
146
- * Resolve an anchor reference to its declared color string.
147
- *
148
- * `anchor:<name>` on an object-form anchor resolves the `color` key; a
149
- * slot reference into a string-form anchor has nowhere to point and
150
- * resolves `null`, as do unknown names and slots.
151
- */
152
- export declare function resolveAnchorColor(anchors: ThemeAnchors, reference: AnchorReference): string | null;
153
- /**
154
- * Resolve a data color source to a concrete CSS color.
155
- *
156
- * Data palettes and ramps accept either a CSS color directly or the same
157
- * `anchor:<name>[.<slot>]` references as semantic mappings. The returned color
158
- * is parseable and opaque; invalid or unresolved sources return `null`.
159
- */
160
- export declare function resolveDataColorSource(source: string, anchors: ThemeAnchors): string | null;
161
- /** Every semantic color token the system computes. */
162
- export type SemanticColorName = "background" | "layer1" | "layer2" | "layer3" | "layer4" | "actionBackground" | "actionText" | "border" | "shadow" | "text" | "typeOverline" | "typeLabel" | "typeLead" | "typeCaption" | "dangerText" | "headings" | "headingsHover" | "link" | "linkHover" | "linkHoverBg" | "inputCaret" | "inputSelection" | "inputSelectionBg";
163
- /** Chroma range enforced on a semantic token before gamut mapping. */
164
- export interface ChromaRange {
165
- /** Minimum chroma (≥ 0). */
166
- min: number;
167
- /** Maximum chroma (≤ 0.4). */
168
- max: number;
169
- }
170
- /**
171
- * Describes how a single semantic color is derived:
172
- * which color source provides the hue + chroma, and which
173
- * lightness ramp position sets the perceived brightness.
174
- */
175
- export interface SemanticMapping {
176
- /**
177
- * The color source to sample: a geometric/status family, or a
178
- * declared anchor as `anchor:<name>` / `anchor:<name>.<slot>`.
179
- */
180
- source: MappingSource;
181
- /** A built-in ramp stop, or a named custom tone as `tone:<name>`. */
182
- lightness: LightnessReference;
183
- }
184
- /** Full mapping table — one entry per semantic color token. */
185
- export type SemanticMappings = Record<SemanticColorName, SemanticMapping>;
186
- /**
187
- * The designer-facing color roles.
188
- *
189
- * `semantic-groups.md` has always described these groups and then warned
190
- * that exposing the twenty-three raw tokens is "handing users the engine
191
- * room instead of the dashboard" — but the groups were documentation
192
- * only. Roles make them addressable: a sentence a designer would say
193
- * becomes a line of theme.
194
- *
195
- * - `canvas` — the page and its raised surfaces
196
- * - `ink` — body copy, with a `heading` slot for titles
197
- * - `accent` — decoration (rules, icons, hover washes), with a `text`
198
- * slot for the deepened variant that may carry copy
199
- * - `action` — filled action surfaces; its paired ink derives
200
- * automatically (see {@link ROLE_PAIRED_INK})
201
- * - `structure` — borders and shadows
202
- *
203
- * `status` is deliberately absent as a role: the four status families
204
- * (`danger`, `success`, `warning`, `info`) carry reserved *meanings*
205
- * that no role may reassign (ADR-004, as amended). Their *colors* are
206
- * a brand decision — retune a family with the theme's `intents` field
207
- * and every derived token follows.
208
- */
209
- export type RoleName = "canvas" | "ink" | "accent" | "action" | "structure";
210
- /**
211
- * A role binding: a color source, or an object with the base `color`
212
- * plus role-specific slots.
213
- *
214
- * Sources are the same vocabulary mappings use — a geometric family, a
215
- * status family, or an `anchor:<name>` reference (ADR-015).
216
- */
217
- export type RoleSlotName = {
218
- canvas: never;
219
- ink: "heading";
220
- accent: "text" | "hover";
221
- action: "ink";
222
- structure: never;
223
- };
224
- export type RoleBinding<R extends RoleName = RoleName> = MappingSource | ({
225
- color: MappingSource;
226
- } & Partial<Record<RoleSlotName[R], MappingSource>>);
227
- /**
228
- * The roles a theme declares. Every role is optional, and each one
229
- * admits only its own slots — `ink.heading`, `accent.text`,
230
- * `action.ink` — so the structural claims the roles layer makes are
231
- * checked by the type system, not only by validateTheme.
232
- */
233
- export type ThemeRoles = {
234
- [R in RoleName]?: RoleBinding<R>;
235
- };
236
- /**
237
- * One named zone-level rebinding of the designer-facing color roles.
238
- *
239
- * A context may also carry a partial lightness ramp. Color sources alone
240
- * cannot make a dark zone inside a light scheme because semantic derivation
241
- * deliberately takes lightness from the ramp rather than from an anchor.
242
- *
243
- * A context may also carry custom `tones` and token-level
244
- * `semanticMappings` (ESP0175, ESP0180). Root-level tones and explicit
245
- * mappings survive into every context by design, while a zone may add or
246
- * override a tone and pin a token locally. Each record layers by name.
247
- */
248
- export type ThemeContext = ThemeRoles & {
249
- lightness?: Partial<LightnessMap>;
250
- tones?: PartialThemeTones;
251
- semanticMappings?: Partial<SemanticMappings>;
252
- };
253
- /** Named role-rebinding zones available to `context` attributes. */
254
- export type ThemeContexts = Record<string, ThemeContext>;
255
- /** Context declarations while partial themes are being layered. */
256
- export type PartialThemeContexts = Record<string, ThemeContext | undefined>;
257
- /** Ordered role names, for validation and iteration. */
258
- export declare const ROLE_NAMES: readonly RoleName[];
259
- /**
260
- * Map role slots to semantic tokens and ramp stops.
261
- *
262
- * `dangerText` stays outside the roles layer because status meanings are reserved.
263
- * Accent body copy must use the legible `accent.text` slot. `accent.hover` can
264
- * select a different family; without it, hovered links follow `accent.text`.
265
- */
266
- export declare const ROLE_TOKEN_PLAN: Readonly<Record<RoleName, Readonly<Record<string, ReadonlyArray<[SemanticColorName, LightnessKey]>>>>>;
267
- /**
268
- * Role slots whose ink lightness is derived from the surface that role
269
- * actually painted, rather than taken from {@link ROLE_TOKEN_PLAN}.
270
- *
271
- * {@link resolvePairedInkStop} used to run only for a slot the theme
272
- * left *undeclared*, so naming `action.ink` took the plan's `surface`
273
- * stop verbatim. In a light ramp both rules answer `surface` and the
274
- * difference never showed. In a dark ramp the plan's stop is the
275
- * near-black page ground, which is the wrong side of a mid-dark action
276
- * surface: enforcement had to walk the label the whole way across the
277
- * ramp and stopped at the first value that cleared the target, emitting
278
- * a weaker ink than the ramp could give. ADR-016 is explicit that the
279
- * model's job is to hand enforcement the strongest available starting
280
- * point on the correct side, so the derivation now runs for a declared
281
- * slot too (ESP0223).
282
- *
283
- * The source still comes from the theme: naming `action.ink` chooses
284
- * the family, exactly as ADR-015 says an anchor supplies hue and chroma
285
- * while the ramp supplies lightness.
286
- *
287
- * Every entry here must also appear in {@link ROLE_PAIRED_INK}: the
288
- * compile branch is gated on `paired` first, and
289
- * {@link roleInkProvenance} walks the pairing table, so an entry in only
290
- * this set would be silently inert in both.
291
- */
292
- export declare const ROLE_DERIVED_INK: ReadonlySet<string>;
293
- /**
294
- * Ink slots that derive from another role when the theme does not
295
- * declare them.
296
- *
297
- * A role that paints a surface must also answer "what writes on it".
298
- * `action.ink` defaults to the canvas color: the ink paired with a
299
- * filled action is the page ground, and APCA enforcement against
300
- * `actionBackground` then guarantees it is legible — which is exactly
301
- * how "white on plum for reversed sections" becomes one theme line
302
- * instead of a hand-picked hex.
303
- */
304
- export declare const ROLE_PAIRED_INK: Readonly<Record<string, {
305
- role: RoleName;
306
- slot: string;
307
- }>>;
308
- interface CompileRoleOptions {
309
- /** Token mappings declared explicitly at this merge boundary. */
310
- explicitMappings?: Partial<SemanticMappings>;
311
- /** Custom tones available to explicit surface mappings. */
312
- tones?: ThemeTones;
313
- /** Exact maximum paired-ink contrast of an action surface candidate. */
314
- actionSurfaceContrast?: (source: MappingSource, stop: LightnessKey) => number;
315
- /** ΔE-OK between an action surface candidate and the theme's background. */
316
- actionSurfaceSeparation?: (source: MappingSource, stop: LightnessKey) => number;
317
- /** Which ink pole reads better on a finished action surface at a lightness. */
318
- actionSurfacePole?: (source: MappingSource, lightness: number) => "dark" | "light";
319
- }
320
- /**
321
- * Compile declared roles into semantic mappings.
322
- *
323
- * A theme with no roles produces no role overrides. Token-level
324
- * `semanticMappings` take precedence over the compiled result.
325
- */
326
- export declare function compileRoles(roles: ThemeRoles, lightness: LightnessMap, baseMappings: SemanticMappings, options?: CompileRoleOptions): Partial<SemanticMappings>;
327
- /**
328
- * Whether each role-paired ink token's *source* was named by the theme
329
- * or paired off another role (ESP0223).
330
- *
331
- * The distinction matters to anything judging how far a token landed
332
- * from the swatch it names. `action.ink` defaults to the canvas colour,
333
- * so an undeclared ink IS the page ground by contract — it is re-lit to
334
- * the opposite end of the ramp on purpose, and the large anchor ΔE that
335
- * follows describes the contract working, not a theme missing its
336
- * brand. A theme that names the slot has made a separate claim about
337
- * the label's family, and the same ΔE then describes a claim that did
338
- * not survive.
339
- *
340
- * A pure read of `roles`: the compile is not re-run, and a role the
341
- * theme never declared reports nothing rather than guessing.
342
- */
343
- export declare function roleInkProvenance(roles: ThemeRoles): Partial<Record<SemanticColorName, "declared" | "derived">>;
344
- /** The complete, resolved Espalier theme. */
345
- export interface EspalierTheme {
346
- /**
347
- * Seed color — drives the entire palette.
348
- *
349
- * A theme author may supply any common CSS color form (`#rrggbb`,
350
- * `#rgb`, `rgb()`, `hsl()`, or `oklch()`); non-OKLCH forms are
351
- * converted at the merge boundary, so a **resolved** theme always
352
- * carries an `oklch()` string here.
353
- */
354
- seedColor: string;
355
- /**
356
- * CSS `font-family` for body / UI text. Empty and omitted overrides resolve
357
- * to the built-in UI stack.
358
- *
359
- * @default "system-ui, sans-serif"
360
- */
361
- fontBody: string;
362
- /**
363
- * CSS `font-family` for headings. When empty, heading recipes fall back to
364
- * {@link fontBody} without changing this authored value.
365
- *
366
- * @default ""
367
- */
368
- fontHeadings: string;
369
- /**
370
- * CSS `font-family` for brand marks and product names. When empty, brand
371
- * recipes fall back through {@link fontHeadings} to {@link fontBody}.
372
- *
373
- * @default ""
374
- */
375
- fontBrand: string;
376
- /**
377
- * CSS `font-family` for navigation menu items and group labels. When empty,
378
- * menu recipes fall back to {@link fontBody} — never to headings — so a
379
- * theme that sets only a heading face keeps its navigation unchanged.
380
- *
381
- * @default ""
382
- */
383
- fontMenu: string;
384
- /**
385
- * CSS `font-family` for code / monospace text. Empty and omitted overrides
386
- * resolve to the built-in monospace family.
387
- *
388
- * @default "monospace"
389
- */
390
- fontMonospace: string;
391
- /**
392
- * CSS `font-weight` for body / UI text.
393
- *
394
- * Accepts any valid CSS font-weight value: numeric (`"400"`,
395
- * `"700"`, range 1–1000), keyword (`"normal"`, `"bold"`,
396
- * `"lighter"`, `"bolder"`), or CSS-wide keyword (`"inherit"`,
397
- * `"initial"`, `"unset"`, `"revert"`, `"revert-layer"`).
398
- *
399
- * Emitted as `--esp-font-weight-body`.
400
- *
401
- * @default "normal"
402
- */
403
- fontWeightBody: string;
404
- /**
405
- * CSS `font-weight` for headings.
406
- *
407
- * Accepts the same values as {@link fontWeightBody}.
408
- *
409
- * Emitted as `--esp-font-weight-headings`.
410
- *
411
- * @default "bold"
412
- */
413
- fontWeightHeadings: string;
414
- /**
415
- * CSS `font-weight` for brand marks and product names.
416
- *
417
- * Accepts the same values as {@link fontWeightBody}.
418
- *
419
- * Emitted as `--esp-font-weight-brand`.
420
- *
421
- * @default "bold"
422
- */
423
- fontWeightBrand: string;
424
- /**
425
- * CSS `font-weight` for horizontal navigation menu items.
426
- *
427
- * Accepts the same values as {@link fontWeightBody}.
428
- *
429
- * Emitted as `--esp-font-weight-menu`.
430
- *
431
- * @default "bold"
432
- */
433
- fontWeightMenu: string;
434
- /**
435
- * CSS `font-weight` for code / monospace text.
436
- *
437
- * Accepts the same values as {@link fontWeightBody}.
438
- *
439
- * Emitted as `--esp-font-weight-monospace`.
440
- *
441
- * @default "normal"
442
- */
443
- fontWeightMonospace: string;
444
- /** External stylesheets injected into `document.head`. */
445
- stylesheets: string[];
446
- /** Scale coefficient in px relative to a 16px baseline; does not set or measure HTML font-size. */
447
- rootFontSize: number;
448
- /** Modular ratio for the type scale (Major Third = 1.25). */
449
- typeRatio: number;
450
- /** Modular ratio for the spacing scale (Golden Ratio ≈ 1.618). */
451
- spaceRatio: number;
452
- /** Global border-radius in rem. */
453
- borderRadius: number;
454
- /** Minimum viewport width (px) for fluid interpolation. */
455
- viewportMin: number;
456
- /** Maximum viewport width (px) for fluid interpolation. */
457
- viewportMax: number;
458
- /** Hue-rotation angles for geometric color variants. */
459
- angles: {
460
- /** Analogous offset from seed (default 30). */
461
- analogous: number;
462
- /** Complementary offset from seed (default 180). */
463
- complementary: number;
464
- /**
465
- * Split-complementary offset **from the complement**.
466
- * The mirror is computed automatically (default 30).
467
- */
468
- splitComplementary: number;
469
- /** Triadic offset from seed (default 120). */
470
- triadic: number;
471
- };
472
- /** Fixed hue angles for the danger / success / warning / info families. */
473
- semanticHues: {
474
- /** Danger hue angle (default 27, red-orange). */
475
- danger: number;
476
- /** Success hue angle (default 150, green). */
477
- success: number;
478
- /** Warning hue angle (default 90, yellow-green). */
479
- warning: number;
480
- /** Info hue angle (default 244, blue). */
481
- info: number;
482
- };
483
- /**
484
- * Status-family color overrides, by family (ESP0172).
485
- *
486
- * Each entry retunes one of the fixed status families — the colors
487
- * `intent="danger|success|warning|info"` and the same-named mapping
488
- * sources resolve to — with a declared color: an
489
- * `anchor:<name>[.<slot>]` reference or a supported color form —
490
- * `#rrggbb`, `#rgb`, `rgb()`, `hsl()`, or `oklch()`. CSS keywords
491
- * such as `red` are not parsed.
492
- *
493
- * An override is **absolute**, like an anchor: it carries its own
494
- * lightness, chroma, and hue, and `semanticHues` / `variantChroma`
495
- * are ignored for that family. Overrides retune a family; they do
496
- * not reassign its meaning (ADR-004): give `danger` your brand's
497
- * red, but never point one family at another — a family name as a
498
- * value (`intents.success: "danger"`) is rejected by validation; a
499
- * color choice that creates a rendered collision is flagged by the
500
- * distance warning, while a merely unusual — but separated — color
501
- * passes silently. `validateTheme` warns when two
502
- * status families — or a family and the action color — become hard
503
- * to distinguish as rendered on controls, and its advice is
504
- * counterfactual-tested per pair: it recommends retuning, widening
505
- * the chroma band, or moving the lightness stop only when that
506
- * change can actually separate the pair, and says "then retune"
507
- * when a band or stop change merely makes a retune possible rather
508
- * than separating the pair on its own. The built-in warning is
509
- * normal-vision-only; status meanings need redundant cues (icons,
510
- * labels) regardless, though lightness and chroma separation chosen
511
- * here can still genuinely help color-vision-deficient users — see
512
- * ADR-004's amendment and the data-color guidance.
513
- *
514
- * @example
515
- * ```jsonc
516
- * "intents": { "info": "anchor:sky", "danger": "#700007" }
517
- * ```
518
- */
519
- intents: ThemeIntents;
520
- /**
521
- * Per-variant chroma overrides (OKLCH chroma, 0–0.4).
522
- *
523
- * Each entry sets the **base chroma** for the corresponding
524
- * color variant, overriding the seed color's chroma for that
525
- * variant only. Omitted entries inherit the seed color's
526
- * chroma at compute time.
527
- *
528
- * This is independent of the per-semantic-token `chroma` ranges
529
- * which clamp chroma *after* derivation. `variantChroma` controls
530
- * the input chroma of the variant itself, while `chroma` controls
531
- * the output range of each semantic token.
532
- *
533
- * @example
534
- * ```ts
535
- * // Make complementary colors more vivid, mute triadic colors
536
- * variantChroma: {
537
- * "complementary": 0.22,
538
- * "triadic-left": 0.06,
539
- * "triadic-right": 0.06,
540
- * }
541
- * ```
542
- */
543
- variantChroma: Partial<Record<VariantColorSource, number>>;
544
- /** Lightness values (0–1) for the eleven ramp positions. */
545
- lightness: LightnessMap;
546
- /**
547
- * Named custom lightness values for explicit semantic mappings.
548
- *
549
- * Refer to one as `tone:<name>` from `semanticMappings`. Tones do not
550
- * become built-in ramp stops, emit `--esp-l-*` properties, or participate
551
- * in automatic role and action-stop selection.
552
- */
553
- tones: ThemeTones;
554
- /** Per-semantic-token chroma min / max. */
555
- chroma: Record<SemanticColorName, ChromaRange>;
556
- /** Maps each semantic token to its color source + lightness. */
557
- semanticMappings: SemanticMappings;
558
- /**
559
- * Tokens in {@link semanticMappings} that were authored as explicit pins.
560
- *
561
- * A resolved theme also contains mappings generated by {@link roles}. This
562
- * compact marker preserves that distinction when a complete theme document
563
- * is serialized, then rehydrated through {@link mergeTheme}. Consumers
564
- * normally do not author this field; `mergeTheme` maintains it.
565
- */
566
- explicitMappingTokens?: SemanticColorName[];
567
- /**
568
- * Named brand colors available to semantic mappings as
569
- * `anchor:<name>` sources. Empty by default — a single-color brand
570
- * needs none; a multi-color brand declares its swatches here instead
571
- * of bending hue angles. See {@link ThemeAnchors} and ADR-015.
572
- */
573
- anchors: ThemeAnchors;
574
- /**
575
- * Designer-facing color roles, compiled into
576
- * {@link EspalierTheme.semanticMappings} at merge time. Empty by
577
- * default; token-level mappings layer over whatever roles produce.
578
- * See {@link ThemeRoles} and ADR-016.
579
- */
580
- roles: ThemeRoles;
581
- /**
582
- * Named zone-level role rebindings. A base-derived element selects one with
583
- * its `context` attribute; the selected context is resolved against this
584
- * scheme's complete theme and re-enforces every semantic ink pairing.
585
- */
586
- contexts: ThemeContexts;
587
- /**
588
- * Eight stable categorical data-series colors. Each value is a CSS color or
589
- * an `anchor:<name>[.<slot>]` reference. Emitted as
590
- * `--esp-color-series-1`–`--esp-color-series-8`.
591
- */
592
- dataPalette: DataPalette;
593
- /**
594
- * Named sequential and diverging data ramps. Empty by default; each
595
- * declaration emits `--esp-color-ramp-<name>-1…<steps>`.
596
- */
597
- dataRamps: DataRamps;
598
- /** Optional CSS `background-image` for the page surface. */
599
- pageBackgroundImage?: string;
600
- /** Opacity (0–1) for the page background image. */
601
- pageBackgroundImageOpacity?: number;
602
- /** Optional CSS `background-image` for `esp-box` surfaces. */
603
- boxBackgroundImage?: string;
604
- /** Opacity (0–1) for the box background image. */
605
- boxBackgroundImageOpacity?: number;
606
- /** Opacity (0–1) for the vellum (modal overlay) backdrop. */
607
- vellumOpacity?: number;
608
- /** Optional CSS `background-image` for vellum overlays. */
609
- vellumBackgroundImage?: string;
610
- /** Opacity (0–1) for the vellum background image layer. */
611
- vellumBackgroundImageOpacity?: number;
612
- }
613
- /**
614
- * Recursively-partial version of {@link EspalierTheme}.
615
- *
616
- * `anchors` is stated explicitly rather than derived: a partial may
617
- * carry slot-only anchor overrides, which the resolved
618
- * {@link ThemeAnchor} deliberately does not permit.
619
- */
620
- export type PartialTheme = Omit<DeepPartial<EspalierTheme>, "anchors" | "contexts" | "dataRamps" | "tones"> & {
621
- anchors?: PartialThemeAnchors;
622
- contexts?: PartialThemeContexts;
623
- dataRamps?: PartialDataRamps;
624
- tones?: PartialThemeTones;
625
- };
626
- /** Validation result returned by {@link validateTheme}. */
627
- export interface ThemeValidationResult {
628
- /** `true` when there are zero errors (warnings are allowed). */
629
- valid: boolean;
630
- /** Hard failures — the theme should not be applied. */
631
- errors: string[];
632
- /** Soft issues — the theme will work but values are unusual. */
633
- warnings: string[];
634
- }
635
- /** Ordered list of all semantic color token names. */
636
- export declare const SEMANTIC_COLOR_NAMES: readonly SemanticColorName[];
637
- /** `true` when `value` is one of the stable semantic color token names. */
638
- export declare function isSemanticColorName(value: unknown): value is SemanticColorName;
639
- /** Valid color-source identifiers for {@link SemanticMapping.source}. */
640
- export declare const COLOR_SOURCES: readonly ColorSource[];
641
- /** The four fixed status families, matching {@link StatusColorSource}. */
642
- export declare const STATUS_COLOR_SOURCES: readonly StatusColorSource[];
643
- /**
644
- * Non-primary color sources that support independent chroma overrides.
645
- *
646
- * Matches the eleven entries in {@link VariantColorSource}.
647
- */
648
- export declare const VARIANT_COLOR_SOURCES: readonly VariantColorSource[];
649
- /** Valid keys for the lightness ramp. */
650
- export declare const LIGHTNESS_KEYS: readonly LightnessKey[];
651
- /** Return the custom tone name carried by a valid `tone:<slug>` reference. */
652
- export declare function toneReferenceName(reference: unknown): string | null;
653
- /** True when a string names one of the eleven engine-owned ramp stops. */
654
- export declare function isLightnessKey(reference: unknown): reference is LightnessKey;
655
- /**
656
- * Resolve the lightness an explicit semantic mapping requested.
657
- *
658
- * Custom tones are a lookup namespace only: this function never adds them to
659
- * {@link LIGHTNESS_KEYS}, so automatic role and action-stop algorithms continue
660
- * to consider exactly the built-in eleven. An invalid runtime reference falls
661
- * back to `surface`; validation reports the authoring error before mounting.
662
- */
663
- export declare function resolveLightnessReference(lightness: LightnessMap, tones: ThemeTones | undefined, reference: LightnessReference): number;
664
- /**
665
- * Default lightness ramp for the **light** scheme.
666
- *
667
- * High values for surfaces → low values for text, following the
668
- * natural top-to-bottom contrast gradient of a printed page.
669
- */
670
- export declare const DEFAULT_LIGHT_LIGHTNESS: Readonly<LightnessMap>;
671
- /**
672
- * Default lightness ramp for the **dark** scheme.
673
- *
674
- * Inverted: low values for surfaces, high values for text.
675
- */
676
- export declare const DEFAULT_DARK_LIGHTNESS: Readonly<LightnessMap>;
677
- /**
678
- * Default semantic color mappings that match the existing CSS.
679
- *
680
- * Each entry tells the color engine which variant supplies the
681
- * hue and which lightness key sets the perceived brightness.
682
- *
683
- * `actionBackground` carries the **light** scheme's stop; the dark
684
- * theme overrides it through {@link buildDefaultSemanticMappings}. See
685
- * {@link DEFAULT_ACTION_BACKGROUND_STOP} for why that one mapping
686
- * cannot share a name across schemes.
687
- */
688
- export declare const DEFAULT_SEMANTIC_MAPPINGS: Readonly<SemanticMappings>;
689
- /** Built-in authored stack for body and UI text. */
690
- export declare const DEFAULT_BODY_FONT_FAMILY = "system-ui, sans-serif";
691
- /** Built-in authored family for code and monospace text. */
692
- export declare const DEFAULT_MONOSPACE_FONT_FAMILY = "monospace";
693
- /**
694
- * The built-in **light** theme.
695
- *
696
- * Identical to the dark theme in every field except `lightness`,
697
- * which uses a high-surface / low-text ramp suited for bright
698
- * backgrounds.
699
- */
700
- export declare const DEFAULT_LIGHT_THEME: Readonly<EspalierTheme>;
701
- /**
702
- * The built-in **dark** theme.
703
- *
704
- * Identical to the light theme in every field except `lightness`,
705
- * which uses a low-surface / high-text ramp suited for dark
706
- * backgrounds.
707
- */
708
- export declare const DEFAULT_DARK_THEME: Readonly<EspalierTheme>;
709
- /**
710
- * Recursively-partial utility type.
711
- *
712
- * Arrays are left as-is (a partial array is still an array),
713
- * while plain objects are made deeply optional.
714
- */
715
- type DeepPartial<T> = {
716
- [P in keyof T]?: T[P] extends (infer U)[] ? U[] : T[P] extends Record<string, unknown> ? DeepPartial<T[P]> : T[P];
717
- };
718
- /**
719
- * Convert a {@link SemanticColorName} (camelCase) to its CSS
720
- * custom-property name (kebab-case with `--esp-color-` prefix).
721
- *
722
- * ```
723
- * linkHoverBg → --esp-color-link-hover-bg
724
- * layer1 → --esp-color-layer-1
725
- * ```
726
- */
727
- export declare function semanticToCSS(name: SemanticColorName): string;
728
- /**
729
- * Decode a Base64-encoded JSON string into a {@link PartialTheme}.
730
- *
731
- * Returns `null` if decoding or JSON parsing fails — never throws.
732
- *
733
- * Unsafe property names (`__proto__`, `constructor`, `prototype`)
734
- * are stripped during parsing via a JSON reviver to prevent
735
- * prototype pollution from untrusted encoded themes.
736
- *
737
- * @param base64 A Base64-encoded JSON string.
738
- * @returns The decoded partial theme, or `null` on failure.
739
- */
740
- export declare function parseTheme(base64: string): PartialTheme | null;
741
- /**
742
- * Encode a {@link PartialTheme} as a Base64 JSON string.
743
- *
744
- * The inverse of {@link parseTheme}. Unicode-safe: theme strings (font
745
- * names, anchor slugs' display metadata) may carry any code point.
746
- *
747
- * @param partial The partial theme to encode.
748
- * @returns A Base64-encoded JSON string.
749
- */
750
- export declare function encodeTheme(partial: PartialTheme): string;
751
- /** True for an ordinary record whose entries can be merged by key. */
752
- export declare function isObjectRecord(value: unknown): value is Record<string, unknown>;
753
- /**
754
- * Recover explicit mapping provenance from a resolved theme.
755
- *
756
- * Themes produced in this process carry exact provenance in the WeakMap and
757
- * serialize it in `explicitMappingTokens`. The comparison fallback preserves
758
- * historical behavior for a legacy or manually reconstructed resolved theme
759
- * that carries neither form.
760
- *
761
- * Exported for the fit report (ESP0175), which marks explicit tokens so
762
- * a zone's surprising value traces to the mapping that pinned it.
763
- */
764
- export declare function explicitMappingTokens(theme: EspalierTheme): Set<SemanticColorName>;
765
- /**
766
- * Deep-merge a {@link PartialTheme} over a set of defaults.
767
- *
768
- * Primitive fields are replaced; nested objects (`angles`,
769
- * `semanticHues`, `lightness`, `tones`, `chroma`, `semanticMappings`, `contexts`)
770
- * are merged key-by-key. Arrays (`stylesheets`) are replaced
771
- * wholesale.
772
- *
773
- * @param defaults The fully-resolved base theme.
774
- * @param overrides User-supplied partial overrides.
775
- * @returns A new fully-resolved {@link EspalierTheme}.
776
- */
777
- export declare function mergeTheme(defaults: EspalierTheme, overrides: PartialTheme): EspalierTheme;
778
- /**
779
- * Compile a named context over a resolved theme — the exact theme a
780
- * `context="<name>"` zone renders (ESP0175).
781
- *
782
- * This is the same compilation `esp-element-base` performs for a zone
783
- * host, exported so a check script or the fit report can inspect a
784
- * context surface without a DOM: role rebindings, the partial lightness ramp,
785
- * and custom tones merge over the root theme, and any context-level
786
- * `semanticMappings` layer on top as explicit token pins. Returns `null` when
787
- * the theme does not define the context.
788
- *
789
- * @param theme A resolved theme (as `mergeTheme` returns).
790
- * @param name The context name a zone would set in its attribute.
791
- */
792
- export declare function resolveContextTheme(theme: EspalierTheme, name: string): EspalierTheme | null;
793
- /**
794
- * Validate a single encoded theme partial.
795
- *
796
- * Structural grammar aside, the advisory checks (the status-collision
797
- * warning and chroma-band provenance) resolve the partial against
798
- * {@link DEFAULT_LIGHT_THEME}. A partial written for the dark side of a
799
- * pair should be validated through {@link validateThemePair}, which
800
- * audits it against the dark defaults instead.
801
- */
802
- export declare function validateTheme(base64: string): ThemeValidationResult;
803
- /**
804
- * Validate the light and dark partials that form one scheme-paired theme.
805
- *
806
- * Each side runs the same validation as {@link validateTheme}, with one
807
- * scheme-aware difference: the dark partial's advisory checks resolve
808
- * against {@link DEFAULT_DARK_THEME}, so a collision that only appears
809
- * through the dark ramp is caught. Once both sides are structurally
810
- * valid, their context-name sets must match exactly so a stable
811
- * `context` attribute cannot silently change meaning when the scheme
812
- * changes.
813
- */
814
- export declare function validateThemePair(lightBase64: string, darkBase64: string): ThemeValidationResult;
815
- /**
816
- * Keys of {@link EspalierTheme} whose values are nested objects
817
- * and therefore need key-by-key merging instead of wholesale
818
- * replacement when combining two {@link PartialTheme} objects.
819
- */
820
- export declare const NESTED_THEME_KEYS: readonly ["anchors", "angles", "contexts", "dataPalette", "dataRamps", "intents", "roles", "chroma", "lightness", "tones", "semanticHues", "semanticMappings", "variantChroma"];
821
- /**
822
- * Deep-merge two {@link PartialTheme} objects.
823
- *
824
- * Top-level primitive fields are replaced by the override when the
825
- * override value is not `undefined`. Override keys that are
826
- * explicitly `undefined` are skipped so they don't erase
827
- * previously-layered values.
828
- *
829
- * Nested-object fields listed in {@link NESTED_THEME_KEYS} are
830
- * merged key-by-key (also skipping `undefined` inner values) so
831
- * that the override adds to (rather than replaces) the base.
832
- *
833
- * This differs from {@link mergeTheme}, which merges a
834
- * {@link PartialTheme} over a fully-resolved {@link EspalierTheme}.
835
- * `mergePartials` keeps the result partial — useful when layering
836
- * multiple partial overrides before resolving against defaults.
837
- *
838
- * @param base The base partial theme.
839
- * @param override Partial overrides to apply on top.
840
- * @returns A new {@link PartialTheme} with merged values.
841
- */
842
- export declare function mergePartials(base: PartialTheme, override: PartialTheme): PartialTheme;
843
- /**
844
- * Layer multiple encoded theme strings into a single encoded result.
845
- *
846
- * Each argument is a Base64-encoded JSON {@link PartialTheme} (as
847
- * produced by {@link encodeTheme}). They are parsed, merged left
848
- * to right via {@link mergePartials}, and re-encoded.
849
- *
850
- * Entries that are `null`, `undefined`, empty strings, or strings
851
- * that fail to decode/parse are silently skipped, making it safe
852
- * to pass optional or potentially-invalid theme overrides without
853
- * conditional logic.
854
- *
855
- * @param encodedThemes Variadic encoded theme strings.
856
- * @returns A single Base64-encoded merged theme.
857
- */
858
- export declare function layerThemes(...encodedThemes: Array<string | undefined | null>): string;
859
- /**
860
- * Build the Taproot **light** default theme as an encoded string.
861
- *
862
- * @param backgroundImageUrl URL of the page background image
863
- * (e.g. a manifest-hashed asset path or a static path).
864
- * Wrapped in `url("…")` automatically — the URL is escaped
865
- * so special characters cannot break the CSS context.
866
- * @returns A Base64-encoded {@link PartialTheme}.
867
- */
868
- export declare function buildTaprootLightTheme(backgroundImageUrl: string): string;
869
- /**
870
- * Build the Taproot **dark** default theme as an encoded string.
871
- *
872
- * @param backgroundImageUrl URL of the page background image
873
- * (e.g. a manifest-hashed asset path or a static path).
874
- * Wrapped in `url("…")` automatically — the URL is escaped
875
- * so special characters cannot break the CSS context.
876
- * @returns A Base64-encoded {@link PartialTheme}.
877
- */
878
- export declare function buildTaprootDarkTheme(backgroundImageUrl: string): string;