@tenphi/glaze 0.0.0-snapshot.f3bb46b → 0.0.0-snapshot.f404191

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/dist/index.d.cts CHANGED
@@ -1,91 +1,263 @@
1
1
  //#region src/contrast-solver.d.ts
2
- /**
3
- * OKHSL Contrast Solver
4
- *
5
- * Finds the closest OKHSL lightness that satisfies a WCAG 2 contrast target
6
- * against a base color. Used by glaze when resolving dependent colors
7
- * with `contrast`.
8
- */
9
2
  type LinearRgb = [number, number, number];
10
3
  type ContrastPreset = 'AA' | 'AAA' | 'AA-large' | 'AAA-large';
11
4
  type MinContrast$1 = number | ContrastPreset;
12
- interface FindLightnessForContrastOptions {
5
+ /**
6
+ * Named APCA Lc floor presets (APCA Bronze Simple Mode conformance levels),
7
+ * independent of role. Use them anywhere an APCA target is accepted.
8
+ *
9
+ * | Preset | Lc | Use case |
10
+ * | ------------- | --- | ---------------------------------------------------- |
11
+ * | `'preferred'` | 90 | Preferred body / column text |
12
+ * | `'body'` | 75 | Minimum body / column text |
13
+ * | `'content'` | 60 | Readable non-body content (~WCAG AA 4.5:1) |
14
+ * | `'large'` | 45 | Large/bold headlines; fine icons/outlines (~3:1) |
15
+ * | `'non-text'` | 30 | Solid icons/controls; placeholder/disabled text |
16
+ * | `'min'` | 15 | Dividers/decorative; APCA "point of invisibility" |
17
+ */
18
+ type ApcaPreset = 'preferred' | 'body' | 'content' | 'large' | 'non-text' | 'min';
19
+ declare const APCA_PRESETS: Record<ApcaPreset, number>;
20
+ /**
21
+ * APCA-W3 "Enhanced Level" delta added to a bare APCA target in high-contrast
22
+ * mode when no explicit HC value is provided (analogous to WCAG AAA over AA).
23
+ * Only applied when neither the outer `contrast` pair nor the inner `apca`
24
+ * pair carries an explicit HC entry.
25
+ */
26
+ declare const APCA_HC_ENHANCEMENT = 15;
27
+ /** Upper bound for an APCA Lc target after HC enhancement. */
28
+ declare const APCA_MAX_LC = 106;
29
+ /**
30
+ * Resolve an APCA target — a raw Lc number (kept as-is) or an `ApcaPreset`
31
+ * keyword mapped to its Lc value. The magnitude is forced non-negative.
32
+ */
33
+ declare function resolveApcaTarget(value: number | ApcaPreset): number;
34
+ /** Metric + numeric target after resolving a `ContrastSpec` for a mode. */
35
+ interface ResolvedContrast {
36
+ metric: 'wcag' | 'apca';
37
+ /** WCAG ratio (>= 1) or APCA Lc magnitude (0–106). */
38
+ target: number;
39
+ /**
40
+ * APCA argument order: which side the resolved (candidate) color plays
41
+ * against the base. `'fg'` (default) → `apcaContrast(yCandidate, yBase)`;
42
+ * `'bg'` → `apcaContrast(yBase, yCandidate)`. Always `'fg'` for WCAG
43
+ * (symmetric, ignored).
44
+ */
45
+ polarity?: 'fg' | 'bg';
46
+ }
47
+ declare function resolveMinContrast(value: MinContrast$1): number;
48
+ /**
49
+ * Resolve a `ContrastSpec` (already selected from any outer HC pair) for a
50
+ * given mode into `{ metric, target }`. Handles the inner metric HC pair and
51
+ * preset resolution. `polarity` is passed through to the result for the APCA
52
+ * branch (it controls argument order in the solver); WCAG ignores it.
53
+ *
54
+ * `outerExplicitHC` indicates whether the caller selected this `spec` from an
55
+ * explicit high-contrast entry of the outer `contrast` pair. Together with the
56
+ * inner metric pair, it decides whether the HC auto-enhancement fires:
57
+ * - APCA: +15 Lc "Enhanced Level" boost when neither level is explicit.
58
+ * - WCAG: AA → AAA / AA-large → AAA-large promotion (SC 1.4.3 → 1.4.6) when
59
+ * neither level is explicit. AAA-family presets and bare numbers are left
60
+ * unchanged (AAA is the top WCAG tier).
61
+ * Defaults to `false` (correct for direct callers, which pass a single
62
+ * selected spec rather than an outer pair).
63
+ */
64
+ declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean, polarity?: 'fg' | 'bg', outerExplicitHC?: boolean): ResolvedContrast;
65
+ /**
66
+ * Resolve a `contrast` spec — including its outer `[normal, highContrast]`
67
+ * pair — at a manual contrast `level` (0–100), by resolving both ends and
68
+ * interpolating the numeric target.
69
+ *
70
+ * Level 0 / 100 delegate verbatim to {@link resolveContrastForMode}, so the
71
+ * endpoints are bit-identical to classic normal / high-contrast resolution.
72
+ * Resolving each end fully first also means every rule that governs the
73
+ * escalation still applies at both ends for free: preset mapping, the
74
+ * `APCA_MAX_LC` clamp, and the explicit-HC suppression that cancels the
75
+ * `AA → AAA` promotion and the `+15 Lc` enhancement.
76
+ *
77
+ * Throws when the two ends measure in different metrics — a WCAG ratio and an
78
+ * APCA Lc live on different scales, so there is no target between them. Such a
79
+ * pair is rejected at authoring time by `validateColorDefs`; this is the guard
80
+ * for direct callers.
81
+ */
82
+ declare function resolveContrastForLevel(spec: HCPair<ContrastSpec>, level: number, polarity?: 'fg' | 'bg'): ResolvedContrast;
83
+ /**
84
+ * APCA lightness contrast (Lc), signed: positive for dark text on light bg,
85
+ * negative for light text on dark bg. Inputs are screen luminances (0–1).
86
+ */
87
+ declare function apcaContrast(yText: number, yBg: number): number;
88
+ interface FindToneForContrastOptions {
13
89
  /** Hue of the candidate color (0–360). */
14
90
  hue: number;
15
91
  /** Saturation of the candidate color (0–1). */
16
92
  saturation: number;
17
- /** Preferred lightness of the candidate (0–1). */
18
- preferredLightness: number;
19
- /** Base/reference color as linear sRGB (channels may be outside 0–1 before clamp). */
20
- baseLinearRgb: [number, number, number];
21
- /** WCAG contrast ratio target floor. */
22
- contrast: MinContrast$1;
23
- /** Search bounds for lightness. Default: [0, 1]. */
24
- lightnessRange?: [number, number];
93
+ /** Preferred tone of the candidate (0–1). */
94
+ preferredTone: number;
95
+ /** Base/reference color as linear sRGB. */
96
+ baseLinearRgb: LinearRgb;
97
+ /** Resolved contrast floor (metric + target). */
98
+ contrast: ResolvedContrast;
99
+ /** Search bounds for tone. Default: [0, 1]. */
100
+ toneRange?: [number, number];
25
101
  /** Convergence threshold. Default: 1e-4. */
26
102
  epsilon?: number;
27
- /** Maximum binary-search iterations per branch. Default: 14. */
103
+ /** Maximum binary-search iterations per branch. Default: 18. */
28
104
  maxIterations?: number;
105
+ /**
106
+ * Preferred search direction before auto-flip is considered. Default: the
107
+ * side whose bound scores higher (the only open side when `preferredTone`
108
+ * sits on a bound); a tie within float noise starts `'darker'`.
109
+ */
110
+ initialDirection?: 'lighter' | 'darker';
111
+ /**
112
+ * Also search the opposite direction. Default: false. When both directions
113
+ * meet the target, the result nearer `preferredTone` wins; a gap within
114
+ * twice the search resolution is a tie and keeps `initialDirection`.
115
+ */
116
+ flip?: boolean;
117
+ /**
118
+ * When `flip` is on and *both* directions meet the target, keep
119
+ * `initialDirection` instead of taking whichever result lands nearer the
120
+ * preferred tone. Default: false (nearest wins).
121
+ *
122
+ * The nearest-wins tie-break is unstable along a ramp of targets: which side
123
+ * is nearer shifts as the target grows, so a color can swap sides between two
124
+ * adjacent targets. Set this when a caller needs the side to be a property of
125
+ * the color rather than of the target — the manual contrast level does. The
126
+ * flip itself is unaffected: an initial direction that cannot reach the
127
+ * target still falls back to the opposite side.
128
+ */
129
+ preferInitial?: boolean;
130
+ /** Use the hue-independent "safe" chroma boundary. Default: false. */
131
+ pastel?: boolean;
29
132
  }
30
- interface FindLightnessForContrastResult {
31
- /** Chosen lightness in 0–1. */
32
- lightness: number;
33
- /** Achieved WCAG contrast ratio. */
133
+ interface FindToneForContrastResult {
134
+ /** Chosen tone in 0–1. */
135
+ tone: number;
136
+ /** Achieved score (WCAG ratio or APCA Lc magnitude). */
34
137
  contrast: number;
35
138
  /** Whether the target was reached. */
36
139
  met: boolean;
37
- /** Which branch was selected. */
140
+ /**
141
+ * The side the result was found on. The two sides meet at `preferredTone`,
142
+ * so a met result sits on that side of the base too. `'preferred'` whenever
143
+ * a met result is `preferredTone` itself: it already cleared the
144
+ * overshooting search target, or it clears the bare target and no search
145
+ * could improve on it — no searched side met the floor, or the starting
146
+ * side's only position was `preferredTone` (it sits on that side's bound).
147
+ * Also `'preferred'` when `toneRange` leaves no room to search, met or not.
148
+ * An unmet result otherwise reports the side whose extreme it pinned to.
149
+ */
38
150
  branch: 'lighter' | 'darker' | 'preferred';
151
+ /** Whether the result auto-flipped to the opposite direction. */
152
+ flipped?: boolean;
39
153
  }
40
- declare function resolveMinContrast(value: MinContrast$1): number;
41
154
  /**
42
- * Find the OKHSL lightness that satisfies a WCAG 2 contrast target
43
- * against a base color, staying as close to `preferredLightness` as possible.
155
+ * Find the tone that satisfies a contrast floor against a base color,
156
+ * staying as close to `preferredTone` as possible. A searched result keeps the
157
+ * overshoot (1% for WCAG, 0.5 Lc for APCA). When no searched side reaches the
158
+ * floor, the result pins to the initial direction's extreme, unmet — unless
159
+ * `preferredTone` itself clears the bare target, which is then kept as met
160
+ * (`branch: 'preferred'`, the same label a met result gets when the starting
161
+ * side's only position is `preferredTone`).
44
162
  */
45
- declare function findLightnessForContrast(options: FindLightnessForContrastOptions): FindLightnessForContrastResult;
163
+ declare function findToneForContrast(options: FindToneForContrastOptions): FindToneForContrastResult;
46
164
  interface FindValueForMixContrastOptions {
47
165
  /** Preferred mix parameter (0–1). */
48
166
  preferredValue: number;
49
- /** Base color as linear sRGB. */
167
+ /** Base color as linear sRGB — the color the mix is measured against. */
50
168
  baseLinearRgb: LinearRgb;
51
- /** Target color as linear sRGB. */
52
- targetLinearRgb: LinearRgb;
53
- /** WCAG contrast target. */
54
- contrast: MinContrast$1;
169
+ /** Resolved contrast floor (metric + target). */
170
+ contrast: ResolvedContrast;
55
171
  /**
56
- * Compute the luminance of the mixed color at parameter t.
57
- * For opaque: luminance of OKHSL-interpolated color.
58
- * For transparent: luminance of alpha-composited color over base.
172
+ * Luminance of the mixed color at parameter t, in the metric's basis
173
+ * ({@link metricLuminance}). This closure is the only view the solver has of
174
+ * the mix's target color, blend, and color space.
59
175
  */
60
176
  luminanceAtValue: (t: number) => number;
61
177
  /** Convergence threshold. Default: 1e-4. */
62
178
  epsilon?: number;
63
179
  /** Maximum binary-search iterations per branch. Default: 20. */
64
180
  maxIterations?: number;
181
+ /** Auto-flip mix direction when contrast can't be met. Default: false. */
182
+ flip?: boolean;
65
183
  }
66
184
  interface FindValueForMixContrastResult {
67
- /** Chosen mix parameter (0–1). */
68
185
  value: number;
69
- /** Achieved WCAG contrast ratio. */
70
186
  contrast: number;
71
- /** Whether the target was reached. */
72
187
  met: boolean;
188
+ flipped?: boolean;
73
189
  }
74
190
  /**
75
- * Find the mix parameter (ratio or opacity) that satisfies a WCAG 2 contrast
76
- * target against a base color, staying as close to `preferredValue` as possible.
191
+ * Find the mix parameter (ratio or opacity) that satisfies a contrast floor
192
+ * against a base color, staying as close to `preferredValue` as possible.
193
+ * Misses pin to the initial direction's end like the tone solver, and a
194
+ * `preferredValue` that clears the bare target is kept as met when no searched
195
+ * side reaches the floor (a value of 1 has no room toward the target).
77
196
  */
78
197
  declare function findValueForMixContrast(options: FindValueForMixContrastOptions): FindValueForMixContrastResult;
79
198
  //#endregion
80
199
  //#region src/types.d.ts
81
200
  /** A value or [normal, high-contrast] pair. */
82
201
  type HCPair<T> = T | [T, T];
202
+ /** Bare WCAG contrast target: a ratio number or a named preset. */
83
203
  type MinContrast = number | ContrastPreset;
204
+ /**
205
+ * A contrast floor with a pluggable metric.
206
+ *
207
+ * - `number` / `ContrastPreset`: a WCAG ratio (bare form).
208
+ * - `{ wcag }`: WCAG ratio or preset, optionally an HC pair.
209
+ * - `{ apca }`: APCA Lc target (absolute value or preset), optionally an HC pair.
210
+ *
211
+ * The `[normal, highContrast]` pair may live at the outer level
212
+ * (`[4.5, 7]`, `[{ wcag: 4.5 }, { wcag: 7 }]`) or inside the metric
213
+ * (`{ wcag: [4.5, 7] }`, `{ apca: [45, 60] }`, `{ apca: ['content', 'body'] }`).
214
+ */
215
+ type ContrastSpec = number | ContrastPreset | {
216
+ wcag: HCPair<number | ContrastPreset>;
217
+ } | {
218
+ apca: HCPair<number | ApcaPreset>;
219
+ };
220
+ /**
221
+ * The semantic role a color plays against its base, used to fix APCA contrast
222
+ * polarity (which side is the foreground vs the background). WCAG is
223
+ * symmetric, so role never changes WCAG results.
224
+ */
225
+ type Role = 'text' | 'surface' | 'border';
226
+ /**
227
+ * Any string accepted as a `role`. Canonical values plus aliases normalized by
228
+ * `normalizeRole` (see `roles.ts`): `surface` (bg/background/fill/canvas/
229
+ * paper/layer), `text` (fg/foreground/content/ink/label/stroke), `border`
230
+ * (divider/outline/separator/hairline/rule).
231
+ */
232
+ type RoleInput = Role | 'bg' | 'background' | 'fill' | 'canvas' | 'paper' | 'layer' | 'fg' | 'foreground' | 'content' | 'ink' | 'label' | 'stroke' | 'divider' | 'outline' | 'separator' | 'hairline' | 'rule';
84
233
  type AdaptationMode = 'auto' | 'fixed' | 'static';
85
234
  /** A signed relative offset string, e.g. '+20' or '-15.5'. */
86
235
  type RelativeValue = `+${number}` | `-${number}`;
236
+ /**
237
+ * Force a color to a tone extreme:
238
+ * - `'max'`: the highest tone in the active scheme range/window.
239
+ * - `'min'`: the lowest tone.
240
+ *
241
+ * Under `mode: 'auto'` the extreme inverts in the dark scheme (so `'max'`
242
+ * tracks the inversion and becomes the darkest tone). No `base` required.
243
+ */
244
+ type ExtremeValue = 'max' | 'min';
245
+ /**
246
+ * A tone value as authored on a color.
247
+ * - Number: absolute tone (0–100).
248
+ * - `'+N'` / `'-N'`: relative to the base's tone (requires `base`).
249
+ * - `'max'` / `'min'`: forced to the scheme's tone extreme (no base needed).
250
+ */
251
+ type ToneValue = number | RelativeValue | ExtremeValue;
87
252
  /** Color format for output. */
88
- type GlazeColorFormat = 'okhsl' | 'rgb' | 'hsl' | 'oklch';
253
+ type GlazeColorFormat = 'okhsl' | 'okhst' | 'rgb' | 'hsl' | 'oklch';
254
+ /**
255
+ * Output format for an HDR glow value (`glaze.formatHdr()`). Only
256
+ * `'srgb-linear'` — `color(srgb-linear R G B)` with channels that may exceed
257
+ * 1 — since OKLCH lightness clamps at parse time and `rgb()` / `hsl()` cannot
258
+ * go past white.
259
+ */
260
+ type GlazeHdrFormat = 'srgb-linear';
89
261
  /**
90
262
  * Controls which scheme variants are generated in the export.
91
263
  * Light is always included (it's the default).
@@ -93,8 +265,29 @@ type GlazeColorFormat = 'okhsl' | 'rgb' | 'hsl' | 'oklch';
93
265
  interface GlazeOutputModes {
94
266
  /** Include dark scheme variants. Default: true. */
95
267
  dark?: boolean;
96
- /** Include high-contrast variants (both light-HC and dark-HC). Default: false. */
268
+ /**
269
+ * Include high-contrast variants (both light-HC and dark-HC). Default: false.
270
+ *
271
+ * Independent of `contrastLevel` — the level positions the normal variants
272
+ * while these stay the true high-contrast resolution, so the two compose. The
273
+ * exception is a global level of 100, where the normal variants already *are*
274
+ * the high-contrast ones: the tier would duplicate them and is dropped.
275
+ * @see GlazeConfig.contrastLevel
276
+ */
97
277
  highContrast?: boolean;
278
+ /**
279
+ * Include the HDR tier of glows past SDR white (`variant.hdr`, set by
280
+ * `GlowTuning.headroom`). Default: false — every exporter's output stays
281
+ * byte-identical to SDR even when a headroom is set.
282
+ *
283
+ * When on, each exporter adds the HDR values next to the SDR ones it
284
+ * already emits (only for the scheme variants the other modes include),
285
+ * always written as `color(srgb-linear R G B)`: Tasty `hdr` state keys,
286
+ * `json()` `lightHdr` / `darkHdr` / … keys, `tokens()` `lightHdr` / … maps,
287
+ * Tailwind blocks under `hdrSelector`, DTCG `$extensions`. `css()` reads
288
+ * its own `hdr` option, which falls back to this.
289
+ */
290
+ hdr?: boolean;
98
291
  }
99
292
  /** Hex color string for DX hints. Runtime validation in `parseHex()`. */
100
293
  type HexColor = `#${string}`;
@@ -104,14 +297,66 @@ interface OkhslColor {
104
297
  s: number;
105
298
  l: number;
106
299
  }
300
+ /**
301
+ * Direct OKHST color input — OKHSL with the lightness axis replaced by the
302
+ * contrast-uniform tone axis. `h`: 0–360, `s`: 0–1, `t`: 0–1 (tone).
303
+ */
304
+ interface OkhstColor {
305
+ h: number;
306
+ s: number;
307
+ t: number;
308
+ }
309
+ /** sRGB components in 0–255 (value-shorthand object form). */
310
+ interface RgbColor {
311
+ r: number;
312
+ g: number;
313
+ b: number;
314
+ }
315
+ /** OKLCh components matching CSS `oklch(L C H)` (L/C: 0–1, H: degrees). */
316
+ interface OklchColor {
317
+ l: number;
318
+ c: number;
319
+ h: number;
320
+ }
107
321
  interface RegularColorDef {
108
322
  /**
109
- * Lightness value (0–100).
110
- * - Number: absolute lightness.
111
- * - String ('+N' / '-N'): relative to base color's lightness (requires `base`).
323
+ * Seed this color from a literal color instead of from the theme.
324
+ *
325
+ * Accepts the same values as `glaze.color()` — hex, `rgb()`, `hsl()`,
326
+ * `okhsl()`, `okhst()`, `oklch()`, or a value object. It supplies three
327
+ * things at once: `hue`, `tone`, and — unlike every other color in a theme —
328
+ * an **absolute saturation** rather than a factor of the seed. That last
329
+ * part is the point: a color can now be more saturated than its theme, so
330
+ * honoring a brand color no longer means re-seeding the whole theme to reach
331
+ * it.
332
+ *
333
+ * The **light, normal-contrast** variant reproduces the value exactly
334
+ * (a local `lightTone: false`, matching the value-shorthand form of
335
+ * `glaze.color()`). Dark and high-contrast variants adapt as usual — they
336
+ * are where readability outranks fidelity, and a color pinned across every
337
+ * scheme would defeat both. A `contrast` floor still applies everywhere and
338
+ * still only moves the color when the authored value misses it.
339
+ *
340
+ * Sibling fields override what the value supplied, so
341
+ * `{ from: '#2F5BFF', hue: 300 }` keeps its saturation and tone but rotates
342
+ * the hue.
343
+ */
344
+ from?: GlazeColorValue;
345
+ /**
346
+ * Tone value (0–100, contrast-uniform — see `docs/okhst.mdx`).
347
+ * - Number: absolute tone.
348
+ * - String ('+N' / '-N'): relative to base color's tone (requires `base`).
349
+ * - `'max'` / `'min'`: force to the scheme's tone extreme (no base needed).
350
+ *
351
+ * Defaults to the tone of `from` when that is set.
352
+ */
353
+ tone?: HCPair<ToneValue>;
354
+ /**
355
+ * Saturation factor applied to the seed saturation (0–1, default: 1).
356
+ *
357
+ * With `from`, an explicit value here is still a factor of the seed and
358
+ * overrides the absolute saturation the color carried.
112
359
  */
113
- lightness?: HCPair<number | RelativeValue>;
114
- /** Saturation factor applied to the seed saturation (0–1, default: 1). */
115
360
  saturation?: number;
116
361
  /**
117
362
  * Hue override for this color.
@@ -119,64 +364,224 @@ interface RegularColorDef {
119
364
  * - String ('+N' / '-N'): relative to the theme seed hue.
120
365
  */
121
366
  hue?: number | RelativeValue;
367
+ /**
368
+ * Dark-scheme hue override. Applies to the `dark` and `darkContrast`
369
+ * variants; falls back to `hue` when omitted.
370
+ * - Number: absolute hue (0–360).
371
+ * - String ('+N' / '-N'): relative to the theme's **dark** seed hue
372
+ * (`GlazeTheme.darkHue`, itself defaulting to the light seed hue).
373
+ *
374
+ * Ignored under `mode: 'static'`, which pins one value across all schemes.
375
+ */
376
+ darkHue?: number | RelativeValue;
377
+ /**
378
+ * Dark-scheme saturation factor (0–1) applied to the dark seed
379
+ * saturation. Applies to the `dark` and `darkContrast` variants; falls
380
+ * back to `saturation` when omitted.
381
+ *
382
+ * When set, the global `darkDesaturation` reduction is **not** applied on
383
+ * top — the resulting saturation is taken literally. Ignored under
384
+ * `mode: 'static'`.
385
+ */
386
+ darkSaturation?: number;
122
387
  /** Name of another color in the same theme (dependent color). */
123
388
  base?: string;
124
- /** WCAG contrast ratio floor against the base color. */
125
- contrast?: HCPair<MinContrast>;
389
+ /**
390
+ * Contrast floor against the base color. A bare number/preset is WCAG;
391
+ * use `{ wcag }` / `{ apca }` to pick the metric. Accepts an HC pair.
392
+ */
393
+ contrast?: HCPair<ContrastSpec>;
126
394
  /** Adaptation mode. Default: 'auto'. */
127
395
  mode?: AdaptationMode;
396
+ /**
397
+ * Whether to flip out-of-bounds results to the opposite side instead of
398
+ * clamping to the extreme. Affects both:
399
+ * - relative `tone`: when `base ± delta` exceeds `[0, 100]`, mirror the
400
+ * delta to the other side of the base. If the mirrored target is also
401
+ * out of range, keep the original delta and clamp on the authored side.
402
+ * - `contrast`: when the requested direction can't meet the floor, try the
403
+ * opposite side (same as the global `autoFlip`).
404
+ *
405
+ * Defaults to the global `autoFlip` config (default `true`). Set `false`
406
+ * to clamp instead.
407
+ */
408
+ autoFlip?: boolean;
128
409
  /**
129
410
  * Fixed opacity (0–1).
130
411
  * Output includes alpha in the CSS value.
131
412
  * Does not affect contrast resolution — a semi-transparent color
132
- * has no fixed perceived lightness, so `contrast` and `opacity`
413
+ * has no fixed perceived tone, so `contrast` and `opacity`
133
414
  * should not be combined (a console.warn is emitted).
134
415
  */
135
416
  opacity?: number;
417
+ /**
418
+ * Per-color override for the hue-independent "safe" chroma limit used in
419
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
420
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
421
+ * @see GlazeConfigOverride.pastel
422
+ */
423
+ pastel?: boolean;
424
+ /**
425
+ * Semantic role against `base`: how this color is used. Fixes APCA contrast
426
+ * polarity (the argument order in `apcaContrast`). WCAG is symmetric so it
427
+ * never affects WCAG results.
428
+ *
429
+ * Resolution: explicit `role` wins; else inferred from the color name when
430
+ * `inferRole` is enabled (default); else the opposite of the base's role;
431
+ * else defaults to `'text'` (foreground).
432
+ */
433
+ role?: RoleInput;
434
+ /**
435
+ * Whether this color is inherited by child themes created via `extend()`.
436
+ * Default: true. Set to false to make this color local to the current theme.
437
+ */
438
+ inherit?: boolean;
136
439
  }
137
- /** Shadow tuning knobs. All values use the 0–1 scale (OKHSL). */
138
- interface ShadowTuning {
139
- /** Fraction of fg saturation kept in pigment (0-1). Default: 0.18. */
140
- saturationFactor?: number;
141
- /** Upper clamp on pigment saturation (0-1). Default: 0.25. */
142
- maxSaturation?: number;
143
- /** Multiplier for bg lightness → pigment lightness. Default: 0.25. */
144
- lightnessFactor?: number;
145
- /** [min, max] clamp for pigment lightness (0-1). Default: [0.05, 0.20]. */
146
- lightnessBounds?: [number, number];
440
+ /**
441
+ * Tuning shared by `shadow` and `glow`. Global defaults come from
442
+ * `shadowTuning` / `glowTuning`; a per-color `tuning` merges over them field
443
+ * by field.
444
+ */
445
+ interface LightingTuning {
446
+ /**
447
+ * β — how strongly the object (`fg`) scales the step. The step is
448
+ * `intensity × k` with `k = max(0, 1 + β · d · (t_bg − t_fg) / 100)`,
449
+ * `d = +1` for a shadow and `−1` for a glow: a darker object deepens its
450
+ * shadow, a lighter one strengthens its glow. An object at the surface's
451
+ * own tone (or no `fg`) gives exactly `intensity`. `0` ignores the object.
452
+ * Default: 0.5.
453
+ */
454
+ objectInfluence?: number;
147
455
  /**
148
- * Target minimum gap between pigment lightness and bg lightness (0-1).
149
- * Default: 0.05.
456
+ * Pigment saturation (0–1) in the surface's hue. Default: 0 (neutral black /
457
+ * white). Shows only with `reach` below 1 — pure black and white have no hue.
458
+ * A neutral surface has no hue either: there the tint takes the object's
459
+ * hue with `hueBleed` above 0, and the pigment stays neutral otherwise.
150
460
  */
151
- minGapTarget?: number;
152
- /** Max alpha (0-1). Reached at intensity=100 with max contrast. Default: 1.0. */
153
- alphaMax?: number;
461
+ tint?: number;
154
462
  /**
155
- * Blend weight (0-1) pulling pigment hue toward bg hue.
156
- * 0 = pure fg hue, 1 = pure bg hue. Default: 0.2.
463
+ * Where the pigment sits (0–1): the fraction of the way from the surface's
464
+ * tone to black (shadow) / white (glow). Default: 1 (pure black / white),
465
+ * the most reach. Lower values let a `tint` show at the cost of reach.
157
466
  */
158
- bgHueBlend?: number;
467
+ reach?: number;
468
+ /**
469
+ * Pull (0–1) of the pigment hue from the surface's hue toward the object's
470
+ * (`fg`) hue. Default: 0. Needs `fg`, a `tint`, and `reach` below 1 to show.
471
+ */
472
+ hueBleed?: number;
159
473
  }
474
+ /**
475
+ * Tuning for `shadow` colors: the shared {@link LightingTuning}. It has no
476
+ * `headroom` — a shadow darkens toward black, and nothing goes below black —
477
+ * so a `headroom` set on a shadow's tuning throws.
478
+ */
479
+ type ShadowTuning = LightingTuning;
480
+ /** Tuning for `glow` colors: the shared {@link LightingTuning} plus HDR `headroom`. */
481
+ interface GlowTuning extends LightingTuning {
482
+ /**
483
+ * Stops above SDR white a glow may use when its step crosses white. Default:
484
+ * 0 (SDR only). Counted in stops — doublings of SDR white's luminance — not
485
+ * as a ratio: `1` allows up to 2× white, `2` up to 4×. Must be a finite
486
+ * number ≥ 0; values above 2 clamp to 2 with a one-time warning.
487
+ *
488
+ * Only a glow whose target tone (surface tone + `intensity × k`) passes 100
489
+ * gets an HDR value: the variant's `hdr`, an opaque exposure of what SDR
490
+ * paints at its brightest — the pigment at full opacity, or a white surface
491
+ * no pigment can lift — plus a gain in stops. A pigment that cannot lift a
492
+ * non-white surface at all (`reach: 0` on a gray surface, say) paints
493
+ * nothing in SDR, so it gets no HDR value either and keeps the SDR "cannot
494
+ * reach" warning. On a chromatic surface a `reach: 0` gray can measure
495
+ * slightly brighter than the surface and pins at full opacity instead.
496
+ * Nothing about the SDR variant changes. The gain lands the exact step when
497
+ * the headroom allows it; the brightest channel caps at `2^headroom`.
498
+ * High-contrast schemes use the same headroom.
499
+ *
500
+ * The HDR value lands the whole step, not just the part past white. A
501
+ * full-reach glow (the default `reach: 1`) is pinned at white, so its HDR
502
+ * value starts at white (`exposure` → 0) as the target passes 100. A glow
503
+ * with `reach` below 1 is pinned at its pigment, below white: just under 100
504
+ * it stays short there (and warns), and just past 100 its HDR value jumps to
505
+ * the exact step.
506
+ */
507
+ headroom?: number;
508
+ }
509
+ /**
510
+ * A translucent dark overlay that lands the surface (`bg`) exactly
511
+ * `intensity` tones darker in every scheme — a shade for state layers and
512
+ * scrims, or, with `fg`, an object-aware drop shadow.
513
+ */
160
514
  interface ShadowColorDef {
161
515
  type: 'shadow';
162
516
  /**
163
- * Background color name — the surface the shadow sits on.
164
- * Must reference a non-shadow color in the same theme.
517
+ * The surface the shadow falls on. Must reference a color that is not a
518
+ * shadow or glow.
165
519
  */
166
520
  bg: string;
167
521
  /**
168
- * Foreground color name for tinting and intensity modulation.
169
- * Must reference a non-shadow color in the same theme.
170
- * Omit for achromatic shadow at full user-specified intensity.
522
+ * The object casting the shadow (e.g. the card). A darker object casts a
523
+ * deeper shadow, a lighter one a softer shadow — see
524
+ * `LightingTuning.objectInfluence`. Omit for an exact shade of `intensity`
525
+ * tones. Must reference a color that is not a shadow or glow.
171
526
  */
172
527
  fg?: string;
173
528
  /**
174
- * Shadow intensity, 0-100.
529
+ * Tone step, 0–100: how many tones darker than `bg` the composite lands.
175
530
  * Supports [normal, highContrast] pair.
176
531
  */
177
532
  intensity: HCPair<number>;
178
533
  /** Override default tuning. Merged field-by-field with global `shadowTuning`. */
179
534
  tuning?: ShadowTuning;
535
+ /**
536
+ * Per-color override for the hue-independent "safe" chroma limit used in
537
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
538
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
539
+ * @see GlazeConfigOverride.pastel
540
+ */
541
+ pastel?: boolean;
542
+ /**
543
+ * Whether this color is inherited by child themes created via `extend()`.
544
+ * Default: true. Set to false to make this color local to the current theme.
545
+ */
546
+ inherit?: boolean;
547
+ }
548
+ /**
549
+ * The mirror of {@link ShadowColorDef}: a translucent light overlay that lands
550
+ * the surface (`bg`) exactly `intensity` tones lighter in every scheme — for
551
+ * dark-mode elevation, edge highlights, and lightening state layers.
552
+ */
553
+ interface GlowColorDef {
554
+ type: 'glow';
555
+ /**
556
+ * The surface the glow falls on. Must reference a color that is not a
557
+ * shadow or glow.
558
+ */
559
+ bg: string;
560
+ /**
561
+ * The object emitting the glow. A lighter object glows stronger, a darker
562
+ * one weaker — see `LightingTuning.objectInfluence`. Omit for an exact tint
563
+ * of `intensity` tones. Must reference a color that is not a shadow or glow.
564
+ */
565
+ fg?: string;
566
+ /**
567
+ * Tone step, 0–100: how many tones lighter than `bg` the composite lands.
568
+ * Supports [normal, highContrast] pair.
569
+ */
570
+ intensity: HCPair<number>;
571
+ /** Override default tuning. Merged field-by-field with global `glowTuning`. */
572
+ tuning?: GlowTuning;
573
+ /**
574
+ * Per-color override for the hue-independent "safe" chroma limit used in
575
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
576
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
577
+ * @see GlazeConfigOverride.pastel
578
+ */
579
+ pastel?: boolean;
580
+ /**
581
+ * Whether this color is inherited by child themes created via `extend()`.
582
+ * Default: true. Set to false to make this color local to the current theme.
583
+ */
584
+ inherit?: boolean;
180
585
  }
181
586
  interface MixColorDef {
182
587
  type: 'mix';
@@ -199,31 +604,94 @@ interface MixColorDef {
199
604
  /**
200
605
  * Interpolation color space for opaque blending. Default: 'okhsl'.
201
606
  * - 'okhsl': perceptually uniform, consistent with Glaze's internal model.
202
- * - 'srgb': linear sRGB interpolation, matches browser compositing.
607
+ * - 'srgb': linear-light sRGB interpolation (like CSS
608
+ * `color-mix(in srgb-linear, …)`).
203
609
  *
204
- * Ignored for 'transparent' blend (always composites in linear sRGB).
610
+ * Ignored for 'transparent' blend: the browser composites that one, and
611
+ * its contrast solve models the browser (`source-over` on gamma-encoded
612
+ * sRGB).
205
613
  */
206
614
  space?: 'okhsl' | 'srgb';
207
615
  /**
208
- * Minimum WCAG contrast between the base and the resulting color.
616
+ * Minimum contrast between the base and the resulting color.
209
617
  * In 'opaque' mode, adjusts the mix ratio to meet contrast.
210
618
  * In 'transparent' mode, adjusts opacity to meet contrast against the composite.
211
- * Supports [normal, highContrast] pair.
619
+ * A bare number/preset is WCAG; use `{ wcag }` / `{ apca }` to pick the
620
+ * metric. Supports [normal, highContrast] pair.
621
+ */
622
+ contrast?: HCPair<ContrastSpec>;
623
+ /**
624
+ * Per-color override for the hue-independent "safe" chroma limit used in
625
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
626
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
627
+ * @see GlazeConfigOverride.pastel
628
+ */
629
+ pastel?: boolean;
630
+ /**
631
+ * Semantic role of the mixed result against `base`. Same semantics as
632
+ * `RegularColorDef.role` (fixes APCA polarity). Resolution and defaults
633
+ * are identical.
212
634
  */
213
- contrast?: HCPair<MinContrast>;
635
+ role?: RoleInput;
636
+ /**
637
+ * Whether this color is inherited by child themes created via `extend()`.
638
+ * Default: true. Set to false to make this color local to the current theme.
639
+ */
640
+ inherit?: boolean;
214
641
  }
215
- type ColorDef = RegularColorDef | ShadowColorDef | MixColorDef;
642
+ type ColorDef = RegularColorDef | ShadowColorDef | GlowColorDef | MixColorDef;
216
643
  type ColorMap = Record<string, ColorDef>;
217
- /** Resolved color for a single scheme variant. */
644
+ /**
645
+ * Resolved color for a single scheme variant.
646
+ *
647
+ * Stored in OKHST: `h` / `s` are OKHSL hue/saturation, `t` is the canonical
648
+ * contrast-uniform tone (0–1, reference eps). Convert to OKHSL lightness via
649
+ * `variantToOkhsl` at the rendering / luminance edges.
650
+ */
218
651
  interface ResolvedColorVariant {
219
652
  /** OKHSL hue (0–360). */
220
653
  h: number;
221
654
  /** OKHSL saturation (0–1). */
222
655
  s: number;
223
- /** OKHSL lightness (0–1). */
224
- l: number;
656
+ /** Canonical tone (0–1, reference eps). */
657
+ t: number;
225
658
  /** Opacity (0–1). Default: 1. */
226
659
  alpha: number;
660
+ /**
661
+ * Effective `pastel` flag used while resolving this variant (author def or
662
+ * config fallback). Carried on the variant so output formatting matches the
663
+ * gamut mapping applied during resolution.
664
+ */
665
+ pastel?: boolean;
666
+ /**
667
+ * HDR tier of a glow whose step crosses SDR white, present only when the
668
+ * glow's `headroom` is above 0, its target tone passes 100, and SDR is
669
+ * pinned at its brightest — the pigment at full opacity, or a white surface
670
+ * (see `GlowTuning.headroom`). Absent everywhere else — shadows, mixes,
671
+ * regular colors, a glow whose pigment cannot lift a non-white surface, and
672
+ * every glow at the default headroom of 0.
673
+ */
674
+ hdr?: ResolvedHdr;
675
+ }
676
+ /**
677
+ * The HDR value of a glow past SDR white: an opaque base plus a gain. The base
678
+ * is what SDR paints at its brightest — the glow's pigment at full opacity, or
679
+ * the white surface it cannot lift — and the HDR color is that base's linear
680
+ * sRGB times `2^exposure`. Format it with `glaze.formatHdr()`.
681
+ *
682
+ * Stored in OKHST like the variant. `s` is always standard (non-pastel)
683
+ * OKHSL saturation, whatever the variant's `pastel`, since the base is an
684
+ * arbitrary in-gamut composite.
685
+ */
686
+ interface ResolvedHdr {
687
+ /** Base OKHSL hue (0–360). */
688
+ h: number;
689
+ /** Base OKHSL saturation (0–1, non-pastel). */
690
+ s: number;
691
+ /** Base canonical tone (0–1, reference eps). */
692
+ t: number;
693
+ /** Gain over the base in stops (`log2` of the linear factor), above 0. */
694
+ exposure: number;
227
695
  }
228
696
  /** Fully resolved color across all scheme variants. */
229
697
  interface ResolvedColor {
@@ -232,68 +700,486 @@ interface ResolvedColor {
232
700
  dark: ResolvedColorVariant;
233
701
  lightContrast: ResolvedColorVariant;
234
702
  darkContrast: ResolvedColorVariant;
235
- /** Adaptation mode. Present only for regular colors, omitted for shadows. */
703
+ /** Adaptation mode of a regular color; `undefined` for shadow / glow / mix. */
236
704
  mode?: AdaptationMode;
237
705
  }
706
+ /**
707
+ * A scheme tone window.
708
+ * - `[lo, hi]`: OKHSL-lightness endpoints (0–100) the authored tone is
709
+ * remapped into, using the reference eps `0.05`. The common form.
710
+ * - `{ lo, hi, eps }`: same, with an explicit render curvature `eps`
711
+ * (advanced — most palettes never need this).
712
+ * - `false`: disable clamping (full range `[0, 100]` at the reference eps).
713
+ * This removes the *boundaries*, not the tone curve.
714
+ */
715
+ type ToneWindow = false | [number, number] | {
716
+ lo: number;
717
+ hi: number;
718
+ eps: number;
719
+ };
238
720
  interface GlazeConfig {
239
- /** Light scheme lightness window [lo, hi]. Default: [10, 100]. */
240
- lightLightness?: [number, number];
241
- /** Dark scheme lightness window [lo, hi]. Default: [15, 95]. */
242
- darkLightness?: [number, number];
721
+ /** Light scheme tone window — `[lo, hi]` (default `[10, 100]`), `{ lo, hi, eps }` for advanced eps tuning, or `false` to disable clamping. */
722
+ lightTone?: ToneWindow;
723
+ /** Dark scheme tone window — `[lo, hi]` (default `[15, 95]`), `{ lo, hi, eps }`, or `false` to disable clamping. */
724
+ darkTone?: ToneWindow;
243
725
  /** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
244
726
  darkDesaturation?: number;
245
727
  /**
246
- * Möbius beta for dark auto-inversion (0–1).
247
- * Lower values expand subtle near-white distinctions in dark mode.
248
- * Set to 1 for linear (legacy) behavior. Default: 0.5.
249
- * Accepts [normal, highContrast] pair for separate HC tuning.
728
+ * State alias names for Tasty token export. Default to media-query states
729
+ * (`'@media(prefers-color-scheme: dark)'` / `'@media(prefers-contrast: more)'`
730
+ * / `'@media(dynamic-range: high)'`) so tokens react to the OS preference
731
+ * and the display without registering custom states. `hdr` keys an HDR
732
+ * glow value and is used only with `modes.hdr`.
250
733
  */
251
- darkCurve?: HCPair<number>;
252
- /** State alias names for token export. */
253
734
  states?: {
254
735
  dark?: string;
255
736
  highContrast?: string;
737
+ hdr?: string;
256
738
  };
257
- /** Which scheme variants to include in exports. Default: both true. */
739
+ /**
740
+ * Which scheme variants to include in exports. Defaults: `dark: true`,
741
+ * `highContrast: false`, `hdr: false`.
742
+ */
258
743
  modes?: GlazeOutputModes;
259
- /** Default tuning for all shadow colors. Per-color tuning merges field-by-field. */
744
+ /**
745
+ * Default tuning for all shadow colors. Per-color tuning merges field-by-field.
746
+ * A `headroom` here throws: it is a glow-only field.
747
+ */
260
748
  shadowTuning?: ShadowTuning;
749
+ /**
750
+ * Default tuning for all glow colors, including HDR `headroom`. Per-color
751
+ * tuning merges field-by-field.
752
+ */
753
+ glowTuning?: GlowTuning;
754
+ /**
755
+ * Manual contrast level — a 0–100 slider from normal contrast (`0`) to high
756
+ * contrast (`100`), or `'auto'` (the default) to take the authored normal
757
+ * entries as-is.
758
+ *
759
+ * With a number, Glaze resolves the `light` / `dark` variants *at* that level.
760
+ * That is all it does: `lightContrast` / `darkContrast` stay the true
761
+ * high-contrast resolution at every level, and `modes.highContrast` alone
762
+ * decides whether they are emitted. Level `0` therefore reproduces `'auto'`
763
+ * bit for bit. At `100` the normal variants *are* the high-contrast ones, so a
764
+ * separate tier would duplicate them and a global level of 100 drops it.
765
+ *
766
+ * The level interpolates all three things that make high contrast differ:
767
+ * authored `[normal, highContrast]` pairs, the tone-window widening, and
768
+ * the `AA → AAA` / APCA `+15 Lc` escalation. Contrast floors are re-solved
769
+ * at the interpolated target, so every level is a solution rather than an
770
+ * approximation, and a color keeps to one side of its base as the level moves.
771
+ *
772
+ * Pass `'auto'` to leave manual mode; `configure()` never clears a field by
773
+ * omission. See `docs/reference/contrast.md` for the ramp's edge cases (un-interpolable
774
+ * pairs, side changes) and the export-freeze rule.
775
+ *
776
+ * @default 'auto'
777
+ */
778
+ contrastLevel?: number | 'auto';
779
+ /**
780
+ * Automatically flip tone direction when contrast can't be met.
781
+ *
782
+ * When enabled (default `true`), the solver searches the requested
783
+ * tone direction first. If that direction can't reach the target,
784
+ * it tries the opposite direction and uses it when it passes. If neither
785
+ * side passes, the tone is pinned to the requested-direction
786
+ * extreme and a warning is emitted.
787
+ *
788
+ * Set to `false` for strict "no flip" behavior. The opposite
789
+ * direction is never considered: if the requested direction can't
790
+ * meet the target, the tone is pinned to its extreme (never
791
+ * falls back to the originally requested tone).
792
+ */
793
+ autoFlip?: boolean;
794
+ /**
795
+ * If true (default), infer a color's `role` from its name when no explicit
796
+ * `role` is set. Set to `false` to opt out of name-based inference (the
797
+ * base-opposite and default-foreground fallbacks still apply).
798
+ * @default true
799
+ */
800
+ inferRole?: boolean;
261
801
  }
262
802
  interface GlazeConfigResolved {
263
- lightLightness: [number, number];
264
- darkLightness: [number, number];
803
+ lightTone: ToneWindow;
804
+ darkTone: ToneWindow;
265
805
  darkDesaturation: number;
266
- darkCurve: HCPair<number>;
267
806
  states: {
268
807
  dark: string;
269
808
  highContrast: string;
809
+ hdr: string;
270
810
  };
271
811
  modes: Required<GlazeOutputModes>;
272
812
  shadowTuning?: ShadowTuning;
813
+ glowTuning?: GlowTuning;
814
+ autoFlip: boolean;
815
+ /**
816
+ * Manual contrast level (0–100) for the normal variants, or `'auto'` to take
817
+ * the authored normal entries as-is.
818
+ * @see GlazeConfig.contrastLevel
819
+ */
820
+ contrastLevel: number | 'auto';
821
+ /**
822
+ * Instance-level pastel default (`def.pastel ?? config.pastel`).
823
+ * Not set via `glaze.configure()` — only via per-theme / per-token
824
+ * `GlazeConfigOverride` (default `false`).
825
+ */
826
+ pastel: boolean;
827
+ inferRole: boolean;
828
+ }
829
+ /**
830
+ * Per-instance config override for `glaze.color()` and `glaze()` themes.
831
+ * Fields that are set take priority over the live global config. Fields
832
+ * that are omitted fall through to the live global at resolve time
833
+ * (`pastel` is instance-only and defaults to `false` when omitted).
834
+ *
835
+ * `false` for a tone window disables clamping (full range at reference eps).
836
+ */
837
+ interface GlazeConfigOverride {
838
+ /** Light scheme tone window, or `false` to disable clamping. */
839
+ lightTone?: ToneWindow;
840
+ /** Dark scheme tone window, or `false` to disable clamping. */
841
+ darkTone?: ToneWindow;
842
+ /** Saturation reduction factor for dark scheme (0–1). */
843
+ darkDesaturation?: number;
844
+ /** Whether to auto-flip tone when contrast can't be met. */
845
+ autoFlip?: boolean;
846
+ /**
847
+ * Manual contrast level (0–100) for this instance, or `'auto'` to opt out of a
848
+ * global level and take the authored normal entries as-is. Either way the
849
+ * instance keeps its high-contrast tier; a per-instance level never changes
850
+ * which modes are emitted.
851
+ *
852
+ * Only an instance-authored level is frozen into `.export()` snapshots — a
853
+ * level inherited from the global config is treated as a live preference and
854
+ * re-read at restore time.
855
+ *
856
+ * @see GlazeConfig.contrastLevel
857
+ */
858
+ contrastLevel?: number | 'auto';
859
+ /**
860
+ * Instance-level pastel default for colors that omit per-color `pastel`.
861
+ * Not available on `glaze.configure()` — set here or per-color.
862
+ * @default false
863
+ */
864
+ pastel?: boolean;
865
+ /**
866
+ * If true, infer a color's `role` from its name when no explicit `role` is
867
+ * set. Falls through to the live global at resolve time when omitted.
868
+ */
869
+ inferRole?: boolean;
870
+ /**
871
+ * Shadow tuning defaults. Only meaningful for themes; harmless on
872
+ * standalone color tokens.
873
+ */
874
+ shadowTuning?: ShadowTuning;
875
+ /**
876
+ * Glow tuning defaults. Only meaningful for themes; harmless on
877
+ * standalone color tokens.
878
+ */
879
+ glowTuning?: GlowTuning;
273
880
  }
881
+ /**
882
+ * Current authoring-export schema version. Bump when the export shape
883
+ * changes in a non-compatible way. Written on every `.export()` snapshot.
884
+ *
885
+ * - `1` — Glaze 2.x.
886
+ * - `2` — Glaze 3: `shadow` `intensity` / `fg` / `tuning` changed meaning and
887
+ * `glow` was added. Version-1 theme snapshots that carry shadow defs or a
888
+ * `shadowTuning` are rejected on restore.
889
+ */
890
+ declare const GLAZE_EXPORT_VERSION: 2;
891
+ /** Literal type of {@link GLAZE_EXPORT_VERSION}. */
892
+ type GlazeExportVersion = typeof GLAZE_EXPORT_VERSION;
893
+ /** Discriminator for authoring export snapshots. */
894
+ type GlazeExportKind = 'theme' | 'color' | 'palette';
274
895
  /** Serialized theme configuration (no resolved values). */
275
896
  interface GlazeThemeExport {
897
+ /** Snapshot kind. Always written by `theme.export()`; optional on legacy hand-written configs. */
898
+ kind?: 'theme';
899
+ /** Schema version. Always written by `theme.export()`; optional on legacy configs. */
900
+ version?: number;
276
901
  hue: number;
277
902
  saturation: number;
903
+ /** Dark-scheme seed hue (0–360). Omitted when the theme reuses `hue`. */
904
+ darkHue?: number;
905
+ /** Dark-scheme seed saturation (0–100). Omitted when the theme reuses `saturation`. */
906
+ darkSaturation?: number;
278
907
  colors: ColorMap;
908
+ /**
909
+ * Effective config freeze from `.export()` —
910
+ * `getConfig() ∪ instance local ∪ exportArg`. May be sparse on legacy
911
+ * snapshots (omitted fields fall through to the live global at restore).
912
+ */
913
+ config?: GlazeConfigOverride;
279
914
  }
280
- /** Input for `glaze.shadow()` standalone factory. */
281
- interface GlazeShadowInput {
282
- /** Background color — hex string or OKHSL { h, s (0-1), l (0-1) }. */
283
- bg: HexColor | OkhslColor;
284
- /** Foreground color for tinting + intensity modulation. */
285
- fg?: HexColor | OkhslColor;
286
- /** Intensity 0-100. */
915
+ /** Input for the `glaze.shadow()` and `glaze.glow()` standalone factories. */
916
+ interface GlazeLightingInput {
917
+ /**
918
+ * The surface — accepts any `GlazeColorValue` form: hex
919
+ * (`#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa`), `rgb()` / `hsl()` /
920
+ * `okhsl()` / `okhst()` / `oklch()` strings, or literal objects
921
+ * (`{ r, g, b }`, `{ h, s, l }`, `{ h, s, t }`, `{ l, c, h }`). Alpha
922
+ * components are dropped with a warning.
923
+ */
924
+ bg: GlazeColorValue;
925
+ /** The object casting the shadow / emitting the glow. Same forms as `bg`. */
926
+ fg?: GlazeColorValue;
927
+ /** Tone step, 0–100. */
287
928
  intensity: number;
288
- tuning?: ShadowTuning;
929
+ tuning?: LightingTuning;
289
930
  }
290
- /** Input for `glaze.color()` standalone factory. */
931
+ /** Input for `glaze.shadow()`. */
932
+ type GlazeShadowInput = GlazeLightingInput;
933
+ /** Input for `glaze.glow()`: the shared input, with glow tuning (`headroom`). */
934
+ interface GlazeGlowInput extends GlazeLightingInput {
935
+ tuning?: GlowTuning;
936
+ }
937
+ /** Input for the structured `glaze.color()` overload. */
291
938
  interface GlazeColorInput {
292
939
  hue: number;
293
940
  saturation: number;
294
- lightness: HCPair<number>;
941
+ tone: HCPair<number | ExtremeValue>;
295
942
  saturationFactor?: number;
943
+ /**
944
+ * Dark-scheme hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
945
+ * to the dark seed hue, which defaults to `hue`. Falls back to `hue`.
946
+ */
947
+ darkHue?: number | RelativeValue;
948
+ /** Dark-scheme seed saturation (0–100). Defaults to `saturation`. */
949
+ darkSaturation?: number;
950
+ /** Dark-scheme multiplier on the dark seed (0–1). Defaults to `saturationFactor`. */
951
+ darkSaturationFactor?: number;
296
952
  mode?: AdaptationMode;
953
+ /** Flip out-of-bounds results instead of clamping. Default: global `autoFlip`. */
954
+ autoFlip?: boolean;
955
+ /**
956
+ * Fixed opacity (0–1). Output includes alpha in the CSS value.
957
+ * Combining with `contrast` is not recommended (perceived tone
958
+ * becomes unpredictable) — a `console.warn` is emitted in that case.
959
+ */
960
+ opacity?: number;
961
+ /**
962
+ * Optional dependency on another color. Same semantics as
963
+ * `GlazeColorOverrides.base` — `contrast` and relative `tone`
964
+ * anchor to the base per scheme.
965
+ */
966
+ base?: GlazeColorToken | GlazeColorValue;
967
+ /**
968
+ * Contrast floor. Without `base`, solved against the token's own input
969
+ * color (`hue`, `saturation`, normal `tone`), held fixed in every scheme;
970
+ * with `base`, against the base's resolved variant per scheme. A bare
971
+ * number/preset is WCAG; use `{ wcag }` / `{ apca }` to pick the metric.
972
+ */
973
+ contrast?: HCPair<ContrastSpec>;
974
+ /**
975
+ * Optional human-readable name for the token. Used in error and
976
+ * warning messages (otherwise an internal name like `"value"` is
977
+ * used) and as `resolve().name`. A debug label only: it does not
978
+ * affect output keys or the token's `role`.
979
+ */
980
+ name?: string;
981
+ /**
982
+ * Per-color override for the hue-independent "safe" chroma limit used in
983
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
984
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
985
+ * @see GlazeConfigOverride.pastel
986
+ */
987
+ pastel?: boolean;
988
+ /**
989
+ * Semantic role against the token's anchor (`base`, or its own input
990
+ * color when `contrast` is set without one): how this token is used.
991
+ * Fixes APCA contrast polarity; WCAG ignores it. Defaults to `'text'` —
992
+ * the token is the foreground and the anchor the background, with or
993
+ * without `base`. Unlike a theme color, a token never infers its role
994
+ * from `name`, so `inferRole` has no effect on it.
995
+ */
996
+ role?: RoleInput;
997
+ }
998
+ /**
999
+ * Any single-color input form accepted by the value-shorthand
1000
+ * overload of `glaze.color()`.
1001
+ *
1002
+ * Strings cover hex with a leading `#` (`#rgb` / `#rgba` / `#rrggbb` /
1003
+ * `#rrggbbaa`) and the five color functions Glaze itself emits: `rgb()`,
1004
+ * `hsl()`, `okhsl()`, `okhst()`, `oklch()`, plus the `rgba()` / `hsla()`
1005
+ * aliases. Function names are case-insensitive; components are numbers or
1006
+ * percentages, separated by spaces or commas. Their scales:
1007
+ * - `rgb()` — channels 0–255, or percentages (`100%` is 255).
1008
+ * - `hsl()` / `okhsl()` / `okhst()` — saturation, lightness and tone are
1009
+ * percentages or bare 0–1 fractions: `hsl(120 50% 50%)` or
1010
+ * `hsl(120 0.5 0.5)`. Unlike CSS, a bare `hsl(120 50 50)` does not mean
1011
+ * 50%; it is out of range and resolves to white without a warning.
1012
+ * - `oklch()` — L 0–1 or a percentage; C bare, or a percentage where
1013
+ * `100%` is 0.4.
1014
+ * - Hue is in degrees, bare or with `deg`. Other angle units (`turn`,
1015
+ * `rad`, `grad`) are misread as degrees rather than rejected.
1016
+ *
1017
+ * An alpha component (hex alpha, `/ A`, or any fourth component) is
1018
+ * dropped with a warning. Named colors, other color functions, and
1019
+ * relative color syntax throw.
1020
+ *
1021
+ * Literal object forms, told apart by their keys:
1022
+ * - `{ r, g, b }` — sRGB 0–255.
1023
+ * - `{ l, c, h }` — OKLCh (L/C: 0–1, H: degrees), same as `oklch()` strings.
1024
+ * - `{ h, s, t }` — OKHST (h: 0–360, s/t: 0–1). Tone in 0–1, so `t: 0.7` is
1025
+ * tone 70.
1026
+ * - `{ h, s, l }` — OKHSL (h: 0–360, s/l: 0–1).
1027
+ *
1028
+ * An object `s`, `l`, `t` or `c` above 1.5 throws, which catches 0–100
1029
+ * input; the OKHSL / OKHST errors point to the structured form. String
1030
+ * components have no such check.
1031
+ */
1032
+ type GlazeColorValue = string | OkhslColor | OkhstColor | RgbColor | OklchColor;
1033
+ /** Color overrides for the `from` and value-shorthand inputs. */
1034
+ interface GlazeColorOverrides {
1035
+ /**
1036
+ * Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
1037
+ * to the extracted (or overridden) seed hue — same semantics as
1038
+ * `RegularColorDef.hue`.
1039
+ */
1040
+ hue?: number | RelativeValue;
1041
+ /** Override seed saturation (0–100). Default: extracted from value. */
1042
+ saturation?: number;
1043
+ /**
1044
+ * Dark-scheme hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
1045
+ * to the dark seed hue, which defaults to the (possibly overridden) seed
1046
+ * hue. Falls back to `hue` when omitted.
1047
+ */
1048
+ darkHue?: number | RelativeValue;
1049
+ /**
1050
+ * Dark-scheme seed saturation (0–100). Defaults to `saturation`. When set,
1051
+ * the global `darkDesaturation` reduction is not applied on top.
1052
+ */
1053
+ darkSaturation?: number;
1054
+ /**
1055
+ * Dark-scheme multiplier on the dark seed (0–1). Defaults to
1056
+ * `saturationFactor`. When set, the global `darkDesaturation` reduction is
1057
+ * not applied on top.
1058
+ */
1059
+ darkSaturationFactor?: number;
1060
+ /**
1061
+ * Override tone. Number is absolute (0–100, contrast-uniform); `'+N'`/`'-N'`
1062
+ * is relative to the literal seed (the value passed to `glaze.color()`);
1063
+ * `'max'` / `'min'` force to the scheme's tone extreme.
1064
+ * Supports HCPair for high-contrast.
1065
+ */
1066
+ tone?: HCPair<ToneValue>;
1067
+ /** Saturation multiplier on the seed (0–1). Default: 1. */
1068
+ saturationFactor?: number;
1069
+ /**
1070
+ * Adaptation mode. Defaults to `'auto'` for every input form, so
1071
+ * colors automatically adapt between light and dark like an ordinary
1072
+ * theme color. Value-shorthand inputs (strings and literal objects)
1073
+ * preserve light tone via a local `lightTone: false` default; other
1074
+ * omitted config fields fall through to the live global at resolve
1075
+ * time. Structured `{ hue, saturation, tone }` form also falls
1076
+ * through for both tone windows unless overridden.
1077
+ *
1078
+ * Pass `'fixed'` explicitly to opt back into the linear, non-
1079
+ * inverting mapping; pass `'static'` to pin the same tone
1080
+ * across every variant.
1081
+ */
1082
+ mode?: AdaptationMode;
1083
+ /**
1084
+ * Flip out-of-bounds results (relative `tone` overshoot / unmet
1085
+ * `contrast`) to the opposite side instead of clamping. Defaults to
1086
+ * the global `autoFlip`.
1087
+ */
1088
+ autoFlip?: boolean;
1089
+ /**
1090
+ * Contrast floor. By default solved against the literal seed
1091
+ * (the value itself); when `base` is set, solved against the base's
1092
+ * resolved variant per scheme. Same shape as `RegularColorDef.contrast`
1093
+ * (bare number/preset = WCAG; `{ wcag }` / `{ apca }` to pick the metric).
1094
+ */
1095
+ contrast?: HCPair<ContrastSpec>;
1096
+ /**
1097
+ * Optional dependency on another color. Accepts either a
1098
+ * `GlazeColorToken` (returned by another `glaze.color()`) or a raw
1099
+ * `GlazeColorValue` (hex / CSS strings / `{ r, g, b }` / `{ h, s, l }` / …),
1100
+ * which is automatically wrapped in `glaze.color(value)`.
1101
+ *
1102
+ * When set:
1103
+ * - `contrast` is solved against the base's resolved variant
1104
+ * per-scheme (light / dark / lightContrast / darkContrast).
1105
+ * - Relative `tone: '+N'` / `'-N'` is anchored to the base's
1106
+ * tone per-scheme (matches theme behavior for dependent colors).
1107
+ * - Relative `hue: '+N'` / `'-N'` still anchors to the seed (the
1108
+ * value passed to `glaze.color()`), not the base.
1109
+ * - The link resolves against the base token's own variants in every
1110
+ * scheme: what the base paints, under its own config, whatever form
1111
+ * the base was made in. A light `'+0'` lands on the base and a light
1112
+ * `contrast` floor is measured against it.
1113
+ *
1114
+ * The base token's `.resolve()` is called lazily on first resolve and
1115
+ * its result is captured by reference; later mutations to the base's
1116
+ * defining call don't apply (matches existing token snapshot semantics).
1117
+ */
1118
+ base?: GlazeColorToken | GlazeColorValue;
1119
+ /**
1120
+ * Fixed opacity (0–1). Output includes alpha in the CSS value.
1121
+ * Combining with `contrast` is not recommended (perceived tone
1122
+ * becomes unpredictable) — a `console.warn` is emitted in that case.
1123
+ */
1124
+ opacity?: number;
1125
+ /**
1126
+ * Optional human-readable name for the token. Used in error and
1127
+ * warning messages (otherwise an internal name like `"value"` is
1128
+ * used) and as `resolve().name`. A debug label only: it does not
1129
+ * affect output keys or the token's `role`.
1130
+ */
1131
+ name?: string;
1132
+ /**
1133
+ * Per-color override for the hue-independent "safe" chroma limit used in
1134
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
1135
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
1136
+ * @see GlazeConfigOverride.pastel
1137
+ */
1138
+ pastel?: boolean;
1139
+ /**
1140
+ * Semantic role against the token's anchor (`base`, or the literal seed
1141
+ * when `contrast` / a relative `tone` is set without one): how this token
1142
+ * is used. Fixes APCA contrast polarity; WCAG ignores it. Defaults to
1143
+ * `'text'` — the token is the foreground and the anchor the background,
1144
+ * with or without `base`. Unlike a theme color, a token never infers its
1145
+ * role from `name`, so `inferRole` has no effect on it.
1146
+ */
1147
+ role?: RoleInput;
1148
+ }
1149
+ /**
1150
+ * Object input for `glaze.color()` that carries a raw color value plus
1151
+ * optional color overrides in the same object.
1152
+ *
1153
+ * ```ts
1154
+ * glaze.color({ from: '#1a1a2e', base: bg, contrast: 'AA' })
1155
+ * glaze.color({ from: { r: 38, g: 252, b: 178 }, tone: '+10' })
1156
+ * ```
1157
+ */
1158
+ interface GlazeFromInput extends GlazeColorOverrides {
1159
+ /** The source color value. Accepts the same forms as a bare `GlazeColorValue`. */
1160
+ from: GlazeColorValue;
1161
+ }
1162
+ /** Options for `GlazeColorToken.css()`. */
1163
+ interface GlazeColorCssOptions {
1164
+ /**
1165
+ * Custom property base name (without leading `--`). Required.
1166
+ * Becomes the variable identifier in the output, e.g.
1167
+ * `name: 'brand'` → `--brand-color: …`.
1168
+ */
1169
+ name: string;
1170
+ /** Output color format. Default: 'oklch'. */
1171
+ format?: GlazeColorFormat;
1172
+ /**
1173
+ * Suffix appended to the name. Default: '-color' (matches
1174
+ * `theme.css` default).
1175
+ */
1176
+ suffix?: string;
1177
+ /**
1178
+ * Emit hue as a separate `--{name}-hue` custom property, referenced via
1179
+ * `var()`. Requires `format: 'oklch'` (any other format throws) and a
1180
+ * pastel token.
1181
+ */
1182
+ splitHue?: boolean;
297
1183
  }
298
1184
  /** Return type for `glaze.color()`. */
299
1185
  interface GlazeColorToken {
@@ -303,18 +1189,156 @@ interface GlazeColorToken {
303
1189
  token(options?: GlazeTokenOptions): Record<string, string>;
304
1190
  /**
305
1191
  * Export as a tasty style-to-state binding (no color name key).
306
- * Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
307
- * @see https://cube-ui-kit.vercel.app/?path=/docs/tasty-documentation--docs
1192
+ * Uses `#name` keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
1193
+ * @see https://tasty.style/docs
308
1194
  */
309
1195
  tasty(options?: GlazeTokenOptions): Record<string, string>;
310
1196
  /** Export as a flat JSON map (no color name key). */
311
1197
  json(options?: GlazeJsonOptions): Record<string, string>;
1198
+ /** Export as CSS custom property declarations grouped by scheme variant. */
1199
+ css(options: GlazeColorCssOptions): GlazeCssResult;
1200
+ /**
1201
+ * Export as W3C DTCG color tokens (one per scheme variant, no color name
1202
+ * key). Each entry is a full `{ $type: 'color', $value }` token.
1203
+ * @see https://www.designtokens.org/
1204
+ */
1205
+ dtcg(options?: GlazeDtcgOptions): GlazeColorDtcgResult;
1206
+ /**
1207
+ * Export as a single W3C DTCG Resolver-Module document for this color,
1208
+ * keyed by `name` across all scheme variants. `name` is required.
1209
+ * @see https://www.designtokens.org/
1210
+ */
1211
+ dtcgResolver(options: GlazeColorDtcgResolverOptions): GlazeDtcgResolverDocument;
1212
+ /**
1213
+ * Export as a Tailwind CSS v4 `@theme` block (light baseline) plus dark /
1214
+ * high-contrast overrides. Returns a single ready-to-paste CSS string.
1215
+ * `name` is required (forms `--color-<name>`).
1216
+ * @see https://tailwindcss.com/docs/theme
1217
+ */
1218
+ tailwind(options: GlazeColorTailwindOptions): string;
1219
+ /**
1220
+ * Serialize the token as a JSON-safe object. Captures the original
1221
+ * input value, overrides, and config so it can be rehydrated via
1222
+ * `glaze.colorFrom(...)`. `base` is recursively serialized.
1223
+ * Optional `override` is merged over the instance local at export time.
1224
+ */
1225
+ export(override?: GlazeConfigOverride): GlazeColorTokenExport;
1226
+ }
1227
+ /**
1228
+ * JSON-safe serialization of a `glaze.color()` token. Pass to
1229
+ * `glaze.colorFrom(...)` to rehydrate.
1230
+ */
1231
+ interface GlazeColorTokenExport {
1232
+ /** Snapshot kind. Always written by `token.export()`; optional on legacy snapshots. */
1233
+ kind?: 'color';
1234
+ /** Schema version. Always written by `token.export()`; optional on legacy snapshots. */
1235
+ version?: number;
1236
+ /**
1237
+ * Discriminator for the source overload that created the token.
1238
+ * - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
1239
+ * - `'structured'`: created via `glaze.color({ hue, saturation, ... })`.
1240
+ */
1241
+ form: 'value' | 'structured';
1242
+ /** Original input. For `form: 'value'` this is the raw `GlazeColorValue`; for `form: 'structured'` this is the structured input. */
1243
+ input: GlazeColorValue | GlazeColorInputExport;
1244
+ /**
1245
+ * Overrides recorded at creation time. `base` is recursively
1246
+ * serialized. Only present for `form: 'value'`.
1247
+ */
1248
+ overrides?: GlazeColorOverridesExport;
1249
+ /**
1250
+ * Effective config freeze from `.export()` — `getConfig() ∪ local ∪
1251
+ * exportArg` at call time. Used by `glaze.colorFrom()` to pin
1252
+ * deterministic behavior across later `configure()` calls.
1253
+ */
1254
+ config?: GlazeConfigOverride;
1255
+ }
1256
+ /**
1257
+ * JSON-safe serialization of a `glaze.palette()` composition.
1258
+ * Pass to `glaze.paletteFrom(...)` to rehydrate.
1259
+ */
1260
+ interface GlazePaletteExport {
1261
+ /** Snapshot kind. Always written by `palette.export()`. */
1262
+ kind?: 'palette';
1263
+ /** Schema version. Always written by `palette.export()`. */
1264
+ version?: number;
1265
+ /** Per-theme authoring snapshots keyed by theme name. */
1266
+ themes: Record<string, GlazeThemeExport>;
1267
+ /** Primary theme name, if set on the palette. */
1268
+ primary?: string;
1269
+ }
1270
+ /**
1271
+ * Serializable shape of a structured `glaze.color({...})` input.
1272
+ * Differs from `GlazeColorInput` only in that `base` is replaced by an
1273
+ * `export` instead of a token reference.
1274
+ */
1275
+ interface GlazeColorInputExport {
1276
+ hue: number;
1277
+ saturation: number;
1278
+ tone: HCPair<number | ExtremeValue>;
1279
+ saturationFactor?: number;
1280
+ darkHue?: number | RelativeValue;
1281
+ darkSaturation?: number;
1282
+ darkSaturationFactor?: number;
1283
+ mode?: AdaptationMode;
1284
+ autoFlip?: boolean;
1285
+ opacity?: number;
1286
+ base?: GlazeColorTokenExport | GlazeColorValue;
1287
+ contrast?: HCPair<ContrastSpec>;
1288
+ name?: string;
1289
+ pastel?: boolean;
1290
+ role?: RoleInput;
1291
+ }
1292
+ /**
1293
+ * Serializable shape of `GlazeColorOverrides`. `base` is replaced by
1294
+ * its export (or left as a `GlazeColorValue` if it was originally a value).
1295
+ */
1296
+ interface GlazeColorOverridesExport {
1297
+ hue?: number | RelativeValue;
1298
+ saturation?: number;
1299
+ darkHue?: number | RelativeValue;
1300
+ darkSaturation?: number;
1301
+ darkSaturationFactor?: number;
1302
+ tone?: HCPair<ToneValue>;
1303
+ saturationFactor?: number;
1304
+ mode?: AdaptationMode;
1305
+ autoFlip?: boolean;
1306
+ contrast?: HCPair<ContrastSpec>;
1307
+ base?: GlazeColorTokenExport | GlazeColorValue;
1308
+ opacity?: number;
1309
+ name?: string;
1310
+ pastel?: boolean;
1311
+ role?: RoleInput;
1312
+ }
1313
+ /**
1314
+ * The hue/saturation seed pair a theme resolves against.
1315
+ *
1316
+ * `darkHue` / `darkSaturation` are a separate seed for the `dark` and
1317
+ * `darkContrast` variants; each falls back to its light counterpart. Setting
1318
+ * `darkSaturation` opts the theme out of the global `darkDesaturation`
1319
+ * reduction — the authored value is used literally.
1320
+ */
1321
+ interface GlazeThemeSeed {
1322
+ /** Light-scheme hue seed (0–360). */
1323
+ hue: number;
1324
+ /** Light-scheme saturation seed (0–100). */
1325
+ saturation: number;
1326
+ /** Dark-scheme hue seed (0–360). Defaults to `hue`. */
1327
+ darkHue?: number;
1328
+ /** Dark-scheme saturation seed (0–100). Defaults to `saturation`. */
1329
+ darkSaturation?: number;
312
1330
  }
313
1331
  interface GlazeTheme {
314
1332
  /** The hue seed (0–360). */
315
1333
  readonly hue: number;
316
1334
  /** The saturation seed (0–100). */
317
1335
  readonly saturation: number;
1336
+ /** The dark-scheme hue seed (0–360), or `undefined` when `hue` is reused. */
1337
+ readonly darkHue: number | undefined;
1338
+ /** The dark-scheme saturation seed (0–100), or `undefined` when `saturation` is reused. */
1339
+ readonly darkSaturation: number | undefined;
1340
+ /** The effective config for this theme. */
1341
+ getConfig(): GlazeConfigResolved;
318
1342
  /** Add/replace colors (additive merge with existing definitions). */
319
1343
  colors(defs: ColorMap): void;
320
1344
  /** Get a color definition by name. */
@@ -330,7 +1354,7 @@ interface GlazeTheme {
330
1354
  /** Clear all color definitions. */
331
1355
  reset(): void;
332
1356
  /** Export the theme configuration as a JSON-safe object. */
333
- export(): GlazeThemeExport;
1357
+ export(override?: GlazeConfigOverride): GlazeThemeExport;
334
1358
  /** Create a child theme inheriting all color definitions. */
335
1359
  extend(options: GlazeExtendOptions): GlazeTheme;
336
1360
  /** Resolve all colors and return the result map. */
@@ -342,57 +1366,368 @@ interface GlazeTheme {
342
1366
  * theme.tokens()
343
1367
  * // → { light: { surface: 'okhsl(...)' }, dark: { surface: 'okhsl(...)' } }
344
1368
  * ```
1369
+ *
1370
+ * With `modes.hdr`, each scheme map is followed by a dense `<scheme>Hdr`
1371
+ * map (`lightHdr`, `darkHdr`, …): every glow with an HDR value in any
1372
+ * emitted scheme, as `color(srgb-linear …)`, or its SDR value where that
1373
+ * scheme has none.
345
1374
  */
346
1375
  tokens(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
347
1376
  /**
348
1377
  * Export as tasty style-to-state bindings.
349
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
1378
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
350
1379
  * Spread into component styles or register as a recipe via `configure({ recipes })`.
351
- * @see https://cube-ui-kit.vercel.app/?path=/docs/tasty-documentation--docs
1380
+ * With `modes.hdr`, a glow's HDR value follows each SDR key that has one,
1381
+ * under `states.hdr` (`'@media(dynamic-range: high)'`) combined with it.
1382
+ * @see https://tasty.style/docs
1383
+ */
1384
+ tasty(options?: GlazeTastyOptions): Record<string, Record<string, string>>;
1385
+ /**
1386
+ * Export as plain JSON. With `modes.hdr`, a glow variant with an HDR value
1387
+ * adds a `<scheme>Hdr` key (`lightHdr`, …) right after its SDR key.
352
1388
  */
353
- tasty(options?: GlazeTokenOptions): Record<string, Record<string, string>>;
354
- /** Export as plain JSON. */
355
1389
  json(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
356
1390
  /** Export as CSS custom property declarations. */
357
1391
  css(options?: GlazeCssOptions): GlazeCssResult;
1392
+ /**
1393
+ * Export as W3C Design Tokens Format Module (2025.10) documents, one per
1394
+ * scheme variant. Consumable by Figma, Tokens Studio, Style Dictionary,
1395
+ * Terrazzo, and any DTCG-compatible tool.
1396
+ * @see https://www.designtokens.org/
1397
+ */
1398
+ dtcg(options?: GlazeDtcgOptions): GlazeDtcgResult;
1399
+ /**
1400
+ * Export as a single W3C DTCG Resolver-Module document describing every
1401
+ * scheme variant as one `sets` entry plus a single `scheme` modifier with a
1402
+ * context per variant. Consumable by resolver tools such as Dispersa.
1403
+ * @see https://www.designtokens.org/
1404
+ */
1405
+ dtcgResolver(options?: GlazeDtcgResolverOptions): GlazeDtcgResolverDocument;
1406
+ /**
1407
+ * Export as a Tailwind CSS v4 `@theme` block (light baseline) plus dark /
1408
+ * high-contrast overrides under configurable selectors. Returns a single
1409
+ * ready-to-paste CSS string.
1410
+ * @see https://tailwindcss.com/docs/theme
1411
+ */
1412
+ tailwind(options?: GlazeTailwindOptions): string;
358
1413
  }
359
1414
  interface GlazeExtendOptions {
360
1415
  hue?: number;
361
1416
  saturation?: number;
1417
+ /** Replace the dark-scheme hue seed (0–360). Defaults to the parent's. */
1418
+ darkHue?: number;
1419
+ /** Replace the dark-scheme saturation seed (0–100). Defaults to the parent's. */
1420
+ darkSaturation?: number;
362
1421
  colors?: ColorMap;
1422
+ /** Config override for the child theme. Merged with the parent's override. */
1423
+ config?: GlazeConfigOverride;
363
1424
  }
1425
+ /**
1426
+ * Options for `token.token()` / `token.tasty()`, and the base of the theme and
1427
+ * palette `tasty()` options: output format, scheme variants, state aliases.
1428
+ */
364
1429
  interface GlazeTokenOptions {
365
- /** Prefix mode. `true` uses "<themeName>-", or provide a custom map. */
366
- prefix?: boolean | Record<string, string>;
367
- /** Override state aliases for this export. */
1430
+ /**
1431
+ * Override state aliases for this export. `hdr` keys an HDR glow value
1432
+ * (with `modes.hdr`); a `glaze.color()` token is never a glow, so it never
1433
+ * uses it.
1434
+ */
368
1435
  states?: {
369
1436
  dark?: string;
370
1437
  highContrast?: string;
1438
+ hdr?: string;
371
1439
  };
372
1440
  /** Override which scheme variants to include. */
373
1441
  modes?: GlazeOutputModes;
374
- /** Output color format. Default: 'okhsl'. */
1442
+ /** Output color format. Default: 'oklch'. */
375
1443
  format?: GlazeColorFormat;
376
1444
  }
1445
+ /** Options for `theme.tasty()`. */
1446
+ interface GlazeTastyOptions extends GlazeTokenOptions {
1447
+ /**
1448
+ * Emit hue as a separate custom property, referenced via `var()`.
1449
+ * Requires `format: 'oklch'` (any other format throws) and every color to
1450
+ * be pastel.
1451
+ */
1452
+ splitHue?: boolean;
1453
+ /**
1454
+ * Base name for the theme-level hue var (`--{name}-hue`). Default: `'theme'`.
1455
+ * Must not equal the name of a color that sets its own hue (throws).
1456
+ */
1457
+ name?: string;
1458
+ }
1459
+ /** Options for `theme.tokens()` / `theme.json()` and their palette and token counterparts. */
377
1460
  interface GlazeJsonOptions {
378
1461
  /** Override which scheme variants to include. */
379
1462
  modes?: GlazeOutputModes;
380
- /** Output color format. Default: 'okhsl'. */
1463
+ /** Output color format. Default: 'oklch'. */
381
1464
  format?: GlazeColorFormat;
382
1465
  }
1466
+ /** Options for `theme.css()`. */
383
1467
  interface GlazeCssOptions {
384
- /** Output color format. Default: 'rgb'. */
1468
+ /** Output color format. Default: 'oklch'. */
385
1469
  format?: GlazeColorFormat;
386
1470
  /** Suffix appended to each CSS custom property name. Default: '-color'. */
387
1471
  suffix?: string;
1472
+ /**
1473
+ * Emit hue as a separate custom property, referenced via `var()`.
1474
+ * Requires `format: 'oklch'` (any other format throws) and every color to
1475
+ * be pastel.
1476
+ */
1477
+ splitHue?: boolean;
1478
+ /**
1479
+ * Base name for the theme-level hue var (`--{name}-hue`). Default: `'theme'`.
1480
+ * Must not equal the name of a color that sets its own hue (throws).
1481
+ */
1482
+ name?: string;
1483
+ /**
1484
+ * Add the HDR tier as `result.hdr` (see {@link GlazeCssResult.hdr}).
1485
+ * Default: the global `modes.hdr` (false). `css()` has no `modes` — it
1486
+ * always emits all four schemes — so this is its HDR switch.
1487
+ */
1488
+ hdr?: boolean;
388
1489
  }
389
- /** CSS custom property declarations grouped by scheme variant. */
390
- interface GlazeCssResult {
1490
+ /** CSS custom property declarations for each scheme variant. */
1491
+ interface GlazeCssSchemeBlocks {
391
1492
  light: string;
392
1493
  dark: string;
393
1494
  lightContrast: string;
394
1495
  darkContrast: string;
395
1496
  }
1497
+ /** CSS custom property declarations grouped by scheme variant. */
1498
+ interface GlazeCssResult extends GlazeCssSchemeBlocks {
1499
+ /**
1500
+ * The HDR tier, present when HDR output is on — the `hdr` option, which
1501
+ * defaults to the global `modes.hdr`: one block per scheme,
1502
+ * each re-declaring every color that has an HDR value in any scheme — its
1503
+ * HDR value (`color(srgb-linear R G B)`) where that scheme has one, and
1504
+ * the scheme's SDR declaration where it has none. The blocks are dense so
1505
+ * a light HDR value can never leak into dark: wire each one after the SDR
1506
+ * blocks, under the same selector plus `(dynamic-range: high)`. Every block
1507
+ * is an empty string when no color has an HDR value.
1508
+ */
1509
+ hdr?: GlazeCssSchemeBlocks;
1510
+ }
1511
+ /**
1512
+ * Color space used for DTCG `$value` color objects.
1513
+ * @see https://www.designtokens.org/
1514
+ */
1515
+ type DtcgColorSpace = 'srgb' | 'oklch';
1516
+ /**
1517
+ * A DTCG color `$value` in the sRGB color space: gamma sRGB components in
1518
+ * 0–1 plus a 6-digit `hex` hint. Universally understood by Figma, Tokens
1519
+ * Studio, Style Dictionary, and every DTCG reader.
1520
+ */
1521
+ interface DtcgSrgbColorValue {
1522
+ colorSpace: 'srgb';
1523
+ components: [number, number, number];
1524
+ hex: HexColor;
1525
+ /** Opacity 0–1. Omitted when fully opaque (alpha = 1). */
1526
+ alpha?: number;
1527
+ }
1528
+ /**
1529
+ * A DTCG color `$value` in the OKLCH color space: `[L, C, H]` components
1530
+ * (L/C: 0–1, H: degrees). Wide-gamut and Glaze-native; no `hex` is emitted.
1531
+ */
1532
+ interface DtcgOklchColorValue {
1533
+ colorSpace: 'oklch';
1534
+ components: [number, number, number];
1535
+ /** Opacity 0–1. Omitted when fully opaque (alpha = 1). */
1536
+ alpha?: number;
1537
+ }
1538
+ /** A DTCG `$value` for a color token, in either supported color space. */
1539
+ type DtcgColorValue = DtcgSrgbColorValue | DtcgOklchColorValue;
1540
+ /**
1541
+ * The HDR value of a glow past SDR white, carried in a DTCG token's
1542
+ * `$extensions['me.tenphi.glaze'].hdr` (`$value` stays the SDR color, since
1543
+ * DTCG color components stop at 1). Maps onto native APIs: UIKit / AppKit
1544
+ * `exposure`, SwiftUI `exposureAdjust(exposure)` on `base`, or Android
1545
+ * `Color.pack(…components, LINEAR_EXTENDED_SRGB)` from `value`.
1546
+ */
1547
+ interface GlazeDtcgHdr {
1548
+ /** Gain over `base` in stops (`log2` of the linear factor), above 0. */
1549
+ exposure: number;
1550
+ /**
1551
+ * Luminance tone of the HDR value (e.g. `112`) — past 100 when the headroom
1552
+ * covers the step; a saturated base capped by `headroom` can land below 100,
1553
+ * though its brightest channel still exceeds 1.
1554
+ */
1555
+ tone: number;
1556
+ /** The opaque base (what SDR paints), as a DTCG sRGB color. */
1557
+ base: DtcgSrgbColorValue;
1558
+ /**
1559
+ * The HDR color: linear sRGB `base × 2^exposure`, its brightest channel
1560
+ * above 1 (the others may stay below).
1561
+ */
1562
+ value: {
1563
+ colorSpace: 'srgb-linear';
1564
+ components: [number, number, number];
1565
+ };
1566
+ }
1567
+ /** The Glaze namespace of a DTCG token's `$extensions`. */
1568
+ interface GlazeDtcgExtensions {
1569
+ 'me.tenphi.glaze': {
1570
+ /** Present only with `modes.hdr`, on a glow variant that has an HDR value. */hdr: GlazeDtcgHdr;
1571
+ };
1572
+ }
1573
+ /**
1574
+ * A single W3C DTCG color token: `{ $type: 'color', $value }`.
1575
+ * `$description` is optional and not populated by Glaze today. `$extensions`
1576
+ * is set only with `modes.hdr`, on a glow variant with an HDR value.
1577
+ */
1578
+ interface DtcgColorToken {
1579
+ $type: 'color';
1580
+ $value: DtcgColorValue;
1581
+ $description?: string;
1582
+ $extensions?: GlazeDtcgExtensions;
1583
+ }
1584
+ /**
1585
+ * A W3C Design Tokens Format Module (2025.10) token tree for one scheme.
1586
+ * Glaze emits one document per scheme variant — the most tool-compatible
1587
+ * convention (one file per Style Dictionary theme / Tokens Studio set /
1588
+ * Figma variable mode).
1589
+ */
1590
+ type DtcgDocument = Record<string, DtcgColorToken>;
1591
+ /** DTCG token documents grouped by scheme variant. Light is always present. */
1592
+ interface GlazeDtcgResult {
1593
+ light: DtcgDocument;
1594
+ dark?: DtcgDocument;
1595
+ lightContrast?: DtcgDocument;
1596
+ darkContrast?: DtcgDocument;
1597
+ }
1598
+ /** A single DTCG color token grouped by scheme variant (standalone tokens). */
1599
+ interface GlazeColorDtcgResult {
1600
+ light: DtcgColorToken;
1601
+ dark?: DtcgColorToken;
1602
+ lightContrast?: DtcgColorToken;
1603
+ darkContrast?: DtcgColorToken;
1604
+ }
1605
+ /** Options for `theme.dtcg()` / `palette.dtcg()`. */
1606
+ interface GlazeDtcgOptions {
1607
+ /** Override which scheme variants to include. */
1608
+ modes?: GlazeOutputModes;
1609
+ /**
1610
+ * DTCG color space. `'srgb'` (default) emits sRGB components plus a `hex`
1611
+ * hint — universally understood (Figma, Tokens Studio). `'oklch'` emits
1612
+ * OKLCH components with no hex — Glaze-native, wide-gamut.
1613
+ */
1614
+ colorSpace?: DtcgColorSpace;
1615
+ }
1616
+ /**
1617
+ * A node in a DTCG Resolver-Module token tree: either a leaf color token or a
1618
+ * nested group. A flat `DtcgDocument` (top-level color-name keys) is a valid
1619
+ * shallow tree, so Glaze's per-scheme documents slot directly into
1620
+ * `sets.<name>.sources` and `modifiers.<name>.contexts.<ctx>` entries.
1621
+ */
1622
+ interface DtcgTokenTree {
1623
+ [key: string]: DtcgColorToken | DtcgTokenTree;
1624
+ }
1625
+ /** A named set in a resolver document: a list of token-tree sources. */
1626
+ interface DtcgResolverSet {
1627
+ sources: DtcgTokenTree[];
1628
+ }
1629
+ /**
1630
+ * A named modifier (an axis such as `scheme`) in a resolver document.
1631
+ * `default` names the context applied when no override is selected; `contexts`
1632
+ * maps each context name to the token-tree overrides applied for it.
1633
+ */
1634
+ interface DtcgResolverModifier {
1635
+ default: string;
1636
+ contexts: Record<string, DtcgTokenTree[]>;
1637
+ }
1638
+ /** A JSON-pointer `$ref` entry in a resolver document's `resolutionOrder`. */
1639
+ interface DtcgResolverRef {
1640
+ $ref: string;
1641
+ }
1642
+ /**
1643
+ * A W3C DTCG Resolver-Module document. Describes every scheme variant in a
1644
+ * single file as `sets` (base token sources) plus `modifiers` (per-context
1645
+ * overrides) composed in `resolutionOrder`. Consumable by resolver tools such
1646
+ * as Dispersa.
1647
+ * @see https://www.designtokens.org/
1648
+ */
1649
+ interface GlazeDtcgResolverDocument {
1650
+ version: string;
1651
+ sets: Record<string, DtcgResolverSet>;
1652
+ modifiers: Record<string, DtcgResolverModifier>;
1653
+ resolutionOrder: DtcgResolverRef[];
1654
+ }
1655
+ /** Renaming of the four scheme variants as resolver-modifier context names. */
1656
+ interface GlazeDtcgResolverContextNames {
1657
+ light?: string;
1658
+ dark?: string;
1659
+ lightContrast?: string;
1660
+ darkContrast?: string;
1661
+ }
1662
+ /**
1663
+ * Options for `theme.dtcgResolver()` / `palette.dtcgResolver()`. Extends
1664
+ * `GlazeDtcgOptions` so `modes` + `colorSpace` pass through to the underlying
1665
+ * per-scheme `dtcg()` build.
1666
+ */
1667
+ interface GlazeDtcgResolverOptions extends GlazeDtcgOptions {
1668
+ /** Name of the single set holding the default (light) token tree. Default `'base'`. */
1669
+ setName?: string;
1670
+ /**
1671
+ * Name of the modifier describing the scheme axis. Default `'scheme'`
1672
+ * (Glaze's term for the light / dark / high-contrast axis).
1673
+ */
1674
+ modifierName?: string;
1675
+ /**
1676
+ * Override the four context names emitted on the modifier. Defaults to the
1677
+ * Glaze variant keys: `light` / `dark` / `lightContrast` / `darkContrast`.
1678
+ */
1679
+ contextNames?: GlazeDtcgResolverContextNames;
1680
+ /** Resolver document version. Default `'2025.10'`. */
1681
+ version?: string;
1682
+ }
1683
+ /** Options for `glaze.color().dtcgResolver()`. `name` is required. */
1684
+ interface GlazeColorDtcgResolverOptions extends GlazeDtcgResolverOptions {
1685
+ /** Token name keying the color within each token tree. Required. */
1686
+ name: string;
1687
+ }
1688
+ /** Options for `theme.tailwind()` / `palette.tailwind()`. */
1689
+ interface GlazeTailwindOptions {
1690
+ /** Override which scheme variants to include. */
1691
+ modes?: GlazeOutputModes;
1692
+ /** Output color format. Default: 'oklch'. */
1693
+ format?: GlazeColorFormat;
1694
+ /**
1695
+ * CSS custom property namespace, forming `--<namespace><name>`.
1696
+ * Default: `'color-'` → `--color-surface`. (Tailwind v4's `--color-*`
1697
+ * convention, which auto-generates `bg-*` / `text-*` / `border-*`.)
1698
+ *
1699
+ * Named `namespace` rather than `prefix` to avoid clashing with the
1700
+ * palette theme-prefix option on `palette.tailwind()`.
1701
+ */
1702
+ namespace?: string;
1703
+ /**
1704
+ * Selector wrapping the dark-scheme overrides. Default: `'.dark'`.
1705
+ * Pass a media query such as `'@media (prefers-color-scheme: dark)'` to
1706
+ * drive dark mode from the OS preference instead of a class.
1707
+ */
1708
+ darkSelector?: string;
1709
+ /**
1710
+ * Selector wrapping the light high-contrast overrides. Default:
1711
+ * `'.high-contrast'`. The combined dark + high-contrast overrides are
1712
+ * emitted under `${darkSelector}${highContrastSelector}` (e.g.
1713
+ * `.dark.high-contrast`).
1714
+ */
1715
+ highContrastSelector?: string;
1716
+ /**
1717
+ * Selector wrapping the HDR overrides, emitted with `modes.hdr` after every
1718
+ * SDR block. Default: `'@media (dynamic-range: high)'`. Each HDR block is
1719
+ * dense (every color with an HDR value in any emitted scheme, SDR value
1720
+ * where the scheme has none) and is scoped by this selector alone (light),
1721
+ * combined with `darkSelector` (dark), with `highContrastSelector` (light
1722
+ * high contrast), or with both.
1723
+ */
1724
+ hdrSelector?: string;
1725
+ }
1726
+ /** Options for `glaze.color().tailwind()`. `name` is required. */
1727
+ interface GlazeColorTailwindOptions extends GlazeTailwindOptions {
1728
+ /** Custom property base name (without leading `--`). Required. */
1729
+ name: string;
1730
+ }
396
1731
  /** Options for `glaze.palette()` creation. */
397
1732
  interface GlazePaletteOptions {
398
1733
  /**
@@ -409,7 +1744,10 @@ interface GlazePaletteOptions {
409
1744
  */
410
1745
  primary?: string;
411
1746
  }
412
- /** Options shared by palette `tokens()`, `tasty()`, and `css()` exports. */
1747
+ /**
1748
+ * Options shared by every palette export except `json()`: `tokens()`,
1749
+ * `tasty()`, `css()`, `dtcg()`, `dtcgResolver()`, and `tailwind()`.
1750
+ */
413
1751
  interface GlazePaletteExportOptions {
414
1752
  /**
415
1753
  * Prefix mode. `true` uses `"<themeName>-"`, or provide a custom map.
@@ -425,7 +1763,58 @@ interface GlazePaletteExportOptions {
425
1763
  */
426
1764
  primary?: string | false;
427
1765
  }
1766
+ /**
1767
+ * Options for `palette.tasty()`. There is no `name`: each theme's hue var is
1768
+ * named after the theme.
1769
+ */
1770
+ interface GlazePaletteTastyOptions extends GlazeTokenOptions, GlazePaletteExportOptions {
1771
+ /**
1772
+ * Emit hue as a separate custom property, referenced via `var()`.
1773
+ * Requires `format: 'oklch'` (any other format throws) and every color to
1774
+ * be pastel. The theme-level hue var is `--{themeName}-hue`.
1775
+ */
1776
+ splitHue?: boolean;
1777
+ }
1778
+ /**
1779
+ * Options for `palette.css()`. There is no `name`: each theme's hue var is
1780
+ * named after the theme.
1781
+ */
1782
+ interface GlazePaletteCssOptions extends GlazePaletteExportOptions {
1783
+ /** Output color format. Default: 'oklch'. */
1784
+ format?: GlazeColorFormat;
1785
+ /** Suffix appended to each CSS custom property name. Default: '-color'. */
1786
+ suffix?: string;
1787
+ /**
1788
+ * Emit hue as a separate custom property, referenced via `var()`.
1789
+ * Requires `format: 'oklch'` (any other format throws) and every color to
1790
+ * be pastel. The theme-level hue var is `--{themeName}-hue`.
1791
+ */
1792
+ splitHue?: boolean;
1793
+ /**
1794
+ * Add the HDR tier as `result.hdr` (see {@link GlazeCssResult.hdr}).
1795
+ * Default: the global `modes.hdr` (false).
1796
+ */
1797
+ hdr?: boolean;
1798
+ }
428
1799
  interface GlazePalette {
1800
+ /** Theme names in insertion order. */
1801
+ list(): string[];
1802
+ /** Primary theme name, if set at palette creation. */
1803
+ readonly primary: string | undefined;
1804
+ /** Get a theme by name. Returns the live instance held by the palette. */
1805
+ theme(name: string): GlazeTheme | undefined;
1806
+ /**
1807
+ * Shallow copy of the theme map (same instances the palette holds).
1808
+ * Mutating a returned theme affects subsequent palette exports.
1809
+ */
1810
+ themes(): Record<string, GlazeTheme>;
1811
+ /**
1812
+ * Export the palette authoring configuration as a JSON-safe object.
1813
+ * Restorable via `glaze.paletteFrom(...)`. Distinct from `json()`, which
1814
+ * emits resolved color strings. Optional `override` is forwarded to each
1815
+ * nested `theme.export(override)`.
1816
+ */
1817
+ export(override?: GlazeConfigOverride): GlazePaletteExport;
429
1818
  /**
430
1819
  * Export all themes as a flat token map grouped by scheme variant.
431
1820
  * Prefix defaults to `true` — all tokens are prefixed with the theme name.
@@ -440,17 +1829,37 @@ interface GlazePalette {
440
1829
  tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
441
1830
  /**
442
1831
  * Export all themes as tasty style-to-state bindings.
443
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
1832
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
444
1833
  * Prefix defaults to `true`. Inherits the palette-level `primary`.
445
- * @see https://cube-ui-kit.vercel.app/?path=/docs/tasty-documentation--docs
1834
+ * @see https://tasty.style/docs
1835
+ */
1836
+ tasty(options?: GlazePaletteTastyOptions): Record<string, Record<string, string>>;
1837
+ /**
1838
+ * Export all themes as plain JSON grouped by theme name. No prefix, primary
1839
+ * alias, or collision handling: each theme keeps its own key.
446
1840
  */
447
- tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
448
- /** Export all themes as plain JSON grouped by theme name. */
449
- json(options?: GlazeJsonOptions & {
450
- prefix?: boolean | Record<string, string>;
451
- }): Record<string, Record<string, Record<string, string>>>;
1841
+ json(options?: GlazeJsonOptions): Record<string, Record<string, Record<string, string>>>;
452
1842
  /** Export all themes as CSS custom property declarations. */
453
- css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
1843
+ css(options?: GlazePaletteCssOptions): GlazeCssResult;
1844
+ /**
1845
+ * Export all themes as W3C DTCG documents, one per scheme variant.
1846
+ * Prefix defaults to `true`. Inherits the palette-level `primary`.
1847
+ * @see https://www.designtokens.org/
1848
+ */
1849
+ dtcg(options?: GlazeDtcgOptions & GlazePaletteExportOptions): GlazeDtcgResult;
1850
+ /**
1851
+ * Export all themes as a single W3C DTCG Resolver-Module document. Prefix
1852
+ * defaults to `true`. Inherits the palette-level `primary`.
1853
+ * @see https://www.designtokens.org/
1854
+ */
1855
+ dtcgResolver(options?: GlazeDtcgResolverOptions & GlazePaletteExportOptions): GlazeDtcgResolverDocument;
1856
+ /**
1857
+ * Export all themes as a Tailwind CSS v4 `@theme` block plus dark /
1858
+ * high-contrast overrides. Returns a single ready-to-paste CSS string.
1859
+ * Prefix defaults to `true`.
1860
+ * @see https://tailwindcss.com/docs/theme
1861
+ */
1862
+ tailwind(options?: GlazeTailwindOptions & GlazePaletteExportOptions): string;
454
1863
  }
455
1864
  //#endregion
456
1865
  //#region src/glaze.d.ts
@@ -458,54 +1867,239 @@ type PaletteInput = Record<string, GlazeTheme>;
458
1867
  /**
459
1868
  * Create a single-hue glaze theme.
460
1869
  *
1870
+ * An optional `config` override can be supplied to customize the resolve
1871
+ * behavior for this theme (tone windows, etc.). The
1872
+ * override is **merged over the live global config at resolve time** —
1873
+ * the theme still reacts to later `configure()` calls for fields it
1874
+ * didn't override.
1875
+ *
1876
+ * The object form also accepts `darkHue` / `darkSaturation` — a separate
1877
+ * seed pair for the dark and dark-high-contrast schemes. Both default to
1878
+ * their light counterparts, and an explicit `darkSaturation` opts the theme
1879
+ * out of the global `darkDesaturation` reduction.
1880
+ *
461
1881
  * @example
462
1882
  * ```ts
463
- * const primary = glaze({ hue: 280, saturation: 80 });
464
- * // or shorthand:
465
1883
  * const primary = glaze(280, 80);
1884
+ * // or shorthand:
1885
+ * const primary = glaze({ hue: 280, saturation: 80 });
1886
+ * // with a retuned dark seed:
1887
+ * const primary = glaze({ hue: 280, saturation: 80, darkHue: 268, darkSaturation: 65 });
1888
+ * // with config override:
1889
+ * const raw = glaze(280, 80, { lightTone: false });
1890
+ * const rawSeed = glaze({ hue: 280, saturation: 80 }, { lightTone: false });
466
1891
  * ```
467
1892
  */
468
- declare function glaze(hueOrOptions: number | {
469
- hue: number;
470
- saturation: number;
471
- }, saturation?: number): GlazeTheme;
1893
+ declare function glaze(hue: number, saturation?: number, config?: GlazeConfigOverride): GlazeTheme;
1894
+ declare function glaze(seed: GlazeThemeSeed, config?: GlazeConfigOverride): GlazeTheme;
1895
+ /** @deprecated Pass the config second: `glaze(seed, config)`. */
1896
+ declare function glaze(seed: GlazeThemeSeed, saturation: undefined, config?: GlazeConfigOverride): GlazeTheme;
472
1897
  declare namespace glaze {
473
1898
  var configure: (config: GlazeConfig) => void;
474
- var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => {
475
- tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
476
- tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
477
- json(options?: GlazeJsonOptions & {
478
- prefix?: boolean | Record<string, string>;
479
- }): Record<string, Record<string, Record<string, string>>>;
480
- css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
481
- };
1899
+ var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
1900
+ var themeFrom: (data: GlazeThemeExport) => GlazeTheme;
482
1901
  var from: (data: GlazeThemeExport) => GlazeTheme;
483
- var color: (input: GlazeColorInput) => GlazeColorToken;
1902
+ var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
484
1903
  var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
485
- var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
1904
+ var glow: (input: GlazeGlowInput) => ResolvedColorVariant;
1905
+ var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat, pastel?: boolean) => string;
1906
+ var formatHdr: (variant: ResolvedColorVariant, hdrFormat?: GlazeHdrFormat) => string | undefined;
486
1907
  var fromHex: (hex: string) => GlazeTheme;
487
1908
  var fromRgb: (r: number, g: number, b: number) => GlazeTheme;
1909
+ var colorFrom: (data: GlazeColorTokenExport) => GlazeColorToken;
1910
+ var paletteFrom: (data: GlazePaletteExport) => GlazePalette;
1911
+ var isThemeExport: (value: unknown) => value is GlazeThemeExport;
1912
+ var isColorTokenExport: (value: unknown) => value is GlazeColorTokenExport;
1913
+ var isPaletteExport: (value: unknown) => value is GlazePaletteExport;
488
1914
  var getConfig: () => GlazeConfigResolved;
489
1915
  var resetConfig: () => void;
490
1916
  }
491
1917
  //#endregion
1918
+ //#region src/serialize.d.ts
1919
+ /** Type guard for theme authoring snapshots (prefers `kind`, falls back to shape). */
1920
+ declare function isThemeExport(data: unknown): data is GlazeThemeExport;
1921
+ /** Type guard for color-token authoring snapshots. */
1922
+ declare function isColorTokenExport(data: unknown): data is GlazeColorTokenExport;
1923
+ /** Type guard for palette authoring snapshots. */
1924
+ declare function isPaletteExport(data: unknown): data is GlazePaletteExport;
1925
+ //#endregion
1926
+ //#region src/channels.d.ts
1927
+ interface HueDeclaration {
1928
+ prop: string;
1929
+ value: string;
1930
+ }
1931
+ interface HuePlan {
1932
+ /** CSS `var()` reference spliced into `oklch(L C <hueVar>)`. */
1933
+ hueVar: string;
1934
+ /** When true, emit a full inline color (shadow/glow/mix/achromatic). */
1935
+ inline: boolean;
1936
+ /** Scheme-independent `--*-hue` declarations for this color. */
1937
+ declarations: HueDeclaration[];
1938
+ }
1939
+ interface ChannelCtx {
1940
+ seedHue: number;
1941
+ /**
1942
+ * Dark-scheme seed hue, when the theme authored one. Drives the dark
1943
+ * `--{baseName}-hue` value; falls back to `seedHue`.
1944
+ */
1945
+ darkSeedHue?: number;
1946
+ /** Theme-level hue var base name (without `--` / `-hue`). */
1947
+ baseName: string;
1948
+ /** Token / custom-property name prefix used for hue var naming (`brand-` etc.). */
1949
+ prefix: string;
1950
+ defs: ColorMap;
1951
+ mode: 'theme' | 'standalone';
1952
+ /** Standalone: resolved hue from the primary variant (scheme-independent). */
1953
+ resolvedHue?: number;
1954
+ /**
1955
+ * When false, hue declarations are not emitted (the pass only references
1956
+ * hue vars already declared by a sibling pass). Used by palette primary
1957
+ * unprefixed aliases so they reference the themed `--{themeName}-*-hue`
1958
+ * vars without re-declaring (and colliding with) other themes' base vars.
1959
+ * Defaults to true.
1960
+ */
1961
+ emitDeclarations?: boolean;
1962
+ }
1963
+ //#endregion
1964
+ //#region src/format-guard.d.ts
1965
+ /**
1966
+ * Throw when a non-native Glaze color space is requested for an export that
1967
+ * emits raw CSS or non-Tasty token maps.
1968
+ */
1969
+ declare function assertNativeFormat(format: GlazeColorFormat | undefined, method: string): void;
1970
+ /** The modes `assertAllPastel` reads: which schemes are emitted. */
1971
+ type SchemeModes = Required<Pick<GlazeOutputModes, 'dark' | 'highContrast'>>;
1972
+ /**
1973
+ * Throw when `splitHue` is enabled but any exported color is not pastel.
1974
+ * Hue rotation is only clip-free when chroma is bounded by the hue-independent
1975
+ * safe chroma (`computeSafeChromaOKLCH`).
1976
+ */
1977
+ declare function assertAllPastel(resolved: Map<string, ResolvedColor>, modes: SchemeModes): void;
1978
+ //#endregion
1979
+ //#region src/roles.d.ts
1980
+ /**
1981
+ * Normalize a `RoleInput` (canonical value or alias) into a canonical `Role`.
1982
+ * Returns `undefined` for unrecognized strings so callers can fall through to
1983
+ * the next step of the resolution chain.
1984
+ */
1985
+ declare function normalizeRole(input: RoleInput | undefined): Role | undefined;
1986
+ /**
1987
+ * Infer a `Role` from a color name by matching its tokens against the role
1988
+ * keyword sets. When multiple tokens match, the **last** recognized token
1989
+ * wins (so `button-text` → `text`, `input-bg` → `surface`, `card-border` →
1990
+ * `border`). Returns `undefined` when no token matches.
1991
+ */
1992
+ declare function inferRoleFromName(name: string): Role | undefined;
1993
+ /** APCA argument order: which side the resolved color plays. */
1994
+ type Polarity = 'fg' | 'bg';
1995
+ /**
1996
+ * Map a role to its APCA polarity. `text` and `border` are foreground spots
1997
+ * against their base (the candidate is the text argument); `surface` is the
1998
+ * background (the base is the text argument).
1999
+ */
2000
+ declare function roleToPolarity(role: Role): Polarity;
2001
+ /**
2002
+ * The opposite role of `role`, used when a color with no explicit role and no
2003
+ * inferable name depends on a base: the dependent color plays the opposite
2004
+ * role of its base. `surface` ↔ `text`; `border` is treated as a foreground
2005
+ * spot, so its opposite is `surface`.
2006
+ */
2007
+ declare function oppositeRole(role: Role): Role;
2008
+ //#endregion
2009
+ //#region src/okhst.d.ts
2010
+ /**
2011
+ * Reference eps for the OKHST color space. WCAG 2 contrast is
2012
+ * `(Y_hi + 0.05) / (Y_lo + 0.05)`, so an eps of `0.05` makes equal tone
2013
+ * steps yield equal WCAG contrast. This is the canonical eps used by
2014
+ * `okhst()` input, `{ h, s, t }` input, stored `ResolvedColorVariant.t`,
2015
+ * relative `tone` offsets, and the contrast solver.
2016
+ */
2017
+ declare const REF_EPS = 0.05;
2018
+ /**
2019
+ * Map a luminance `Y` (0–1) to tone (0–100) at the given eps.
2020
+ * `toneFromY(0) === 0` and `toneFromY(1) === 100` for any eps.
2021
+ */
2022
+ declare function toneFromY(y: number, eps?: number): number;
2023
+ /** Map a tone (0–100) back to luminance (0–1). Inverse of {@link toneFromY}. */
2024
+ declare function yFromTone(t: number, eps?: number): number;
2025
+ /** OKHSL lightness (0–1) -> tone (0–100). */
2026
+ declare function toTone(l: number, eps?: number): number;
2027
+ /** Tone (0–100) -> OKHSL lightness (0–1). Inverse of {@link toTone}. */
2028
+ declare function fromTone(t: number, eps?: number): number;
2029
+ /** Convert OKHST `{ h, s, t }` (t in 0–1) to OKHSL `{ h, s, l }`. */
2030
+ declare function okhstToOkhsl(c: {
2031
+ h: number;
2032
+ s: number;
2033
+ t: number;
2034
+ }): {
2035
+ h: number;
2036
+ s: number;
2037
+ l: number;
2038
+ };
2039
+ /** Convert OKHSL `{ h, s, l }` to OKHST `{ h, s, t }` (t in 0–1). */
2040
+ declare function okhslToOkhst(c: {
2041
+ h: number;
2042
+ s: number;
2043
+ l: number;
2044
+ }): {
2045
+ h: number;
2046
+ s: number;
2047
+ t: number;
2048
+ };
2049
+ /**
2050
+ * Edge adapter: a resolved variant stores canonical tone `t` (0–1). Convert
2051
+ * it to the OKHSL `{ h, s, l }` the formatters and luminance pipeline expect —
2052
+ * `s` and `l` on the same 0–1 factor scale, so `const { h, s, l } =
2053
+ * variantToOkhsl(v)` destructures straight into `formatOkhsl` / `formatRgb` /
2054
+ * `okhslToLinearSrgb` with no rescaling. `alpha` stays on the variant; use
2055
+ * `glaze.format(v, format)` for a string that carries it.
2056
+ */
2057
+ declare function variantToOkhsl(v: {
2058
+ h: number;
2059
+ s: number;
2060
+ t: number;
2061
+ }): {
2062
+ h: number;
2063
+ s: number;
2064
+ l: number;
2065
+ };
2066
+ //#endregion
492
2067
  //#region src/okhsl-color-math.d.ts
493
2068
  /**
494
2069
  * OKHSL color math primitives for the glaze theme generator.
495
2070
  *
496
- * Provides bidirectional OKHSL ↔ sRGB conversion, relative luminance
497
- * computation for WCAG 2 contrast calculations, and multi-format output
498
- * (okhsl, rgb, hsl, oklch).
2071
+ * Provides bidirectional OKHSL ↔ sRGB conversion, luminance computation
2072
+ * for both contrast metrics (WCAG 2 relative luminance and APCA screen
2073
+ * luminance `Ys` — both the exact functions the contrast solver uses, and
2074
+ * both public), strict hex parsing (`parseHex` / `parseHexAlpha` check every
2075
+ * digit), and multi-format output (okhsl, rgb, hsl, oklch, plus the
2076
+ * `color(srgb-linear …)` writer for HDR glow values, whose channels may exceed
2077
+ * 1).
2078
+ */
2079
+ type Vec3 = [number, number, number];
2080
+ /**
2081
+ * OKHSL toe function: maps OKLab lightness L to perceptual lightness l.
2082
+ * Exported for the OKHST tone transfers in `okhst.ts`.
2083
+ */
2084
+ /**
2085
+ * OKHSL lightness of the gamut cusp for a hue — the lightness where the
2086
+ * realizable chroma peaks. Reuses the same `find_cusp` OKHSL already runs for
2087
+ * its `s` normalization (no new color math); the OKLab cusp lightness is run
2088
+ * through the OKHSL `toe` and clamped to `[0.001, 0.999]` so divisions that
2089
+ * key off it stay safe. Cached per (rounded) hue.
2090
+ *
2091
+ * @param h Hue, 0–360.
499
2092
  */
2093
+ declare function cuspLightness(h: number): number;
500
2094
  /**
501
2095
  * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLab [L, a, b].
502
2096
  */
503
- declare function okhslToOklab(h: number, s: number, l: number): [number, number, number];
2097
+ declare function okhslToOklab(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
504
2098
  /**
505
2099
  * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to linear sRGB.
506
2100
  * Channels may exceed [0, 1] near gamut boundaries — caller must clamp if needed.
507
2101
  */
508
- declare function okhslToLinearSrgb(h: number, s: number, l: number): [number, number, number];
2102
+ declare function okhslToLinearSrgb(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
509
2103
  /**
510
2104
  * Compute relative luminance Y from linear sRGB channels.
511
2105
  * Per WCAG 2: Y = 0.2126·R + 0.7152·G + 0.0722·B
@@ -517,45 +2111,123 @@ declare function relativeLuminanceFromLinearRgb(rgb: [number, number, number]):
517
2111
  declare function contrastRatioFromLuminance(yA: number, yB: number): number;
518
2112
  /**
519
2113
  * Convert OKHSL to gamma-encoded sRGB (clamped to 0–1).
2114
+ * h: 0–360, s: 0–1, l: 0–1. Returns [r, g, b] with each channel 0–1.
520
2115
  */
521
- declare function okhslToSrgb(h: number, s: number, l: number): [number, number, number];
2116
+ declare function okhslToSrgb(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
522
2117
  /**
523
2118
  * Compute WCAG 2 relative luminance from linear sRGB, matching the browser
524
2119
  * rendering pipeline: gamma-encode, clamp to sRGB gamut [0,1], then linearize.
525
2120
  * This avoids over/under-estimating luminance for out-of-gamut OKHSL colors.
526
2121
  */
527
2122
  declare function gamutClampedLuminance(linearRgb: [number, number, number]): number;
2123
+ /**
2124
+ * Compute APCA screen luminance (`Ys`) from linear sRGB.
2125
+ *
2126
+ * APCA does not use the WCAG piecewise sRGB EOTF; it defines its own
2127
+ * luminance as `0.2126·R^2.4 + 0.7152·G^2.4 + 0.0722·B^2.4` over the
2128
+ * gamma-encoded (display) channels with a simple 2.4 exponent. The APCA
2129
+ * soft-clamp threshold in `apcaContrast` is calibrated against this basis,
2130
+ * so the solver must feed it `Ys`, not WCAG relative luminance. Channels
2131
+ * are gamut-clamped to [0, 1] first, matching `gamutClampedLuminance`.
2132
+ *
2133
+ * This is exactly the luminance Glaze's contrast solver (and its drift
2134
+ * check) feeds `apcaContrast`, so
2135
+ * `apcaContrast(apcaLuminanceFromLinearRgb(text), apcaLuminanceFromLinearRgb(bg))`
2136
+ * reproduces the solver's Lc for a resolved pair.
2137
+ */
2138
+ declare function apcaLuminanceFromLinearRgb(linearRgb: [number, number, number]): number;
2139
+ /**
2140
+ * Convert OKLab to OKHSL.
2141
+ * Input: [L, a, b] where L: 0–1, a/b: roughly -0.5 to 0.5.
2142
+ * Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
2143
+ */
2144
+ declare const oklabToOkhsl: (lab: Vec3, pastel?: boolean) => Vec3;
528
2145
  /**
529
2146
  * Convert gamma-encoded sRGB (0–1 per channel) to OKHSL.
530
2147
  * Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
531
2148
  */
532
- declare function srgbToOkhsl(rgb: [number, number, number]): [number, number, number];
2149
+ declare function srgbToOkhsl(rgb: [number, number, number], pastel?: boolean): [number, number, number];
2150
+ /**
2151
+ * Convert CSS HSL (sRGB-based) to gamma-encoded sRGB [r, g, b] in 0–1 range.
2152
+ * h: 0–360, s: 0–1, l: 0–1.
2153
+ *
2154
+ * Note: CSS HSL is not the same as OKHSL — it's HSL in the sRGB color space.
2155
+ * Use this when parsing `hsl(...)` strings before passing to `srgbToOkhsl`.
2156
+ */
2157
+ declare function hslToSrgb(h: number, s: number, l: number): [number, number, number];
533
2158
  /**
534
2159
  * Parse a hex color string (#rgb or #rrggbb) to sRGB [r, g, b] in 0–1 range.
535
- * Returns null if the string is not a valid hex color.
2160
+ * The leading `#` is optional. Returns null if the string is not a valid hex
2161
+ * color: a wrong length, any character outside `0-9a-f` (case-insensitive),
2162
+ * or a form with alpha.
2163
+ *
2164
+ * For 8-digit hex (`#rrggbbaa`) and 4-digit hex (`#rgba`) with alpha,
2165
+ * use {@link parseHexAlpha}.
536
2166
  */
537
2167
  declare function parseHex(hex: string): [number, number, number] | null;
2168
+ /**
2169
+ * Parse a hex color string (#rgb, #rrggbb, #rgba, or #rrggbbaa) to
2170
+ * sRGB [r, g, b] in 0–1 range plus an optional alpha (0–1).
2171
+ * The leading `#` is optional. Returns null if the string is not a valid hex
2172
+ * color: a wrong length or any character outside `0-9a-f`
2173
+ * (case-insensitive).
2174
+ *
2175
+ * Every digit is checked up front: `parseInt` alone stops at the first bad
2176
+ * character, so `'#1z2z3z'` would otherwise read as `#010203`.
2177
+ */
2178
+ declare function parseHexAlpha(hex: string): {
2179
+ rgb: [number, number, number];
2180
+ alpha?: number;
2181
+ } | null;
538
2182
  /**
539
2183
  * Format OKHSL values as a CSS `okhsl(H S% L%)` string.
540
- * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
2184
+ * h: 0–360, s: 0–1, l: 0–1 (factor scale, as returned by every converter).
2185
+ */
2186
+ declare function formatOkhsl(h: number, s: number, l: number, pastel?: boolean): string;
2187
+ /**
2188
+ * Format OKHST values as a CSS `okhst(H S% T%)` string.
2189
+ * h: 0–360, s: 0–1, t: 0–1 (factor scale, matching `ResolvedColorVariant`).
2190
+ *
2191
+ * Pastel recompute matches `formatOkhsl`: convert via OKLab so external
2192
+ * parsers that only understand non-pastel OKHST render identically.
541
2193
  */
542
- declare function formatOkhsl(h: number, s: number, l: number): string;
2194
+ declare function formatOkhst(h: number, s: number, t: number, pastel?: boolean): string;
543
2195
  /**
544
2196
  * Format OKHSL values as a CSS `rgb(R G B)` string.
545
2197
  * Uses 2 decimal places to avoid 8-bit quantization contrast loss.
546
- * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
2198
+ * h: 0–360, s: 0–1, l: 0–1 (factor scale, as returned by every converter).
547
2199
  */
548
- declare function formatRgb(h: number, s: number, l: number): string;
2200
+ declare function formatRgb(h: number, s: number, l: number, pastel?: boolean): string;
549
2201
  /**
550
2202
  * Format OKHSL values as a CSS `hsl(H S% L%)` string.
551
- * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
2203
+ * h: 0–360, s: 0–1, l: 0–1 (factor scale, as returned by every converter).
552
2204
  */
553
- declare function formatHsl(h: number, s: number, l: number): string;
2205
+ declare function formatHsl(h: number, s: number, l: number, pastel?: boolean): string;
554
2206
  /**
555
2207
  * Format OKHSL values as a CSS `oklch(L C H)` string.
556
- * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
2208
+ * h: 0–360, s: 0–1, l: 0–1 (factor scale, as returned by every converter).
2209
+ */
2210
+ declare function formatOklch(h: number, s: number, l: number, pastel?: boolean): string;
2211
+ /**
2212
+ * Format linear sRGB channels as a CSS `color(srgb-linear R G B)` string with
2213
+ * 4 decimals. Unlike the other writers it takes linear light, not OKHSL, and
2214
+ * does not clamp: a channel may exceed 1, which is how an HDR glow value
2215
+ * (`glaze.formatHdr()`) goes past SDR white — `1` is SDR white, `2` one stop
2216
+ * above it. Opaque only; HDR values carry no alpha.
2217
+ */
2218
+ declare function formatSrgbLinear(rgb: [number, number, number]): string;
2219
+ /**
2220
+ * Convert gamma-encoded sRGB channels (0–1) to a 6-digit lowercase hex
2221
+ * string (`#rrggbb`). Channels are clamped to [0,1] and rounded to 8-bit.
2222
+ * Alpha is not encoded here — DTCG carries it as a separate `alpha` field.
2223
+ */
2224
+ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
2225
+ /**
2226
+ * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLCH components `[L, C, H]`.
2227
+ * L: 0–1, C: 0–~0.4 (chroma), H: 0–360 (hue). Shared by `formatOklch` and
2228
+ * the DTCG `oklch` colorSpace exporter so the two never drift apart.
557
2229
  */
558
- declare function formatOklch(h: number, s: number, l: number): string;
2230
+ declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
559
2231
  //#endregion
560
- export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorToken, type GlazeConfig, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type MinContrast, type MixColorDef, type OkhslColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, parseHex, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
2232
+ export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, GLAZE_EXPORT_VERSION, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeCssSchemeBlocks, type GlazeDtcgExtensions, type GlazeDtcgHdr, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExportKind, type GlazeExportVersion, type GlazeExtendOptions, type GlazeFromInput, type GlazeGlowInput, type GlazeHdrFormat, type GlazeJsonOptions, type GlazeLightingInput, type GlazeOutputModes, type GlazePalette, type GlazePaletteCssOptions, type GlazePaletteExport, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazePaletteTastyOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTastyOptions, type GlazeTheme, type GlazeThemeExport, type GlazeThemeSeed, type GlazeTokenOptions, type GlowColorDef, type GlowTuning, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type LightingTuning, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type ResolvedHdr, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, apcaLuminanceFromLinearRgb, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, formatSrgbLinear, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, isColorTokenExport, isPaletteExport, isThemeExport, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForLevel, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
561
2233
  //# sourceMappingURL=index.d.cts.map