@tenphi/glaze 0.16.1 → 0.17.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/dist/index.d.cts CHANGED
@@ -248,7 +248,7 @@ interface RegularColorDef {
248
248
  * Defaults to the global `autoFlip` config (default `true`). Set `false`
249
249
  * to clamp instead.
250
250
  */
251
- flip?: boolean;
251
+ autoFlip?: boolean;
252
252
  /**
253
253
  * Fixed opacity (0–1).
254
254
  * Output includes alpha in the CSS value.
@@ -565,7 +565,7 @@ interface GlazeColorInput {
565
565
  saturationFactor?: number;
566
566
  mode?: AdaptationMode;
567
567
  /** Flip out-of-bounds results instead of clamping. Default: global `autoFlip`. */
568
- flip?: boolean;
568
+ autoFlip?: boolean;
569
569
  /**
570
570
  * Fixed opacity (0–1). Output includes alpha in the CSS value.
571
571
  * Combining with `contrast` is not recommended (perceived tone
@@ -660,7 +660,7 @@ interface GlazeColorOverrides {
660
660
  * `contrast`) to the opposite side instead of clamping. Defaults to
661
661
  * the global `autoFlip`.
662
662
  */
663
- flip?: boolean;
663
+ autoFlip?: boolean;
664
664
  /**
665
665
  * Contrast floor. By default solved against the literal seed
666
666
  * (the value itself); when `base` is set, solved against the base's
@@ -739,7 +739,7 @@ interface GlazeColorCssOptions {
739
739
  * `name: 'brand'` → `--brand-color: …`.
740
740
  */
741
741
  name: string;
742
- /** Output color format. Default: 'rgb' (matches `theme.css` default). */
742
+ /** Output color format. Default: 'oklch'. */
743
743
  format?: GlazeColorFormat;
744
744
  /**
745
745
  * Suffix appended to the name. Default: '-color' (matches
@@ -832,7 +832,7 @@ interface GlazeColorInputExport {
832
832
  tone: HCPair<number | ExtremeValue>;
833
833
  saturationFactor?: number;
834
834
  mode?: AdaptationMode;
835
- flip?: boolean;
835
+ autoFlip?: boolean;
836
836
  opacity?: number;
837
837
  base?: GlazeColorTokenExport | GlazeColorValue;
838
838
  contrast?: HCPair<ContrastSpec>;
@@ -850,7 +850,7 @@ interface GlazeColorOverridesExport {
850
850
  tone?: HCPair<ToneValue>;
851
851
  saturationFactor?: number;
852
852
  mode?: AdaptationMode;
853
- flip?: boolean;
853
+ autoFlip?: boolean;
854
854
  contrast?: HCPair<ContrastSpec>;
855
855
  base?: GlazeColorTokenExport | GlazeColorValue;
856
856
  opacity?: number;
@@ -944,7 +944,7 @@ interface GlazeTokenOptions {
944
944
  };
945
945
  /** Override which scheme variants to include. */
946
946
  modes?: GlazeOutputModes;
947
- /** Output color format. Default: 'okhsl'. */
947
+ /** Output color format. Default: 'oklch'. */
948
948
  format?: GlazeColorFormat;
949
949
  /**
950
950
  * Emit hue as a separate custom property, referenced via `var()`.
@@ -960,11 +960,11 @@ interface GlazeTokenOptions {
960
960
  interface GlazeJsonOptions {
961
961
  /** Override which scheme variants to include. */
962
962
  modes?: GlazeOutputModes;
963
- /** Output color format. Default: 'okhsl'. */
963
+ /** Output color format. Default: 'oklch'. */
964
964
  format?: GlazeColorFormat;
965
965
  }
966
966
  interface GlazeCssOptions {
967
- /** Output color format. Default: 'rgb'. */
967
+ /** Output color format. Default: 'oklch'. */
968
968
  format?: GlazeColorFormat;
969
969
  /** Suffix appended to each CSS custom property name. Default: '-color'. */
970
970
  suffix?: string;
package/dist/index.d.mts CHANGED
@@ -248,7 +248,7 @@ interface RegularColorDef {
248
248
  * Defaults to the global `autoFlip` config (default `true`). Set `false`
249
249
  * to clamp instead.
250
250
  */
251
- flip?: boolean;
251
+ autoFlip?: boolean;
252
252
  /**
253
253
  * Fixed opacity (0–1).
254
254
  * Output includes alpha in the CSS value.
@@ -565,7 +565,7 @@ interface GlazeColorInput {
565
565
  saturationFactor?: number;
566
566
  mode?: AdaptationMode;
567
567
  /** Flip out-of-bounds results instead of clamping. Default: global `autoFlip`. */
568
- flip?: boolean;
568
+ autoFlip?: boolean;
569
569
  /**
570
570
  * Fixed opacity (0–1). Output includes alpha in the CSS value.
571
571
  * Combining with `contrast` is not recommended (perceived tone
@@ -660,7 +660,7 @@ interface GlazeColorOverrides {
660
660
  * `contrast`) to the opposite side instead of clamping. Defaults to
661
661
  * the global `autoFlip`.
662
662
  */
663
- flip?: boolean;
663
+ autoFlip?: boolean;
664
664
  /**
665
665
  * Contrast floor. By default solved against the literal seed
666
666
  * (the value itself); when `base` is set, solved against the base's
@@ -739,7 +739,7 @@ interface GlazeColorCssOptions {
739
739
  * `name: 'brand'` → `--brand-color: …`.
740
740
  */
741
741
  name: string;
742
- /** Output color format. Default: 'rgb' (matches `theme.css` default). */
742
+ /** Output color format. Default: 'oklch'. */
743
743
  format?: GlazeColorFormat;
744
744
  /**
745
745
  * Suffix appended to the name. Default: '-color' (matches
@@ -832,7 +832,7 @@ interface GlazeColorInputExport {
832
832
  tone: HCPair<number | ExtremeValue>;
833
833
  saturationFactor?: number;
834
834
  mode?: AdaptationMode;
835
- flip?: boolean;
835
+ autoFlip?: boolean;
836
836
  opacity?: number;
837
837
  base?: GlazeColorTokenExport | GlazeColorValue;
838
838
  contrast?: HCPair<ContrastSpec>;
@@ -850,7 +850,7 @@ interface GlazeColorOverridesExport {
850
850
  tone?: HCPair<ToneValue>;
851
851
  saturationFactor?: number;
852
852
  mode?: AdaptationMode;
853
- flip?: boolean;
853
+ autoFlip?: boolean;
854
854
  contrast?: HCPair<ContrastSpec>;
855
855
  base?: GlazeColorTokenExport | GlazeColorValue;
856
856
  opacity?: number;
@@ -944,7 +944,7 @@ interface GlazeTokenOptions {
944
944
  };
945
945
  /** Override which scheme variants to include. */
946
946
  modes?: GlazeOutputModes;
947
- /** Output color format. Default: 'okhsl'. */
947
+ /** Output color format. Default: 'oklch'. */
948
948
  format?: GlazeColorFormat;
949
949
  /**
950
950
  * Emit hue as a separate custom property, referenced via `var()`.
@@ -960,11 +960,11 @@ interface GlazeTokenOptions {
960
960
  interface GlazeJsonOptions {
961
961
  /** Override which scheme variants to include. */
962
962
  modes?: GlazeOutputModes;
963
- /** Output color format. Default: 'okhsl'. */
963
+ /** Output color format. Default: 'oklch'. */
964
964
  format?: GlazeColorFormat;
965
965
  }
966
966
  interface GlazeCssOptions {
967
- /** Output color format. Default: 'rgb'. */
967
+ /** Output color format. Default: 'oklch'. */
968
968
  format?: GlazeColorFormat;
969
969
  /** Suffix appended to each CSS custom property name. Default: '-color'. */
970
970
  suffix?: string;
package/dist/index.mjs CHANGED
@@ -1853,7 +1853,7 @@ function resolveDependentColor(name, def, ctx, isHighContrast, isDark, effective
1853
1853
  if (!baseResolved) throw new Error(`glaze: base "${baseName}" not yet resolved for "${name}".`);
1854
1854
  const mode = def.mode ?? "auto";
1855
1855
  const satFactor = clamp(def.saturation ?? 1, 0, 1);
1856
- const flip = def.flip ?? ctx.config.autoFlip;
1856
+ const flip = def.autoFlip ?? ctx.config.autoFlip;
1857
1857
  const pastel = effectivePastel;
1858
1858
  const baseVariant = getSchemeVariant(baseResolved, isDark, isHighContrast);
1859
1859
  const baseTone = baseVariant.t * 100;
@@ -2284,7 +2284,7 @@ const formatters = {
2284
2284
  function fmt(value, decimals) {
2285
2285
  return parseFloat(value.toFixed(decimals)).toString();
2286
2286
  }
2287
- function formatVariant(v, format = "okhsl", pastel = false) {
2287
+ function formatVariant(v, format = "oklch", pastel = false) {
2288
2288
  const effectivePastel = v.pastel ?? pastel;
2289
2289
  let base;
2290
2290
  if (format === "okhst") base = formatOkhst(v.h, v.s * 100, v.t * 100, effectivePastel);
@@ -2323,7 +2323,7 @@ function resolveModes(override) {
2323
2323
  highContrast: override?.highContrast ?? cfg.modes.highContrast
2324
2324
  };
2325
2325
  }
2326
- function buildTokenMap(resolved, prefix, states, modes, format = "okhsl", pastel = false, channelCtx) {
2326
+ function buildTokenMap(resolved, prefix, states, modes, format = "oklch", pastel = false, channelCtx) {
2327
2327
  const tokens = {};
2328
2328
  const huePlans = channelCtx !== void 0 && format === "oklch" ? buildHuePlans(resolved, channelCtx) : void 0;
2329
2329
  if (huePlans !== void 0 && channelCtx !== void 0) {
@@ -2353,7 +2353,7 @@ function buildTokenEntry(color, states, modes, format, pastel, huePlan) {
2353
2353
  if (modes.dark && modes.highContrast) entry[`${states.dark} & ${states.highContrast}`] = formatColorValue(color.darkContrast, format, pastel, huePlan);
2354
2354
  return entry;
2355
2355
  }
2356
- function buildFlatTokenMap(resolved, prefix, modes, format = "okhsl", pastel = false) {
2356
+ function buildFlatTokenMap(resolved, prefix, modes, format = "oklch", pastel = false) {
2357
2357
  const result = { light: {} };
2358
2358
  if (modes.dark) result.dark = {};
2359
2359
  if (modes.highContrast) result.lightContrast = {};
@@ -2367,7 +2367,7 @@ function buildFlatTokenMap(resolved, prefix, modes, format = "okhsl", pastel = f
2367
2367
  }
2368
2368
  return result;
2369
2369
  }
2370
- function buildJsonMap(resolved, modes, format = "okhsl", pastel = false) {
2370
+ function buildJsonMap(resolved, modes, format = "oklch", pastel = false) {
2371
2371
  const result = {};
2372
2372
  for (const [name, color] of resolved) {
2373
2373
  const entry = { light: formatVariant(color.light, format, pastel) };
@@ -2930,7 +2930,7 @@ function buildStandaloneValueDefs(main, options) {
2930
2930
  tone: toneOption ?? seedTone,
2931
2931
  contrast: options?.contrast,
2932
2932
  mode: options?.mode ?? "auto",
2933
- flip: options?.flip,
2933
+ autoFlip: options?.autoFlip,
2934
2934
  opacity: options?.opacity,
2935
2935
  pastel: options?.pastel,
2936
2936
  role: options?.role,
@@ -2965,7 +2965,7 @@ function createColorTokenFromDefs(seedHue, seedSaturation, defs, primary, effect
2965
2965
  };
2966
2966
  };
2967
2967
  const tokenLike = (options) => {
2968
- return buildTokenMap(resolveOnce(), "", resolveStates(options), resolveModes(options?.modes), options?.format, effectiveConfig.pastel)[`#${primary}`];
2968
+ return buildTokenMap(resolveOnce(), "", resolveStates(options), resolveModes(options?.modes), options?.format ?? "oklch", effectiveConfig.pastel)[`#${primary}`];
2969
2969
  };
2970
2970
  return {
2971
2971
  resolve() {
@@ -2979,7 +2979,7 @@ function createColorTokenFromDefs(seedHue, seedSaturation, defs, primary, effect
2979
2979
  return buildJsonMap(resolveOnce(), resolveModes(options?.modes), format, effectiveConfig.pastel)[primary];
2980
2980
  },
2981
2981
  css(options) {
2982
- const format = options.format ?? "rgb";
2982
+ const format = options.format ?? "oklch";
2983
2983
  assertNativeFormat(format, "css");
2984
2984
  const resolved = resolveOnce().get(primary);
2985
2985
  const renamed = new Map([[options.name, resolved]]);
@@ -3072,7 +3072,7 @@ function createColorToken(input, configOverride) {
3072
3072
  tone: input.tone,
3073
3073
  saturation: input.saturationFactor,
3074
3074
  mode: input.mode ?? "auto",
3075
- flip: input.flip,
3075
+ autoFlip: input.autoFlip,
3076
3076
  contrast: input.contrast,
3077
3077
  opacity: input.opacity,
3078
3078
  pastel: input.pastel,
@@ -3122,7 +3122,7 @@ function buildOverridesExport(options) {
3122
3122
  if (options.tone !== void 0) out.tone = options.tone;
3123
3123
  if (options.saturationFactor !== void 0) out.saturationFactor = options.saturationFactor;
3124
3124
  if (options.mode !== void 0) out.mode = options.mode;
3125
- if (options.flip !== void 0) out.flip = options.flip;
3125
+ if (options.autoFlip !== void 0) out.autoFlip = options.autoFlip;
3126
3126
  if (options.contrast !== void 0) out.contrast = options.contrast;
3127
3127
  if (options.opacity !== void 0) out.opacity = options.opacity;
3128
3128
  if (options.name !== void 0) out.name = options.name;
@@ -3139,7 +3139,7 @@ function buildStructuredInputExport(input) {
3139
3139
  };
3140
3140
  if (input.saturationFactor !== void 0) out.saturationFactor = input.saturationFactor;
3141
3141
  if (input.mode !== void 0) out.mode = input.mode;
3142
- if (input.flip !== void 0) out.flip = input.flip;
3142
+ if (input.autoFlip !== void 0) out.autoFlip = input.autoFlip;
3143
3143
  if (input.opacity !== void 0) out.opacity = input.opacity;
3144
3144
  if (input.contrast !== void 0) out.contrast = input.contrast;
3145
3145
  if (input.name !== void 0) out.name = input.name;
@@ -3161,7 +3161,7 @@ function rehydrateOverrides(data) {
3161
3161
  if (data.tone !== void 0) out.tone = data.tone;
3162
3162
  if (data.saturationFactor !== void 0) out.saturationFactor = data.saturationFactor;
3163
3163
  if (data.mode !== void 0) out.mode = data.mode;
3164
- if (data.flip !== void 0) out.flip = data.flip;
3164
+ if (data.autoFlip !== void 0) out.autoFlip = data.autoFlip;
3165
3165
  if (data.contrast !== void 0) out.contrast = data.contrast;
3166
3166
  if (data.opacity !== void 0) out.opacity = data.opacity;
3167
3167
  if (data.name !== void 0) out.name = data.name;
@@ -3178,7 +3178,7 @@ function rehydrateStructuredInput(data) {
3178
3178
  };
3179
3179
  if (data.saturationFactor !== void 0) out.saturationFactor = data.saturationFactor;
3180
3180
  if (data.mode !== void 0) out.mode = data.mode;
3181
- if (data.flip !== void 0) out.flip = data.flip;
3181
+ if (data.autoFlip !== void 0) out.autoFlip = data.autoFlip;
3182
3182
  if (data.opacity !== void 0) out.opacity = data.opacity;
3183
3183
  if (data.contrast !== void 0) out.contrast = data.contrast;
3184
3184
  if (data.name !== void 0) out.name = data.name;
@@ -3316,7 +3316,7 @@ function createPalette(themes, paletteOptions) {
3316
3316
  highContrast: options?.states?.highContrast ?? cfg.states.highContrast
3317
3317
  };
3318
3318
  const modes = resolveModes(options?.modes);
3319
- const format = options?.format ?? "okhsl";
3319
+ const format = options?.format ?? "oklch";
3320
3320
  return buildPaletteOutput(themes, paletteOptions, options, (filtered, prefix, pastel, themeName, theme) => {
3321
3321
  return buildTokenMap(filtered, prefix, states, modes, format, pastel, channelCtxForTheme(theme, themeName, prefix, resolvePrefix(options, themeName, true), options?.splitHue, format, modes, filtered));
3322
3322
  }, (acc, part) => Object.assign(acc, part), () => ({}));
@@ -3331,7 +3331,7 @@ function createPalette(themes, paletteOptions) {
3331
3331
  },
3332
3332
  css(options) {
3333
3333
  const suffix = options?.suffix ?? "-color";
3334
- const format = options?.format ?? "rgb";
3334
+ const format = options?.format ?? "oklch";
3335
3335
  assertNativeFormat(format, "css");
3336
3336
  const modes = resolveModes();
3337
3337
  const lines = buildPaletteOutput(themes, paletteOptions, options, (filtered, prefix, pastel, themeName, theme) => {
@@ -3498,8 +3498,8 @@ function createTheme(hue, saturation, initialColors, configOverride) {
3498
3498
  highContrast: options?.states?.highContrast ?? cfg.states.highContrast
3499
3499
  };
3500
3500
  const modes = resolveModes(options?.modes);
3501
- const format = options?.format ?? "okhsl";
3502
- const channelCtx = channelCtxFor(options, "okhsl", "");
3501
+ const format = options?.format ?? "oklch";
3502
+ const channelCtx = channelCtxFor(options, "oklch", "");
3503
3503
  return buildTokenMap(resolveCached(), "", states, modes, format, cfg.pastel, channelCtx);
3504
3504
  },
3505
3505
  json(options) {
@@ -3509,9 +3509,9 @@ function createTheme(hue, saturation, initialColors, configOverride) {
3509
3509
  return buildJsonMap(resolveCached(), modes, format, getEffectiveConfig().pastel);
3510
3510
  },
3511
3511
  css(options) {
3512
- const format = options?.format ?? "rgb";
3512
+ const format = options?.format ?? "oklch";
3513
3513
  assertNativeFormat(format, "css");
3514
- const channelCtx = channelCtxFor(options, "rgb", "");
3514
+ const channelCtx = channelCtxFor(options, "oklch", "");
3515
3515
  return buildCssMap(resolveCached(), "", options?.suffix ?? "-color", format, getEffectiveConfig().pastel, channelCtx);
3516
3516
  },
3517
3517
  dtcg(options) {