@tenphi/glaze 0.0.0-snapshot.4e8eab7 → 0.0.0-snapshot.52e0dd6

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
@@ -26,6 +26,12 @@ interface FindLightnessForContrastOptions {
26
26
  epsilon?: number;
27
27
  /** Maximum binary-search iterations per branch. Default: 14. */
28
28
  maxIterations?: number;
29
+ /**
30
+ * When both branches fail to meet contrast, try flipping
31
+ * the lightness around the center of the search range.
32
+ * Default: false (no flip). Set true for auto-flip behavior.
33
+ */
34
+ flip?: boolean;
29
35
  }
30
36
  interface FindLightnessForContrastResult {
31
37
  /** Chosen lightness in 0–1. */
@@ -36,6 +42,8 @@ interface FindLightnessForContrastResult {
36
42
  met: boolean;
37
43
  /** Which branch was selected. */
38
44
  branch: 'lighter' | 'darker' | 'preferred';
45
+ /** Whether the result was auto-flipped to the opposite direction. */
46
+ flipped?: boolean;
39
47
  }
40
48
  declare function resolveMinContrast(value: MinContrast$1): number;
41
49
  /**
@@ -62,6 +70,12 @@ interface FindValueForMixContrastOptions {
62
70
  epsilon?: number;
63
71
  /** Maximum binary-search iterations per branch. Default: 20. */
64
72
  maxIterations?: number;
73
+ /**
74
+ * When both branches fail to meet contrast, try flipping
75
+ * the mix value around the center of [0, 1].
76
+ * Default: false (no flip). Set true for auto-flip behavior.
77
+ */
78
+ flip?: boolean;
65
79
  }
66
80
  interface FindValueForMixContrastResult {
67
81
  /** Chosen mix parameter (0–1). */
@@ -70,6 +84,8 @@ interface FindValueForMixContrastResult {
70
84
  contrast: number;
71
85
  /** Whether the target was reached. */
72
86
  met: boolean;
87
+ /** Whether the result was auto-flipped to the opposite direction. */
88
+ flipped?: boolean;
73
89
  }
74
90
  /**
75
91
  * Find the mix parameter (ratio or opacity) that satisfies a WCAG 2 contrast
@@ -273,6 +289,18 @@ interface GlazeConfig {
273
289
  modes?: GlazeOutputModes;
274
290
  /** Default tuning for all shadow colors. Per-color tuning merges field-by-field. */
275
291
  shadowTuning?: ShadowTuning;
292
+ /**
293
+ * Automatically flip lightness direction when contrast can't be met.
294
+ *
295
+ * When enabled (default `true`), if the preferred branch (e.g., darker
296
+ * than base) cannot reach the target contrast, the solver tries the
297
+ * opposite direction (lighter). Falls back to a warning if neither side
298
+ * works.
299
+ *
300
+ * Set to `false` for strict "no flip" behavior that always warns on
301
+ * unmet contrast and uses the best partial result without flipping.
302
+ */
303
+ autoFlip?: boolean;
276
304
  }
277
305
  interface GlazeConfigResolved {
278
306
  lightLightness: [number, number];
@@ -285,6 +313,7 @@ interface GlazeConfigResolved {
285
313
  };
286
314
  modes: Required<GlazeOutputModes>;
287
315
  shadowTuning?: ShadowTuning;
316
+ autoFlip: boolean;
288
317
  }
289
318
  /** Serialized theme configuration (no resolved values). */
290
319
  interface GlazeThemeExport {
@@ -528,6 +557,13 @@ interface GlazeColorTokenExport {
528
557
  overrides?: GlazeColorOverridesExport;
529
558
  /** Lightness scaling override, if any. */
530
559
  scaling?: GlazeColorScaling;
560
+ /**
561
+ * Auto-flip setting snapshotted at creation time from
562
+ * `globalConfig.autoFlip`. Only present when it differs from the
563
+ * global default (`true`). Rehydrated tokens use this value instead
564
+ * of whatever is current in `globalConfig`.
565
+ */
566
+ autoFlip?: boolean;
531
567
  }
532
568
  /**
533
569
  * Serializable shape of a structured `glaze.color({...})` input.
@@ -721,14 +757,7 @@ declare function glaze(hueOrOptions: number | {
721
757
  }, saturation?: number): GlazeTheme;
722
758
  declare namespace glaze {
723
759
  var configure: (config: GlazeConfig) => void;
724
- var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => {
725
- tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
726
- tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
727
- json(options?: GlazeJsonOptions & {
728
- prefix?: boolean | Record<string, string>;
729
- }): Record<string, Record<string, Record<string, string>>>;
730
- css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
731
- };
760
+ var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
732
761
  var from: (data: GlazeThemeExport) => GlazeTheme;
733
762
  var color: {
734
763
  (input: GlazeColorInput, scaling?: GlazeColorScaling): GlazeColorToken;
package/dist/index.d.mts CHANGED
@@ -26,6 +26,12 @@ interface FindLightnessForContrastOptions {
26
26
  epsilon?: number;
27
27
  /** Maximum binary-search iterations per branch. Default: 14. */
28
28
  maxIterations?: number;
29
+ /**
30
+ * When both branches fail to meet contrast, try flipping
31
+ * the lightness around the center of the search range.
32
+ * Default: false (no flip). Set true for auto-flip behavior.
33
+ */
34
+ flip?: boolean;
29
35
  }
30
36
  interface FindLightnessForContrastResult {
31
37
  /** Chosen lightness in 0–1. */
@@ -36,6 +42,8 @@ interface FindLightnessForContrastResult {
36
42
  met: boolean;
37
43
  /** Which branch was selected. */
38
44
  branch: 'lighter' | 'darker' | 'preferred';
45
+ /** Whether the result was auto-flipped to the opposite direction. */
46
+ flipped?: boolean;
39
47
  }
40
48
  declare function resolveMinContrast(value: MinContrast$1): number;
41
49
  /**
@@ -62,6 +70,12 @@ interface FindValueForMixContrastOptions {
62
70
  epsilon?: number;
63
71
  /** Maximum binary-search iterations per branch. Default: 20. */
64
72
  maxIterations?: number;
73
+ /**
74
+ * When both branches fail to meet contrast, try flipping
75
+ * the mix value around the center of [0, 1].
76
+ * Default: false (no flip). Set true for auto-flip behavior.
77
+ */
78
+ flip?: boolean;
65
79
  }
66
80
  interface FindValueForMixContrastResult {
67
81
  /** Chosen mix parameter (0–1). */
@@ -70,6 +84,8 @@ interface FindValueForMixContrastResult {
70
84
  contrast: number;
71
85
  /** Whether the target was reached. */
72
86
  met: boolean;
87
+ /** Whether the result was auto-flipped to the opposite direction. */
88
+ flipped?: boolean;
73
89
  }
74
90
  /**
75
91
  * Find the mix parameter (ratio or opacity) that satisfies a WCAG 2 contrast
@@ -273,6 +289,18 @@ interface GlazeConfig {
273
289
  modes?: GlazeOutputModes;
274
290
  /** Default tuning for all shadow colors. Per-color tuning merges field-by-field. */
275
291
  shadowTuning?: ShadowTuning;
292
+ /**
293
+ * Automatically flip lightness direction when contrast can't be met.
294
+ *
295
+ * When enabled (default `true`), if the preferred branch (e.g., darker
296
+ * than base) cannot reach the target contrast, the solver tries the
297
+ * opposite direction (lighter). Falls back to a warning if neither side
298
+ * works.
299
+ *
300
+ * Set to `false` for strict "no flip" behavior that always warns on
301
+ * unmet contrast and uses the best partial result without flipping.
302
+ */
303
+ autoFlip?: boolean;
276
304
  }
277
305
  interface GlazeConfigResolved {
278
306
  lightLightness: [number, number];
@@ -285,6 +313,7 @@ interface GlazeConfigResolved {
285
313
  };
286
314
  modes: Required<GlazeOutputModes>;
287
315
  shadowTuning?: ShadowTuning;
316
+ autoFlip: boolean;
288
317
  }
289
318
  /** Serialized theme configuration (no resolved values). */
290
319
  interface GlazeThemeExport {
@@ -528,6 +557,13 @@ interface GlazeColorTokenExport {
528
557
  overrides?: GlazeColorOverridesExport;
529
558
  /** Lightness scaling override, if any. */
530
559
  scaling?: GlazeColorScaling;
560
+ /**
561
+ * Auto-flip setting snapshotted at creation time from
562
+ * `globalConfig.autoFlip`. Only present when it differs from the
563
+ * global default (`true`). Rehydrated tokens use this value instead
564
+ * of whatever is current in `globalConfig`.
565
+ */
566
+ autoFlip?: boolean;
531
567
  }
532
568
  /**
533
569
  * Serializable shape of a structured `glaze.color({...})` input.
@@ -721,14 +757,7 @@ declare function glaze(hueOrOptions: number | {
721
757
  }, saturation?: number): GlazeTheme;
722
758
  declare namespace glaze {
723
759
  var configure: (config: GlazeConfig) => void;
724
- var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => {
725
- tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
726
- tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
727
- json(options?: GlazeJsonOptions & {
728
- prefix?: boolean | Record<string, string>;
729
- }): Record<string, Record<string, Record<string, string>>>;
730
- css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
731
- };
760
+ var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
732
761
  var from: (data: GlazeThemeExport) => GlazeTheme;
733
762
  var color: {
734
763
  (input: GlazeColorInput, scaling?: GlazeColorScaling): GlazeColorToken;