@tenphi/glaze 0.0.0-snapshot.60e8979 → 0.0.0-snapshot.63c08ea

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.mts CHANGED
@@ -1,48 +1,113 @@
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
+ * APCA lightness contrast (Lc), signed: positive for dark text on light bg,
67
+ * negative for light text on dark bg. Inputs are screen luminances (0–1).
68
+ */
69
+ declare function apcaContrast(yText: number, yBg: number): number;
70
+ interface FindToneForContrastOptions {
13
71
  /** Hue of the candidate color (0–360). */
14
72
  hue: number;
15
73
  /** Saturation of the candidate color (0–1). */
16
74
  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];
75
+ /** Preferred tone of the candidate (0–1). */
76
+ preferredTone: number;
77
+ /** Base/reference color as linear sRGB. */
78
+ baseLinearRgb: LinearRgb;
79
+ /** Resolved contrast floor (metric + target). */
80
+ contrast: ResolvedContrast;
81
+ /** Search bounds for tone. Default: [0, 1]. */
82
+ toneRange?: [number, number];
25
83
  /** Convergence threshold. Default: 1e-4. */
26
84
  epsilon?: number;
27
- /** Maximum binary-search iterations per branch. Default: 14. */
85
+ /** Maximum binary-search iterations per branch. Default: 18. */
28
86
  maxIterations?: number;
87
+ /** Preferred search direction before auto-flip is considered. */
88
+ initialDirection?: 'lighter' | 'darker';
89
+ /** Auto-flip tone direction when contrast can't be met. Default: false. */
90
+ flip?: boolean;
91
+ /** Use the hue-independent "safe" chroma boundary. Default: false. */
92
+ pastel?: boolean;
29
93
  }
30
- interface FindLightnessForContrastResult {
31
- /** Chosen lightness in 0–1. */
32
- lightness: number;
33
- /** Achieved WCAG contrast ratio. */
94
+ interface FindToneForContrastResult {
95
+ /** Chosen tone in 0–1. */
96
+ tone: number;
97
+ /** Achieved score (WCAG ratio or APCA Lc magnitude). */
34
98
  contrast: number;
35
99
  /** Whether the target was reached. */
36
100
  met: boolean;
37
101
  /** Which branch was selected. */
38
102
  branch: 'lighter' | 'darker' | 'preferred';
103
+ /** Whether the result auto-flipped to the opposite direction. */
104
+ flipped?: boolean;
39
105
  }
40
- declare function resolveMinContrast(value: MinContrast$1): number;
41
106
  /**
42
- * Find the OKHSL lightness that satisfies a WCAG 2 contrast target
43
- * against a base color, staying as close to `preferredLightness` as possible.
107
+ * Find the tone that satisfies a contrast floor against a base color,
108
+ * staying as close to `preferredTone` as possible.
44
109
  */
45
- declare function findLightnessForContrast(options: FindLightnessForContrastOptions): FindLightnessForContrastResult;
110
+ declare function findToneForContrast(options: FindToneForContrastOptions): FindToneForContrastResult;
46
111
  interface FindValueForMixContrastOptions {
47
112
  /** Preferred mix parameter (0–1). */
48
113
  preferredValue: number;
@@ -50,42 +115,84 @@ interface FindValueForMixContrastOptions {
50
115
  baseLinearRgb: LinearRgb;
51
116
  /** Target color as linear sRGB. */
52
117
  targetLinearRgb: LinearRgb;
53
- /** WCAG contrast target. */
54
- contrast: MinContrast$1;
55
- /**
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.
59
- */
118
+ /** Resolved contrast floor (metric + target). */
119
+ contrast: ResolvedContrast;
120
+ /** Compute the luminance of the mixed color at parameter t. */
60
121
  luminanceAtValue: (t: number) => number;
61
122
  /** Convergence threshold. Default: 1e-4. */
62
123
  epsilon?: number;
63
124
  /** Maximum binary-search iterations per branch. Default: 20. */
64
125
  maxIterations?: number;
126
+ /** Auto-flip mix direction when contrast can't be met. Default: false. */
127
+ flip?: boolean;
65
128
  }
66
129
  interface FindValueForMixContrastResult {
67
- /** Chosen mix parameter (0–1). */
68
130
  value: number;
69
- /** Achieved WCAG contrast ratio. */
70
131
  contrast: number;
71
- /** Whether the target was reached. */
72
132
  met: boolean;
133
+ flipped?: boolean;
73
134
  }
74
135
  /**
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.
136
+ * Find the mix parameter (ratio or opacity) that satisfies a contrast floor
137
+ * against a base color, staying as close to `preferredValue` as possible.
77
138
  */
78
139
  declare function findValueForMixContrast(options: FindValueForMixContrastOptions): FindValueForMixContrastResult;
79
140
  //#endregion
80
141
  //#region src/types.d.ts
81
142
  /** A value or [normal, high-contrast] pair. */
82
143
  type HCPair<T> = T | [T, T];
144
+ /** Bare WCAG contrast target: a ratio number or a named preset. */
83
145
  type MinContrast = number | ContrastPreset;
146
+ /**
147
+ * A contrast floor with a pluggable metric.
148
+ *
149
+ * - `number` / `ContrastPreset`: a WCAG ratio (bare form).
150
+ * - `{ wcag }`: WCAG ratio or preset, optionally an HC pair.
151
+ * - `{ apca }`: APCA Lc target (absolute value or preset), optionally an HC pair.
152
+ *
153
+ * The `[normal, highContrast]` pair may live at the outer level
154
+ * (`[4.5, 7]`, `[{ wcag: 4.5 }, { wcag: 7 }]`) or inside the metric
155
+ * (`{ wcag: [4.5, 7] }`, `{ apca: [45, 60] }`, `{ apca: ['content', 'body'] }`).
156
+ */
157
+ type ContrastSpec = number | ContrastPreset | {
158
+ wcag: HCPair<number | ContrastPreset>;
159
+ } | {
160
+ apca: HCPair<number | ApcaPreset>;
161
+ };
162
+ /**
163
+ * The semantic role a color plays against its base, used to fix APCA contrast
164
+ * polarity (which side is the foreground vs the background). WCAG is
165
+ * symmetric, so role never changes WCAG results.
166
+ */
167
+ type Role = 'text' | 'surface' | 'border';
168
+ /**
169
+ * Any string accepted as a `role`. Canonical values plus aliases normalized by
170
+ * `normalizeRole` (see `roles.ts`): `surface` (bg/background/fill/canvas/
171
+ * paper/layer), `text` (fg/foreground/content/ink/label/stroke), `border`
172
+ * (divider/outline/separator/hairline/rule).
173
+ */
174
+ type RoleInput = Role | 'bg' | 'background' | 'fill' | 'canvas' | 'paper' | 'layer' | 'fg' | 'foreground' | 'content' | 'ink' | 'label' | 'stroke' | 'divider' | 'outline' | 'separator' | 'hairline' | 'rule';
84
175
  type AdaptationMode = 'auto' | 'fixed' | 'static';
85
176
  /** A signed relative offset string, e.g. '+20' or '-15.5'. */
86
177
  type RelativeValue = `+${number}` | `-${number}`;
178
+ /**
179
+ * Force a color to a tone extreme:
180
+ * - `'max'`: the highest tone in the active scheme range/window.
181
+ * - `'min'`: the lowest tone.
182
+ *
183
+ * Under `mode: 'auto'` the extreme inverts in the dark scheme (so `'max'`
184
+ * tracks the inversion and becomes the darkest tone). No `base` required.
185
+ */
186
+ type ExtremeValue = 'max' | 'min';
187
+ /**
188
+ * A tone value as authored on a color.
189
+ * - Number: absolute tone (0–100).
190
+ * - `'+N'` / `'-N'`: relative to the base's tone (requires `base`).
191
+ * - `'max'` / `'min'`: forced to the scheme's tone extreme (no base needed).
192
+ */
193
+ type ToneValue = number | RelativeValue | ExtremeValue;
87
194
  /** Color format for output. */
88
- type GlazeColorFormat = 'okhsl' | 'rgb' | 'hsl' | 'oklch';
195
+ type GlazeColorFormat = 'okhsl' | 'okhst' | 'rgb' | 'hsl' | 'oklch';
89
196
  /**
90
197
  * Controls which scheme variants are generated in the export.
91
198
  * Light is always included (it's the default).
@@ -104,13 +211,35 @@ interface OkhslColor {
104
211
  s: number;
105
212
  l: number;
106
213
  }
214
+ /**
215
+ * Direct OKHST color input — OKHSL with the lightness axis replaced by the
216
+ * contrast-uniform tone axis. `h`: 0–360, `s`: 0–1, `t`: 0–1 (tone).
217
+ */
218
+ interface OkhstColor {
219
+ h: number;
220
+ s: number;
221
+ t: number;
222
+ }
223
+ /** sRGB components in 0–255 (value-shorthand object form). */
224
+ interface RgbColor {
225
+ r: number;
226
+ g: number;
227
+ b: number;
228
+ }
229
+ /** OKLCh components matching CSS `oklch(L C H)` (L/C: 0–1, H: degrees). */
230
+ interface OklchColor {
231
+ l: number;
232
+ c: number;
233
+ h: number;
234
+ }
107
235
  interface RegularColorDef {
108
236
  /**
109
- * Lightness value (0–100).
110
- * - Number: absolute lightness.
111
- * - String ('+N' / '-N'): relative to base color's lightness (requires `base`).
237
+ * Tone value (0–100, contrast-uniform — see `docs/okhst.md`).
238
+ * - Number: absolute tone.
239
+ * - String ('+N' / '-N'): relative to base color's tone (requires `base`).
240
+ * - `'max'` / `'min'`: force to the scheme's tone extreme (no base needed).
112
241
  */
113
- lightness?: HCPair<number | RelativeValue>;
242
+ tone?: HCPair<ToneValue>;
114
243
  /** Saturation factor applied to the seed saturation (0–1, default: 1). */
115
244
  saturation?: number;
116
245
  /**
@@ -121,18 +250,55 @@ interface RegularColorDef {
121
250
  hue?: number | RelativeValue;
122
251
  /** Name of another color in the same theme (dependent color). */
123
252
  base?: string;
124
- /** WCAG contrast ratio floor against the base color. */
125
- contrast?: HCPair<MinContrast>;
253
+ /**
254
+ * Contrast floor against the base color. A bare number/preset is WCAG;
255
+ * use `{ wcag }` / `{ apca }` to pick the metric. Accepts an HC pair.
256
+ */
257
+ contrast?: HCPair<ContrastSpec>;
126
258
  /** Adaptation mode. Default: 'auto'. */
127
259
  mode?: AdaptationMode;
260
+ /**
261
+ * Whether to flip out-of-bounds results to the opposite side instead of
262
+ * clamping to the extreme. Affects both:
263
+ * - relative `tone`: when `base ± delta` exceeds `[0, 100]`, mirror the
264
+ * delta to the other side of the base.
265
+ * - `contrast`: when the requested direction can't meet the floor, try the
266
+ * opposite side (same as the global `autoFlip`).
267
+ *
268
+ * Defaults to the global `autoFlip` config (default `true`). Set `false`
269
+ * to clamp instead.
270
+ */
271
+ autoFlip?: boolean;
128
272
  /**
129
273
  * Fixed opacity (0–1).
130
274
  * Output includes alpha in the CSS value.
131
275
  * Does not affect contrast resolution — a semi-transparent color
132
- * has no fixed perceived lightness, so `contrast` and `opacity`
276
+ * has no fixed perceived tone, so `contrast` and `opacity`
133
277
  * should not be combined (a console.warn is emitted).
134
278
  */
135
279
  opacity?: number;
280
+ /**
281
+ * Per-color override for the hue-independent "safe" chroma limit used in
282
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
283
+ * Falls through to the global / per-theme `pastel` config when omitted.
284
+ * @see GlazeConfig.pastel
285
+ */
286
+ pastel?: boolean;
287
+ /**
288
+ * Semantic role against `base`: how this color is used. Fixes APCA contrast
289
+ * polarity (the argument order in `apcaContrast`). WCAG is symmetric so it
290
+ * never affects WCAG results.
291
+ *
292
+ * Resolution: explicit `role` wins; else inferred from the color name when
293
+ * `inferRole` is enabled (default); else the opposite of the base's role;
294
+ * else defaults to `'text'` (foreground).
295
+ */
296
+ role?: RoleInput;
297
+ /**
298
+ * Whether this color is inherited by child themes created via `extend()`.
299
+ * Default: true. Set to false to make this color local to the current theme.
300
+ */
301
+ inherit?: boolean;
136
302
  }
137
303
  /** Shadow tuning knobs. All values use the 0–1 scale (OKHSL). */
138
304
  interface ShadowTuning {
@@ -177,6 +343,18 @@ interface ShadowColorDef {
177
343
  intensity: HCPair<number>;
178
344
  /** Override default tuning. Merged field-by-field with global `shadowTuning`. */
179
345
  tuning?: ShadowTuning;
346
+ /**
347
+ * Per-color override for the hue-independent "safe" chroma limit used in
348
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
349
+ * Falls through to the global / per-theme `pastel` config when omitted.
350
+ * @see GlazeConfig.pastel
351
+ */
352
+ pastel?: boolean;
353
+ /**
354
+ * Whether this color is inherited by child themes created via `extend()`.
355
+ * Default: true. Set to false to make this color local to the current theme.
356
+ */
357
+ inherit?: boolean;
180
358
  }
181
359
  interface MixColorDef {
182
360
  type: 'mix';
@@ -205,25 +383,56 @@ interface MixColorDef {
205
383
  */
206
384
  space?: 'okhsl' | 'srgb';
207
385
  /**
208
- * Minimum WCAG contrast between the base and the resulting color.
386
+ * Minimum contrast between the base and the resulting color.
209
387
  * In 'opaque' mode, adjusts the mix ratio to meet contrast.
210
388
  * In 'transparent' mode, adjusts opacity to meet contrast against the composite.
211
- * Supports [normal, highContrast] pair.
389
+ * A bare number/preset is WCAG; use `{ wcag }` / `{ apca }` to pick the
390
+ * metric. Supports [normal, highContrast] pair.
391
+ */
392
+ contrast?: HCPair<ContrastSpec>;
393
+ /**
394
+ * Per-color override for the hue-independent "safe" chroma limit used in
395
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
396
+ * Falls through to the global / per-theme `pastel` config when omitted.
397
+ * @see GlazeConfig.pastel
212
398
  */
213
- contrast?: HCPair<MinContrast>;
399
+ pastel?: boolean;
400
+ /**
401
+ * Semantic role of the mixed result against `base`. Same semantics as
402
+ * `RegularColorDef.role` (fixes APCA polarity). Resolution and defaults
403
+ * are identical.
404
+ */
405
+ role?: RoleInput;
406
+ /**
407
+ * Whether this color is inherited by child themes created via `extend()`.
408
+ * Default: true. Set to false to make this color local to the current theme.
409
+ */
410
+ inherit?: boolean;
214
411
  }
215
412
  type ColorDef = RegularColorDef | ShadowColorDef | MixColorDef;
216
413
  type ColorMap = Record<string, ColorDef>;
217
- /** Resolved color for a single scheme variant. */
414
+ /**
415
+ * Resolved color for a single scheme variant.
416
+ *
417
+ * Stored in OKHST: `h` / `s` are OKHSL hue/saturation, `t` is the canonical
418
+ * contrast-uniform tone (0–1, reference eps). Convert to OKHSL lightness via
419
+ * `variantToOkhsl` at the rendering / luminance edges.
420
+ */
218
421
  interface ResolvedColorVariant {
219
422
  /** OKHSL hue (0–360). */
220
423
  h: number;
221
424
  /** OKHSL saturation (0–1). */
222
425
  s: number;
223
- /** OKHSL lightness (0–1). */
224
- l: number;
426
+ /** Canonical tone (0–1, reference eps). */
427
+ t: number;
225
428
  /** Opacity (0–1). Default: 1. */
226
429
  alpha: number;
430
+ /**
431
+ * Effective `pastel` flag used while resolving this variant (author def or
432
+ * config fallback). Carried on the variant so output formatting matches the
433
+ * gamut mapping applied during resolution.
434
+ */
435
+ pastel?: boolean;
227
436
  }
228
437
  /** Fully resolved color across all scheme variants. */
229
438
  interface ResolvedColor {
@@ -235,21 +444,32 @@ interface ResolvedColor {
235
444
  /** Adaptation mode. Present only for regular colors, omitted for shadows. */
236
445
  mode?: AdaptationMode;
237
446
  }
447
+ /**
448
+ * A scheme tone window.
449
+ * - `[lo, hi]`: OKHSL-lightness endpoints (0–100) the authored tone is
450
+ * remapped into, using the reference eps `0.05`. The common form.
451
+ * - `{ lo, hi, eps }`: same, with an explicit render curvature `eps`
452
+ * (advanced — most palettes never need this).
453
+ * - `false`: disable clamping (full range `[0, 100]` at the reference eps).
454
+ * This removes the *boundaries*, not the tone curve.
455
+ */
456
+ type ToneWindow = false | [number, number] | {
457
+ lo: number;
458
+ hi: number;
459
+ eps: number;
460
+ };
238
461
  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];
462
+ /** Light scheme tone window — `[lo, hi]` (default `[10, 100]`), `{ lo, hi, eps }` for advanced eps tuning, or `false` to disable clamping. */
463
+ lightTone?: ToneWindow;
464
+ /** Dark scheme tone window — `[lo, hi]` (default `[15, 95]`), `{ lo, hi, eps }`, or `false` to disable clamping. */
465
+ darkTone?: ToneWindow;
243
466
  /** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
244
467
  darkDesaturation?: number;
245
468
  /**
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.
469
+ * State alias names for Tasty token export. Default to media-query states
470
+ * (`'@media(prefers-color-scheme: dark)'` / `'@media(prefers-contrast: more)'`)
471
+ * so tokens react to the OS preference without registering custom states.
250
472
  */
251
- darkCurve?: HCPair<number>;
252
- /** State alias names for token export. */
253
473
  states?: {
254
474
  dark?: string;
255
475
  highContrast?: string;
@@ -258,42 +478,303 @@ interface GlazeConfig {
258
478
  modes?: GlazeOutputModes;
259
479
  /** Default tuning for all shadow colors. Per-color tuning merges field-by-field. */
260
480
  shadowTuning?: ShadowTuning;
481
+ /**
482
+ * Automatically flip tone direction when contrast can't be met.
483
+ *
484
+ * When enabled (default `true`), the solver searches the requested
485
+ * tone direction first. If that direction can't reach the target,
486
+ * it tries the opposite direction and uses it when it passes. If neither
487
+ * side passes, the tone is pinned to the requested-direction
488
+ * extreme and a warning is emitted.
489
+ *
490
+ * Set to `false` for strict "no flip" behavior. The opposite
491
+ * direction is never considered: if the requested direction can't
492
+ * meet the target, the tone is pinned to its extreme (never
493
+ * falls back to the originally requested tone).
494
+ */
495
+ autoFlip?: boolean;
496
+ /**
497
+ * If true, uses a hue-independent "safe" chroma limit across all colors
498
+ * so that scaling saturation never exceeds the sRGB boundary at any hue
499
+ * for the given lightness.
500
+ * @default false
501
+ */
502
+ pastel?: boolean;
503
+ /**
504
+ * If true (default), infer a color's `role` from its name when no explicit
505
+ * `role` is set. Set to `false` to opt out of name-based inference (the
506
+ * base-opposite and default-foreground fallbacks still apply).
507
+ * @default true
508
+ */
509
+ inferRole?: boolean;
261
510
  }
262
511
  interface GlazeConfigResolved {
263
- lightLightness: [number, number];
264
- darkLightness: [number, number];
512
+ lightTone: ToneWindow;
513
+ darkTone: ToneWindow;
265
514
  darkDesaturation: number;
266
- darkCurve: HCPair<number>;
267
515
  states: {
268
516
  dark: string;
269
517
  highContrast: string;
270
518
  };
271
519
  modes: Required<GlazeOutputModes>;
272
520
  shadowTuning?: ShadowTuning;
521
+ autoFlip: boolean;
522
+ pastel: boolean;
523
+ inferRole: boolean;
524
+ }
525
+ /**
526
+ * Per-instance config override for `glaze.color()` and `glaze()` themes.
527
+ * Fields that are set take priority over the live global config. Fields
528
+ * that are omitted fall through to the live global at resolve time.
529
+ *
530
+ * `false` for a tone window disables clamping (full range at reference eps).
531
+ */
532
+ interface GlazeConfigOverride {
533
+ /** Light scheme tone window, or `false` to disable clamping. */
534
+ lightTone?: ToneWindow;
535
+ /** Dark scheme tone window, or `false` to disable clamping. */
536
+ darkTone?: ToneWindow;
537
+ /** Saturation reduction factor for dark scheme (0–1). */
538
+ darkDesaturation?: number;
539
+ /** Whether to auto-flip tone when contrast can't be met. */
540
+ autoFlip?: boolean;
541
+ /**
542
+ * If true, uses a hue-independent "safe" chroma limit across all colors
543
+ * so that scaling saturation never exceeds the sRGB boundary at any hue
544
+ * for the given lightness.
545
+ */
546
+ pastel?: boolean;
547
+ /**
548
+ * If true, infer a color's `role` from its name when no explicit `role` is
549
+ * set. Falls through to the live global at resolve time when omitted.
550
+ */
551
+ inferRole?: boolean;
552
+ /**
553
+ * Shadow tuning defaults. Only meaningful for themes; harmless on
554
+ * standalone color tokens.
555
+ */
556
+ shadowTuning?: ShadowTuning;
273
557
  }
274
558
  /** Serialized theme configuration (no resolved values). */
275
559
  interface GlazeThemeExport {
276
560
  hue: number;
277
561
  saturation: number;
278
562
  colors: ColorMap;
563
+ /** Per-theme config override, if any. */
564
+ config?: GlazeConfigOverride;
279
565
  }
280
566
  /** Input for `glaze.shadow()` standalone factory. */
281
567
  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;
568
+ /**
569
+ * Background color — accepts any `GlazeColorValue` form: hex
570
+ * (`#rgb` / `#rrggbb` / `#rrggbbaa`), `rgb()` / `hsl()` / `okhsl()`
571
+ * / `oklch()` strings, or literal objects (`{ r, g, b }`, `{ h, s, l }`,
572
+ * `{ l, c, h }`). Alpha components are dropped with a warning.
573
+ */
574
+ bg: GlazeColorValue;
575
+ /**
576
+ * Foreground color for tinting + intensity modulation. Accepts the
577
+ * same forms as `bg`.
578
+ */
579
+ fg?: GlazeColorValue;
286
580
  /** Intensity 0-100. */
287
581
  intensity: number;
288
582
  tuning?: ShadowTuning;
289
583
  }
290
- /** Input for `glaze.color()` standalone factory. */
584
+ /** Input for the structured `glaze.color()` overload. */
291
585
  interface GlazeColorInput {
292
586
  hue: number;
293
587
  saturation: number;
294
- lightness: HCPair<number>;
588
+ tone: HCPair<number | ExtremeValue>;
295
589
  saturationFactor?: number;
296
590
  mode?: AdaptationMode;
591
+ /** Flip out-of-bounds results instead of clamping. Default: global `autoFlip`. */
592
+ autoFlip?: boolean;
593
+ /**
594
+ * Fixed opacity (0–1). Output includes alpha in the CSS value.
595
+ * Combining with `contrast` is not recommended (perceived tone
596
+ * becomes unpredictable) — a `console.warn` is emitted in that case.
597
+ */
598
+ opacity?: number;
599
+ /**
600
+ * Optional dependency on another color. Same semantics as
601
+ * `GlazeColorOverrides.base` — `contrast` and relative `tone`
602
+ * anchor to the base per scheme.
603
+ */
604
+ base?: GlazeColorToken | GlazeColorValue;
605
+ /**
606
+ * Contrast floor against `base`. Requires `base` to be set. A bare
607
+ * number/preset is WCAG; use `{ wcag }` / `{ apca }` to pick the metric.
608
+ */
609
+ contrast?: HCPair<ContrastSpec>;
610
+ /**
611
+ * Optional human-readable name for the token. Used in error and
612
+ * warning messages (otherwise an internal name like `"value"` is
613
+ * used). Does not affect output keys.
614
+ */
615
+ name?: string;
616
+ /**
617
+ * Per-color override for the hue-independent "safe" chroma limit used in
618
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
619
+ * Falls through to the global / per-theme `pastel` config when omitted.
620
+ * @see GlazeConfig.pastel
621
+ */
622
+ pastel?: boolean;
623
+ /**
624
+ * Semantic role against `base` / the literal seed: how this token is used.
625
+ * Fixes APCA contrast polarity. Same resolution chain as
626
+ * `RegularColorDef.role` (explicit → name inference → opposite of base →
627
+ * `'text'`). For standalone tokens the name is internal, so set `role`
628
+ * explicitly or rely on the base-opposite / foreground default.
629
+ */
630
+ role?: RoleInput;
631
+ }
632
+ /**
633
+ * Any single-color input form accepted by the value-shorthand
634
+ * overload of `glaze.color()`.
635
+ *
636
+ * Strings cover hex (`#rgb` / `#rrggbb` / `#rrggbbaa`, alpha dropped
637
+ * with a warning) and the four CSS color functions Glaze itself emits:
638
+ * `rgb()`, `hsl()`, `okhsl()`, `oklch()` (alpha components also dropped
639
+ * with a warning).
640
+ *
641
+ * Literal object forms:
642
+ * - `{ h, s, l }` — OKHSL (h: 0–360, s/l: 0–1). Passing 0–100 for `s`/`l`
643
+ * throws with a hint to use the structured form.
644
+ * - `{ h, s, t }` — OKHST (h: 0–360, s/t: 0–1). Tone in 0–1.
645
+ * - `{ r, g, b }` — sRGB 0–255.
646
+ * - `{ l, c, h }` — OKLCh (L/C: 0–1, H: degrees), same as `oklch()` strings.
647
+ */
648
+ type GlazeColorValue = string | OkhslColor | OkhstColor | RgbColor | OklchColor;
649
+ /** Color overrides for the `from` and value-shorthand inputs. */
650
+ interface GlazeColorOverrides {
651
+ /**
652
+ * Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
653
+ * to the extracted (or overridden) seed hue — same semantics as
654
+ * `RegularColorDef.hue`.
655
+ */
656
+ hue?: number | RelativeValue;
657
+ /** Override seed saturation (0–100). Default: extracted from value. */
658
+ saturation?: number;
659
+ /**
660
+ * Override tone. Number is absolute (0–100, contrast-uniform); `'+N'`/`'-N'`
661
+ * is relative to the literal seed (the value passed to `glaze.color()`);
662
+ * `'max'` / `'min'` force to the scheme's tone extreme.
663
+ * Supports HCPair for high-contrast.
664
+ */
665
+ tone?: HCPair<ToneValue>;
666
+ /** Saturation multiplier on the seed (0–1). Default: 1. */
667
+ saturationFactor?: number;
668
+ /**
669
+ * Adaptation mode. Defaults to `'auto'` for every input form, so
670
+ * colors automatically adapt between light and dark like an ordinary
671
+ * theme color. All value-shorthand inputs (strings and literal objects)
672
+ * preserve light tone (`lightTone: false`) and snapshot
673
+ * `globalConfig.darkTone` on the dark side. Only the structured
674
+ * `{ hue, saturation, tone }` form also snapshots
675
+ * `globalConfig.lightTone`.
676
+ *
677
+ * Pass `'fixed'` explicitly to opt back into the linear, non-
678
+ * inverting mapping; pass `'static'` to pin the same tone
679
+ * across every variant.
680
+ */
681
+ mode?: AdaptationMode;
682
+ /**
683
+ * Flip out-of-bounds results (relative `tone` overshoot / unmet
684
+ * `contrast`) to the opposite side instead of clamping. Defaults to
685
+ * the global `autoFlip`.
686
+ */
687
+ autoFlip?: boolean;
688
+ /**
689
+ * Contrast floor. By default solved against the literal seed
690
+ * (the value itself); when `base` is set, solved against the base's
691
+ * resolved variant per scheme. Same shape as `RegularColorDef.contrast`
692
+ * (bare number/preset = WCAG; `{ wcag }` / `{ apca }` to pick the metric).
693
+ */
694
+ contrast?: HCPair<ContrastSpec>;
695
+ /**
696
+ * Optional dependency on another color. Accepts either a
697
+ * `GlazeColorToken` (returned by another `glaze.color()`) or a raw
698
+ * `GlazeColorValue` (hex / CSS strings / `{ r, g, b }` / `{ h, s, l }` / …),
699
+ * which is automatically wrapped in `glaze.color(value)`.
700
+ *
701
+ * When set:
702
+ * - `contrast` is solved against the base's resolved variant
703
+ * per-scheme (light / dark / lightContrast / darkContrast).
704
+ * - Relative `tone: '+N'` / `'-N'` is anchored to the base's
705
+ * tone per-scheme (matches theme behavior for dependent colors).
706
+ * - Relative `hue: '+N'` / `'-N'` still anchors to the seed (the
707
+ * value passed to `glaze.color()`), not the base.
708
+ * - When the base was created via the structured form (with explicit
709
+ * `hue`/`saturation`/`tone`), it is resolved at full range
710
+ * (`lightTone: false`) for the linking math — ensuring the
711
+ * contrast/tone anchor matches the input tone, not the
712
+ * windowed output. The base's own `.resolve()` output is unaffected.
713
+ *
714
+ * The base token's `.resolve()` is called lazily on first resolve and
715
+ * its result is captured by reference; later mutations to the base's
716
+ * defining call don't apply (matches existing token snapshot semantics).
717
+ */
718
+ base?: GlazeColorToken | GlazeColorValue;
719
+ /**
720
+ * Fixed opacity (0–1). Output includes alpha in the CSS value.
721
+ * Combining with `contrast` is not recommended (perceived tone
722
+ * becomes unpredictable) — a `console.warn` is emitted in that case.
723
+ */
724
+ opacity?: number;
725
+ /**
726
+ * Optional human-readable name for the token. Used in error and
727
+ * warning messages (otherwise an internal name like `"value"` is
728
+ * used). Does not affect output keys.
729
+ */
730
+ name?: string;
731
+ /**
732
+ * Per-color override for the hue-independent "safe" chroma limit used in
733
+ * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
734
+ * Falls through to the global / per-theme `pastel` config when omitted.
735
+ * @see GlazeConfig.pastel
736
+ */
737
+ pastel?: boolean;
738
+ /**
739
+ * Semantic role against `base` / the literal seed: how this token is used.
740
+ * Fixes APCA contrast polarity. Same resolution chain as
741
+ * `RegularColorDef.role`.
742
+ */
743
+ role?: RoleInput;
744
+ }
745
+ /**
746
+ * Object input for `glaze.color()` that carries a raw color value plus
747
+ * optional color overrides in the same object.
748
+ *
749
+ * ```ts
750
+ * glaze.color({ from: '#1a1a2e', base: bg, contrast: 'AA' })
751
+ * glaze.color({ from: { r: 38, g: 252, b: 178 }, tone: '+10' })
752
+ * ```
753
+ */
754
+ interface GlazeFromInput extends GlazeColorOverrides {
755
+ /** The source color value. Accepts the same forms as a bare `GlazeColorValue`. */
756
+ from: GlazeColorValue;
757
+ }
758
+ /** Options for `GlazeColorToken.css()`. */
759
+ interface GlazeColorCssOptions {
760
+ /**
761
+ * Custom property base name (without leading `--`). Required.
762
+ * Becomes the variable identifier in the output, e.g.
763
+ * `name: 'brand'` → `--brand-color: …`.
764
+ */
765
+ name: string;
766
+ /** Output color format. Default: 'oklch'. */
767
+ format?: GlazeColorFormat;
768
+ /**
769
+ * Suffix appended to the name. Default: '-color' (matches
770
+ * `theme.css` default).
771
+ */
772
+ suffix?: string;
773
+ /**
774
+ * Emit hue as a separate custom property, referenced via `var()`.
775
+ * Requires `format: 'oklch'` and a pastel token. oklch + all-pastel only.
776
+ */
777
+ splitHue?: boolean;
297
778
  }
298
779
  /** Return type for `glaze.color()`. */
299
780
  interface GlazeColorToken {
@@ -303,18 +784,111 @@ interface GlazeColorToken {
303
784
  token(options?: GlazeTokenOptions): Record<string, string>;
304
785
  /**
305
786
  * 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
787
+ * Uses `#name` keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
788
+ * @see https://tasty.style/docs
308
789
  */
309
790
  tasty(options?: GlazeTokenOptions): Record<string, string>;
310
791
  /** Export as a flat JSON map (no color name key). */
311
792
  json(options?: GlazeJsonOptions): Record<string, string>;
793
+ /** Export as CSS custom property declarations grouped by scheme variant. */
794
+ css(options: GlazeColorCssOptions): GlazeCssResult;
795
+ /**
796
+ * Export as W3C DTCG color tokens (one per scheme variant, no color name
797
+ * key). Each entry is a full `{ $type: 'color', $value }` token.
798
+ * @see https://www.designtokens.org/
799
+ */
800
+ dtcg(options?: GlazeDtcgOptions): GlazeColorDtcgResult;
801
+ /**
802
+ * Export as a single W3C DTCG Resolver-Module document for this color,
803
+ * keyed by `name` across all scheme variants. `name` is required.
804
+ * @see https://www.designtokens.org/
805
+ */
806
+ dtcgResolver(options: GlazeColorDtcgResolverOptions): GlazeDtcgResolverDocument;
807
+ /**
808
+ * Export as a Tailwind CSS v4 `@theme` block (light baseline) plus dark /
809
+ * high-contrast overrides. Returns a single ready-to-paste CSS string.
810
+ * `name` is required (forms `--color-<name>`).
811
+ * @see https://tailwindcss.com/docs/theme
812
+ */
813
+ tailwind(options: GlazeColorTailwindOptions): string;
814
+ /**
815
+ * Serialize the token as a JSON-safe object. Captures the original
816
+ * input value, overrides, and config so it can be rehydrated via
817
+ * `glaze.colorFrom(...)`. `base` is recursively serialized.
818
+ */
819
+ export(): GlazeColorTokenExport;
820
+ }
821
+ /**
822
+ * JSON-safe serialization of a `glaze.color()` token. Pass to
823
+ * `glaze.colorFrom(...)` to rehydrate.
824
+ */
825
+ interface GlazeColorTokenExport {
826
+ /**
827
+ * Discriminator for the source overload that created the token.
828
+ * - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
829
+ * - `'structured'`: created via `glaze.color({ hue, saturation, ... })`.
830
+ */
831
+ form: 'value' | 'structured';
832
+ /** Original input. For `form: 'value'` this is the raw `GlazeColorValue`; for `form: 'structured'` this is the structured input. */
833
+ input: GlazeColorValue | GlazeColorInputExport;
834
+ /**
835
+ * Overrides recorded at creation time. `base` is recursively
836
+ * serialized. Only present for `form: 'value'`.
837
+ */
838
+ overrides?: GlazeColorOverridesExport;
839
+ /**
840
+ * Effective config snapshot at creation time — captures the merged
841
+ * result of the global config + any per-call override at the moment
842
+ * the token was created. Only fields that differ from their
843
+ * post-merge defaults are present. Used by `glaze.colorFrom()` to
844
+ * reproduce deterministic behavior across `configure()` calls.
845
+ */
846
+ config?: GlazeConfigOverride;
847
+ }
848
+ /**
849
+ * Serializable shape of a structured `glaze.color({...})` input.
850
+ * Differs from `GlazeColorInput` only in that `base` is replaced by an
851
+ * `export` instead of a token reference.
852
+ */
853
+ interface GlazeColorInputExport {
854
+ hue: number;
855
+ saturation: number;
856
+ tone: HCPair<number | ExtremeValue>;
857
+ saturationFactor?: number;
858
+ mode?: AdaptationMode;
859
+ autoFlip?: boolean;
860
+ opacity?: number;
861
+ base?: GlazeColorTokenExport | GlazeColorValue;
862
+ contrast?: HCPair<ContrastSpec>;
863
+ name?: string;
864
+ pastel?: boolean;
865
+ role?: RoleInput;
866
+ }
867
+ /**
868
+ * Serializable shape of `GlazeColorOverrides`. `base` is replaced by
869
+ * its export (or left as a `GlazeColorValue` if it was originally a value).
870
+ */
871
+ interface GlazeColorOverridesExport {
872
+ hue?: number | RelativeValue;
873
+ saturation?: number;
874
+ tone?: HCPair<ToneValue>;
875
+ saturationFactor?: number;
876
+ mode?: AdaptationMode;
877
+ autoFlip?: boolean;
878
+ contrast?: HCPair<ContrastSpec>;
879
+ base?: GlazeColorTokenExport | GlazeColorValue;
880
+ opacity?: number;
881
+ name?: string;
882
+ pastel?: boolean;
883
+ role?: RoleInput;
312
884
  }
313
885
  interface GlazeTheme {
314
886
  /** The hue seed (0–360). */
315
887
  readonly hue: number;
316
888
  /** The saturation seed (0–100). */
317
889
  readonly saturation: number;
890
+ /** The effective config for this theme. */
891
+ getConfig(): GlazeConfigResolved;
318
892
  /** Add/replace colors (additive merge with existing definitions). */
319
893
  colors(defs: ColorMap): void;
320
894
  /** Get a color definition by name. */
@@ -346,20 +920,43 @@ interface GlazeTheme {
346
920
  tokens(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
347
921
  /**
348
922
  * Export as tasty style-to-state bindings.
349
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
923
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
350
924
  * 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
925
+ * @see https://tasty.style/docs
352
926
  */
353
927
  tasty(options?: GlazeTokenOptions): Record<string, Record<string, string>>;
354
928
  /** Export as plain JSON. */
355
929
  json(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
356
930
  /** Export as CSS custom property declarations. */
357
931
  css(options?: GlazeCssOptions): GlazeCssResult;
932
+ /**
933
+ * Export as W3C Design Tokens Format Module (2025.10) documents, one per
934
+ * scheme variant. Consumable by Figma, Tokens Studio, Style Dictionary,
935
+ * Terrazzo, and any DTCG-compatible tool.
936
+ * @see https://www.designtokens.org/
937
+ */
938
+ dtcg(options?: GlazeDtcgOptions): GlazeDtcgResult;
939
+ /**
940
+ * Export as a single W3C DTCG Resolver-Module document describing every
941
+ * scheme variant as one `sets` entry plus a single `scheme` modifier with a
942
+ * context per variant. Consumable by resolver tools such as Dispersa.
943
+ * @see https://www.designtokens.org/
944
+ */
945
+ dtcgResolver(options?: GlazeDtcgResolverOptions): GlazeDtcgResolverDocument;
946
+ /**
947
+ * Export as a Tailwind CSS v4 `@theme` block (light baseline) plus dark /
948
+ * high-contrast overrides under configurable selectors. Returns a single
949
+ * ready-to-paste CSS string.
950
+ * @see https://tailwindcss.com/docs/theme
951
+ */
952
+ tailwind(options?: GlazeTailwindOptions): string;
358
953
  }
359
954
  interface GlazeExtendOptions {
360
955
  hue?: number;
361
956
  saturation?: number;
362
957
  colors?: ColorMap;
958
+ /** Config override for the child theme. Merged with the parent's override. */
959
+ config?: GlazeConfigOverride;
363
960
  }
364
961
  interface GlazeTokenOptions {
365
962
  /** Prefix mode. `true` uses "<themeName>-", or provide a custom map. */
@@ -371,20 +968,40 @@ interface GlazeTokenOptions {
371
968
  };
372
969
  /** Override which scheme variants to include. */
373
970
  modes?: GlazeOutputModes;
374
- /** Output color format. Default: 'okhsl'. */
971
+ /** Output color format. Default: 'oklch'. */
375
972
  format?: GlazeColorFormat;
973
+ /**
974
+ * Emit hue as a separate custom property, referenced via `var()`.
975
+ * Requires `format: 'oklch'` and every color to be pastel.
976
+ */
977
+ splitHue?: boolean;
978
+ /**
979
+ * Base name for the theme-level hue var (`--{name}-hue`). Default: `'theme'`.
980
+ * Palette export auto-derives this from the theme name.
981
+ */
982
+ name?: string;
376
983
  }
377
984
  interface GlazeJsonOptions {
378
985
  /** Override which scheme variants to include. */
379
986
  modes?: GlazeOutputModes;
380
- /** Output color format. Default: 'okhsl'. */
987
+ /** Output color format. Default: 'oklch'. */
381
988
  format?: GlazeColorFormat;
382
989
  }
383
990
  interface GlazeCssOptions {
384
- /** Output color format. Default: 'rgb'. */
991
+ /** Output color format. Default: 'oklch'. */
385
992
  format?: GlazeColorFormat;
386
993
  /** Suffix appended to each CSS custom property name. Default: '-color'. */
387
994
  suffix?: string;
995
+ /**
996
+ * Emit hue as a separate custom property, referenced via `var()`.
997
+ * Requires `format: 'oklch'` and every color to be pastel.
998
+ */
999
+ splitHue?: boolean;
1000
+ /**
1001
+ * Base name for the theme-level hue var (`--{name}-hue`). Default: `'theme'`.
1002
+ * Palette export auto-derives this from the theme name.
1003
+ */
1004
+ name?: string;
388
1005
  }
389
1006
  /** CSS custom property declarations grouped by scheme variant. */
390
1007
  interface GlazeCssResult {
@@ -393,6 +1010,182 @@ interface GlazeCssResult {
393
1010
  lightContrast: string;
394
1011
  darkContrast: string;
395
1012
  }
1013
+ /**
1014
+ * Color space used for DTCG `$value` color objects.
1015
+ * @see https://www.designtokens.org/
1016
+ */
1017
+ type DtcgColorSpace = 'srgb' | 'oklch';
1018
+ /**
1019
+ * A DTCG color `$value` in the sRGB color space: gamma sRGB components in
1020
+ * 0–1 plus a 6-digit `hex` hint. Universally understood by Figma, Tokens
1021
+ * Studio, Style Dictionary, and every DTCG reader.
1022
+ */
1023
+ interface DtcgSrgbColorValue {
1024
+ colorSpace: 'srgb';
1025
+ components: [number, number, number];
1026
+ hex: HexColor;
1027
+ /** Opacity 0–1. Omitted when fully opaque (alpha = 1). */
1028
+ alpha?: number;
1029
+ }
1030
+ /**
1031
+ * A DTCG color `$value` in the OKLCH color space: `[L, C, H]` components
1032
+ * (L/C: 0–1, H: degrees). Wide-gamut and Glaze-native; no `hex` is emitted.
1033
+ */
1034
+ interface DtcgOklchColorValue {
1035
+ colorSpace: 'oklch';
1036
+ components: [number, number, number];
1037
+ /** Opacity 0–1. Omitted when fully opaque (alpha = 1). */
1038
+ alpha?: number;
1039
+ }
1040
+ /** A DTCG `$value` for a color token, in either supported color space. */
1041
+ type DtcgColorValue = DtcgSrgbColorValue | DtcgOklchColorValue;
1042
+ /**
1043
+ * A single W3C DTCG color token: `{ $type: 'color', $value }`.
1044
+ * `$description` is optional and not populated by Glaze today.
1045
+ */
1046
+ interface DtcgColorToken {
1047
+ $type: 'color';
1048
+ $value: DtcgColorValue;
1049
+ $description?: string;
1050
+ }
1051
+ /**
1052
+ * A W3C Design Tokens Format Module (2025.10) token tree for one scheme.
1053
+ * Glaze emits one document per scheme variant — the most tool-compatible
1054
+ * convention (one file per Style Dictionary theme / Tokens Studio set /
1055
+ * Figma variable mode).
1056
+ */
1057
+ type DtcgDocument = Record<string, DtcgColorToken>;
1058
+ /** DTCG token documents grouped by scheme variant. Light is always present. */
1059
+ interface GlazeDtcgResult {
1060
+ light: DtcgDocument;
1061
+ dark?: DtcgDocument;
1062
+ lightContrast?: DtcgDocument;
1063
+ darkContrast?: DtcgDocument;
1064
+ }
1065
+ /** A single DTCG color token grouped by scheme variant (standalone tokens). */
1066
+ interface GlazeColorDtcgResult {
1067
+ light: DtcgColorToken;
1068
+ dark?: DtcgColorToken;
1069
+ lightContrast?: DtcgColorToken;
1070
+ darkContrast?: DtcgColorToken;
1071
+ }
1072
+ /** Options for `theme.dtcg()` / `palette.dtcg()`. */
1073
+ interface GlazeDtcgOptions {
1074
+ /** Override which scheme variants to include. */
1075
+ modes?: GlazeOutputModes;
1076
+ /**
1077
+ * DTCG color space. `'srgb'` (default) emits sRGB components plus a `hex`
1078
+ * hint — universally understood (Figma, Tokens Studio). `'oklch'` emits
1079
+ * OKLCH components with no hex — Glaze-native, wide-gamut.
1080
+ */
1081
+ colorSpace?: DtcgColorSpace;
1082
+ }
1083
+ /**
1084
+ * A node in a DTCG Resolver-Module token tree: either a leaf color token or a
1085
+ * nested group. A flat `DtcgDocument` (top-level color-name keys) is a valid
1086
+ * shallow tree, so Glaze's per-scheme documents slot directly into
1087
+ * `sets.<name>.sources` and `modifiers.<name>.contexts.<ctx>` entries.
1088
+ */
1089
+ interface DtcgTokenTree {
1090
+ [key: string]: DtcgColorToken | DtcgTokenTree;
1091
+ }
1092
+ /** A named set in a resolver document: a list of token-tree sources. */
1093
+ interface DtcgResolverSet {
1094
+ sources: DtcgTokenTree[];
1095
+ }
1096
+ /**
1097
+ * A named modifier (an axis such as `scheme`) in a resolver document.
1098
+ * `default` names the context applied when no override is selected; `contexts`
1099
+ * maps each context name to the token-tree overrides applied for it.
1100
+ */
1101
+ interface DtcgResolverModifier {
1102
+ default: string;
1103
+ contexts: Record<string, DtcgTokenTree[]>;
1104
+ }
1105
+ /** A JSON-pointer `$ref` entry in a resolver document's `resolutionOrder`. */
1106
+ interface DtcgResolverRef {
1107
+ $ref: string;
1108
+ }
1109
+ /**
1110
+ * A W3C DTCG Resolver-Module document. Describes every scheme variant in a
1111
+ * single file as `sets` (base token sources) plus `modifiers` (per-context
1112
+ * overrides) composed in `resolutionOrder`. Consumable by resolver tools such
1113
+ * as Dispersa.
1114
+ * @see https://www.designtokens.org/
1115
+ */
1116
+ interface GlazeDtcgResolverDocument {
1117
+ version: string;
1118
+ sets: Record<string, DtcgResolverSet>;
1119
+ modifiers: Record<string, DtcgResolverModifier>;
1120
+ resolutionOrder: DtcgResolverRef[];
1121
+ }
1122
+ /** Renaming of the four scheme variants as resolver-modifier context names. */
1123
+ interface GlazeDtcgResolverContextNames {
1124
+ light?: string;
1125
+ dark?: string;
1126
+ lightContrast?: string;
1127
+ darkContrast?: string;
1128
+ }
1129
+ /**
1130
+ * Options for `theme.dtcgResolver()` / `palette.dtcgResolver()`. Extends
1131
+ * `GlazeDtcgOptions` so `modes` + `colorSpace` pass through to the underlying
1132
+ * per-scheme `dtcg()` build.
1133
+ */
1134
+ interface GlazeDtcgResolverOptions extends GlazeDtcgOptions {
1135
+ /** Name of the single set holding the default (light) token tree. Default `'base'`. */
1136
+ setName?: string;
1137
+ /**
1138
+ * Name of the modifier describing the scheme axis. Default `'scheme'`
1139
+ * (Glaze's term for the light / dark / high-contrast axis).
1140
+ */
1141
+ modifierName?: string;
1142
+ /**
1143
+ * Override the four context names emitted on the modifier. Defaults to the
1144
+ * Glaze variant keys: `light` / `dark` / `lightContrast` / `darkContrast`.
1145
+ */
1146
+ contextNames?: GlazeDtcgResolverContextNames;
1147
+ /** Resolver document version. Default `'2025.10'`. */
1148
+ version?: string;
1149
+ }
1150
+ /** Options for `glaze.color().dtcgResolver()`. `name` is required. */
1151
+ interface GlazeColorDtcgResolverOptions extends GlazeDtcgResolverOptions {
1152
+ /** Token name keying the color within each token tree. Required. */
1153
+ name: string;
1154
+ }
1155
+ /** Options for `theme.tailwind()` / `palette.tailwind()`. */
1156
+ interface GlazeTailwindOptions {
1157
+ /** Override which scheme variants to include. */
1158
+ modes?: GlazeOutputModes;
1159
+ /** Output color format. Default: 'oklch'. */
1160
+ format?: GlazeColorFormat;
1161
+ /**
1162
+ * CSS custom property namespace, forming `--<namespace><name>`.
1163
+ * Default: `'color-'` → `--color-surface`. (Tailwind v4's `--color-*`
1164
+ * convention, which auto-generates `bg-*` / `text-*` / `border-*`.)
1165
+ *
1166
+ * Named `namespace` rather than `prefix` to avoid clashing with the
1167
+ * palette theme-prefix option on `palette.tailwind()`.
1168
+ */
1169
+ namespace?: string;
1170
+ /**
1171
+ * Selector wrapping the dark-scheme overrides. Default: `'.dark'`.
1172
+ * Pass a media query such as `'@media (prefers-color-scheme: dark)'` to
1173
+ * drive dark mode from the OS preference instead of a class.
1174
+ */
1175
+ darkSelector?: string;
1176
+ /**
1177
+ * Selector wrapping the light high-contrast overrides. Default:
1178
+ * `'.high-contrast'`. The combined dark + high-contrast overrides are
1179
+ * emitted under `${darkSelector}${highContrastSelector}` (e.g.
1180
+ * `.dark.high-contrast`).
1181
+ */
1182
+ highContrastSelector?: string;
1183
+ }
1184
+ /** Options for `glaze.color().tailwind()`. `name` is required. */
1185
+ interface GlazeColorTailwindOptions extends GlazeTailwindOptions {
1186
+ /** Custom property base name (without leading `--`). Required. */
1187
+ name: string;
1188
+ }
396
1189
  /** Options for `glaze.palette()` creation. */
397
1190
  interface GlazePaletteOptions {
398
1191
  /**
@@ -424,6 +1217,11 @@ interface GlazePaletteExportOptions {
424
1217
  * When omitted, inherits the palette-level `primary`.
425
1218
  */
426
1219
  primary?: string | false;
1220
+ /**
1221
+ * Emit hue as a separate custom property, referenced via `var()`.
1222
+ * Requires `format: 'oklch'` and every color to be pastel.
1223
+ */
1224
+ splitHue?: boolean;
427
1225
  }
428
1226
  interface GlazePalette {
429
1227
  /**
@@ -440,9 +1238,9 @@ interface GlazePalette {
440
1238
  tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
441
1239
  /**
442
1240
  * Export all themes as tasty style-to-state bindings.
443
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
1241
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
444
1242
  * Prefix defaults to `true`. Inherits the palette-level `primary`.
445
- * @see https://cube-ui-kit.vercel.app/?path=/docs/tasty-documentation--docs
1243
+ * @see https://tasty.style/docs
446
1244
  */
447
1245
  tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
448
1246
  /** Export all themes as plain JSON grouped by theme name. */
@@ -451,6 +1249,25 @@ interface GlazePalette {
451
1249
  }): Record<string, Record<string, Record<string, string>>>;
452
1250
  /** Export all themes as CSS custom property declarations. */
453
1251
  css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
1252
+ /**
1253
+ * Export all themes as W3C DTCG documents, one per scheme variant.
1254
+ * Prefix defaults to `true`. Inherits the palette-level `primary`.
1255
+ * @see https://www.designtokens.org/
1256
+ */
1257
+ dtcg(options?: GlazeDtcgOptions & GlazePaletteExportOptions): GlazeDtcgResult;
1258
+ /**
1259
+ * Export all themes as a single W3C DTCG Resolver-Module document. Prefix
1260
+ * defaults to `true`. Inherits the palette-level `primary`.
1261
+ * @see https://www.designtokens.org/
1262
+ */
1263
+ dtcgResolver(options?: GlazeDtcgResolverOptions & GlazePaletteExportOptions): GlazeDtcgResolverDocument;
1264
+ /**
1265
+ * Export all themes as a Tailwind CSS v4 `@theme` block plus dark /
1266
+ * high-contrast overrides. Returns a single ready-to-paste CSS string.
1267
+ * Prefix defaults to `true`.
1268
+ * @see https://tailwindcss.com/docs/theme
1269
+ */
1270
+ tailwind(options?: GlazeTailwindOptions & GlazePaletteExportOptions): string;
454
1271
  }
455
1272
  //#endregion
456
1273
  //#region src/glaze.d.ts
@@ -458,54 +1275,201 @@ type PaletteInput = Record<string, GlazeTheme>;
458
1275
  /**
459
1276
  * Create a single-hue glaze theme.
460
1277
  *
1278
+ * An optional `config` override can be supplied to customize the resolve
1279
+ * behavior for this theme (tone windows, etc.). The
1280
+ * override is **merged over the live global config at resolve time** —
1281
+ * the theme still reacts to later `configure()` calls for fields it
1282
+ * didn't override.
1283
+ *
461
1284
  * @example
462
1285
  * ```ts
463
- * const primary = glaze({ hue: 280, saturation: 80 });
464
- * // or shorthand:
465
1286
  * const primary = glaze(280, 80);
1287
+ * // or shorthand:
1288
+ * const primary = glaze({ hue: 280, saturation: 80 });
1289
+ * // with config override:
1290
+ * const raw = glaze(280, 80, { lightTone: false });
466
1291
  * ```
467
1292
  */
468
1293
  declare function glaze(hueOrOptions: number | {
469
1294
  hue: number;
470
1295
  saturation: number;
471
- }, saturation?: number): GlazeTheme;
1296
+ }, saturation?: number, config?: GlazeConfigOverride): GlazeTheme;
472
1297
  declare namespace glaze {
473
1298
  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
- };
1299
+ var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
482
1300
  var from: (data: GlazeThemeExport) => GlazeTheme;
483
- var color: (input: GlazeColorInput) => GlazeColorToken;
1301
+ var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
484
1302
  var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
485
- var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
1303
+ var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat, pastel?: boolean) => string;
486
1304
  var fromHex: (hex: string) => GlazeTheme;
487
1305
  var fromRgb: (r: number, g: number, b: number) => GlazeTheme;
1306
+ var colorFrom: (data: GlazeColorTokenExport) => GlazeColorToken;
488
1307
  var getConfig: () => GlazeConfigResolved;
489
1308
  var resetConfig: () => void;
490
1309
  }
491
1310
  //#endregion
1311
+ //#region src/channels.d.ts
1312
+ interface HueDeclaration {
1313
+ prop: string;
1314
+ value: string;
1315
+ }
1316
+ interface HuePlan {
1317
+ /** CSS `var()` reference spliced into `oklch(L C <hueVar>)`. */
1318
+ hueVar: string;
1319
+ /** When true, emit a full inline color (shadow/mix/achromatic). */
1320
+ inline: boolean;
1321
+ /** Scheme-independent `--*-hue` declarations for this color. */
1322
+ declarations: HueDeclaration[];
1323
+ }
1324
+ interface ChannelCtx {
1325
+ seedHue: number;
1326
+ /** Theme-level hue var base name (without `--` / `-hue`). */
1327
+ baseName: string;
1328
+ /** Token / custom-property name prefix used for hue var naming (`brand-` etc.). */
1329
+ prefix: string;
1330
+ defs: ColorMap;
1331
+ mode: 'theme' | 'standalone';
1332
+ /** Standalone: resolved hue from the primary variant (scheme-independent). */
1333
+ resolvedHue?: number;
1334
+ /**
1335
+ * When false, hue declarations are not emitted (the pass only references
1336
+ * hue vars already declared by a sibling pass). Used by palette primary
1337
+ * unprefixed aliases so they reference the themed `--{themeName}-*-hue`
1338
+ * vars without re-declaring (and colliding with) other themes' base vars.
1339
+ * Defaults to true.
1340
+ */
1341
+ emitDeclarations?: boolean;
1342
+ }
1343
+ //#endregion
1344
+ //#region src/format-guard.d.ts
1345
+ /**
1346
+ * Throw when a non-native Glaze color space is requested for an export that
1347
+ * emits raw CSS or non-Tasty token maps.
1348
+ */
1349
+ declare function assertNativeFormat(format: GlazeColorFormat | undefined, method: string): void;
1350
+ /**
1351
+ * Throw when `splitHue` is enabled but any exported color is not pastel.
1352
+ * Hue rotation is only clip-free when chroma is bounded by the hue-independent
1353
+ * safe chroma (`computeSafeChromaOKLCH`).
1354
+ */
1355
+ declare function assertAllPastel(resolved: Map<string, ResolvedColor>, modes: Required<GlazeOutputModes>): void;
1356
+ //#endregion
1357
+ //#region src/roles.d.ts
1358
+ /**
1359
+ * Normalize a `RoleInput` (canonical value or alias) into a canonical `Role`.
1360
+ * Returns `undefined` for unrecognized strings so callers can fall through to
1361
+ * the next step of the resolution chain.
1362
+ */
1363
+ declare function normalizeRole(input: RoleInput | undefined): Role | undefined;
1364
+ /**
1365
+ * Infer a `Role` from a color name by matching its tokens against the role
1366
+ * keyword sets. When multiple tokens match, the **last** recognized token
1367
+ * wins (so `button-text` → `text`, `input-bg` → `surface`, `card-border` →
1368
+ * `border`). Returns `undefined` when no token matches.
1369
+ */
1370
+ declare function inferRoleFromName(name: string): Role | undefined;
1371
+ /** APCA argument order: which side the resolved color plays. */
1372
+ type Polarity = 'fg' | 'bg';
1373
+ /**
1374
+ * Map a role to its APCA polarity. `text` and `border` are foreground spots
1375
+ * against their base (the candidate is the text argument); `surface` is the
1376
+ * background (the base is the text argument).
1377
+ */
1378
+ declare function roleToPolarity(role: Role): Polarity;
1379
+ /**
1380
+ * The opposite role of `role`, used when a color with no explicit role and no
1381
+ * inferable name depends on a base: the dependent color plays the opposite
1382
+ * role of its base. `surface` ↔ `text`; `border` is treated as a foreground
1383
+ * spot, so its opposite is `surface`.
1384
+ */
1385
+ declare function oppositeRole(role: Role): Role;
1386
+ //#endregion
1387
+ //#region src/okhst.d.ts
1388
+ /**
1389
+ * Reference eps for the OKHST color space. WCAG 2 contrast is
1390
+ * `(Y_hi + 0.05) / (Y_lo + 0.05)`, so an eps of `0.05` makes equal tone
1391
+ * steps yield equal WCAG contrast. This is the canonical eps used by
1392
+ * `okhst()` input, `{ h, s, t }` input, stored `ResolvedColorVariant.t`,
1393
+ * relative `tone` offsets, and the contrast solver.
1394
+ */
1395
+ declare const REF_EPS = 0.05;
1396
+ /**
1397
+ * Map a luminance `Y` (0–1) to tone (0–100) at the given eps.
1398
+ * `toneFromY(0) === 0` and `toneFromY(1) === 100` for any eps.
1399
+ */
1400
+ declare function toneFromY(y: number, eps?: number): number;
1401
+ /** Map a tone (0–100) back to luminance (0–1). Inverse of {@link toneFromY}. */
1402
+ declare function yFromTone(t: number, eps?: number): number;
1403
+ /** OKHSL lightness (0–1) -> tone (0–100). */
1404
+ declare function toTone(l: number, eps?: number): number;
1405
+ /** Tone (0–100) -> OKHSL lightness (0–1). Inverse of {@link toTone}. */
1406
+ declare function fromTone(t: number, eps?: number): number;
1407
+ /** Convert OKHST `{ h, s, t }` (t in 0–1) to OKHSL `{ h, s, l }`. */
1408
+ declare function okhstToOkhsl(c: {
1409
+ h: number;
1410
+ s: number;
1411
+ t: number;
1412
+ }): {
1413
+ h: number;
1414
+ s: number;
1415
+ l: number;
1416
+ };
1417
+ /** Convert OKHSL `{ h, s, l }` to OKHST `{ h, s, t }` (t in 0–1). */
1418
+ declare function okhslToOkhst(c: {
1419
+ h: number;
1420
+ s: number;
1421
+ l: number;
1422
+ }): {
1423
+ h: number;
1424
+ s: number;
1425
+ t: number;
1426
+ };
1427
+ /**
1428
+ * Edge adapter: a resolved variant stores canonical tone `t` (0–1). Convert
1429
+ * it to the OKHSL `{ h, s, l }` the formatters and luminance pipeline expect.
1430
+ */
1431
+ declare function variantToOkhsl(v: {
1432
+ h: number;
1433
+ s: number;
1434
+ t: number;
1435
+ }): {
1436
+ h: number;
1437
+ s: number;
1438
+ l: number;
1439
+ };
1440
+ //#endregion
492
1441
  //#region src/okhsl-color-math.d.ts
493
1442
  /**
494
1443
  * OKHSL color math primitives for the glaze theme generator.
495
1444
  *
496
- * Provides bidirectional OKHSL ↔ sRGB conversion, relative luminance
497
- * computation for WCAG 2 contrast calculations, and multi-format output
498
- * (okhsl, rgb, hsl, oklch).
1445
+ * Provides bidirectional OKHSL ↔ sRGB conversion, luminance computation
1446
+ * for both contrast metrics (WCAG 2 relative luminance and APCA screen
1447
+ * luminance `Ys`), and multi-format output (okhsl, rgb, hsl, oklch).
1448
+ */
1449
+ type Vec3 = [number, number, number];
1450
+ /**
1451
+ * OKHSL toe function: maps OKLab lightness L to perceptual lightness l.
1452
+ * Exported for the OKHST tone transfers in `okhst.ts`.
1453
+ */
1454
+ /**
1455
+ * OKHSL lightness of the gamut cusp for a hue — the lightness where the
1456
+ * realizable chroma peaks. Reuses the same `find_cusp` OKHSL already runs for
1457
+ * its `s` normalization (no new color math); the OKLab cusp lightness is run
1458
+ * through the OKHSL `toe` and clamped to `[0.001, 0.999]` so divisions that
1459
+ * key off it stay safe. Cached per (rounded) hue.
1460
+ *
1461
+ * @param h Hue, 0–360.
499
1462
  */
1463
+ declare function cuspLightness(h: number): number;
500
1464
  /**
501
1465
  * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLab [L, a, b].
502
1466
  */
503
- declare function okhslToOklab(h: number, s: number, l: number): [number, number, number];
1467
+ declare function okhslToOklab(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
504
1468
  /**
505
1469
  * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to linear sRGB.
506
1470
  * Channels may exceed [0, 1] near gamut boundaries — caller must clamp if needed.
507
1471
  */
508
- declare function okhslToLinearSrgb(h: number, s: number, l: number): [number, number, number];
1472
+ declare function okhslToLinearSrgb(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
509
1473
  /**
510
1474
  * Compute relative luminance Y from linear sRGB channels.
511
1475
  * Per WCAG 2: Y = 0.2126·R + 0.7152·G + 0.0722·B
@@ -518,44 +1482,90 @@ declare function contrastRatioFromLuminance(yA: number, yB: number): number;
518
1482
  /**
519
1483
  * Convert OKHSL to gamma-encoded sRGB (clamped to 0–1).
520
1484
  */
521
- declare function okhslToSrgb(h: number, s: number, l: number): [number, number, number];
1485
+ declare function okhslToSrgb(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
522
1486
  /**
523
1487
  * Compute WCAG 2 relative luminance from linear sRGB, matching the browser
524
1488
  * rendering pipeline: gamma-encode, clamp to sRGB gamut [0,1], then linearize.
525
1489
  * This avoids over/under-estimating luminance for out-of-gamut OKHSL colors.
526
1490
  */
527
1491
  declare function gamutClampedLuminance(linearRgb: [number, number, number]): number;
1492
+ /**
1493
+ * Convert OKLab to OKHSL.
1494
+ * Input: [L, a, b] where L: 0–1, a/b: roughly -0.5 to 0.5.
1495
+ * Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
1496
+ */
1497
+ declare const oklabToOkhsl: (lab: Vec3, pastel?: boolean) => Vec3;
528
1498
  /**
529
1499
  * Convert gamma-encoded sRGB (0–1 per channel) to OKHSL.
530
1500
  * Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
531
1501
  */
532
- declare function srgbToOkhsl(rgb: [number, number, number]): [number, number, number];
1502
+ declare function srgbToOkhsl(rgb: [number, number, number], pastel?: boolean): [number, number, number];
1503
+ /**
1504
+ * Convert CSS HSL (sRGB-based) to gamma-encoded sRGB [r, g, b] in 0–1 range.
1505
+ * h: 0–360, s: 0–1, l: 0–1.
1506
+ *
1507
+ * Note: CSS HSL is not the same as OKHSL — it's HSL in the sRGB color space.
1508
+ * Use this when parsing `hsl(...)` strings before passing to `srgbToOkhsl`.
1509
+ */
1510
+ declare function hslToSrgb(h: number, s: number, l: number): [number, number, number];
533
1511
  /**
534
1512
  * Parse a hex color string (#rgb or #rrggbb) to sRGB [r, g, b] in 0–1 range.
535
1513
  * Returns null if the string is not a valid hex color.
1514
+ *
1515
+ * For 8-digit hex (`#rrggbbaa`) and 4-digit hex (`#rgba`) with alpha,
1516
+ * use {@link parseHexAlpha}.
536
1517
  */
537
1518
  declare function parseHex(hex: string): [number, number, number] | null;
1519
+ /**
1520
+ * Parse a hex color string (#rgb, #rrggbb, #rgba, or #rrggbbaa) to
1521
+ * sRGB [r, g, b] in 0–1 range plus an optional alpha (0–1).
1522
+ * Returns null if the string is not a valid hex color.
1523
+ */
1524
+ declare function parseHexAlpha(hex: string): {
1525
+ rgb: [number, number, number];
1526
+ alpha?: number;
1527
+ } | null;
538
1528
  /**
539
1529
  * Format OKHSL values as a CSS `okhsl(H S% L%)` string.
540
1530
  * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
541
1531
  */
542
- declare function formatOkhsl(h: number, s: number, l: number): string;
1532
+ declare function formatOkhsl(h: number, s: number, l: number, pastel?: boolean): string;
1533
+ /**
1534
+ * Format OKHST values as a CSS `okhst(H S% T%)` string.
1535
+ * h: 0–360, s: 0–100, t: 0–100 (percentage scale for s and t).
1536
+ *
1537
+ * Pastel recompute matches `formatOkhsl`: convert via OKLab so external
1538
+ * parsers that only understand non-pastel OKHST render identically.
1539
+ */
1540
+ declare function formatOkhst(h: number, s: number, t: number, pastel?: boolean): string;
543
1541
  /**
544
1542
  * Format OKHSL values as a CSS `rgb(R G B)` string.
545
1543
  * Uses 2 decimal places to avoid 8-bit quantization contrast loss.
546
1544
  * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
547
1545
  */
548
- declare function formatRgb(h: number, s: number, l: number): string;
1546
+ declare function formatRgb(h: number, s: number, l: number, pastel?: boolean): string;
549
1547
  /**
550
1548
  * Format OKHSL values as a CSS `hsl(H S% L%)` string.
551
1549
  * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
552
1550
  */
553
- declare function formatHsl(h: number, s: number, l: number): string;
1551
+ declare function formatHsl(h: number, s: number, l: number, pastel?: boolean): string;
554
1552
  /**
555
1553
  * Format OKHSL values as a CSS `oklch(L C H)` string.
556
1554
  * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
557
1555
  */
558
- declare function formatOklch(h: number, s: number, l: number): string;
1556
+ declare function formatOklch(h: number, s: number, l: number, pastel?: boolean): string;
1557
+ /**
1558
+ * Convert gamma-encoded sRGB channels (0–1) to a 6-digit lowercase hex
1559
+ * string (`#rrggbb`). Channels are clamped to [0,1] and rounded to 8-bit.
1560
+ * Alpha is not encoded here — DTCG carries it as a separate `alpha` field.
1561
+ */
1562
+ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
1563
+ /**
1564
+ * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLCH components `[L, C, H]`.
1565
+ * L: 0–1, C: 0–~0.4 (chroma), H: 0–360 (hue). Shared by `formatOklch` and
1566
+ * the DTCG `oklch` colorSpace exporter so the two never drift apart.
1567
+ */
1568
+ declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
559
1569
  //#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 };
1570
+ 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, 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 GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, 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 RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
561
1571
  //# sourceMappingURL=index.d.mts.map