hextimator 0.12.2 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,3 +1,47 @@
1
+ ## 0.13.0
2
+
3
+ ### Minor Changes
4
+
5
+ - [#169](https://github.com/fgrgic/hextimator/pull/169) [`bcd6d93`](https://github.com/fgrgic/hextimator/commit/bcd6d934dc792393870e08ae3b453ecdea9a4c51) Thanks [@fgrgic](https://github.com/fgrgic)! - Overriding a generated token with `addToken` now uses a dotted key and applies before derivation (`surface.strong` instead of `surface-strong`). Kebab keys that collide with a generated label throw (`collides with a generated token`). See migration.md.
6
+
7
+ - [#170](https://github.com/fgrgic/hextimator/pull/170) [`1fd85c9`](https://github.com/fgrgic/hextimator/commit/1fd85c99ae3996aa601fec78d5b6d1c84ed59bcf) Thanks [@fgrgic](https://github.com/fgrgic)! - `HextimateConfig` and `fromConfig()` — express a theme's inputs as a plain object instead of a method chain.
8
+
9
+ ```ts
10
+ fromConfig({ color: "#3a86ff" });
11
+ fromConfig({
12
+ color: "#3a86ff",
13
+ presets: [
14
+ {
15
+ tokens: [
16
+ {
17
+ name: "surface.weak",
18
+ value:
19
+ "[#123456](https://github.com/fgrgic/hextimator/issues/123456)",
20
+ },
21
+ ],
22
+ },
23
+ ],
24
+ });
25
+ ```
26
+
27
+ Returns a builder, so chaining continues as usual. Presets were already serializable — the colour wasn't. Pairing them makes a whole theme a value you can store, diff, or share between programs.
28
+
29
+ ### Patch Changes
30
+
31
+ - [#167](https://github.com/fgrgic/hextimator/pull/167) [`8d34573`](https://github.com/fgrgic/hextimator/commit/8d34573fb423ebeaac96c6f220bef03affc021c4) Thanks [@fgrgic](https://github.com/fgrgic)! - docs: fix wrong claim in readme
32
+
33
+ ## 0.13.0
34
+
35
+ ### Major Changes
36
+
37
+ - **Breaking.** Overriding a generated token with `addToken` now uses a dotted key and applies before derivation (`surface.strong` instead of `surface-strong`). Kebab keys that collide with a generated label throw (`collides with a generated token`). See [migration.md](./docs/migration.md).
38
+
39
+ ## 0.12.3
40
+
41
+ ### Patch Changes
42
+
43
+ - [#164](https://github.com/fgrgic/hextimator/pull/164) [`4c4974e`](https://github.com/fgrgic/hextimator/commit/4c4974edaf14f3d75ad35cd84db48890d44dc2c4) Thanks [@fgrgic](https://github.com/fgrgic)! - docs: update README gif
44
+
1
45
  ## 0.12.2
2
46
 
3
47
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # hextimator
2
2
 
3
3
  <p align="center">
4
- <img src="https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/assets/gh-cover.gif?raw=true" alt="hextimator" width="600">
4
+ <img src="https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/assets/gh-cover.webp?raw=true" alt="hextimator" width="100%">
5
5
  </p>
6
6
  <p>
7
7
  <a href="https://www.npmjs.com/package/hextimator"><img src="https://img.shields.io/npm/v/hextimator" alt="npm version"></a>
@@ -22,6 +22,10 @@ Try it: **[hextimator.com](https://hextimator.com)**
22
22
 
23
23
  ## Why `hextimator` exists
24
24
 
25
+ <p align="center">
26
+ <video src="https://github.com/user-attachments/assets/245f0728-38e3-425a-8d0c-87bff6f48b0f" width="100%" controls playsinline></video>
27
+ </p>
28
+
25
29
  You ship a B2B, B2B2C, or white-label app. Every tenant brings a brand color. Your choices today:
26
30
 
27
31
  - **Let them pick any hex.** Legal-pad yellow buttons become unreadable. Cheeto tangerine toasts look like your warning state.
@@ -33,7 +37,7 @@ hextimator is the third option. **One color in, whole theme out.** Light and dar
33
37
 
34
38
  hextimator is not the first palette generator. It targets one job the others skip: arbitrary brand colors at runtime.
35
39
 
36
- - **[Adobe Leonardo](https://leonardocolor.io)** Contrast-driven scales with manual control. Designers build palettes ahead of time. No runtime API for arbitrary hex, semantic roles, or dark mode.
40
+ - **[Adobe Leonardo](https://leonardocolor.io)** Runtime contrast scales from arbitrary hex (`Theme` → `contrastColors`, target ratios). A construction kit: you wire roles, surfaces, and dark mode yourself. hextimator is one call with those built in.
37
41
  - **[Material dynamic color](https://github.com/material-foundation/material-color-utilities)** Full theming from one seed color. Battle-tested on Android. Output follows Material's token scheme. Hard to use outside Material-shaped UIs.
38
42
  - **[Radix Colors](https://www.radix-ui.com/colors)** Hand-tuned scales with strong semantics. Fixed curated set. Does not generate themes from arbitrary input.
39
43
  - **[tints.dev](https://tints.dev) / [uicolors.app](https://uicolors.app)** Quick Tailwind shade scales from one color. Build-time only. No semantic roles, contrast guarantees, dark theme, or library API.
@@ -435,17 +435,10 @@ declare class HextimatePaletteBuilder {
435
435
  */
436
436
  addVariant(name: string, placement: VariantPlacement): this;
437
437
  /**
438
- * Adds a standalone/one-off token that doesn't fit the role+variant structure.
439
- * The value can be a direct color, a derived token based on an existing role+variant, or an object specifying different values for light and dark themes.
438
+ * Adds a standalone token, or overrides a generated palette color before derivation.
440
439
  *
441
- * e.g. `addToken('brand', '#3a86ff')` adds a "brand" token with the specified color in both themes.
442
- * `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
443
- *
444
- * It can also be used to override specific tokens after generation.
445
- * `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
446
- *
447
- * @param name Token name (e.g. "brand", "logo")
448
- * @param value Token value, which can be an exact color, or derived from an existing role+variant.
440
+ * Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
441
+ * A kebab key that matches a generated label throws at format time.
449
442
  */
450
443
  addToken(name: string, value: TokenValue): this;
451
444
  /**
@@ -540,6 +533,12 @@ declare class HextimatePaletteBuilder {
540
533
  private applyVariant;
541
534
  private applyAnchoredVariant;
542
535
  private applyToken;
536
+ private applyPalettePin;
537
+ /**
538
+ * Standalone token names must not squash palette flat keys after
539
+ * roleNames / variantNames / separator / excludes are applied.
540
+ */
541
+ private assertNoPaletteLabelCollisions;
543
542
  private resolveStandaloneTokens;
544
543
  private resolveTokenValue;
545
544
  private resolveTokenSingle;
@@ -1833,17 +1833,10 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1833
1833
  return this;
1834
1834
  }
1835
1835
  /**
1836
- * Adds a standalone/one-off token that doesn't fit the role+variant structure.
1837
- * The value can be a direct color, a derived token based on an existing role+variant, or an object specifying different values for light and dark themes.
1836
+ * Adds a standalone token, or overrides a generated palette color before derivation.
1838
1837
  *
1839
- * e.g. `addToken('brand', '#3a86ff')` adds a "brand" token with the specified color in both themes.
1840
- * `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
1841
- *
1842
- * It can also be used to override specific tokens after generation.
1843
- * `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
1844
- *
1845
- * @param name Token name (e.g. "brand", "logo")
1846
- * @param value Token value, which can be an exact color, or derived from an existing role+variant.
1838
+ * Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
1839
+ * A kebab key that matches a generated label throws at format time.
1847
1840
  */
1848
1841
  addToken(name, value) {
1849
1842
  this.operations.push({ method: "addToken", args: [name, value] });
@@ -2013,6 +2006,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2013
2006
  }
2014
2007
  } : options;
2015
2008
  const colorFormat = mergedOptions?.colors ?? "hex";
2009
+ this.assertNoPaletteLabelCollisions(mergedOptions);
2016
2010
  const lightTokens = this.resolveStandaloneTokens(
2017
2011
  "light",
2018
2012
  this.lightPalette,
@@ -2179,10 +2173,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2179
2173
  }
2180
2174
  scale[name] = {
2181
2175
  ...anchor,
2182
- l: Math.max(
2183
- 0,
2184
- Math.min(1, anchor.l + emphasis * contrastDirection)
2185
- ),
2176
+ l: Math.max(0, Math.min(1, anchor.l + emphasis * contrastDirection)),
2186
2177
  c: Math.max(0, anchor.c + chromaOffset),
2187
2178
  h: wrapHue(anchor.h + hueOffset)
2188
2179
  };
@@ -2190,8 +2181,86 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2190
2181
  }
2191
2182
  }
2192
2183
  applyToken(name, value) {
2184
+ if (name.includes(".")) {
2185
+ this.applyPalettePin(name, value);
2186
+ return;
2187
+ }
2193
2188
  this.standaloneTokens.push({ name, value });
2194
2189
  }
2190
+ applyPalettePin(coordinate, value) {
2191
+ const dot = coordinate.indexOf(".");
2192
+ const role = coordinate.slice(0, dot);
2193
+ const variant = coordinate.slice(dot + 1);
2194
+ if (!role || !variant) {
2195
+ throw new Error(
2196
+ `Invalid palette coordinate "${coordinate}". Expected "role.variant".`
2197
+ );
2198
+ }
2199
+ for (const palette of [this.lightPalette, this.darkPalette]) {
2200
+ const scale = palette[role];
2201
+ if (!scale) {
2202
+ throw new Error(
2203
+ `Unknown role "${role}" in palette coordinate "${coordinate}"`
2204
+ );
2205
+ }
2206
+ if (scale[variant] === void 0) {
2207
+ throw new Error(
2208
+ `Unknown variant "${variant}" in palette coordinate "${coordinate}"`
2209
+ );
2210
+ }
2211
+ }
2212
+ this.lightPalette[role][variant] = convert(
2213
+ this.resolveTokenValue(value, "light", this.lightPalette),
2214
+ "oklch"
2215
+ );
2216
+ this.darkPalette[role][variant] = convert(
2217
+ this.resolveTokenValue(value, "dark", this.darkPalette),
2218
+ "oklch"
2219
+ );
2220
+ }
2221
+ /**
2222
+ * Standalone token names must not squash palette flat keys after
2223
+ * roleNames / variantNames / separator / excludes are applied.
2224
+ */
2225
+ assertNoPaletteLabelCollisions(options) {
2226
+ if (this.standaloneTokens.length === 0) return;
2227
+ const sep = options?.separator ?? "-";
2228
+ const excludeRoles = new Set(options?.excludeRoles ?? []);
2229
+ const excludeVariants = new Set(options?.excludeVariants ?? []);
2230
+ const labelToCoord = /* @__PURE__ */ new Map();
2231
+ for (const role of Object.keys(this.lightPalette)) {
2232
+ if (excludeRoles.has(role)) continue;
2233
+ const scale = this.lightPalette[role];
2234
+ for (const variant of Object.keys(scale)) {
2235
+ if (excludeVariants.has(variant)) continue;
2236
+ const raw = scale[variant];
2237
+ if (typeof raw !== "object" || raw === null || !("space" in raw)) {
2238
+ continue;
2239
+ }
2240
+ const isDefault = variant === "DEFAULT";
2241
+ const entry = {
2242
+ role: options?.roleNames?.[role] ?? role,
2243
+ variant: options?.variantNames?.[variant] ?? variant,
2244
+ isDefault,
2245
+ value: ""
2246
+ };
2247
+ labelToCoord.set(toFlatKey(entry, sep), {
2248
+ role,
2249
+ variant,
2250
+ isDefault
2251
+ });
2252
+ }
2253
+ }
2254
+ for (const { name } of this.standaloneTokens) {
2255
+ const coord = labelToCoord.get(name);
2256
+ if (!coord) continue;
2257
+ const suggestion = coord.isDefault ? `${coord.role}.DEFAULT` : `${coord.role}.${coord.variant}`;
2258
+ throw new Error(
2259
+ `addToken("${name}") collides with a generated token.
2260
+ Did you mean addToken("${suggestion}") to change the palette?`
2261
+ );
2262
+ }
2263
+ }
2195
2264
  resolveStandaloneTokens(themeType, palette, colorFormat) {
2196
2265
  return this.standaloneTokens.map(({ name, value }) => {
2197
2266
  const color = this.resolveTokenValue(value, themeType, palette);
@@ -2457,7 +2526,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2457
2526
  }
2458
2527
  };
2459
2528
 
2460
- // src/index.ts
2529
+ // src/hextimate.ts
2461
2530
  var HextimateError = class extends Error {
2462
2531
  constructor(input, message) {
2463
2532
  super(message ?? `Failed to hextimate color: ${String(input)}`);
@@ -2480,6 +2549,13 @@ function hextimate(color) {
2480
2549
  }
2481
2550
  }
2482
2551
 
2552
+ // src/presets/fromConfig.ts
2553
+ function fromConfig(c) {
2554
+ let b = hextimate(c.color);
2555
+ for (const p of c.presets ?? []) b = b.preset(p);
2556
+ return b;
2557
+ }
2558
+
2483
2559
  export {
2484
2560
  convert,
2485
2561
  parse,
@@ -2487,5 +2563,6 @@ export {
2487
2563
  simulateColor,
2488
2564
  HextimatePaletteBuilder,
2489
2565
  HextimateError,
2490
- hextimate
2566
+ hextimate,
2567
+ fromConfig
2491
2568
  };
package/dist/cli.js CHANGED
@@ -1841,17 +1841,10 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1841
1841
  return this;
1842
1842
  }
1843
1843
  /**
1844
- * Adds a standalone/one-off token that doesn't fit the role+variant structure.
1845
- * The value can be a direct color, a derived token based on an existing role+variant, or an object specifying different values for light and dark themes.
1844
+ * Adds a standalone token, or overrides a generated palette color before derivation.
1846
1845
  *
1847
- * e.g. `addToken('brand', '#3a86ff')` adds a "brand" token with the specified color in both themes.
1848
- * `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
1849
- *
1850
- * It can also be used to override specific tokens after generation.
1851
- * `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
1852
- *
1853
- * @param name Token name (e.g. "brand", "logo")
1854
- * @param value Token value, which can be an exact color, or derived from an existing role+variant.
1846
+ * Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
1847
+ * A kebab key that matches a generated label throws at format time.
1855
1848
  */
1856
1849
  addToken(name, value) {
1857
1850
  this.operations.push({ method: "addToken", args: [name, value] });
@@ -2021,6 +2014,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2021
2014
  }
2022
2015
  } : options;
2023
2016
  const colorFormat = mergedOptions?.colors ?? "hex";
2017
+ this.assertNoPaletteLabelCollisions(mergedOptions);
2024
2018
  const lightTokens = this.resolveStandaloneTokens(
2025
2019
  "light",
2026
2020
  this.lightPalette,
@@ -2187,10 +2181,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2187
2181
  }
2188
2182
  scale[name] = {
2189
2183
  ...anchor,
2190
- l: Math.max(
2191
- 0,
2192
- Math.min(1, anchor.l + emphasis * contrastDirection)
2193
- ),
2184
+ l: Math.max(0, Math.min(1, anchor.l + emphasis * contrastDirection)),
2194
2185
  c: Math.max(0, anchor.c + chromaOffset),
2195
2186
  h: wrapHue(anchor.h + hueOffset)
2196
2187
  };
@@ -2198,8 +2189,86 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2198
2189
  }
2199
2190
  }
2200
2191
  applyToken(name, value) {
2192
+ if (name.includes(".")) {
2193
+ this.applyPalettePin(name, value);
2194
+ return;
2195
+ }
2201
2196
  this.standaloneTokens.push({ name, value });
2202
2197
  }
2198
+ applyPalettePin(coordinate, value) {
2199
+ const dot = coordinate.indexOf(".");
2200
+ const role = coordinate.slice(0, dot);
2201
+ const variant = coordinate.slice(dot + 1);
2202
+ if (!role || !variant) {
2203
+ throw new Error(
2204
+ `Invalid palette coordinate "${coordinate}". Expected "role.variant".`
2205
+ );
2206
+ }
2207
+ for (const palette of [this.lightPalette, this.darkPalette]) {
2208
+ const scale = palette[role];
2209
+ if (!scale) {
2210
+ throw new Error(
2211
+ `Unknown role "${role}" in palette coordinate "${coordinate}"`
2212
+ );
2213
+ }
2214
+ if (scale[variant] === void 0) {
2215
+ throw new Error(
2216
+ `Unknown variant "${variant}" in palette coordinate "${coordinate}"`
2217
+ );
2218
+ }
2219
+ }
2220
+ this.lightPalette[role][variant] = convert(
2221
+ this.resolveTokenValue(value, "light", this.lightPalette),
2222
+ "oklch"
2223
+ );
2224
+ this.darkPalette[role][variant] = convert(
2225
+ this.resolveTokenValue(value, "dark", this.darkPalette),
2226
+ "oklch"
2227
+ );
2228
+ }
2229
+ /**
2230
+ * Standalone token names must not squash palette flat keys after
2231
+ * roleNames / variantNames / separator / excludes are applied.
2232
+ */
2233
+ assertNoPaletteLabelCollisions(options) {
2234
+ if (this.standaloneTokens.length === 0) return;
2235
+ const sep = options?.separator ?? "-";
2236
+ const excludeRoles = new Set(options?.excludeRoles ?? []);
2237
+ const excludeVariants = new Set(options?.excludeVariants ?? []);
2238
+ const labelToCoord = /* @__PURE__ */ new Map();
2239
+ for (const role of Object.keys(this.lightPalette)) {
2240
+ if (excludeRoles.has(role)) continue;
2241
+ const scale = this.lightPalette[role];
2242
+ for (const variant of Object.keys(scale)) {
2243
+ if (excludeVariants.has(variant)) continue;
2244
+ const raw = scale[variant];
2245
+ if (typeof raw !== "object" || raw === null || !("space" in raw)) {
2246
+ continue;
2247
+ }
2248
+ const isDefault = variant === "DEFAULT";
2249
+ const entry = {
2250
+ role: options?.roleNames?.[role] ?? role,
2251
+ variant: options?.variantNames?.[variant] ?? variant,
2252
+ isDefault,
2253
+ value: ""
2254
+ };
2255
+ labelToCoord.set(toFlatKey(entry, sep), {
2256
+ role,
2257
+ variant,
2258
+ isDefault
2259
+ });
2260
+ }
2261
+ }
2262
+ for (const { name } of this.standaloneTokens) {
2263
+ const coord = labelToCoord.get(name);
2264
+ if (!coord) continue;
2265
+ const suggestion = coord.isDefault ? `${coord.role}.DEFAULT` : `${coord.role}.${coord.variant}`;
2266
+ throw new Error(
2267
+ `addToken("${name}") collides with a generated token.
2268
+ Did you mean addToken("${suggestion}") to change the palette?`
2269
+ );
2270
+ }
2271
+ }
2203
2272
  resolveStandaloneTokens(themeType, palette, colorFormat) {
2204
2273
  return this.standaloneTokens.map(({ name, value }) => {
2205
2274
  const color = this.resolveTokenValue(value, themeType, palette);
@@ -2465,6 +2534,29 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2465
2534
  }
2466
2535
  };
2467
2536
 
2537
+ // src/hextimate.ts
2538
+ var HextimateError = class extends Error {
2539
+ constructor(input, message) {
2540
+ super(message ?? `Failed to hextimate color: ${String(input)}`);
2541
+ this.input = input;
2542
+ this.name = "HextimateError";
2543
+ }
2544
+ };
2545
+ function hextimate(color) {
2546
+ try {
2547
+ const parsedColor = parse(color);
2548
+ return new HextimatePaletteBuilder(parsedColor);
2549
+ } catch (e) {
2550
+ if (e instanceof HextimateError) {
2551
+ throw e;
2552
+ }
2553
+ throw new HextimateError(
2554
+ color,
2555
+ e instanceof Error ? e.message : "Unknown error"
2556
+ );
2557
+ }
2558
+ }
2559
+
2468
2560
  // src/presets/bold.ts
2469
2561
  var bold = {
2470
2562
  style: {
@@ -2623,29 +2715,6 @@ var vibrant = {
2623
2715
  }
2624
2716
  };
2625
2717
 
2626
- // src/index.ts
2627
- var HextimateError = class extends Error {
2628
- constructor(input, message) {
2629
- super(message ?? `Failed to hextimate color: ${String(input)}`);
2630
- this.input = input;
2631
- this.name = "HextimateError";
2632
- }
2633
- };
2634
- function hextimate(color) {
2635
- try {
2636
- const parsedColor = parse(color);
2637
- return new HextimatePaletteBuilder(parsedColor);
2638
- } catch (e) {
2639
- if (e instanceof HextimateError) {
2640
- throw e;
2641
- }
2642
- throw new HextimateError(
2643
- color,
2644
- e instanceof Error ? e.message : "Unknown error"
2645
- );
2646
- }
2647
- }
2648
-
2649
2718
  // src/cli.ts
2650
2719
  var __dirname = dirname(fileURLToPath(import.meta.url));
2651
2720
  var PKG_VERSION = JSON.parse(
@@ -1,4 +1,4 @@
1
- import { g as HextimatePreset } from './HextimatePaletteBuilder-REeEsEOu.js';
1
+ import { g as HextimatePreset, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BsQOgUcZ.js';
2
2
 
3
3
  /**
4
4
  * Darker accents on light themes, lighter accents on dark themes.
@@ -6,6 +6,19 @@ import { g as HextimatePreset } from './HextimatePaletteBuilder-REeEsEOu.js';
6
6
  */
7
7
  declare const bold: HextimatePreset;
8
8
 
9
+ /**
10
+ * Accent color plus optional presets - plain, serializable theme input.
11
+ *
12
+ * Shared vocabulary between app code and tooling: the same object an app runs
13
+ * is the object a design-tool plugin runs.
14
+ */
15
+ type HextimateConfig = {
16
+ color: ColorInput;
17
+ presets?: HextimatePreset[];
18
+ };
19
+ /** Apply a {@link HextimateConfig}: `hextimate(color)` then each preset in order. */
20
+ declare function fromConfig(c: HextimateConfig): HextimatePaletteBuilder;
21
+
9
22
  /**
10
23
  * Preset for Material UI (MUI) projects.
11
24
  *
@@ -65,6 +78,7 @@ declare const tinted: HextimatePreset;
65
78
  /** High-saturation palette. Colors that pop. */
66
79
  declare const vibrant: HextimatePreset;
67
80
 
81
+ type index_HextimateConfig = HextimateConfig;
68
82
  declare const index_HextimatePreset: typeof HextimatePreset;
69
83
  declare const index_bold: typeof bold;
70
84
  declare const index_mui: typeof mui;
@@ -73,7 +87,7 @@ declare const index_shadcn: typeof shadcn;
73
87
  declare const index_tinted: typeof tinted;
74
88
  declare const index_vibrant: typeof vibrant;
75
89
  declare namespace index {
76
- export { index_HextimatePreset as HextimatePreset, index_bold as bold, index_mui as mui, index_muted as muted, index_shadcn as shadcn, index_tinted as tinted, index_vibrant as vibrant };
90
+ export { type index_HextimateConfig as HextimateConfig, index_HextimatePreset as HextimatePreset, index_bold as bold, index_mui as mui, index_muted as muted, index_shadcn as shadcn, index_tinted as tinted, index_vibrant as vibrant };
77
91
  }
78
92
 
79
- export { muted as a, bold as b, index as i, mui as m, shadcn as s, tinted as t, vibrant as v };
93
+ export { type HextimateConfig as H, muted as a, bold as b, fromConfig as f, index as i, mui as m, shadcn as s, tinted as t, vibrant as v };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-REeEsEOu.js';
2
- export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, j as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-REeEsEOu.js';
3
- export { i as presets } from './index-DSfF_JsR.js';
1
+ import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BsQOgUcZ.js';
2
+ export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, j as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BsQOgUcZ.js';
3
+ export { H as HextimateConfig, f as fromConfig, i as presets } from './index-CA19MMV4.js';
4
4
 
5
5
  /**
6
6
  * Daltonize a color for a specific type of color vision deficiency (CVD).
@@ -43,27 +43,6 @@ declare function simulateColor(color: Color, type: CVDType, severity?: number):
43
43
  */
44
44
  declare function convert<S extends ColorSpace>(color: Color, to: S): ColorInSpace<S>;
45
45
 
46
- /**
47
- * Parse a ColorInput into a Color.
48
- *
49
- * If the input is already a Color, it will be returned as is.
50
- * If the input is a number, it will be parsed as a numeric hex value.
51
- * If the input is a string, it will be parsed as a hex value, CSS function, or comma separated values.
52
- * If the input is a tuple, it will be parsed as a color tuple.
53
- * If the input is a CSS function string, it will be parsed as a CSS function.
54
- * If the input is a comma separated values string, it will be parsed as a comma separated values.
55
- *
56
- * **Alpha is always set to 1.** Transparent inputs like `rgba(255,0,0,0.5)` are treated as
57
- * fully opaque. This is intentional: alpha tokens break WCAG contrast guarantees because
58
- * contrast ratios depend on whatever is rendered behind the element, which hextimator cannot
59
- * know at generation time.
60
- *
61
- * @param input ColorInput
62
- * @param assumeSpace color space to assume. If not provided, the color space will be inferred from the input, and default to 'srgb' if ambiguous
63
- * @returns Color or throws a ColorParseError if parsing fails
64
- */
65
- declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
66
-
67
46
  /** Thrown when `hextimate()` fails to parse or generate a palette from the given input. */
68
47
  declare class HextimateError extends Error {
69
48
  readonly input: ColorInput;
@@ -87,4 +66,25 @@ declare class HextimateError extends Error {
87
66
  */
88
67
  declare function hextimate(color: ColorInput): HextimatePaletteBuilder;
89
68
 
69
+ /**
70
+ * Parse a ColorInput into a Color.
71
+ *
72
+ * If the input is already a Color, it will be returned as is.
73
+ * If the input is a number, it will be parsed as a numeric hex value.
74
+ * If the input is a string, it will be parsed as a hex value, CSS function, or comma separated values.
75
+ * If the input is a tuple, it will be parsed as a color tuple.
76
+ * If the input is a CSS function string, it will be parsed as a CSS function.
77
+ * If the input is a comma separated values string, it will be parsed as a comma separated values.
78
+ *
79
+ * **Alpha is always set to 1.** Transparent inputs like `rgba(255,0,0,0.5)` are treated as
80
+ * fully opaque. This is intentional: alpha tokens break WCAG contrast guarantees because
81
+ * contrast ratios depend on whatever is rendered behind the element, which hextimator cannot
82
+ * know at generation time.
83
+ *
84
+ * @param input ColorInput
85
+ * @param assumeSpace color space to assume. If not provided, the color space will be inferred from the input, and default to 'srgb' if ambiguous
86
+ * @returns Color or throws a ColorParseError if parsing fails
87
+ */
88
+ declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
89
+
90
90
  export { CVDType, HextimateError, HextimatePaletteBuilder, convert as convertColor, daltonizeColor, hextimate, parse as parseColor, simulateColor };
package/dist/index.js CHANGED
@@ -3,10 +3,11 @@ import {
3
3
  HextimatePaletteBuilder,
4
4
  convert,
5
5
  daltonizeColor,
6
+ fromConfig,
6
7
  hextimate,
7
8
  parse,
8
9
  simulateColor
9
- } from "./chunk-SG5HNU7M.js";
10
+ } from "./chunk-V4RWDZQM.js";
10
11
  import {
11
12
  presets_exports
12
13
  } from "./chunk-TEZ2I4CJ.js";
@@ -15,6 +16,7 @@ export {
15
16
  HextimatePaletteBuilder,
16
17
  convert as convertColor,
17
18
  daltonizeColor,
19
+ fromConfig,
18
20
  hextimate,
19
21
  parse as parseColor,
20
22
  presets_exports as presets,
package/dist/presets.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-DSfF_JsR.js';
2
- export { g as HextimatePreset } from './HextimatePaletteBuilder-REeEsEOu.js';
1
+ export { H as HextimateConfig, b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-CA19MMV4.js';
2
+ export { g as HextimatePreset } from './HextimatePaletteBuilder-BsQOgUcZ.js';
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-REeEsEOu.js';
1
+ import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-BsQOgUcZ.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { PropsWithChildren, RefObject, CSSProperties, ReactNode } from 'react';
4
4
 
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hextimate
3
- } from "./chunk-SG5HNU7M.js";
3
+ } from "./chunk-V4RWDZQM.js";
4
4
  import "./chunk-TEZ2I4CJ.js";
5
5
 
6
6
  // src/react/hextimator-provider.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hextimator",
3
- "version": "0.12.2",
3
+ "version": "0.13.0",
4
4
  "description": "Runtime theming for multi-tenant apps.",
5
5
  "keywords": [
6
6
  "color-palette",