hextimator 0.14.4 → 0.15.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/cli.js CHANGED
@@ -907,8 +907,8 @@ ${declsFromEntries(lightEntries, sep, "--", " ")}
907
907
  const rootDarkBlock = `${selector} {
908
908
  ${declsFromEntries(darkEntries, sep, "--", " ")}
909
909
  }`;
910
- if (theme === "light") return lightBlock;
911
910
  if (theme === "dark") return rootDarkBlock;
911
+ if (theme === "light" || darkMode === false) return lightBlock;
912
912
  if (darkMode === "media") {
913
913
  const darkInner = declsFromEntries(darkEntries, sep, "--", " ");
914
914
  return `${lightBlock}
@@ -932,7 +932,7 @@ function formatTailwindStylesheet(lightEntries, darkEntries, sep, opts = {}) {
932
932
  const theme = `@theme {
933
933
  ${declsFromEntries(themeEntries, sep, "--color-", " ")}
934
934
  }`;
935
- if (selectedTheme !== "both") return theme;
935
+ if (selectedTheme !== "both" || darkMode === false) return theme;
936
936
  if (darkMode === "media") {
937
937
  const darkInner = declsFromEntries(darkEntries, sep, "--color-", " ");
938
938
  return `${theme}
@@ -1685,16 +1685,113 @@ function generateSurface(color, themeType, options) {
1685
1685
  }
1686
1686
 
1687
1687
  // src/generate/generate.ts
1688
- function generate(color, themeType, options) {
1688
+ var GeneratePaletteError = class extends Error {
1689
+ constructor(message) {
1690
+ super(message);
1691
+ this.name = "GeneratePaletteError";
1692
+ }
1693
+ };
1694
+ var DEFAULT_ROLES = [
1695
+ { name: "surface", generate: "surface" },
1696
+ { name: "accent", generate: "accent" },
1697
+ { name: "positive", generate: "positive" },
1698
+ { name: "negative", generate: "negative" },
1699
+ { name: "caution", generate: "caution" }
1700
+ ];
1701
+ function generate(color, themeType, options, roles = DEFAULT_ROLES) {
1702
+ if (roles.filter((r) => r.generate === "surface").length > 1) {
1703
+ throw new GeneratePaletteError(
1704
+ "A theme can declare only one surface role."
1705
+ );
1706
+ }
1689
1707
  const resolvedOptions = {
1690
1708
  ...options ?? {},
1691
1709
  inputLightness: convert(color, "oklch").l
1692
1710
  };
1693
- return {
1694
- surface: generateSurface(color, themeType, resolvedOptions),
1695
- accent: generateAccent(color, themeType, resolvedOptions),
1696
- ...generateSemanticColors(color, themeType, resolvedOptions)
1697
- };
1711
+ let semantic;
1712
+ const palette = {};
1713
+ for (const { name, generate: kind } of roles) {
1714
+ if (kind === "surface") {
1715
+ palette[name] = generateSurface(color, themeType, resolvedOptions);
1716
+ } else if (kind === "accent") {
1717
+ palette[name] = generateAccent(color, themeType, resolvedOptions);
1718
+ } else {
1719
+ semantic ??= generateSemanticColors(color, themeType, resolvedOptions);
1720
+ palette[name] = { ...semantic[kind] };
1721
+ }
1722
+ }
1723
+ return palette;
1724
+ }
1725
+
1726
+ // src/generate/surfaceForegrounds.ts
1727
+ var SURFACE_VARIANTS = ["DEFAULT", "weak", "strong"];
1728
+ function isRoleForeground({ surface, roles }, role, variant) {
1729
+ return role === surface && roles.some((r) => variant === `foreground-${r}`);
1730
+ }
1731
+ function solveContrast(base, surfaces, target) {
1732
+ const withL = (l) => ({ ...base, l, alpha: 1 });
1733
+ const contrast = (color) => Math.min(...surfaces.map((surface) => calculateContrast(color, surface)));
1734
+ const endpointL = contrast(withL(0)) >= contrast(withL(1)) ? 0 : 1;
1735
+ const bufferedTarget = Math.min(
1736
+ target + CONTRAST_MARGIN,
1737
+ contrast(withL(endpointL))
1738
+ );
1739
+ let fail = 1 - endpointL;
1740
+ let pass = endpointL;
1741
+ for (let i = 0; i < 24; i++) {
1742
+ const mid = (fail + pass) / 2;
1743
+ if (contrast(withL(mid)) >= bufferedTarget) pass = mid;
1744
+ else fail = mid;
1745
+ }
1746
+ return convert(convert(withL(pass), "srgb"), "oklch");
1747
+ }
1748
+ function surfaceForegrounds(palette, theme, options, { surface: surfaceRole, roles }) {
1749
+ if (!surfaceRole || !palette[surfaceRole]) return palette;
1750
+ const target = resolveContrastRatio(
1751
+ resolveMergedThemeAdjustments(theme, options).minContrastRatio
1752
+ );
1753
+ const surfaces = SURFACE_VARIANTS.map(
1754
+ (variant) => parse(palette[surfaceRole][variant])
1755
+ );
1756
+ const surface = { ...palette[surfaceRole] };
1757
+ for (const role of roles) {
1758
+ if (!palette[role]) continue;
1759
+ surface[`foreground-${role}`] = solveContrast(
1760
+ convert(parse(palette[role].DEFAULT), "oklch"),
1761
+ surfaces,
1762
+ target
1763
+ );
1764
+ }
1765
+ return { ...palette, [surfaceRole]: surface };
1766
+ }
1767
+
1768
+ // src/theme.ts
1769
+ var baseTheme = {
1770
+ roles: {
1771
+ surface: { generate: "surface" },
1772
+ accent: { generate: "accent" },
1773
+ positive: { generate: "positive" },
1774
+ negative: { generate: "negative" },
1775
+ caution: { generate: "caution" }
1776
+ },
1777
+ tokens: [
1778
+ { name: "brand-exact", value: { generate: "brand-exact" } },
1779
+ {
1780
+ name: "brand-exact-foreground",
1781
+ value: { generate: "brand-exact-foreground" }
1782
+ }
1783
+ ]
1784
+ };
1785
+ function isGeneratedRole(role) {
1786
+ return "generate" in role;
1787
+ }
1788
+ function isGeneratedToken(value) {
1789
+ return typeof value === "object" && value !== null && !Array.isArray(value) && "generate" in value;
1790
+ }
1791
+ function generatedRoles(theme) {
1792
+ return Object.entries(theme.roles ?? {}).flatMap(
1793
+ ([name, role]) => isGeneratedRole(role) ? [{ name, generate: role.generate }] : []
1794
+ );
1698
1795
  }
1699
1796
 
1700
1797
  // src/HextimatePaletteBuilder.ts
@@ -1723,22 +1820,28 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1723
1820
  lightPalette;
1724
1821
  darkPalette;
1725
1822
  inputColor;
1823
+ theme;
1726
1824
  options;
1727
1825
  operations = [];
1728
1826
  standaloneTokens = [];
1827
+ foregroundOverrides = /* @__PURE__ */ new Map();
1729
1828
  weakSideVariants = ["weak"];
1730
1829
  strongSideVariants = ["strong"];
1731
1830
  foregroundAnchoredVariants = /* @__PURE__ */ new Set();
1732
1831
  betweenVariants = [];
1733
1832
  presetFormatDefaults;
1734
- constructor(color) {
1833
+ constructor(color, theme = baseTheme) {
1735
1834
  this.inputColor = color;
1835
+ this.theme = theme;
1736
1836
  this.options = {};
1737
- this.seedOptionsForFork({});
1837
+ this.seedOptionsForFork(mergeStyleOptions(theme.style));
1738
1838
  }
1739
1839
  /**
1740
1840
  * Merges style options into the builder and regenerates the palettes,
1741
1841
  * then replays recorded operations so roles and variants reflect the new style.
1842
+ *
1843
+ * @deprecated Set `style` on a `ThemeDefinition`: `hextimate(accent, { ...theme, style })`.
1844
+ * See the {@link https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md#014x--0150-themes | Migration guide}.
1742
1845
  */
1743
1846
  style(partial) {
1744
1847
  this.operations.push({ method: "style", args: [partial] });
@@ -1748,17 +1851,21 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1748
1851
  }
1749
1852
  seedOptionsForFork(seededOptions) {
1750
1853
  this.options = { ...seededOptions };
1854
+ const roles = generatedRoles(this.theme);
1751
1855
  this.lightPalette = generate(
1752
1856
  this.inputColor,
1753
1857
  "light",
1754
- this.resolvedOptions()
1858
+ this.resolvedOptions(),
1859
+ roles
1755
1860
  );
1756
1861
  this.darkPalette = generate(
1757
1862
  this.inputColor,
1758
1863
  "dark",
1759
- this.resolvedOptions()
1864
+ this.resolvedOptions(),
1865
+ roles
1760
1866
  );
1761
1867
  this.standaloneTokens.length = 0;
1868
+ this.foregroundOverrides.clear();
1762
1869
  this.weakSideVariants.length = 0;
1763
1870
  this.weakSideVariants.push("weak");
1764
1871
  this.strongSideVariants.length = 0;
@@ -1766,12 +1873,45 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1766
1873
  this.foregroundAnchoredVariants.clear();
1767
1874
  this.betweenVariants.length = 0;
1768
1875
  this.presetFormatDefaults = void 0;
1769
- this.applyToken("brand-exact", this.inputColor);
1876
+ this.applyTheme();
1877
+ }
1878
+ /** Custom roles, variants, tokens, and format defaults from the theme. Generated roles already exist. */
1879
+ applyTheme() {
1880
+ const theme = this.theme;
1881
+ for (const [name, role] of Object.entries(theme.roles ?? {})) {
1882
+ if (isGeneratedRole(role)) continue;
1883
+ this.applyRole(name, "color" in role ? role.color : role);
1884
+ }
1885
+ for (const variant of theme.variants ?? []) {
1886
+ this.applyVariant(variant.name, variant.placement);
1887
+ }
1888
+ for (const token of theme.tokens ?? []) {
1889
+ this.applyToken(token.name, this.resolveThemeToken(token.value));
1890
+ }
1891
+ if (theme.format || theme.variantNames) {
1892
+ this.presetFormatDefaults = {
1893
+ ...theme.format,
1894
+ variantNames: { ...theme.format?.variantNames, ...theme.variantNames }
1895
+ };
1896
+ }
1897
+ }
1898
+ resolveThemeToken(value) {
1899
+ if (!isGeneratedToken(value)) return value;
1900
+ if (value.generate === "brand-exact") return this.inputColor;
1770
1901
  const colorOKLCH = convert(this.inputColor, "oklch");
1771
1902
  const lightFg = { ...colorOKLCH, l: 0.97, c: Math.min(colorOKLCH.c, 0.01) };
1772
1903
  const darkFg = { ...colorOKLCH, l: 0.1, c: Math.min(colorOKLCH.c, 0.01) };
1773
- const brandForeground = calculateContrast(this.inputColor, lightFg) >= calculateContrast(this.inputColor, darkFg) ? lightFg : darkFg;
1774
- this.applyToken("brand-exact-foreground", brandForeground);
1904
+ return calculateContrast(this.inputColor, lightFg) >= calculateContrast(this.inputColor, darkFg) ? lightFg : darkFg;
1905
+ }
1906
+ /** Every role the theme declares gets colored text on its surface role. */
1907
+ surfaceForegroundRoles() {
1908
+ const surface = generatedRoles(this.theme).find(
1909
+ (r) => r.generate === "surface"
1910
+ )?.name;
1911
+ return {
1912
+ surface,
1913
+ roles: Object.keys(this.theme.roles ?? {}).filter((r) => r !== surface)
1914
+ };
1775
1915
  }
1776
1916
  rebuildFromOperations() {
1777
1917
  this.seedOptionsForFork(this.options);
@@ -1832,6 +1972,8 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1832
1972
  *
1833
1973
  * @param name Role name (e.g. "cta", "banner")
1834
1974
  * @param color Base color or derived token for the role
1975
+ * @deprecated Declare the role in a `ThemeDefinition`: `roles: { cta: { color: '#ff0066' } }`.
1976
+ * See the {@link https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md#014x--0150-themes | Migration guide}.
1835
1977
  */
1836
1978
  addRole(name, color) {
1837
1979
  this.operations.push({ method: "addRole", args: [name, color] });
@@ -1846,6 +1988,8 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1846
1988
  *
1847
1989
  * @param name Variant name (e.g. "placeholder", "highlight")
1848
1990
  * @param placement Placement of the variant, either `{ from: 'weak' }` or `{ between: ['DEFAULT', 'strong'] }`
1991
+ * @deprecated Declare the variant in a `ThemeDefinition`: `variants: [{ name, placement }]`.
1992
+ * See the {@link https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md#014x--0150-themes | Migration guide}.
1849
1993
  */
1850
1994
  addVariant(name, placement) {
1851
1995
  this.operations.push({ method: "addVariant", args: [name, placement] });
@@ -1857,6 +2001,9 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1857
2001
  *
1858
2002
  * Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
1859
2003
  * A kebab key that matches a generated label throws at format time.
2004
+ *
2005
+ * @deprecated Declare the token in a `ThemeDefinition`: `tokens: [{ name, value }]`.
2006
+ * See the {@link https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md#014x--0150-themes | Migration guide}.
1860
2007
  */
1861
2008
  addToken(name, value) {
1862
2009
  this.operations.push({ method: "addToken", args: [name, value] });
@@ -1881,21 +2028,16 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1881
2028
  * const theme = hextimate('#6366F1')
1882
2029
  * .preset(presets.shadcn)
1883
2030
  * .format({ colors: 'hsl-raw' });
2031
+ *
2032
+ * @deprecated Pass a `ThemeDefinition`: `hextimate(accent, themes.shadcn)`.
2033
+ * See the {@link https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md#014x--0150-themes | Migration guide}.
1884
2034
  */
1885
2035
  preset(preset) {
1886
2036
  this.operations.push({ method: "preset", args: [preset] });
1887
2037
  if (preset.style) {
1888
2038
  this.options = mergeStyleOptions(this.options, preset.style);
1889
- this.lightPalette = generate(
1890
- this.inputColor,
1891
- "light",
1892
- this.resolvedOptions()
1893
- );
1894
- this.darkPalette = generate(
1895
- this.inputColor,
1896
- "dark",
1897
- this.resolvedOptions()
1898
- );
2039
+ this.rebuildFromOperations();
2040
+ return this;
1899
2041
  }
1900
2042
  this.applyPresetRolesTokensFormat(preset);
1901
2043
  return this;
@@ -1984,7 +2126,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1984
2126
  */
1985
2127
  fork(color) {
1986
2128
  const newColor = color !== void 0 ? parse(color) : this.inputColor;
1987
- const builder = new _HextimatePaletteBuilder(newColor);
2129
+ const builder = new _HextimatePaletteBuilder(newColor, this.theme);
1988
2130
  builder.seedOptionsForFork({ ...this.options });
1989
2131
  for (const op of this.operations) {
1990
2132
  switch (op.method) {
@@ -2025,43 +2167,51 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2025
2167
  ...options?.variantNames
2026
2168
  }
2027
2169
  } : options;
2170
+ const lightPalette = this.outputPalette("light");
2171
+ const darkPalette = this.outputPalette("dark");
2028
2172
  const colorFormat = mergedOptions?.colors ?? "hex";
2029
- this.assertNoPaletteLabelCollisions(mergedOptions);
2173
+ this.assertNoPaletteLabelCollisions(mergedOptions, lightPalette);
2030
2174
  const lightTokens = this.resolveStandaloneTokens(
2031
2175
  "light",
2032
- this.lightPalette,
2176
+ lightPalette,
2033
2177
  colorFormat
2034
2178
  );
2035
2179
  const darkTokens = this.resolveStandaloneTokens(
2036
2180
  "dark",
2037
- this.darkPalette,
2181
+ darkPalette,
2038
2182
  colorFormat
2039
2183
  );
2040
- const inverted = mergedOptions?.invertedVariants ? this.buildInvertedEntries(mergedOptions, lightTokens, darkTokens) : { lightBlock: [], darkBlock: [] };
2184
+ const inverted = mergedOptions?.invertedVariants ? this.buildInvertedEntries(
2185
+ mergedOptions,
2186
+ lightTokens,
2187
+ darkTokens,
2188
+ lightPalette,
2189
+ darkPalette
2190
+ ) : { lightBlock: [], darkBlock: [] };
2041
2191
  if (mergedOptions?.as === "css" || mergedOptions?.as === "tailwind-css") {
2042
2192
  return formatStylesheet(
2043
- this.lightPalette,
2044
- this.darkPalette,
2193
+ lightPalette,
2194
+ darkPalette,
2045
2195
  mergedOptions,
2046
2196
  [...lightTokens, ...inverted.lightBlock],
2047
2197
  [...darkTokens, ...inverted.darkBlock]
2048
2198
  );
2049
2199
  }
2050
2200
  return {
2051
- light: format(this.lightPalette, mergedOptions, [
2201
+ light: format(lightPalette, mergedOptions, [
2052
2202
  ...lightTokens,
2053
2203
  ...inverted.lightBlock
2054
2204
  ]),
2055
- dark: format(this.darkPalette, mergedOptions, [
2205
+ dark: format(darkPalette, mergedOptions, [
2056
2206
  ...darkTokens,
2057
2207
  ...inverted.darkBlock
2058
2208
  ])
2059
2209
  };
2060
2210
  }
2061
- buildInvertedEntries(options, lightStandalone, darkStandalone) {
2211
+ buildInvertedEntries(options, lightStandalone, darkStandalone, lightPalette, darkPalette) {
2062
2212
  const sep = options.separator ?? "-";
2063
- const lightBase = buildTokenEntries(this.lightPalette, options);
2064
- const darkBase = buildTokenEntries(this.darkPalette, options);
2213
+ const lightBase = buildTokenEntries(lightPalette, options);
2214
+ const darkBase = buildTokenEntries(darkPalette, options);
2065
2215
  return {
2066
2216
  // Light block carries dark values under -inverted suffix.
2067
2217
  lightBlock: [
@@ -2075,6 +2225,22 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2075
2225
  ]
2076
2226
  };
2077
2227
  }
2228
+ outputPalette(theme) {
2229
+ const palette = surfaceForegrounds(
2230
+ theme === "light" ? this.lightPalette : this.darkPalette,
2231
+ theme,
2232
+ this.resolvedOptions(),
2233
+ this.surfaceForegroundRoles()
2234
+ );
2235
+ for (const [coordinate, value] of this.foregroundOverrides) {
2236
+ const [role, variant] = coordinate.split(".");
2237
+ palette[role][variant] = convert(
2238
+ this.resolveTokenValue(value, theme, palette),
2239
+ "oklch"
2240
+ );
2241
+ }
2242
+ return palette;
2243
+ }
2078
2244
  applyRole(name, color) {
2079
2245
  const parsedColor = this.isDerivedToken(color) ? this.resolveDerivedToken(color, this.lightPalette, "light") : parse(color);
2080
2246
  const opts = this.resolvedOptions();
@@ -2199,6 +2365,11 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2199
2365
  }
2200
2366
  }
2201
2367
  applyToken(name, value) {
2368
+ const [role, variant] = name.split(".");
2369
+ if (name === `${role}.${variant}` && isRoleForeground(this.surfaceForegroundRoles(), role, variant)) {
2370
+ this.foregroundOverrides.set(name, value);
2371
+ return;
2372
+ }
2202
2373
  if (name.includes(".")) {
2203
2374
  this.applyPalettePin(name, value);
2204
2375
  return;
@@ -2240,15 +2411,15 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2240
2411
  * Standalone token names must not squash palette flat keys after
2241
2412
  * roleNames / variantNames / separator / excludes are applied.
2242
2413
  */
2243
- assertNoPaletteLabelCollisions(options) {
2414
+ assertNoPaletteLabelCollisions(options, palette) {
2244
2415
  if (this.standaloneTokens.length === 0) return;
2245
2416
  const sep = options?.separator ?? "-";
2246
2417
  const excludeRoles = new Set(options?.excludeRoles ?? []);
2247
2418
  const excludeVariants = new Set(options?.excludeVariants ?? []);
2248
2419
  const labelToCoord = /* @__PURE__ */ new Map();
2249
- for (const role of Object.keys(this.lightPalette)) {
2420
+ for (const role of Object.keys(palette)) {
2250
2421
  if (excludeRoles.has(role)) continue;
2251
- const scale = this.lightPalette[role];
2422
+ const scale = palette[role];
2252
2423
  for (const variant of Object.keys(scale)) {
2253
2424
  if (excludeVariants.has(variant)) continue;
2254
2425
  const raw = scale[variant];
@@ -2386,8 +2557,9 @@ Did you mean addToken("${suggestion}") to change the palette?`
2386
2557
  if (this.strongSideVariants.includes(variantName)) {
2387
2558
  return this.strongSideVariants;
2388
2559
  }
2560
+ const surface = this.surfaceForegroundRoles().surface;
2389
2561
  const sampleRole = Object.keys(this.lightPalette).find(
2390
- (r) => r !== "surface"
2562
+ (r) => r !== surface
2391
2563
  );
2392
2564
  if (!sampleRole) return null;
2393
2565
  const scale = this.lightPalette[sampleRole];
@@ -2552,10 +2724,10 @@ var HextimateError = class extends Error {
2552
2724
  this.name = "HextimateError";
2553
2725
  }
2554
2726
  };
2555
- function hextimate(color) {
2727
+ function hextimate(color, theme) {
2556
2728
  try {
2557
2729
  const parsedColor = parse(color);
2558
- return new HextimatePaletteBuilder(parsedColor);
2730
+ return new HextimatePaletteBuilder(parsedColor, theme);
2559
2731
  } catch (e) {
2560
2732
  if (e instanceof HextimateError) {
2561
2733
  throw e;
@@ -2568,7 +2740,8 @@ function hextimate(color) {
2568
2740
  }
2569
2741
 
2570
2742
  // src/presets/bold.ts
2571
- var bold = {
2743
+ var boldTheme = {
2744
+ ...baseTheme,
2572
2745
  style: {
2573
2746
  light: { baseLightness: 0.5 },
2574
2747
  dark: { baseLightness: 0.8 },
@@ -2576,64 +2749,77 @@ var bold = {
2576
2749
  foregroundMaxChroma: 0.02
2577
2750
  }
2578
2751
  };
2752
+ var bold = { style: boldTheme.style };
2579
2753
 
2580
2754
  // src/presets/mui.ts
2755
+ var variantNames = {
2756
+ DEFAULT: "main",
2757
+ weak: "light",
2758
+ strong: "dark",
2759
+ foreground: "contrastText"
2760
+ };
2761
+ var info = { color: "#0288d1" };
2762
+ var secondary = { from: "accent", hue: 180 };
2763
+ var format2 = {
2764
+ as: "object",
2765
+ colors: "hex",
2766
+ separator: "-",
2767
+ roleNames: {
2768
+ accent: "primary",
2769
+ negative: "error",
2770
+ positive: "success",
2771
+ caution: "warning"
2772
+ },
2773
+ excludeRoles: ["surface"]
2774
+ };
2775
+ var tokens = [
2776
+ // background
2777
+ { name: "background-default", value: { from: "surface" } },
2778
+ {
2779
+ name: "background-paper",
2780
+ value: { from: "surface", emphasis: -0.025 }
2781
+ },
2782
+ // text
2783
+ { name: "text-primary", value: { from: "surface.foreground" } },
2784
+ {
2785
+ name: "text-secondary",
2786
+ value: { from: "surface.foreground", emphasis: -0.2 }
2787
+ },
2788
+ {
2789
+ name: "text-disabled",
2790
+ value: { from: "surface.foreground", emphasis: -0.4 }
2791
+ },
2792
+ // divider
2793
+ { name: "divider", value: { from: "surface", emphasis: 0.12 } },
2794
+ // action tokens
2795
+ { name: "action-hover", value: { from: "surface", emphasis: 0.04 } },
2796
+ { name: "action-selected", value: { from: "surface", emphasis: 0.08 } },
2797
+ { name: "action-disabled", value: { from: "surface", emphasis: 0.15 } },
2798
+ {
2799
+ name: "action-disabledBackground",
2800
+ value: { from: "surface", emphasis: 0.06 }
2801
+ },
2802
+ { name: "action-focus", value: { from: "surface", emphasis: 0.06 } }
2803
+ ];
2581
2804
  var mui = {
2582
2805
  roles: [
2583
- { name: "info", color: "#0288d1" },
2584
- { name: "secondary", color: { from: "accent", hue: 180 } }
2585
- ],
2586
- tokens: [
2587
- // background
2588
- { name: "background-default", value: { from: "surface" } },
2589
- {
2590
- name: "background-paper",
2591
- value: { from: "surface", emphasis: -0.025 }
2592
- },
2593
- // text
2594
- { name: "text-primary", value: { from: "surface.foreground" } },
2595
- {
2596
- name: "text-secondary",
2597
- value: { from: "surface.foreground", emphasis: -0.2 }
2598
- },
2599
- {
2600
- name: "text-disabled",
2601
- value: { from: "surface.foreground", emphasis: -0.4 }
2602
- },
2603
- // divider
2604
- { name: "divider", value: { from: "surface", emphasis: 0.12 } },
2605
- // action tokens
2606
- { name: "action-hover", value: { from: "surface", emphasis: 0.04 } },
2607
- { name: "action-selected", value: { from: "surface", emphasis: 0.08 } },
2608
- { name: "action-disabled", value: { from: "surface", emphasis: 0.15 } },
2609
- {
2610
- name: "action-disabledBackground",
2611
- value: { from: "surface", emphasis: 0.06 }
2612
- },
2613
- { name: "action-focus", value: { from: "surface", emphasis: 0.06 } }
2806
+ { name: "info", color: info.color },
2807
+ { name: "secondary", color: secondary }
2614
2808
  ],
2615
- format: {
2616
- as: "object",
2617
- colors: "hex",
2618
- separator: "-",
2619
- roleNames: {
2620
- accent: "primary",
2621
- negative: "error",
2622
- positive: "success",
2623
- caution: "warning"
2624
- },
2625
- variantNames: {
2626
- DEFAULT: "main",
2627
- weak: "light",
2628
- strong: "dark",
2629
- foreground: "contrastText"
2630
- },
2631
- excludeRoles: ["surface"]
2632
- }
2809
+ tokens,
2810
+ format: { ...format2, variantNames }
2811
+ };
2812
+ var muiTheme = {
2813
+ ...baseTheme,
2814
+ roles: { ...baseTheme.roles, info, secondary },
2815
+ tokens: [...baseTheme.tokens, ...tokens],
2816
+ variantNames,
2817
+ format: format2
2633
2818
  };
2634
2819
 
2635
2820
  // src/presets/muted.ts
2636
- var muted = {
2821
+ var mutedTheme = {
2822
+ ...baseTheme,
2637
2823
  style: {
2638
2824
  light: { maxChroma: 0.08 },
2639
2825
  dark: { maxChroma: 0.07 },
@@ -2641,81 +2827,93 @@ var muted = {
2641
2827
  foregroundMaxChroma: 5e-3
2642
2828
  }
2643
2829
  };
2830
+ var muted = { style: mutedTheme.style };
2644
2831
 
2645
2832
  // src/presets/shadcn.ts
2833
+ var variantNames2 = {
2834
+ foreground: "foreground"
2835
+ };
2836
+ var format3 = {
2837
+ as: "css",
2838
+ colors: "oklch",
2839
+ roleNames: {
2840
+ surface: "background",
2841
+ accent: "primary",
2842
+ negative: "destructive",
2843
+ positive: "success"
2844
+ },
2845
+ excludeRoles: ["caution"],
2846
+ excludeVariants: ["strong", "weak", "foreground-weak"]
2847
+ };
2848
+ var tokens2 = [
2849
+ // shadcn uses bare --foreground (not --background-foreground)
2850
+ { name: "foreground", value: { from: "surface.foreground" } },
2851
+ // card / popover — same as background
2852
+ { name: "card", value: { from: "surface" } },
2853
+ { name: "card-foreground", value: { from: "surface.foreground" } },
2854
+ { name: "popover", value: { from: "surface" } },
2855
+ { name: "popover-foreground", value: { from: "surface.foreground" } },
2856
+ // secondary — subtle contrast from background
2857
+ { name: "secondary", value: { from: "surface" } },
2858
+ { name: "secondary-foreground", value: { from: "surface.foreground" } },
2859
+ // muted — similar to secondary, but with dimmer foreground
2860
+ { name: "muted", value: { from: "surface" } },
2861
+ {
2862
+ name: "muted-foreground",
2863
+ value: {
2864
+ from: "surface.foreground",
2865
+ emphasis: -0.25
2866
+ }
2867
+ },
2868
+ // accent (shadcn meaning: subtle hover highlight, not the brand color)
2869
+ { name: "accent", value: { from: "surface" } },
2870
+ { name: "accent-foreground", value: { from: "surface.foreground" } },
2871
+ // border / input
2872
+ {
2873
+ name: "border",
2874
+ value: { from: "surface", emphasis: 0.8 }
2875
+ },
2876
+ {
2877
+ name: "input",
2878
+ value: {
2879
+ from: "surface",
2880
+ emphasis: 0.8
2881
+ }
2882
+ },
2883
+ // ring — uses the brand/primary color
2884
+ { name: "ring", value: { from: "accent" } },
2885
+ // chart tokens colors use brand/priamry color
2886
+ { name: "chart-1", value: { from: "accent" } },
2887
+ { name: "chart-2", value: { from: "chart-1", emphasis: -0.04 } },
2888
+ { name: "chart-3", value: { from: "chart-2", emphasis: -0.04 } },
2889
+ { name: "chart-4", value: { from: "chart-3", emphasis: -0.04 } },
2890
+ { name: "chart-5", value: { from: "chart-4", emphasis: -0.04 } }
2891
+ ];
2646
2892
  var shadcn = {
2647
- tokens: [
2648
- // shadcn uses bare --foreground (not --background-foreground)
2649
- { name: "foreground", value: { from: "surface.foreground" } },
2650
- // card / popover — same as background
2651
- { name: "card", value: { from: "surface" } },
2652
- { name: "card-foreground", value: { from: "surface.foreground" } },
2653
- { name: "popover", value: { from: "surface" } },
2654
- { name: "popover-foreground", value: { from: "surface.foreground" } },
2655
- // secondary — subtle contrast from background
2656
- { name: "secondary", value: { from: "surface" } },
2657
- { name: "secondary-foreground", value: { from: "surface.foreground" } },
2658
- // muted — similar to secondary, but with dimmer foreground
2659
- { name: "muted", value: { from: "surface" } },
2660
- {
2661
- name: "muted-foreground",
2662
- value: {
2663
- from: "surface.foreground",
2664
- emphasis: -0.25
2665
- }
2666
- },
2667
- // accent (shadcn meaning: subtle hover highlight, not the brand color)
2668
- { name: "accent", value: { from: "surface" } },
2669
- { name: "accent-foreground", value: { from: "surface.foreground" } },
2670
- // border / input
2671
- {
2672
- name: "border",
2673
- value: { from: "surface", emphasis: 0.8 }
2674
- },
2675
- {
2676
- name: "input",
2677
- value: {
2678
- from: "surface",
2679
- emphasis: 0.8
2680
- }
2681
- },
2682
- // ring — uses the brand/primary color
2683
- { name: "ring", value: { from: "accent" } },
2684
- // chart tokens colors use brand/priamry color
2685
- { name: "chart-1", value: { from: "accent" } },
2686
- { name: "chart-2", value: { from: "chart-1", emphasis: -0.04 } },
2687
- { name: "chart-3", value: { from: "chart-2", emphasis: -0.04 } },
2688
- { name: "chart-4", value: { from: "chart-3", emphasis: -0.04 } },
2689
- { name: "chart-5", value: { from: "chart-4", emphasis: -0.04 } }
2690
- ],
2691
- format: {
2692
- as: "css",
2693
- colors: "oklch",
2694
- roleNames: {
2695
- surface: "background",
2696
- accent: "primary",
2697
- negative: "destructive",
2698
- positive: "success"
2699
- },
2700
- variantNames: {
2701
- foreground: "foreground"
2702
- },
2703
- excludeRoles: ["caution"],
2704
- excludeVariants: ["strong", "weak", "foreground-weak"]
2705
- }
2893
+ tokens: tokens2,
2894
+ format: { ...format3, variantNames: variantNames2 }
2895
+ };
2896
+ var shadcnTheme = {
2897
+ ...baseTheme,
2898
+ tokens: [...baseTheme.tokens, ...tokens2],
2899
+ variantNames: variantNames2,
2900
+ format: format3
2706
2901
  };
2707
2902
 
2708
2903
  // src/presets/tinted.ts
2709
- var tinted = {
2904
+ var tintedTheme = {
2905
+ ...baseTheme,
2710
2906
  style: {
2711
2907
  surfaceMaxChroma: 0.05,
2712
2908
  surfaceHueShift: 0,
2713
2909
  foregroundMaxChroma: 0.015
2714
2910
  }
2715
2911
  };
2912
+ var tinted = { style: tintedTheme.style };
2716
2913
 
2717
2914
  // src/presets/vibrant.ts
2718
- var vibrant = {
2915
+ var vibrantTheme = {
2916
+ ...baseTheme,
2719
2917
  style: {
2720
2918
  light: { maxChroma: 0.2, baseLightness: 0.6 },
2721
2919
  dark: { maxChroma: 0.18, baseLightness: 0.65 },
@@ -2724,6 +2922,7 @@ var vibrant = {
2724
2922
  surfaceMaxChroma: 0.08
2725
2923
  }
2726
2924
  };
2925
+ var vibrant = { style: vibrantTheme.style };
2727
2926
 
2728
2927
  // src/cli.ts
2729
2928
  var __dirname = dirname(fileURLToPath(import.meta.url));