@tenphi/glaze 0.15.1 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,19 +2,46 @@
2
2
  type LinearRgb = [number, number, number];
3
3
  type ContrastPreset = 'AA' | 'AAA' | 'AA-large' | 'AAA-large';
4
4
  type MinContrast$1 = number | ContrastPreset;
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
+ /**
20
+ * Resolve an APCA target — a raw Lc number (kept as-is) or an `ApcaPreset`
21
+ * keyword mapped to its Lc value. The magnitude is forced non-negative.
22
+ */
23
+ declare function resolveApcaTarget(value: number | ApcaPreset): number;
5
24
  /** Metric + numeric target after resolving a `ContrastSpec` for a mode. */
6
25
  interface ResolvedContrast {
7
26
  metric: 'wcag' | 'apca';
8
27
  /** WCAG ratio (>= 1) or APCA Lc magnitude (0–106). */
9
28
  target: number;
29
+ /**
30
+ * APCA argument order: which side the resolved (candidate) color plays
31
+ * against the base. `'fg'` (default) → `apcaContrast(yCandidate, yBase)`;
32
+ * `'bg'` → `apcaContrast(yBase, yCandidate)`. Always `'fg'` for WCAG
33
+ * (symmetric, ignored).
34
+ */
35
+ polarity?: 'fg' | 'bg';
10
36
  }
11
37
  declare function resolveMinContrast(value: MinContrast$1): number;
12
38
  /**
13
39
  * Resolve a `ContrastSpec` (already selected from any outer HC pair) for a
14
40
  * given mode into `{ metric, target }`. Handles the inner metric HC pair and
15
- * preset resolution.
41
+ * preset resolution. `polarity` is passed through to the result for the APCA
42
+ * branch (it controls argument order in the solver); WCAG ignores it.
16
43
  */
17
- declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean): ResolvedContrast;
44
+ declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean, polarity?: 'fg' | 'bg'): ResolvedContrast;
18
45
  /**
19
46
  * APCA lightness contrast (Lc), signed: positive for dark text on light bg,
20
47
  * negative for light text on dark bg. Inputs are screen luminances (0–1).
@@ -101,17 +128,30 @@ type MinContrast = number | ContrastPreset;
101
128
  *
102
129
  * - `number` / `ContrastPreset`: a WCAG ratio (bare form).
103
130
  * - `{ wcag }`: WCAG ratio or preset, optionally an HC pair.
104
- * - `{ apca }`: APCA Lc target (absolute value), optionally an HC pair.
131
+ * - `{ apca }`: APCA Lc target (absolute value or preset), optionally an HC pair.
105
132
  *
106
133
  * The `[normal, highContrast]` pair may live at the outer level
107
134
  * (`[4.5, 7]`, `[{ wcag: 4.5 }, { wcag: 7 }]`) or inside the metric
108
- * (`{ wcag: [4.5, 7] }`, `{ apca: [45, 60] }`).
135
+ * (`{ wcag: [4.5, 7] }`, `{ apca: [45, 60] }`, `{ apca: ['content', 'body'] }`).
109
136
  */
110
137
  type ContrastSpec = number | ContrastPreset | {
111
138
  wcag: HCPair<number | ContrastPreset>;
112
139
  } | {
113
- apca: HCPair<number>;
140
+ apca: HCPair<number | ApcaPreset>;
114
141
  };
142
+ /**
143
+ * The semantic role a color plays against its base, used to fix APCA contrast
144
+ * polarity (which side is the foreground vs the background). WCAG is
145
+ * symmetric, so role never changes WCAG results.
146
+ */
147
+ type Role = 'text' | 'surface' | 'border';
148
+ /**
149
+ * Any string accepted as a `role`. Canonical values plus aliases normalized by
150
+ * `normalizeRole` (see `roles.ts`): `surface` (bg/background/fill/canvas/
151
+ * paper/layer), `text` (fg/foreground/content/ink/label/stroke), `border`
152
+ * (divider/outline/separator/hairline/rule).
153
+ */
154
+ type RoleInput = Role | 'bg' | 'background' | 'fill' | 'canvas' | 'paper' | 'layer' | 'fg' | 'foreground' | 'content' | 'ink' | 'label' | 'stroke' | 'divider' | 'outline' | 'separator' | 'hairline' | 'rule';
115
155
  type AdaptationMode = 'auto' | 'fixed' | 'static';
116
156
  /** A signed relative offset string, e.g. '+20' or '-15.5'. */
117
157
  type RelativeValue = `+${number}` | `-${number}`;
@@ -132,7 +172,7 @@ type ExtremeValue = 'max' | 'min';
132
172
  */
133
173
  type ToneValue = number | RelativeValue | ExtremeValue;
134
174
  /** Color format for output. */
135
- type GlazeColorFormat = 'okhsl' | 'rgb' | 'hsl' | 'oklch';
175
+ type GlazeColorFormat = 'okhsl' | 'okhst' | 'rgb' | 'hsl' | 'oklch';
136
176
  /**
137
177
  * Controls which scheme variants are generated in the export.
138
178
  * Light is always included (it's the default).
@@ -224,6 +264,16 @@ interface RegularColorDef {
224
264
  * @see GlazeConfig.pastel
225
265
  */
226
266
  pastel?: boolean;
267
+ /**
268
+ * Semantic role against `base`: how this color is used. Fixes APCA contrast
269
+ * polarity (the argument order in `apcaContrast`). WCAG is symmetric so it
270
+ * never affects WCAG results.
271
+ *
272
+ * Resolution: explicit `role` wins; else inferred from the color name when
273
+ * `inferRole` is enabled (default); else the opposite of the base's role;
274
+ * else defaults to `'text'` (foreground).
275
+ */
276
+ role?: RoleInput;
227
277
  /**
228
278
  * Whether this color is inherited by child themes created via `extend()`.
229
279
  * Default: true. Set to false to make this color local to the current theme.
@@ -327,6 +377,12 @@ interface MixColorDef {
327
377
  * @see GlazeConfig.pastel
328
378
  */
329
379
  pastel?: boolean;
380
+ /**
381
+ * Semantic role of the mixed result against `base`. Same semantics as
382
+ * `RegularColorDef.role` (fixes APCA polarity). Resolution and defaults
383
+ * are identical.
384
+ */
385
+ role?: RoleInput;
330
386
  /**
331
387
  * Whether this color is inherited by child themes created via `extend()`.
332
388
  * Default: true. Set to false to make this color local to the current theme.
@@ -420,6 +476,13 @@ interface GlazeConfig {
420
476
  * @default false
421
477
  */
422
478
  pastel?: boolean;
479
+ /**
480
+ * If true (default), infer a color's `role` from its name when no explicit
481
+ * `role` is set. Set to `false` to opt out of name-based inference (the
482
+ * base-opposite and default-foreground fallbacks still apply).
483
+ * @default true
484
+ */
485
+ inferRole?: boolean;
423
486
  }
424
487
  interface GlazeConfigResolved {
425
488
  lightTone: ToneWindow;
@@ -433,6 +496,7 @@ interface GlazeConfigResolved {
433
496
  shadowTuning?: ShadowTuning;
434
497
  autoFlip: boolean;
435
498
  pastel: boolean;
499
+ inferRole: boolean;
436
500
  }
437
501
  /**
438
502
  * Per-instance config override for `glaze.color()` and `glaze()` themes.
@@ -456,6 +520,11 @@ interface GlazeConfigOverride {
456
520
  * for the given lightness.
457
521
  */
458
522
  pastel?: boolean;
523
+ /**
524
+ * If true, infer a color's `role` from its name when no explicit `role` is
525
+ * set. Falls through to the live global at resolve time when omitted.
526
+ */
527
+ inferRole?: boolean;
459
528
  /**
460
529
  * Shadow tuning defaults. Only meaningful for themes; harmless on
461
530
  * standalone color tokens.
@@ -527,6 +596,14 @@ interface GlazeColorInput {
527
596
  * @see GlazeConfig.pastel
528
597
  */
529
598
  pastel?: boolean;
599
+ /**
600
+ * Semantic role against `base` / the literal seed: how this token is used.
601
+ * Fixes APCA contrast polarity. Same resolution chain as
602
+ * `RegularColorDef.role` (explicit → name inference → opposite of base →
603
+ * `'text'`). For standalone tokens the name is internal, so set `role`
604
+ * explicitly or rely on the base-opposite / foreground default.
605
+ */
606
+ role?: RoleInput;
530
607
  }
531
608
  /**
532
609
  * Any single-color input form accepted by the value-shorthand
@@ -634,6 +711,12 @@ interface GlazeColorOverrides {
634
711
  * @see GlazeConfig.pastel
635
712
  */
636
713
  pastel?: boolean;
714
+ /**
715
+ * Semantic role against `base` / the literal seed: how this token is used.
716
+ * Fixes APCA contrast polarity. Same resolution chain as
717
+ * `RegularColorDef.role`.
718
+ */
719
+ role?: RoleInput;
637
720
  }
638
721
  /**
639
722
  * Object input for `glaze.color()` that carries a raw color value plus
@@ -663,6 +746,11 @@ interface GlazeColorCssOptions {
663
746
  * `theme.css` default).
664
747
  */
665
748
  suffix?: string;
749
+ /**
750
+ * Emit hue as a separate custom property, referenced via `var()`.
751
+ * Requires `format: 'oklch'` and a pastel token. oklch + all-pastel only.
752
+ */
753
+ splitHue?: boolean;
666
754
  }
667
755
  /** Return type for `glaze.color()`. */
668
756
  interface GlazeColorToken {
@@ -680,6 +768,25 @@ interface GlazeColorToken {
680
768
  json(options?: GlazeJsonOptions): Record<string, string>;
681
769
  /** Export as CSS custom property declarations grouped by scheme variant. */
682
770
  css(options: GlazeColorCssOptions): GlazeCssResult;
771
+ /**
772
+ * Export as W3C DTCG color tokens (one per scheme variant, no color name
773
+ * key). Each entry is a full `{ $type: 'color', $value }` token.
774
+ * @see https://www.designtokens.org/
775
+ */
776
+ dtcg(options?: GlazeDtcgOptions): GlazeColorDtcgResult;
777
+ /**
778
+ * Export as a single W3C DTCG Resolver-Module document for this color,
779
+ * keyed by `name` across all scheme variants. `name` is required.
780
+ * @see https://www.designtokens.org/
781
+ */
782
+ dtcgResolver(options: GlazeColorDtcgResolverOptions): GlazeDtcgResolverDocument;
783
+ /**
784
+ * Export as a Tailwind CSS v4 `@theme` block (light baseline) plus dark /
785
+ * high-contrast overrides. Returns a single ready-to-paste CSS string.
786
+ * `name` is required (forms `--color-<name>`).
787
+ * @see https://tailwindcss.com/docs/theme
788
+ */
789
+ tailwind(options: GlazeColorTailwindOptions): string;
683
790
  /**
684
791
  * Serialize the token as a JSON-safe object. Captures the original
685
792
  * input value, overrides, and config so it can be rehydrated via
@@ -731,6 +838,7 @@ interface GlazeColorInputExport {
731
838
  contrast?: HCPair<ContrastSpec>;
732
839
  name?: string;
733
840
  pastel?: boolean;
841
+ role?: RoleInput;
734
842
  }
735
843
  /**
736
844
  * Serializable shape of `GlazeColorOverrides`. `base` is replaced by
@@ -748,6 +856,7 @@ interface GlazeColorOverridesExport {
748
856
  opacity?: number;
749
857
  name?: string;
750
858
  pastel?: boolean;
859
+ role?: RoleInput;
751
860
  }
752
861
  interface GlazeTheme {
753
862
  /** The hue seed (0–360). */
@@ -796,6 +905,27 @@ interface GlazeTheme {
796
905
  json(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
797
906
  /** Export as CSS custom property declarations. */
798
907
  css(options?: GlazeCssOptions): GlazeCssResult;
908
+ /**
909
+ * Export as W3C Design Tokens Format Module (2025.10) documents, one per
910
+ * scheme variant. Consumable by Figma, Tokens Studio, Style Dictionary,
911
+ * Terrazzo, and any DTCG-compatible tool.
912
+ * @see https://www.designtokens.org/
913
+ */
914
+ dtcg(options?: GlazeDtcgOptions): GlazeDtcgResult;
915
+ /**
916
+ * Export as a single W3C DTCG Resolver-Module document describing every
917
+ * scheme variant as one `sets` entry plus a single `scheme` modifier with a
918
+ * context per variant. Consumable by resolver tools such as Dispersa.
919
+ * @see https://www.designtokens.org/
920
+ */
921
+ dtcgResolver(options?: GlazeDtcgResolverOptions): GlazeDtcgResolverDocument;
922
+ /**
923
+ * Export as a Tailwind CSS v4 `@theme` block (light baseline) plus dark /
924
+ * high-contrast overrides under configurable selectors. Returns a single
925
+ * ready-to-paste CSS string.
926
+ * @see https://tailwindcss.com/docs/theme
927
+ */
928
+ tailwind(options?: GlazeTailwindOptions): string;
799
929
  }
800
930
  interface GlazeExtendOptions {
801
931
  hue?: number;
@@ -816,6 +946,16 @@ interface GlazeTokenOptions {
816
946
  modes?: GlazeOutputModes;
817
947
  /** Output color format. Default: 'okhsl'. */
818
948
  format?: GlazeColorFormat;
949
+ /**
950
+ * Emit hue as a separate custom property, referenced via `var()`.
951
+ * Requires `format: 'oklch'` and every color to be pastel.
952
+ */
953
+ splitHue?: boolean;
954
+ /**
955
+ * Base name for the theme-level hue var (`--{name}-hue`). Default: `'theme'`.
956
+ * Palette export auto-derives this from the theme name.
957
+ */
958
+ name?: string;
819
959
  }
820
960
  interface GlazeJsonOptions {
821
961
  /** Override which scheme variants to include. */
@@ -828,6 +968,16 @@ interface GlazeCssOptions {
828
968
  format?: GlazeColorFormat;
829
969
  /** Suffix appended to each CSS custom property name. Default: '-color'. */
830
970
  suffix?: string;
971
+ /**
972
+ * Emit hue as a separate custom property, referenced via `var()`.
973
+ * Requires `format: 'oklch'` and every color to be pastel.
974
+ */
975
+ splitHue?: boolean;
976
+ /**
977
+ * Base name for the theme-level hue var (`--{name}-hue`). Default: `'theme'`.
978
+ * Palette export auto-derives this from the theme name.
979
+ */
980
+ name?: string;
831
981
  }
832
982
  /** CSS custom property declarations grouped by scheme variant. */
833
983
  interface GlazeCssResult {
@@ -836,6 +986,182 @@ interface GlazeCssResult {
836
986
  lightContrast: string;
837
987
  darkContrast: string;
838
988
  }
989
+ /**
990
+ * Color space used for DTCG `$value` color objects.
991
+ * @see https://www.designtokens.org/
992
+ */
993
+ type DtcgColorSpace = 'srgb' | 'oklch';
994
+ /**
995
+ * A DTCG color `$value` in the sRGB color space: gamma sRGB components in
996
+ * 0–1 plus a 6-digit `hex` hint. Universally understood by Figma, Tokens
997
+ * Studio, Style Dictionary, and every DTCG reader.
998
+ */
999
+ interface DtcgSrgbColorValue {
1000
+ colorSpace: 'srgb';
1001
+ components: [number, number, number];
1002
+ hex: HexColor;
1003
+ /** Opacity 0–1. Omitted when fully opaque (alpha = 1). */
1004
+ alpha?: number;
1005
+ }
1006
+ /**
1007
+ * A DTCG color `$value` in the OKLCH color space: `[L, C, H]` components
1008
+ * (L/C: 0–1, H: degrees). Wide-gamut and Glaze-native; no `hex` is emitted.
1009
+ */
1010
+ interface DtcgOklchColorValue {
1011
+ colorSpace: 'oklch';
1012
+ components: [number, number, number];
1013
+ /** Opacity 0–1. Omitted when fully opaque (alpha = 1). */
1014
+ alpha?: number;
1015
+ }
1016
+ /** A DTCG `$value` for a color token, in either supported color space. */
1017
+ type DtcgColorValue = DtcgSrgbColorValue | DtcgOklchColorValue;
1018
+ /**
1019
+ * A single W3C DTCG color token: `{ $type: 'color', $value }`.
1020
+ * `$description` is optional and not populated by Glaze today.
1021
+ */
1022
+ interface DtcgColorToken {
1023
+ $type: 'color';
1024
+ $value: DtcgColorValue;
1025
+ $description?: string;
1026
+ }
1027
+ /**
1028
+ * A W3C Design Tokens Format Module (2025.10) token tree for one scheme.
1029
+ * Glaze emits one document per scheme variant — the most tool-compatible
1030
+ * convention (one file per Style Dictionary theme / Tokens Studio set /
1031
+ * Figma variable mode).
1032
+ */
1033
+ type DtcgDocument = Record<string, DtcgColorToken>;
1034
+ /** DTCG token documents grouped by scheme variant. Light is always present. */
1035
+ interface GlazeDtcgResult {
1036
+ light: DtcgDocument;
1037
+ dark?: DtcgDocument;
1038
+ lightContrast?: DtcgDocument;
1039
+ darkContrast?: DtcgDocument;
1040
+ }
1041
+ /** A single DTCG color token grouped by scheme variant (standalone tokens). */
1042
+ interface GlazeColorDtcgResult {
1043
+ light: DtcgColorToken;
1044
+ dark?: DtcgColorToken;
1045
+ lightContrast?: DtcgColorToken;
1046
+ darkContrast?: DtcgColorToken;
1047
+ }
1048
+ /** Options for `theme.dtcg()` / `palette.dtcg()`. */
1049
+ interface GlazeDtcgOptions {
1050
+ /** Override which scheme variants to include. */
1051
+ modes?: GlazeOutputModes;
1052
+ /**
1053
+ * DTCG color space. `'srgb'` (default) emits sRGB components plus a `hex`
1054
+ * hint — universally understood (Figma, Tokens Studio). `'oklch'` emits
1055
+ * OKLCH components with no hex — Glaze-native, wide-gamut.
1056
+ */
1057
+ colorSpace?: DtcgColorSpace;
1058
+ }
1059
+ /**
1060
+ * A node in a DTCG Resolver-Module token tree: either a leaf color token or a
1061
+ * nested group. A flat `DtcgDocument` (top-level color-name keys) is a valid
1062
+ * shallow tree, so Glaze's per-scheme documents slot directly into
1063
+ * `sets.<name>.sources` and `modifiers.<name>.contexts.<ctx>` entries.
1064
+ */
1065
+ interface DtcgTokenTree {
1066
+ [key: string]: DtcgColorToken | DtcgTokenTree;
1067
+ }
1068
+ /** A named set in a resolver document: a list of token-tree sources. */
1069
+ interface DtcgResolverSet {
1070
+ sources: DtcgTokenTree[];
1071
+ }
1072
+ /**
1073
+ * A named modifier (an axis such as `scheme`) in a resolver document.
1074
+ * `default` names the context applied when no override is selected; `contexts`
1075
+ * maps each context name to the token-tree overrides applied for it.
1076
+ */
1077
+ interface DtcgResolverModifier {
1078
+ default: string;
1079
+ contexts: Record<string, DtcgTokenTree[]>;
1080
+ }
1081
+ /** A JSON-pointer `$ref` entry in a resolver document's `resolutionOrder`. */
1082
+ interface DtcgResolverRef {
1083
+ $ref: string;
1084
+ }
1085
+ /**
1086
+ * A W3C DTCG Resolver-Module document. Describes every scheme variant in a
1087
+ * single file as `sets` (base token sources) plus `modifiers` (per-context
1088
+ * overrides) composed in `resolutionOrder`. Consumable by resolver tools such
1089
+ * as Dispersa.
1090
+ * @see https://www.designtokens.org/
1091
+ */
1092
+ interface GlazeDtcgResolverDocument {
1093
+ version: string;
1094
+ sets: Record<string, DtcgResolverSet>;
1095
+ modifiers: Record<string, DtcgResolverModifier>;
1096
+ resolutionOrder: DtcgResolverRef[];
1097
+ }
1098
+ /** Renaming of the four scheme variants as resolver-modifier context names. */
1099
+ interface GlazeDtcgResolverContextNames {
1100
+ light?: string;
1101
+ dark?: string;
1102
+ lightContrast?: string;
1103
+ darkContrast?: string;
1104
+ }
1105
+ /**
1106
+ * Options for `theme.dtcgResolver()` / `palette.dtcgResolver()`. Extends
1107
+ * `GlazeDtcgOptions` so `modes` + `colorSpace` pass through to the underlying
1108
+ * per-scheme `dtcg()` build.
1109
+ */
1110
+ interface GlazeDtcgResolverOptions extends GlazeDtcgOptions {
1111
+ /** Name of the single set holding the default (light) token tree. Default `'base'`. */
1112
+ setName?: string;
1113
+ /**
1114
+ * Name of the modifier describing the scheme axis. Default `'scheme'`
1115
+ * (Glaze's term for the light / dark / high-contrast axis).
1116
+ */
1117
+ modifierName?: string;
1118
+ /**
1119
+ * Override the four context names emitted on the modifier. Defaults to the
1120
+ * Glaze variant keys: `light` / `dark` / `lightContrast` / `darkContrast`.
1121
+ */
1122
+ contextNames?: GlazeDtcgResolverContextNames;
1123
+ /** Resolver document version. Default `'2025.10'`. */
1124
+ version?: string;
1125
+ }
1126
+ /** Options for `glaze.color().dtcgResolver()`. `name` is required. */
1127
+ interface GlazeColorDtcgResolverOptions extends GlazeDtcgResolverOptions {
1128
+ /** Token name keying the color within each token tree. Required. */
1129
+ name: string;
1130
+ }
1131
+ /** Options for `theme.tailwind()` / `palette.tailwind()`. */
1132
+ interface GlazeTailwindOptions {
1133
+ /** Override which scheme variants to include. */
1134
+ modes?: GlazeOutputModes;
1135
+ /** Output color format. Default: 'oklch'. */
1136
+ format?: GlazeColorFormat;
1137
+ /**
1138
+ * CSS custom property namespace, forming `--<namespace><name>`.
1139
+ * Default: `'color-'` → `--color-surface`. (Tailwind v4's `--color-*`
1140
+ * convention, which auto-generates `bg-*` / `text-*` / `border-*`.)
1141
+ *
1142
+ * Named `namespace` rather than `prefix` to avoid clashing with the
1143
+ * palette theme-prefix option on `palette.tailwind()`.
1144
+ */
1145
+ namespace?: string;
1146
+ /**
1147
+ * Selector wrapping the dark-scheme overrides. Default: `'.dark'`.
1148
+ * Pass a media query such as `'@media (prefers-color-scheme: dark)'` to
1149
+ * drive dark mode from the OS preference instead of a class.
1150
+ */
1151
+ darkSelector?: string;
1152
+ /**
1153
+ * Selector wrapping the light high-contrast overrides. Default:
1154
+ * `'.high-contrast'`. The combined dark + high-contrast overrides are
1155
+ * emitted under `${darkSelector}${highContrastSelector}` (e.g.
1156
+ * `.dark.high-contrast`).
1157
+ */
1158
+ highContrastSelector?: string;
1159
+ }
1160
+ /** Options for `glaze.color().tailwind()`. `name` is required. */
1161
+ interface GlazeColorTailwindOptions extends GlazeTailwindOptions {
1162
+ /** Custom property base name (without leading `--`). Required. */
1163
+ name: string;
1164
+ }
839
1165
  /** Options for `glaze.palette()` creation. */
840
1166
  interface GlazePaletteOptions {
841
1167
  /**
@@ -867,6 +1193,11 @@ interface GlazePaletteExportOptions {
867
1193
  * When omitted, inherits the palette-level `primary`.
868
1194
  */
869
1195
  primary?: string | false;
1196
+ /**
1197
+ * Emit hue as a separate custom property, referenced via `var()`.
1198
+ * Requires `format: 'oklch'` and every color to be pastel.
1199
+ */
1200
+ splitHue?: boolean;
870
1201
  }
871
1202
  interface GlazePalette {
872
1203
  /**
@@ -894,6 +1225,25 @@ interface GlazePalette {
894
1225
  }): Record<string, Record<string, Record<string, string>>>;
895
1226
  /** Export all themes as CSS custom property declarations. */
896
1227
  css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
1228
+ /**
1229
+ * Export all themes as W3C DTCG documents, one per scheme variant.
1230
+ * Prefix defaults to `true`. Inherits the palette-level `primary`.
1231
+ * @see https://www.designtokens.org/
1232
+ */
1233
+ dtcg(options?: GlazeDtcgOptions & GlazePaletteExportOptions): GlazeDtcgResult;
1234
+ /**
1235
+ * Export all themes as a single W3C DTCG Resolver-Module document. Prefix
1236
+ * defaults to `true`. Inherits the palette-level `primary`.
1237
+ * @see https://www.designtokens.org/
1238
+ */
1239
+ dtcgResolver(options?: GlazeDtcgResolverOptions & GlazePaletteExportOptions): GlazeDtcgResolverDocument;
1240
+ /**
1241
+ * Export all themes as a Tailwind CSS v4 `@theme` block plus dark /
1242
+ * high-contrast overrides. Returns a single ready-to-paste CSS string.
1243
+ * Prefix defaults to `true`.
1244
+ * @see https://tailwindcss.com/docs/theme
1245
+ */
1246
+ tailwind(options?: GlazeTailwindOptions & GlazePaletteExportOptions): string;
897
1247
  }
898
1248
  //#endregion
899
1249
  //#region src/glaze.d.ts
@@ -934,6 +1284,82 @@ declare namespace glaze {
934
1284
  var resetConfig: () => void;
935
1285
  }
936
1286
  //#endregion
1287
+ //#region src/channels.d.ts
1288
+ interface HueDeclaration {
1289
+ prop: string;
1290
+ value: string;
1291
+ }
1292
+ interface HuePlan {
1293
+ /** CSS `var()` reference spliced into `oklch(L C <hueVar>)`. */
1294
+ hueVar: string;
1295
+ /** When true, emit a full inline color (shadow/mix/achromatic). */
1296
+ inline: boolean;
1297
+ /** Scheme-independent `--*-hue` declarations for this color. */
1298
+ declarations: HueDeclaration[];
1299
+ }
1300
+ interface ChannelCtx {
1301
+ seedHue: number;
1302
+ /** Theme-level hue var base name (without `--` / `-hue`). */
1303
+ baseName: string;
1304
+ /** Token / custom-property name prefix used for hue var naming (`brand-` etc.). */
1305
+ prefix: string;
1306
+ defs: ColorMap;
1307
+ mode: 'theme' | 'standalone';
1308
+ /** Standalone: resolved hue from the primary variant (scheme-independent). */
1309
+ resolvedHue?: number;
1310
+ /**
1311
+ * When false, hue declarations are not emitted (the pass only references
1312
+ * hue vars already declared by a sibling pass). Used by palette primary
1313
+ * unprefixed aliases so they reference the themed `--{themeName}-*-hue`
1314
+ * vars without re-declaring (and colliding with) other themes' base vars.
1315
+ * Defaults to true.
1316
+ */
1317
+ emitDeclarations?: boolean;
1318
+ }
1319
+ //#endregion
1320
+ //#region src/format-guard.d.ts
1321
+ /**
1322
+ * Throw when a non-native Glaze color space is requested for an export that
1323
+ * emits raw CSS or non-Tasty token maps.
1324
+ */
1325
+ declare function assertNativeFormat(format: GlazeColorFormat | undefined, method: string): void;
1326
+ /**
1327
+ * Throw when `splitHue` is enabled but any exported color is not pastel.
1328
+ * Hue rotation is only clip-free when chroma is bounded by the hue-independent
1329
+ * safe chroma (`computeSafeChromaOKLCH`).
1330
+ */
1331
+ declare function assertAllPastel(resolved: Map<string, ResolvedColor>, modes: Required<GlazeOutputModes>): void;
1332
+ //#endregion
1333
+ //#region src/roles.d.ts
1334
+ /**
1335
+ * Normalize a `RoleInput` (canonical value or alias) into a canonical `Role`.
1336
+ * Returns `undefined` for unrecognized strings so callers can fall through to
1337
+ * the next step of the resolution chain.
1338
+ */
1339
+ declare function normalizeRole(input: RoleInput | undefined): Role | undefined;
1340
+ /**
1341
+ * Infer a `Role` from a color name by matching its tokens against the role
1342
+ * keyword sets. When multiple tokens match, the **last** recognized token
1343
+ * wins (so `button-text` → `text`, `input-bg` → `surface`, `card-border` →
1344
+ * `border`). Returns `undefined` when no token matches.
1345
+ */
1346
+ declare function inferRoleFromName(name: string): Role | undefined;
1347
+ /** APCA argument order: which side the resolved color plays. */
1348
+ type Polarity = 'fg' | 'bg';
1349
+ /**
1350
+ * Map a role to its APCA polarity. `text` and `border` are foreground spots
1351
+ * against their base (the candidate is the text argument); `surface` is the
1352
+ * background (the base is the text argument).
1353
+ */
1354
+ declare function roleToPolarity(role: Role): Polarity;
1355
+ /**
1356
+ * The opposite role of `role`, used when a color with no explicit role and no
1357
+ * inferable name depends on a base: the dependent color plays the opposite
1358
+ * role of its base. `surface` ↔ `text`; `border` is treated as a foreground
1359
+ * spot, so its opposite is `surface`.
1360
+ */
1361
+ declare function oppositeRole(role: Role): Role;
1362
+ //#endregion
937
1363
  //#region src/okhst.d.ts
938
1364
  /**
939
1365
  * Reference eps for the OKHST color space. WCAG 2 contrast is
@@ -1080,6 +1506,14 @@ declare function parseHexAlpha(hex: string): {
1080
1506
  * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
1081
1507
  */
1082
1508
  declare function formatOkhsl(h: number, s: number, l: number, pastel?: boolean): string;
1509
+ /**
1510
+ * Format OKHST values as a CSS `okhst(H S% T%)` string.
1511
+ * h: 0–360, s: 0–100, t: 0–100 (percentage scale for s and t).
1512
+ *
1513
+ * Pastel recompute matches `formatOkhsl`: convert via OKLab so external
1514
+ * parsers that only understand non-pastel OKHST render identically.
1515
+ */
1516
+ declare function formatOkhst(h: number, s: number, t: number, pastel?: boolean): string;
1083
1517
  /**
1084
1518
  * Format OKHSL values as a CSS `rgb(R G B)` string.
1085
1519
  * Uses 2 decimal places to avoid 8-bit quantization contrast loss.
@@ -1096,6 +1530,18 @@ declare function formatHsl(h: number, s: number, l: number, pastel?: boolean): s
1096
1530
  * h: 0–360, s: 0–100, l: 0–100 (percentage scale for s and l).
1097
1531
  */
1098
1532
  declare function formatOklch(h: number, s: number, l: number, pastel?: boolean): string;
1533
+ /**
1534
+ * Convert gamma-encoded sRGB channels (0–1) to a 6-digit lowercase hex
1535
+ * string (`#rrggbb`). Channels are clamped to [0,1] and rounded to 8-bit.
1536
+ * Alpha is not encoded here — DTCG carries it as a separate `alpha` field.
1537
+ */
1538
+ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
1539
+ /**
1540
+ * Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLCH components `[L, C, H]`.
1541
+ * L: 0–1, C: 0–~0.4 (chroma), H: 0–360 (hue). Shared by `formatOklch` and
1542
+ * the DTCG `oklch` colorSpace exporter so the two never drift apart.
1543
+ */
1544
+ declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
1099
1545
  //#endregion
1100
- 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, cuspLightness, 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 };
1546
+ export { 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 };
1101
1547
  //# sourceMappingURL=index.d.cts.map