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