@tenphi/glaze 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/dist/index.cjs +980 -574
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +323 -193
- package/dist/index.d.mts +323 -193
- package/dist/index.mjs +970 -574
- package/dist/index.mjs.map +1 -1
- package/docs/api.md +300 -165
- package/docs/methodology.md +64 -54
- package/docs/migration.md +81 -10
- package/docs/okhst.md +224 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,78 +1,71 @@
|
|
|
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
|
-
|
|
5
|
+
/** Metric + numeric target after resolving a `ContrastSpec` for a mode. */
|
|
6
|
+
interface ResolvedContrast {
|
|
7
|
+
metric: 'wcag' | 'apca';
|
|
8
|
+
/** WCAG ratio (>= 1) or APCA Lc magnitude (0–106). */
|
|
9
|
+
target: number;
|
|
10
|
+
}
|
|
11
|
+
declare function resolveMinContrast(value: MinContrast$1): number;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a `ContrastSpec` (already selected from any outer HC pair) for a
|
|
14
|
+
* given mode into `{ metric, target }`. Handles the inner metric HC pair and
|
|
15
|
+
* preset resolution.
|
|
16
|
+
*/
|
|
17
|
+
declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean): ResolvedContrast;
|
|
18
|
+
/**
|
|
19
|
+
* APCA lightness contrast (Lc), signed: positive for dark text on light bg,
|
|
20
|
+
* negative for light text on dark bg. Inputs are screen luminances (0–1).
|
|
21
|
+
*/
|
|
22
|
+
declare function apcaContrast(yText: number, yBg: number): number;
|
|
23
|
+
interface FindToneForContrastOptions {
|
|
13
24
|
/** Hue of the candidate color (0–360). */
|
|
14
25
|
hue: number;
|
|
15
26
|
/** Saturation of the candidate color (0–1). */
|
|
16
27
|
saturation: number;
|
|
17
|
-
/** Preferred
|
|
18
|
-
|
|
19
|
-
/** Base/reference color as linear sRGB
|
|
20
|
-
baseLinearRgb:
|
|
21
|
-
/**
|
|
22
|
-
contrast:
|
|
23
|
-
/** Search bounds for
|
|
24
|
-
|
|
28
|
+
/** Preferred tone of the candidate (0–1). */
|
|
29
|
+
preferredTone: number;
|
|
30
|
+
/** Base/reference color as linear sRGB. */
|
|
31
|
+
baseLinearRgb: LinearRgb;
|
|
32
|
+
/** Resolved contrast floor (metric + target). */
|
|
33
|
+
contrast: ResolvedContrast;
|
|
34
|
+
/** Search bounds for tone. Default: [0, 1]. */
|
|
35
|
+
toneRange?: [number, number];
|
|
25
36
|
/** Convergence threshold. Default: 1e-4. */
|
|
26
37
|
epsilon?: number;
|
|
27
|
-
/** Maximum binary-search iterations per branch. Default:
|
|
38
|
+
/** Maximum binary-search iterations per branch. Default: 18. */
|
|
28
39
|
maxIterations?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Preferred search direction before auto-flip is considered.
|
|
31
|
-
*
|
|
32
|
-
* Theme resolution sets this from the requested lightness relative to
|
|
33
|
-
* the base color so `autoFlip: false` preserves the authored direction.
|
|
34
|
-
* When omitted, the solver falls back to the side whose extreme has
|
|
35
|
-
* higher contrast against the base.
|
|
36
|
-
*/
|
|
40
|
+
/** Preferred search direction before auto-flip is considered. */
|
|
37
41
|
initialDirection?: 'lighter' | 'darker';
|
|
42
|
+
/** Auto-flip tone direction when contrast can't be met. Default: false. */
|
|
43
|
+
flip?: boolean;
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* uses it when it passes. If neither side passes, it returns the
|
|
44
|
-
* extreme lightness of the initial direction.
|
|
45
|
-
*
|
|
46
|
-
* When `false`, only the initial direction is considered. If it
|
|
47
|
-
* doesn't reach the target, the result is pinned to the initial
|
|
48
|
-
* direction's extreme — never to the original preferred lightness.
|
|
49
|
-
*
|
|
50
|
-
* Default: false.
|
|
45
|
+
* Saturation taper strength (0–1). When set, candidate saturation is rolled
|
|
46
|
+
* off toward the tone extremes via the same envelope the renderer applies,
|
|
47
|
+
* so the solved tone meets the floor with its *rendered* saturation. Default
|
|
48
|
+
* `0` (no taper) for direct/advanced callers.
|
|
51
49
|
*/
|
|
52
|
-
|
|
50
|
+
saturationTaper?: number;
|
|
53
51
|
}
|
|
54
|
-
interface
|
|
55
|
-
/** Chosen
|
|
56
|
-
|
|
57
|
-
/** Achieved WCAG
|
|
52
|
+
interface FindToneForContrastResult {
|
|
53
|
+
/** Chosen tone in 0–1. */
|
|
54
|
+
tone: number;
|
|
55
|
+
/** Achieved score (WCAG ratio or APCA Lc magnitude). */
|
|
58
56
|
contrast: number;
|
|
59
57
|
/** Whether the target was reached. */
|
|
60
58
|
met: boolean;
|
|
61
59
|
/** Which branch was selected. */
|
|
62
60
|
branch: 'lighter' | 'darker' | 'preferred';
|
|
63
|
-
/**
|
|
64
|
-
* Whether the result was auto-flipped to the opposite direction.
|
|
65
|
-
* Only set when the initial direction failed and the opposite
|
|
66
|
-
* direction satisfied the target.
|
|
67
|
-
*/
|
|
61
|
+
/** Whether the result auto-flipped to the opposite direction. */
|
|
68
62
|
flipped?: boolean;
|
|
69
63
|
}
|
|
70
|
-
declare function resolveMinContrast(value: MinContrast$1): number;
|
|
71
64
|
/**
|
|
72
|
-
* Find the
|
|
73
|
-
*
|
|
65
|
+
* Find the tone that satisfies a contrast floor against a base color,
|
|
66
|
+
* staying as close to `preferredTone` as possible.
|
|
74
67
|
*/
|
|
75
|
-
declare function
|
|
68
|
+
declare function findToneForContrast(options: FindToneForContrastOptions): FindToneForContrastResult;
|
|
76
69
|
interface FindValueForMixContrastOptions {
|
|
77
70
|
/** Preferred mix parameter (0–1). */
|
|
78
71
|
preferredValue: number;
|
|
@@ -80,62 +73,69 @@ interface FindValueForMixContrastOptions {
|
|
|
80
73
|
baseLinearRgb: LinearRgb;
|
|
81
74
|
/** Target color as linear sRGB. */
|
|
82
75
|
targetLinearRgb: LinearRgb;
|
|
83
|
-
/**
|
|
84
|
-
contrast:
|
|
85
|
-
/**
|
|
86
|
-
* Compute the luminance of the mixed color at parameter t.
|
|
87
|
-
* For opaque: luminance of OKHSL-interpolated color.
|
|
88
|
-
* For transparent: luminance of alpha-composited color over base.
|
|
89
|
-
*/
|
|
76
|
+
/** Resolved contrast floor (metric + target). */
|
|
77
|
+
contrast: ResolvedContrast;
|
|
78
|
+
/** Compute the luminance of the mixed color at parameter t. */
|
|
90
79
|
luminanceAtValue: (t: number) => number;
|
|
91
80
|
/** Convergence threshold. Default: 1e-4. */
|
|
92
81
|
epsilon?: number;
|
|
93
82
|
/** Maximum binary-search iterations per branch. Default: 20. */
|
|
94
83
|
maxIterations?: number;
|
|
95
|
-
/**
|
|
96
|
-
* Auto-flip mix direction when contrast can't be met.
|
|
97
|
-
*
|
|
98
|
-
* When `true`, the solver searches the initial direction first
|
|
99
|
-
* (the side whose extreme has higher contrast against the base).
|
|
100
|
-
* If that side doesn't reach the target, it tries the opposite
|
|
101
|
-
* direction and uses it when it passes. If neither side passes,
|
|
102
|
-
* it returns the extreme mix value of the initial direction.
|
|
103
|
-
*
|
|
104
|
-
* When `false`, only the initial direction is considered. If it
|
|
105
|
-
* doesn't reach the target, the result is pinned to the initial
|
|
106
|
-
* direction's extreme — never to the original preferred value.
|
|
107
|
-
*
|
|
108
|
-
* Default: false.
|
|
109
|
-
*/
|
|
84
|
+
/** Auto-flip mix direction when contrast can't be met. Default: false. */
|
|
110
85
|
flip?: boolean;
|
|
111
86
|
}
|
|
112
87
|
interface FindValueForMixContrastResult {
|
|
113
|
-
/** Chosen mix parameter (0–1). */
|
|
114
88
|
value: number;
|
|
115
|
-
/** Achieved WCAG contrast ratio. */
|
|
116
89
|
contrast: number;
|
|
117
|
-
/** Whether the target was reached. */
|
|
118
90
|
met: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Whether the result was auto-flipped to the opposite direction.
|
|
121
|
-
* Only set when the initial direction failed and the opposite
|
|
122
|
-
* direction satisfied the target.
|
|
123
|
-
*/
|
|
124
91
|
flipped?: boolean;
|
|
125
92
|
}
|
|
126
93
|
/**
|
|
127
|
-
* Find the mix parameter (ratio or opacity) that satisfies a
|
|
128
|
-
*
|
|
94
|
+
* Find the mix parameter (ratio or opacity) that satisfies a contrast floor
|
|
95
|
+
* against a base color, staying as close to `preferredValue` as possible.
|
|
129
96
|
*/
|
|
130
97
|
declare function findValueForMixContrast(options: FindValueForMixContrastOptions): FindValueForMixContrastResult;
|
|
131
98
|
//#endregion
|
|
132
99
|
//#region src/types.d.ts
|
|
133
100
|
/** A value or [normal, high-contrast] pair. */
|
|
134
101
|
type HCPair<T> = T | [T, T];
|
|
102
|
+
/** Bare WCAG contrast target: a ratio number or a named preset. */
|
|
135
103
|
type MinContrast = number | ContrastPreset;
|
|
104
|
+
/**
|
|
105
|
+
* A contrast floor with a pluggable metric.
|
|
106
|
+
*
|
|
107
|
+
* - `number` / `ContrastPreset`: a WCAG ratio (bare form).
|
|
108
|
+
* - `{ wcag }`: WCAG ratio or preset, optionally an HC pair.
|
|
109
|
+
* - `{ apca }`: APCA Lc target (absolute value), optionally an HC pair.
|
|
110
|
+
*
|
|
111
|
+
* The `[normal, highContrast]` pair may live at the outer level
|
|
112
|
+
* (`[4.5, 7]`, `[{ wcag: 4.5 }, { wcag: 7 }]`) or inside the metric
|
|
113
|
+
* (`{ wcag: [4.5, 7] }`, `{ apca: [45, 60] }`).
|
|
114
|
+
*/
|
|
115
|
+
type ContrastSpec = number | ContrastPreset | {
|
|
116
|
+
wcag: HCPair<number | ContrastPreset>;
|
|
117
|
+
} | {
|
|
118
|
+
apca: HCPair<number>;
|
|
119
|
+
};
|
|
136
120
|
type AdaptationMode = 'auto' | 'fixed' | 'static';
|
|
137
121
|
/** A signed relative offset string, e.g. '+20' or '-15.5'. */
|
|
138
122
|
type RelativeValue = `+${number}` | `-${number}`;
|
|
123
|
+
/**
|
|
124
|
+
* Force a color to a tone extreme:
|
|
125
|
+
* - `'max'`: the highest tone in the active scheme range/window.
|
|
126
|
+
* - `'min'`: the lowest tone.
|
|
127
|
+
*
|
|
128
|
+
* Under `mode: 'auto'` the extreme inverts in the dark scheme (so `'max'`
|
|
129
|
+
* tracks the inversion and becomes the darkest tone). No `base` required.
|
|
130
|
+
*/
|
|
131
|
+
type ExtremeValue = 'max' | 'min';
|
|
132
|
+
/**
|
|
133
|
+
* A tone value as authored on a color.
|
|
134
|
+
* - Number: absolute tone (0–100).
|
|
135
|
+
* - `'+N'` / `'-N'`: relative to the base's tone (requires `base`).
|
|
136
|
+
* - `'max'` / `'min'`: forced to the scheme's tone extreme (no base needed).
|
|
137
|
+
*/
|
|
138
|
+
type ToneValue = number | RelativeValue | ExtremeValue;
|
|
139
139
|
/** Color format for output. */
|
|
140
140
|
type GlazeColorFormat = 'okhsl' | 'rgb' | 'hsl' | 'oklch';
|
|
141
141
|
/**
|
|
@@ -156,6 +156,15 @@ interface OkhslColor {
|
|
|
156
156
|
s: number;
|
|
157
157
|
l: number;
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Direct OKHST color input — OKHSL with the lightness axis replaced by the
|
|
161
|
+
* contrast-uniform tone axis. `h`: 0–360, `s`: 0–1, `t`: 0–1 (tone).
|
|
162
|
+
*/
|
|
163
|
+
interface OkhstColor {
|
|
164
|
+
h: number;
|
|
165
|
+
s: number;
|
|
166
|
+
t: number;
|
|
167
|
+
}
|
|
159
168
|
/** sRGB components in 0–255 (value-shorthand object form). */
|
|
160
169
|
interface RgbColor {
|
|
161
170
|
r: number;
|
|
@@ -170,11 +179,12 @@ interface OklchColor {
|
|
|
170
179
|
}
|
|
171
180
|
interface RegularColorDef {
|
|
172
181
|
/**
|
|
173
|
-
*
|
|
174
|
-
* - Number: absolute
|
|
175
|
-
* - String ('+N' / '-N'): relative to base color's
|
|
182
|
+
* Tone value (0–100, contrast-uniform — see `docs/okhst.md`).
|
|
183
|
+
* - Number: absolute tone.
|
|
184
|
+
* - String ('+N' / '-N'): relative to base color's tone (requires `base`).
|
|
185
|
+
* - `'max'` / `'min'`: force to the scheme's tone extreme (no base needed).
|
|
176
186
|
*/
|
|
177
|
-
|
|
187
|
+
tone?: HCPair<ToneValue>;
|
|
178
188
|
/** Saturation factor applied to the seed saturation (0–1, default: 1). */
|
|
179
189
|
saturation?: number;
|
|
180
190
|
/**
|
|
@@ -185,15 +195,30 @@ interface RegularColorDef {
|
|
|
185
195
|
hue?: number | RelativeValue;
|
|
186
196
|
/** Name of another color in the same theme (dependent color). */
|
|
187
197
|
base?: string;
|
|
188
|
-
/**
|
|
189
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Contrast floor against the base color. A bare number/preset is WCAG;
|
|
200
|
+
* use `{ wcag }` / `{ apca }` to pick the metric. Accepts an HC pair.
|
|
201
|
+
*/
|
|
202
|
+
contrast?: HCPair<ContrastSpec>;
|
|
190
203
|
/** Adaptation mode. Default: 'auto'. */
|
|
191
204
|
mode?: AdaptationMode;
|
|
205
|
+
/**
|
|
206
|
+
* Whether to flip out-of-bounds results to the opposite side instead of
|
|
207
|
+
* clamping to the extreme. Affects both:
|
|
208
|
+
* - relative `tone`: when `base ± delta` exceeds `[0, 100]`, mirror the
|
|
209
|
+
* delta to the other side of the base.
|
|
210
|
+
* - `contrast`: when the requested direction can't meet the floor, try the
|
|
211
|
+
* opposite side (same as the global `autoFlip`).
|
|
212
|
+
*
|
|
213
|
+
* Defaults to the global `autoFlip` config (default `true`). Set `false`
|
|
214
|
+
* to clamp instead.
|
|
215
|
+
*/
|
|
216
|
+
flip?: boolean;
|
|
192
217
|
/**
|
|
193
218
|
* Fixed opacity (0–1).
|
|
194
219
|
* Output includes alpha in the CSS value.
|
|
195
220
|
* Does not affect contrast resolution — a semi-transparent color
|
|
196
|
-
* has no fixed perceived
|
|
221
|
+
* has no fixed perceived tone, so `contrast` and `opacity`
|
|
197
222
|
* should not be combined (a console.warn is emitted).
|
|
198
223
|
*/
|
|
199
224
|
opacity?: number;
|
|
@@ -279,12 +304,13 @@ interface MixColorDef {
|
|
|
279
304
|
*/
|
|
280
305
|
space?: 'okhsl' | 'srgb';
|
|
281
306
|
/**
|
|
282
|
-
* Minimum
|
|
307
|
+
* Minimum contrast between the base and the resulting color.
|
|
283
308
|
* In 'opaque' mode, adjusts the mix ratio to meet contrast.
|
|
284
309
|
* In 'transparent' mode, adjusts opacity to meet contrast against the composite.
|
|
285
|
-
*
|
|
310
|
+
* A bare number/preset is WCAG; use `{ wcag }` / `{ apca }` to pick the
|
|
311
|
+
* metric. Supports [normal, highContrast] pair.
|
|
286
312
|
*/
|
|
287
|
-
contrast?: HCPair<
|
|
313
|
+
contrast?: HCPair<ContrastSpec>;
|
|
288
314
|
/**
|
|
289
315
|
* Whether this color is inherited by child themes created via `extend()`.
|
|
290
316
|
* Default: true. Set to false to make this color local to the current theme.
|
|
@@ -293,14 +319,20 @@ interface MixColorDef {
|
|
|
293
319
|
}
|
|
294
320
|
type ColorDef = RegularColorDef | ShadowColorDef | MixColorDef;
|
|
295
321
|
type ColorMap = Record<string, ColorDef>;
|
|
296
|
-
/**
|
|
322
|
+
/**
|
|
323
|
+
* Resolved color for a single scheme variant.
|
|
324
|
+
*
|
|
325
|
+
* Stored in OKHST: `h` / `s` are OKHSL hue/saturation, `t` is the canonical
|
|
326
|
+
* contrast-uniform tone (0–1, reference eps). Convert to OKHSL lightness via
|
|
327
|
+
* `variantToOkhsl` at the rendering / luminance edges.
|
|
328
|
+
*/
|
|
297
329
|
interface ResolvedColorVariant {
|
|
298
330
|
/** OKHSL hue (0–360). */
|
|
299
331
|
h: number;
|
|
300
332
|
/** OKHSL saturation (0–1). */
|
|
301
333
|
s: number;
|
|
302
|
-
/**
|
|
303
|
-
|
|
334
|
+
/** Canonical tone (0–1, reference eps). */
|
|
335
|
+
t: number;
|
|
304
336
|
/** Opacity (0–1). Default: 1. */
|
|
305
337
|
alpha: number;
|
|
306
338
|
}
|
|
@@ -314,20 +346,33 @@ interface ResolvedColor {
|
|
|
314
346
|
/** Adaptation mode. Present only for regular colors, omitted for shadows. */
|
|
315
347
|
mode?: AdaptationMode;
|
|
316
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* A scheme tone window.
|
|
351
|
+
* - `[lo, hi]`: OKHSL-lightness endpoints (0–100) the authored tone is
|
|
352
|
+
* remapped into, using the reference eps `0.05`. The common form.
|
|
353
|
+
* - `{ lo, hi, eps }`: same, with an explicit render curvature `eps`
|
|
354
|
+
* (advanced — most palettes never need this).
|
|
355
|
+
* - `false`: disable clamping (full range `[0, 100]` at the reference eps).
|
|
356
|
+
* This removes the *boundaries*, not the tone curve.
|
|
357
|
+
*/
|
|
358
|
+
type ToneWindow = false | [number, number] | {
|
|
359
|
+
lo: number;
|
|
360
|
+
hi: number;
|
|
361
|
+
eps: number;
|
|
362
|
+
};
|
|
317
363
|
interface GlazeConfig {
|
|
318
|
-
/** Light scheme
|
|
319
|
-
|
|
320
|
-
/** Dark scheme
|
|
321
|
-
|
|
364
|
+
/** Light scheme tone window — `[lo, hi]` (default `[10, 100]`), `{ lo, hi, eps }` for advanced eps tuning, or `false` to disable clamping. */
|
|
365
|
+
lightTone?: ToneWindow;
|
|
366
|
+
/** Dark scheme tone window — `[lo, hi]` (default `[15, 95]`), `{ lo, hi, eps }`, or `false` to disable clamping. */
|
|
367
|
+
darkTone?: ToneWindow;
|
|
322
368
|
/** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
|
|
323
369
|
darkDesaturation?: number;
|
|
324
370
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* Accepts [normal, highContrast] pair for separate HC tuning.
|
|
371
|
+
* Saturation taper toward the tone extremes (0–1). The fraction of the
|
|
372
|
+
* tone range over which saturation rolls off at each end, where in-gamut
|
|
373
|
+
* chroma collapses. Default: 0.15. Set to 0 to disable.
|
|
329
374
|
*/
|
|
330
|
-
|
|
375
|
+
saturationTaper?: number;
|
|
331
376
|
/** State alias names for token export. */
|
|
332
377
|
states?: {
|
|
333
378
|
dark?: string;
|
|
@@ -338,26 +383,26 @@ interface GlazeConfig {
|
|
|
338
383
|
/** Default tuning for all shadow colors. Per-color tuning merges field-by-field. */
|
|
339
384
|
shadowTuning?: ShadowTuning;
|
|
340
385
|
/**
|
|
341
|
-
* Automatically flip
|
|
386
|
+
* Automatically flip tone direction when contrast can't be met.
|
|
342
387
|
*
|
|
343
388
|
* When enabled (default `true`), the solver searches the requested
|
|
344
|
-
*
|
|
389
|
+
* tone direction first. If that direction can't reach the target,
|
|
345
390
|
* it tries the opposite direction and uses it when it passes. If neither
|
|
346
|
-
* side passes, the
|
|
391
|
+
* side passes, the tone is pinned to the requested-direction
|
|
347
392
|
* extreme and a warning is emitted.
|
|
348
393
|
*
|
|
349
394
|
* Set to `false` for strict "no flip" behavior. The opposite
|
|
350
395
|
* direction is never considered: if the requested direction can't
|
|
351
|
-
* meet the target, the
|
|
352
|
-
* falls back to the originally requested
|
|
396
|
+
* meet the target, the tone is pinned to its extreme (never
|
|
397
|
+
* falls back to the originally requested tone).
|
|
353
398
|
*/
|
|
354
399
|
autoFlip?: boolean;
|
|
355
400
|
}
|
|
356
401
|
interface GlazeConfigResolved {
|
|
357
|
-
|
|
358
|
-
|
|
402
|
+
lightTone: ToneWindow;
|
|
403
|
+
darkTone: ToneWindow;
|
|
359
404
|
darkDesaturation: number;
|
|
360
|
-
|
|
405
|
+
saturationTaper: number;
|
|
361
406
|
states: {
|
|
362
407
|
dark: string;
|
|
363
408
|
highContrast: string;
|
|
@@ -366,11 +411,37 @@ interface GlazeConfigResolved {
|
|
|
366
411
|
shadowTuning?: ShadowTuning;
|
|
367
412
|
autoFlip: boolean;
|
|
368
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Per-instance config override for `glaze.color()` and `glaze()` themes.
|
|
416
|
+
* Fields that are set take priority over the live global config. Fields
|
|
417
|
+
* that are omitted fall through to the live global at resolve time.
|
|
418
|
+
*
|
|
419
|
+
* `false` for a tone window disables clamping (full range at reference eps).
|
|
420
|
+
*/
|
|
421
|
+
interface GlazeConfigOverride {
|
|
422
|
+
/** Light scheme tone window, or `false` to disable clamping. */
|
|
423
|
+
lightTone?: ToneWindow;
|
|
424
|
+
/** Dark scheme tone window, or `false` to disable clamping. */
|
|
425
|
+
darkTone?: ToneWindow;
|
|
426
|
+
/** Saturation reduction factor for dark scheme (0–1). */
|
|
427
|
+
darkDesaturation?: number;
|
|
428
|
+
/** Saturation taper toward the tone extremes (0–1). */
|
|
429
|
+
saturationTaper?: number;
|
|
430
|
+
/** Whether to auto-flip tone when contrast can't be met. */
|
|
431
|
+
autoFlip?: boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Shadow tuning defaults. Only meaningful for themes; harmless on
|
|
434
|
+
* standalone color tokens.
|
|
435
|
+
*/
|
|
436
|
+
shadowTuning?: ShadowTuning;
|
|
437
|
+
}
|
|
369
438
|
/** Serialized theme configuration (no resolved values). */
|
|
370
439
|
interface GlazeThemeExport {
|
|
371
440
|
hue: number;
|
|
372
441
|
saturation: number;
|
|
373
442
|
colors: ColorMap;
|
|
443
|
+
/** Per-theme config override, if any. */
|
|
444
|
+
config?: GlazeConfigOverride;
|
|
374
445
|
}
|
|
375
446
|
/** Input for `glaze.shadow()` standalone factory. */
|
|
376
447
|
interface GlazeShadowInput {
|
|
@@ -394,25 +465,28 @@ interface GlazeShadowInput {
|
|
|
394
465
|
interface GlazeColorInput {
|
|
395
466
|
hue: number;
|
|
396
467
|
saturation: number;
|
|
397
|
-
|
|
468
|
+
tone: HCPair<number | ExtremeValue>;
|
|
398
469
|
saturationFactor?: number;
|
|
399
470
|
mode?: AdaptationMode;
|
|
471
|
+
/** Flip out-of-bounds results instead of clamping. Default: global `autoFlip`. */
|
|
472
|
+
flip?: boolean;
|
|
400
473
|
/**
|
|
401
474
|
* Fixed opacity (0–1). Output includes alpha in the CSS value.
|
|
402
|
-
* Combining with `contrast` is not recommended (perceived
|
|
475
|
+
* Combining with `contrast` is not recommended (perceived tone
|
|
403
476
|
* becomes unpredictable) — a `console.warn` is emitted in that case.
|
|
404
477
|
*/
|
|
405
478
|
opacity?: number;
|
|
406
479
|
/**
|
|
407
480
|
* Optional dependency on another color. Same semantics as
|
|
408
|
-
* `GlazeColorOverrides.base` — `contrast` and relative `
|
|
481
|
+
* `GlazeColorOverrides.base` — `contrast` and relative `tone`
|
|
409
482
|
* anchor to the base per scheme.
|
|
410
483
|
*/
|
|
411
484
|
base?: GlazeColorToken | GlazeColorValue;
|
|
412
485
|
/**
|
|
413
|
-
*
|
|
486
|
+
* Contrast floor against `base`. Requires `base` to be set. A bare
|
|
487
|
+
* number/preset is WCAG; use `{ wcag }` / `{ apca }` to pick the metric.
|
|
414
488
|
*/
|
|
415
|
-
contrast?: HCPair<
|
|
489
|
+
contrast?: HCPair<ContrastSpec>;
|
|
416
490
|
/**
|
|
417
491
|
* Optional human-readable name for the token. Used in error and
|
|
418
492
|
* warning messages (otherwise an internal name like `"value"` is
|
|
@@ -432,11 +506,12 @@ interface GlazeColorInput {
|
|
|
432
506
|
* Literal object forms:
|
|
433
507
|
* - `{ h, s, l }` — OKHSL (h: 0–360, s/l: 0–1). Passing 0–100 for `s`/`l`
|
|
434
508
|
* throws with a hint to use the structured form.
|
|
509
|
+
* - `{ h, s, t }` — OKHST (h: 0–360, s/t: 0–1). Tone in 0–1.
|
|
435
510
|
* - `{ r, g, b }` — sRGB 0–255.
|
|
436
511
|
* - `{ l, c, h }` — OKLCh (L/C: 0–1, H: degrees), same as `oklch()` strings.
|
|
437
512
|
*/
|
|
438
|
-
type GlazeColorValue = string | OkhslColor | RgbColor | OklchColor;
|
|
439
|
-
/**
|
|
513
|
+
type GlazeColorValue = string | OkhslColor | OkhstColor | RgbColor | OklchColor;
|
|
514
|
+
/** Color overrides for the `from` and value-shorthand inputs. */
|
|
440
515
|
interface GlazeColorOverrides {
|
|
441
516
|
/**
|
|
442
517
|
* Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
|
|
@@ -447,33 +522,41 @@ interface GlazeColorOverrides {
|
|
|
447
522
|
/** Override seed saturation (0–100). Default: extracted from value. */
|
|
448
523
|
saturation?: number;
|
|
449
524
|
/**
|
|
450
|
-
* Override
|
|
451
|
-
* relative to the literal seed (the value passed to `glaze.color()`)
|
|
525
|
+
* Override tone. Number is absolute (0–100, contrast-uniform); `'+N'`/`'-N'`
|
|
526
|
+
* is relative to the literal seed (the value passed to `glaze.color()`);
|
|
527
|
+
* `'max'` / `'min'` force to the scheme's tone extreme.
|
|
452
528
|
* Supports HCPair for high-contrast.
|
|
453
529
|
*/
|
|
454
|
-
|
|
530
|
+
tone?: HCPair<ToneValue>;
|
|
455
531
|
/** Saturation multiplier on the seed (0–1). Default: 1. */
|
|
456
532
|
saturationFactor?: number;
|
|
457
533
|
/**
|
|
458
534
|
* Adaptation mode. Defaults to `'auto'` for every input form, so
|
|
459
535
|
* colors automatically adapt between light and dark like an ordinary
|
|
460
536
|
* theme color. All value-shorthand inputs (strings and literal objects)
|
|
461
|
-
* preserve light
|
|
462
|
-
* `globalConfig.
|
|
463
|
-
* `{ hue, saturation,
|
|
464
|
-
* `globalConfig.
|
|
537
|
+
* preserve light tone (`lightTone: false`) and snapshot
|
|
538
|
+
* `globalConfig.darkTone` on the dark side. Only the structured
|
|
539
|
+
* `{ hue, saturation, tone }` form also snapshots
|
|
540
|
+
* `globalConfig.lightTone`.
|
|
465
541
|
*
|
|
466
|
-
* Pass `'fixed'` explicitly to opt back into the
|
|
467
|
-
* inverting mapping; pass `'static'` to pin the same
|
|
542
|
+
* Pass `'fixed'` explicitly to opt back into the linear, non-
|
|
543
|
+
* inverting mapping; pass `'static'` to pin the same tone
|
|
468
544
|
* across every variant.
|
|
469
545
|
*/
|
|
470
546
|
mode?: AdaptationMode;
|
|
471
547
|
/**
|
|
472
|
-
*
|
|
548
|
+
* Flip out-of-bounds results (relative `tone` overshoot / unmet
|
|
549
|
+
* `contrast`) to the opposite side instead of clamping. Defaults to
|
|
550
|
+
* the global `autoFlip`.
|
|
551
|
+
*/
|
|
552
|
+
flip?: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Contrast floor. By default solved against the literal seed
|
|
473
555
|
* (the value itself); when `base` is set, solved against the base's
|
|
474
|
-
* resolved variant per scheme. Same shape as `RegularColorDef.contrast
|
|
556
|
+
* resolved variant per scheme. Same shape as `RegularColorDef.contrast`
|
|
557
|
+
* (bare number/preset = WCAG; `{ wcag }` / `{ apca }` to pick the metric).
|
|
475
558
|
*/
|
|
476
|
-
contrast?: HCPair<
|
|
559
|
+
contrast?: HCPair<ContrastSpec>;
|
|
477
560
|
/**
|
|
478
561
|
* Optional dependency on another color. Accepts either a
|
|
479
562
|
* `GlazeColorToken` (returned by another `glaze.color()`) or a raw
|
|
@@ -483,10 +566,15 @@ interface GlazeColorOverrides {
|
|
|
483
566
|
* When set:
|
|
484
567
|
* - `contrast` is solved against the base's resolved variant
|
|
485
568
|
* per-scheme (light / dark / lightContrast / darkContrast).
|
|
486
|
-
* - Relative `
|
|
487
|
-
*
|
|
569
|
+
* - Relative `tone: '+N'` / `'-N'` is anchored to the base's
|
|
570
|
+
* tone per-scheme (matches theme behavior for dependent colors).
|
|
488
571
|
* - Relative `hue: '+N'` / `'-N'` still anchors to the seed (the
|
|
489
572
|
* value passed to `glaze.color()`), not the base.
|
|
573
|
+
* - When the base was created via the structured form (with explicit
|
|
574
|
+
* `hue`/`saturation`/`tone`), it is resolved at full range
|
|
575
|
+
* (`lightTone: false`) for the linking math — ensuring the
|
|
576
|
+
* contrast/tone anchor matches the input tone, not the
|
|
577
|
+
* windowed output. The base's own `.resolve()` output is unaffected.
|
|
490
578
|
*
|
|
491
579
|
* The base token's `.resolve()` is called lazily on first resolve and
|
|
492
580
|
* its result is captured by reference; later mutations to the base's
|
|
@@ -495,7 +583,7 @@ interface GlazeColorOverrides {
|
|
|
495
583
|
base?: GlazeColorToken | GlazeColorValue;
|
|
496
584
|
/**
|
|
497
585
|
* Fixed opacity (0–1). Output includes alpha in the CSS value.
|
|
498
|
-
* Combining with `contrast` is not recommended (perceived
|
|
586
|
+
* Combining with `contrast` is not recommended (perceived tone
|
|
499
587
|
* becomes unpredictable) — a `console.warn` is emitted in that case.
|
|
500
588
|
*/
|
|
501
589
|
opacity?: number;
|
|
@@ -507,41 +595,17 @@ interface GlazeColorOverrides {
|
|
|
507
595
|
name?: string;
|
|
508
596
|
}
|
|
509
597
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
598
|
+
* Object input for `glaze.color()` that carries a raw color value plus
|
|
599
|
+
* optional color overrides in the same object.
|
|
512
600
|
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
* - **Value-shorthand** (hex / `rgb()` / `hsl()` / `okhsl()` / `oklch()`
|
|
519
|
-
* strings, `{ r, g, b }`, `{ h, s, l }`, `{ l, c, h }`):
|
|
520
|
-
* - `lightLightness: false` — preserve input exactly.
|
|
521
|
-
* - `darkLightness: globalConfig.darkLightness` — snapshotted at create time.
|
|
522
|
-
*
|
|
523
|
-
* - **Structured inputs** (`{ hue, saturation, lightness, ... }`):
|
|
524
|
-
* - `lightLightness: globalConfig.lightLightness` — theme light window.
|
|
525
|
-
* - `darkLightness: globalConfig.darkLightness` — theme dark window.
|
|
526
|
-
*
|
|
527
|
-
* Passing this object replaces both fields at once. To keep one
|
|
528
|
-
* field's default while overriding the other, restate the default
|
|
529
|
-
* explicitly.
|
|
601
|
+
* ```ts
|
|
602
|
+
* glaze.color({ from: '#1a1a2e', base: bg, contrast: 'AA' })
|
|
603
|
+
* glaze.color({ from: { r: 38, g: 252, b: 178 }, tone: '+10' })
|
|
604
|
+
* ```
|
|
530
605
|
*/
|
|
531
|
-
interface
|
|
532
|
-
/**
|
|
533
|
-
|
|
534
|
-
* (preserve input) for value-shorthand inputs; plain
|
|
535
|
-
* `globalConfig.lightLightness` for structured inputs only. Pass
|
|
536
|
-
* `false` to preserve input lightness in light mode.
|
|
537
|
-
*/
|
|
538
|
-
lightLightness?: false | [number, number];
|
|
539
|
-
/**
|
|
540
|
-
* Dark-mode lightness window. Snapshotted from `globalConfig` at
|
|
541
|
-
* create time for value-shorthand and structured inputs. Pass `false`
|
|
542
|
-
* to preserve input lightness in dark mode too.
|
|
543
|
-
*/
|
|
544
|
-
darkLightness?: false | [number, number];
|
|
606
|
+
interface GlazeFromInput extends GlazeColorOverrides {
|
|
607
|
+
/** The source color value. Accepts the same forms as a bare `GlazeColorValue`. */
|
|
608
|
+
from: GlazeColorValue;
|
|
545
609
|
}
|
|
546
610
|
/** Options for `GlazeColorToken.css()`. */
|
|
547
611
|
interface GlazeColorCssOptions {
|
|
@@ -577,7 +641,7 @@ interface GlazeColorToken {
|
|
|
577
641
|
css(options: GlazeColorCssOptions): GlazeCssResult;
|
|
578
642
|
/**
|
|
579
643
|
* Serialize the token as a JSON-safe object. Captures the original
|
|
580
|
-
* input value, overrides, and
|
|
644
|
+
* input value, overrides, and config so it can be rehydrated via
|
|
581
645
|
* `glaze.colorFrom(...)`. `base` is recursively serialized.
|
|
582
646
|
*/
|
|
583
647
|
export(): GlazeColorTokenExport;
|
|
@@ -589,8 +653,8 @@ interface GlazeColorToken {
|
|
|
589
653
|
interface GlazeColorTokenExport {
|
|
590
654
|
/**
|
|
591
655
|
* Discriminator for the source overload that created the token.
|
|
592
|
-
* - `'value'`: created via `glaze.color(value, overrides
|
|
593
|
-
* - `'structured'`: created via `glaze.color({ hue, saturation, ... }
|
|
656
|
+
* - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
|
|
657
|
+
* - `'structured'`: created via `glaze.color({ hue, saturation, ... })`.
|
|
594
658
|
*/
|
|
595
659
|
form: 'value' | 'structured';
|
|
596
660
|
/** Original input. For `form: 'value'` this is the raw `GlazeColorValue`; for `form: 'structured'` this is the structured input. */
|
|
@@ -600,15 +664,14 @@ interface GlazeColorTokenExport {
|
|
|
600
664
|
* serialized. Only present for `form: 'value'`.
|
|
601
665
|
*/
|
|
602
666
|
overrides?: GlazeColorOverridesExport;
|
|
603
|
-
/** Lightness scaling override, if any. */
|
|
604
|
-
scaling?: GlazeColorScaling;
|
|
605
667
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
668
|
+
* Effective config snapshot at creation time — captures the merged
|
|
669
|
+
* result of the global config + any per-call override at the moment
|
|
670
|
+
* the token was created. Only fields that differ from their
|
|
671
|
+
* post-merge defaults are present. Used by `glaze.colorFrom()` to
|
|
672
|
+
* reproduce deterministic behavior across `configure()` calls.
|
|
610
673
|
*/
|
|
611
|
-
|
|
674
|
+
config?: GlazeConfigOverride;
|
|
612
675
|
}
|
|
613
676
|
/**
|
|
614
677
|
* Serializable shape of a structured `glaze.color({...})` input.
|
|
@@ -618,12 +681,13 @@ interface GlazeColorTokenExport {
|
|
|
618
681
|
interface GlazeColorInputExport {
|
|
619
682
|
hue: number;
|
|
620
683
|
saturation: number;
|
|
621
|
-
|
|
684
|
+
tone: HCPair<number | ExtremeValue>;
|
|
622
685
|
saturationFactor?: number;
|
|
623
686
|
mode?: AdaptationMode;
|
|
687
|
+
flip?: boolean;
|
|
624
688
|
opacity?: number;
|
|
625
689
|
base?: GlazeColorTokenExport | GlazeColorValue;
|
|
626
|
-
contrast?: HCPair<
|
|
690
|
+
contrast?: HCPair<ContrastSpec>;
|
|
627
691
|
name?: string;
|
|
628
692
|
}
|
|
629
693
|
/**
|
|
@@ -633,10 +697,11 @@ interface GlazeColorInputExport {
|
|
|
633
697
|
interface GlazeColorOverridesExport {
|
|
634
698
|
hue?: number | RelativeValue;
|
|
635
699
|
saturation?: number;
|
|
636
|
-
|
|
700
|
+
tone?: HCPair<ToneValue>;
|
|
637
701
|
saturationFactor?: number;
|
|
638
702
|
mode?: AdaptationMode;
|
|
639
|
-
|
|
703
|
+
flip?: boolean;
|
|
704
|
+
contrast?: HCPair<ContrastSpec>;
|
|
640
705
|
base?: GlazeColorTokenExport | GlazeColorValue;
|
|
641
706
|
opacity?: number;
|
|
642
707
|
name?: string;
|
|
@@ -691,6 +756,8 @@ interface GlazeExtendOptions {
|
|
|
691
756
|
hue?: number;
|
|
692
757
|
saturation?: number;
|
|
693
758
|
colors?: ColorMap;
|
|
759
|
+
/** Config override for the child theme. Merged with the parent's override. */
|
|
760
|
+
config?: GlazeConfigOverride;
|
|
694
761
|
}
|
|
695
762
|
interface GlazeTokenOptions {
|
|
696
763
|
/** Prefix mode. `true` uses "<themeName>-", or provide a custom map. */
|
|
@@ -789,25 +856,30 @@ type PaletteInput = Record<string, GlazeTheme>;
|
|
|
789
856
|
/**
|
|
790
857
|
* Create a single-hue glaze theme.
|
|
791
858
|
*
|
|
859
|
+
* An optional `config` override can be supplied to customize the resolve
|
|
860
|
+
* behavior for this theme (tone windows, saturation taper, etc.). The
|
|
861
|
+
* override is **merged over the live global config at resolve time** —
|
|
862
|
+
* the theme still reacts to later `configure()` calls for fields it
|
|
863
|
+
* didn't override.
|
|
864
|
+
*
|
|
792
865
|
* @example
|
|
793
866
|
* ```ts
|
|
794
|
-
* const primary = glaze({ hue: 280, saturation: 80 });
|
|
795
|
-
* // or shorthand:
|
|
796
867
|
* const primary = glaze(280, 80);
|
|
868
|
+
* // or shorthand:
|
|
869
|
+
* const primary = glaze({ hue: 280, saturation: 80 });
|
|
870
|
+
* // with config override:
|
|
871
|
+
* const raw = glaze(280, 80, { lightTone: false });
|
|
797
872
|
* ```
|
|
798
873
|
*/
|
|
799
874
|
declare function glaze(hueOrOptions: number | {
|
|
800
875
|
hue: number;
|
|
801
876
|
saturation: number;
|
|
802
|
-
}, saturation?: number): GlazeTheme;
|
|
877
|
+
}, saturation?: number, config?: GlazeConfigOverride): GlazeTheme;
|
|
803
878
|
declare namespace glaze {
|
|
804
879
|
var configure: (config: GlazeConfig) => void;
|
|
805
880
|
var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
|
|
806
881
|
var from: (data: GlazeThemeExport) => GlazeTheme;
|
|
807
|
-
var color:
|
|
808
|
-
(input: GlazeColorInput, scaling?: GlazeColorScaling): GlazeColorToken;
|
|
809
|
-
(value: GlazeColorValue, overrides?: GlazeColorOverrides, scaling?: GlazeColorScaling): GlazeColorToken;
|
|
810
|
-
};
|
|
882
|
+
var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
|
|
811
883
|
var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
|
|
812
884
|
var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
|
|
813
885
|
var fromHex: (hex: string) => GlazeTheme;
|
|
@@ -817,15 +889,73 @@ declare namespace glaze {
|
|
|
817
889
|
var resetConfig: () => void;
|
|
818
890
|
}
|
|
819
891
|
//#endregion
|
|
892
|
+
//#region src/okhst.d.ts
|
|
893
|
+
/**
|
|
894
|
+
* Reference eps for the OKHST color space. WCAG 2 contrast is
|
|
895
|
+
* `(Y_hi + 0.05) / (Y_lo + 0.05)`, so an eps of `0.05` makes equal tone
|
|
896
|
+
* steps yield equal WCAG contrast. This is the canonical eps used by
|
|
897
|
+
* `okhst()` input, `{ h, s, t }` input, stored `ResolvedColorVariant.t`,
|
|
898
|
+
* relative `tone` offsets, and the contrast solver.
|
|
899
|
+
*/
|
|
900
|
+
declare const REF_EPS = 0.05;
|
|
901
|
+
/**
|
|
902
|
+
* Map a luminance `Y` (0–1) to tone (0–100) at the given eps.
|
|
903
|
+
* `toneFromY(0) === 0` and `toneFromY(1) === 100` for any eps.
|
|
904
|
+
*/
|
|
905
|
+
declare function toneFromY(y: number, eps?: number): number;
|
|
906
|
+
/** Map a tone (0–100) back to luminance (0–1). Inverse of {@link toneFromY}. */
|
|
907
|
+
declare function yFromTone(t: number, eps?: number): number;
|
|
908
|
+
/** OKHSL lightness (0–1) -> tone (0–100). */
|
|
909
|
+
declare function toTone(l: number, eps?: number): number;
|
|
910
|
+
/** Tone (0–100) -> OKHSL lightness (0–1). Inverse of {@link toTone}. */
|
|
911
|
+
declare function fromTone(t: number, eps?: number): number;
|
|
912
|
+
/** Convert OKHST `{ h, s, t }` (t in 0–1) to OKHSL `{ h, s, l }`. */
|
|
913
|
+
declare function okhstToOkhsl(c: {
|
|
914
|
+
h: number;
|
|
915
|
+
s: number;
|
|
916
|
+
t: number;
|
|
917
|
+
}): {
|
|
918
|
+
h: number;
|
|
919
|
+
s: number;
|
|
920
|
+
l: number;
|
|
921
|
+
};
|
|
922
|
+
/** Convert OKHSL `{ h, s, l }` to OKHST `{ h, s, t }` (t in 0–1). */
|
|
923
|
+
declare function okhslToOkhst(c: {
|
|
924
|
+
h: number;
|
|
925
|
+
s: number;
|
|
926
|
+
l: number;
|
|
927
|
+
}): {
|
|
928
|
+
h: number;
|
|
929
|
+
s: number;
|
|
930
|
+
t: number;
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* Edge adapter: a resolved variant stores canonical tone `t` (0–1). Convert
|
|
934
|
+
* it to the OKHSL `{ h, s, l }` the formatters and luminance pipeline expect.
|
|
935
|
+
*/
|
|
936
|
+
declare function variantToOkhsl(v: {
|
|
937
|
+
h: number;
|
|
938
|
+
s: number;
|
|
939
|
+
t: number;
|
|
940
|
+
}): {
|
|
941
|
+
h: number;
|
|
942
|
+
s: number;
|
|
943
|
+
l: number;
|
|
944
|
+
};
|
|
945
|
+
//#endregion
|
|
820
946
|
//#region src/okhsl-color-math.d.ts
|
|
821
947
|
/**
|
|
822
948
|
* OKHSL color math primitives for the glaze theme generator.
|
|
823
949
|
*
|
|
824
|
-
* Provides bidirectional OKHSL ↔ sRGB conversion,
|
|
825
|
-
*
|
|
826
|
-
* (okhsl, rgb, hsl, oklch).
|
|
950
|
+
* Provides bidirectional OKHSL ↔ sRGB conversion, luminance computation
|
|
951
|
+
* for both contrast metrics (WCAG 2 relative luminance and APCA screen
|
|
952
|
+
* luminance `Ys`), and multi-format output (okhsl, rgb, hsl, oklch).
|
|
827
953
|
*/
|
|
828
954
|
type Vec3 = [number, number, number];
|
|
955
|
+
/**
|
|
956
|
+
* OKHSL toe function: maps OKLab lightness L to perceptual lightness l.
|
|
957
|
+
* Exported for the OKHST tone transfers in `okhst.ts`.
|
|
958
|
+
*/
|
|
829
959
|
/**
|
|
830
960
|
* Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLab [L, a, b].
|
|
831
961
|
*/
|
|
@@ -912,5 +1042,5 @@ declare function formatHsl(h: number, s: number, l: number): string;
|
|
|
912
1042
|
*/
|
|
913
1043
|
declare function formatOklch(h: number, s: number, l: number): string;
|
|
914
1044
|
//#endregion
|
|
915
|
-
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type
|
|
1045
|
+
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeFromInput, 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 OkhstColor, type OklchColor, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, contrastRatioFromLuminance, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveContrastForMode, resolveMinContrast, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
|
|
916
1046
|
//# sourceMappingURL=index.d.cts.map
|