@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.cjs CHANGED
@@ -1855,7 +1855,7 @@ function resolveDependentColor(name, def, ctx, isHighContrast, isDark, effective
1855
1855
  if (!baseResolved) throw new Error(`glaze: base "${baseName}" not yet resolved for "${name}".`);
1856
1856
  const mode = def.mode ?? "auto";
1857
1857
  const satFactor = clamp(def.saturation ?? 1, 0, 1);
1858
- const flip = def.flip ?? ctx.config.autoFlip;
1858
+ const flip = def.autoFlip ?? ctx.config.autoFlip;
1859
1859
  const pastel = effectivePastel;
1860
1860
  const baseVariant = getSchemeVariant(baseResolved, isDark, isHighContrast);
1861
1861
  const baseTone = baseVariant.t * 100;
@@ -2286,7 +2286,7 @@ const formatters = {
2286
2286
  function fmt(value, decimals) {
2287
2287
  return parseFloat(value.toFixed(decimals)).toString();
2288
2288
  }
2289
- function formatVariant(v, format = "okhsl", pastel = false) {
2289
+ function formatVariant(v, format = "oklch", pastel = false) {
2290
2290
  const effectivePastel = v.pastel ?? pastel;
2291
2291
  let base;
2292
2292
  if (format === "okhst") base = formatOkhst(v.h, v.s * 100, v.t * 100, effectivePastel);
@@ -2325,7 +2325,7 @@ function resolveModes(override) {
2325
2325
  highContrast: override?.highContrast ?? cfg.modes.highContrast
2326
2326
  };
2327
2327
  }
2328
- function buildTokenMap(resolved, prefix, states, modes, format = "okhsl", pastel = false, channelCtx) {
2328
+ function buildTokenMap(resolved, prefix, states, modes, format = "oklch", pastel = false, channelCtx) {
2329
2329
  const tokens = {};
2330
2330
  const huePlans = channelCtx !== void 0 && format === "oklch" ? buildHuePlans(resolved, channelCtx) : void 0;
2331
2331
  if (huePlans !== void 0 && channelCtx !== void 0) {
@@ -2355,7 +2355,7 @@ function buildTokenEntry(color, states, modes, format, pastel, huePlan) {
2355
2355
  if (modes.dark && modes.highContrast) entry[`${states.dark} & ${states.highContrast}`] = formatColorValue(color.darkContrast, format, pastel, huePlan);
2356
2356
  return entry;
2357
2357
  }
2358
- function buildFlatTokenMap(resolved, prefix, modes, format = "okhsl", pastel = false) {
2358
+ function buildFlatTokenMap(resolved, prefix, modes, format = "oklch", pastel = false) {
2359
2359
  const result = { light: {} };
2360
2360
  if (modes.dark) result.dark = {};
2361
2361
  if (modes.highContrast) result.lightContrast = {};
@@ -2369,7 +2369,7 @@ function buildFlatTokenMap(resolved, prefix, modes, format = "okhsl", pastel = f
2369
2369
  }
2370
2370
  return result;
2371
2371
  }
2372
- function buildJsonMap(resolved, modes, format = "okhsl", pastel = false) {
2372
+ function buildJsonMap(resolved, modes, format = "oklch", pastel = false) {
2373
2373
  const result = {};
2374
2374
  for (const [name, color] of resolved) {
2375
2375
  const entry = { light: formatVariant(color.light, format, pastel) };
@@ -2932,7 +2932,7 @@ function buildStandaloneValueDefs(main, options) {
2932
2932
  tone: toneOption ?? seedTone,
2933
2933
  contrast: options?.contrast,
2934
2934
  mode: options?.mode ?? "auto",
2935
- flip: options?.flip,
2935
+ autoFlip: options?.autoFlip,
2936
2936
  opacity: options?.opacity,
2937
2937
  pastel: options?.pastel,
2938
2938
  role: options?.role,
@@ -2967,7 +2967,7 @@ function createColorTokenFromDefs(seedHue, seedSaturation, defs, primary, effect
2967
2967
  };
2968
2968
  };
2969
2969
  const tokenLike = (options) => {
2970
- return buildTokenMap(resolveOnce(), "", resolveStates(options), resolveModes(options?.modes), options?.format, effectiveConfig.pastel)[`#${primary}`];
2970
+ return buildTokenMap(resolveOnce(), "", resolveStates(options), resolveModes(options?.modes), options?.format ?? "oklch", effectiveConfig.pastel)[`#${primary}`];
2971
2971
  };
2972
2972
  return {
2973
2973
  resolve() {
@@ -2981,7 +2981,7 @@ function createColorTokenFromDefs(seedHue, seedSaturation, defs, primary, effect
2981
2981
  return buildJsonMap(resolveOnce(), resolveModes(options?.modes), format, effectiveConfig.pastel)[primary];
2982
2982
  },
2983
2983
  css(options) {
2984
- const format = options.format ?? "rgb";
2984
+ const format = options.format ?? "oklch";
2985
2985
  assertNativeFormat(format, "css");
2986
2986
  const resolved = resolveOnce().get(primary);
2987
2987
  const renamed = new Map([[options.name, resolved]]);
@@ -3074,7 +3074,7 @@ function createColorToken(input, configOverride) {
3074
3074
  tone: input.tone,
3075
3075
  saturation: input.saturationFactor,
3076
3076
  mode: input.mode ?? "auto",
3077
- flip: input.flip,
3077
+ autoFlip: input.autoFlip,
3078
3078
  contrast: input.contrast,
3079
3079
  opacity: input.opacity,
3080
3080
  pastel: input.pastel,
@@ -3124,7 +3124,7 @@ function buildOverridesExport(options) {
3124
3124
  if (options.tone !== void 0) out.tone = options.tone;
3125
3125
  if (options.saturationFactor !== void 0) out.saturationFactor = options.saturationFactor;
3126
3126
  if (options.mode !== void 0) out.mode = options.mode;
3127
- if (options.flip !== void 0) out.flip = options.flip;
3127
+ if (options.autoFlip !== void 0) out.autoFlip = options.autoFlip;
3128
3128
  if (options.contrast !== void 0) out.contrast = options.contrast;
3129
3129
  if (options.opacity !== void 0) out.opacity = options.opacity;
3130
3130
  if (options.name !== void 0) out.name = options.name;
@@ -3141,7 +3141,7 @@ function buildStructuredInputExport(input) {
3141
3141
  };
3142
3142
  if (input.saturationFactor !== void 0) out.saturationFactor = input.saturationFactor;
3143
3143
  if (input.mode !== void 0) out.mode = input.mode;
3144
- if (input.flip !== void 0) out.flip = input.flip;
3144
+ if (input.autoFlip !== void 0) out.autoFlip = input.autoFlip;
3145
3145
  if (input.opacity !== void 0) out.opacity = input.opacity;
3146
3146
  if (input.contrast !== void 0) out.contrast = input.contrast;
3147
3147
  if (input.name !== void 0) out.name = input.name;
@@ -3163,7 +3163,7 @@ function rehydrateOverrides(data) {
3163
3163
  if (data.tone !== void 0) out.tone = data.tone;
3164
3164
  if (data.saturationFactor !== void 0) out.saturationFactor = data.saturationFactor;
3165
3165
  if (data.mode !== void 0) out.mode = data.mode;
3166
- if (data.flip !== void 0) out.flip = data.flip;
3166
+ if (data.autoFlip !== void 0) out.autoFlip = data.autoFlip;
3167
3167
  if (data.contrast !== void 0) out.contrast = data.contrast;
3168
3168
  if (data.opacity !== void 0) out.opacity = data.opacity;
3169
3169
  if (data.name !== void 0) out.name = data.name;
@@ -3180,7 +3180,7 @@ function rehydrateStructuredInput(data) {
3180
3180
  };
3181
3181
  if (data.saturationFactor !== void 0) out.saturationFactor = data.saturationFactor;
3182
3182
  if (data.mode !== void 0) out.mode = data.mode;
3183
- if (data.flip !== void 0) out.flip = data.flip;
3183
+ if (data.autoFlip !== void 0) out.autoFlip = data.autoFlip;
3184
3184
  if (data.opacity !== void 0) out.opacity = data.opacity;
3185
3185
  if (data.contrast !== void 0) out.contrast = data.contrast;
3186
3186
  if (data.name !== void 0) out.name = data.name;
@@ -3318,7 +3318,7 @@ function createPalette(themes, paletteOptions) {
3318
3318
  highContrast: options?.states?.highContrast ?? cfg.states.highContrast
3319
3319
  };
3320
3320
  const modes = resolveModes(options?.modes);
3321
- const format = options?.format ?? "okhsl";
3321
+ const format = options?.format ?? "oklch";
3322
3322
  return buildPaletteOutput(themes, paletteOptions, options, (filtered, prefix, pastel, themeName, theme) => {
3323
3323
  return buildTokenMap(filtered, prefix, states, modes, format, pastel, channelCtxForTheme(theme, themeName, prefix, resolvePrefix(options, themeName, true), options?.splitHue, format, modes, filtered));
3324
3324
  }, (acc, part) => Object.assign(acc, part), () => ({}));
@@ -3333,7 +3333,7 @@ function createPalette(themes, paletteOptions) {
3333
3333
  },
3334
3334
  css(options) {
3335
3335
  const suffix = options?.suffix ?? "-color";
3336
- const format = options?.format ?? "rgb";
3336
+ const format = options?.format ?? "oklch";
3337
3337
  assertNativeFormat(format, "css");
3338
3338
  const modes = resolveModes();
3339
3339
  const lines = buildPaletteOutput(themes, paletteOptions, options, (filtered, prefix, pastel, themeName, theme) => {
@@ -3500,8 +3500,8 @@ function createTheme(hue, saturation, initialColors, configOverride) {
3500
3500
  highContrast: options?.states?.highContrast ?? cfg.states.highContrast
3501
3501
  };
3502
3502
  const modes = resolveModes(options?.modes);
3503
- const format = options?.format ?? "okhsl";
3504
- const channelCtx = channelCtxFor(options, "okhsl", "");
3503
+ const format = options?.format ?? "oklch";
3504
+ const channelCtx = channelCtxFor(options, "oklch", "");
3505
3505
  return buildTokenMap(resolveCached(), "", states, modes, format, cfg.pastel, channelCtx);
3506
3506
  },
3507
3507
  json(options) {
@@ -3511,9 +3511,9 @@ function createTheme(hue, saturation, initialColors, configOverride) {
3511
3511
  return buildJsonMap(resolveCached(), modes, format, getEffectiveConfig().pastel);
3512
3512
  },
3513
3513
  css(options) {
3514
- const format = options?.format ?? "rgb";
3514
+ const format = options?.format ?? "oklch";
3515
3515
  assertNativeFormat(format, "css");
3516
- const channelCtx = channelCtxFor(options, "rgb", "");
3516
+ const channelCtx = channelCtxFor(options, "oklch", "");
3517
3517
  return buildCssMap(resolveCached(), "", options?.suffix ?? "-color", format, getEffectiveConfig().pastel, channelCtx);
3518
3518
  },
3519
3519
  dtcg(options) {