hextimator 0.7.0 → 0.9.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,4 +1,12 @@
1
- ## 0.7.0 (Latest)
1
+ ## 0.9.0 (Latest)
2
+
3
+ - Widens default semantic hue ranges (`positive` [120,160], `negative` [5,30], `warning` [45,70] OKLCH arcs). Themes using library defaults may get different semantic scales.
4
+
5
+ ## 0.8.0
6
+
7
+ - Adds optional `keyPrefix` on `HextimateFormatOptions` for flat `as: "object"` and `as: "json"` output (CLI: `--key-prefix`). Use `keyPrefix: "--"` when you want CSS custom property names as object keys without using stylesheet output.
8
+
9
+ ## 0.7.0
2
10
 
3
11
  - Adds an opt-in `invertedVariants: true` format option that emits an -inverted copy of every token holding the opposite mode's value, plus a companion hextimator/tailwind-inverted.css so utilities like `bg-surface-inverted` just work.
4
12
 
@@ -64,6 +72,7 @@ Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/ma
64
72
  ## 0.3.2
65
73
 
66
74
  - [#99](https://github.com/fgrgic/hextimator/pull/99): Adds option to chain presets. Presets are merged, last added wins if both touch the same tokens.
75
+
67
76
  - For example: `hextimate("#ff6677").preset(shadcn).preset(muted);`
68
77
  - It also works with cli: `npx hextimate "#ff6677" -p shadcn -p vibrant`
69
78
 
package/README.md CHANGED
@@ -175,12 +175,12 @@ Both options use internal names (before any `roleNames`/`variantNames` remapping
175
175
 
176
176
  All formats return `{ light: { ... }, dark: { ... } }`.
177
177
 
178
- - **`"object"`** (default) — plain keys: `accent`, `accent-strong`, …
178
+ - **`"object"`** (default) — plain keys: `accent`, `accent-strong`, … Optional **`keyPrefix: "--"`** gives `--accent`, `--accent-strong`, … when you need CSS-style names without stylesheet output.
179
179
  - **`"css"`** — CSS custom properties: `--accent`, `--accent-strong`, …
180
180
  - **`"tailwind"`** — nested tokens: `{ accent: { DEFAULT, strong, … } }`
181
181
  - **`"tailwind-css"`** — `@theme` block with `--color-accent`, `--color-accent-strong`, …
182
182
  - **`"scss"`** — SCSS variables: `$accent`, `$accent-strong`, …
183
- - **`"json"`** — JSON string of the plain object
183
+ - **`"json"`** — JSON string of the plain object (supports **`keyPrefix`** the same way as **`object`**)
184
184
 
185
185
  ### Color value formats
186
186
 
@@ -158,9 +158,9 @@ interface HextimateStyleOptions {
158
158
  * Degree ranges for the semantic colors.
159
159
  * Determines where to look for "green", "red", "yellow" in the color space.
160
160
  * If not provided, the default ranges will be used:
161
- * - positive: [135, 160] greens
162
- * - negative: [5, 25] reds
163
- * - warning: [45, 65] ambers
161
+ * - positive: [120, 160] greens
162
+ * - negative: [5, 30] reds
163
+ * - warning: [45, 70] ambers
164
164
  */
165
165
  semanticColorRanges?: {
166
166
  positive?: [number, number];
@@ -257,9 +257,19 @@ interface HextimateFormatOptions {
257
257
  * Use "_" for "surface_strong", "/" for "surface/strong", etc.
258
258
  */
259
259
  separator?: string;
260
+ /**
261
+ * String prepended to every flat token key in `as: "object"` and `as: "json"`.
262
+ * Use `"--"` for CSS custom property names (`"--surface"`, `"--accent-strong"`).
263
+ *
264
+ * Ignored for `scss` (`$` prefix), nested `tailwind`, and stylesheet outputs
265
+ * (`css`, `tailwind-css` already declare variables with `--`).
266
+ *
267
+ * Default: `""` (no prefix).
268
+ */
269
+ keyPrefix?: string;
260
270
  /**
261
271
  * Output format.
262
- * - "object" (default): { surface: "#f2eee8", "surface-strong": "#d4cfc8", ...}
272
+ * - "object" (default): { surface: "#f2eee8", "surface-strong": "#d4cfc8", ...} or with keyPrefix "--": { "--surface": "...", "--surface-strong": "..." }
263
273
  * - "css": ready-to-paste CSS stylesheet string with `:root {}` and a dark-mode wrapper
264
274
  * - "tailwind": { surface: { DEFAULT: "#f2eee8", strong: "#d4cfc8", weak: "#faf8f6" } }
265
275
  * - "scss": { $surface: "#f2eee8", $surface-strong: "#d4cfc8", ...}
@@ -570,7 +580,7 @@ declare class HextimatePaletteBuilder {
570
580
  * When a preset has been applied, its format options are used as defaults.
571
581
  * Any options passed here override the preset's defaults.
572
582
  *
573
- * @param options Format options controlling output shape (`as`), color serialization (`colors`), role/variant renaming, and separator.
583
+ * @param options Format options controlling output shape (`as`), color serialization (`colors`), role/variant renaming, separator, and optional flat-key `keyPrefix`.
574
584
  */
575
585
  format(options: HextimateFormatOptions & {
576
586
  as: 'tailwind';
@@ -868,10 +868,10 @@ function toFlatKey(entry, sep) {
868
868
  if (entry.isDefault && entry.variant === "DEFAULT") return entry.role;
869
869
  return `${entry.role}${sep}${entry.variant}`;
870
870
  }
871
- function formatObject(entries, sep) {
871
+ function formatObject(entries, sep, keyPrefix = "") {
872
872
  const result = {};
873
873
  for (const entry of entries) {
874
- result[toFlatKey(entry, sep)] = entry.value;
874
+ result[`${keyPrefix}${toFlatKey(entry, sep)}`] = entry.value;
875
875
  }
876
876
  return result;
877
877
  }
@@ -890,8 +890,8 @@ function formatTailwind(entries) {
890
890
  }
891
891
  return result;
892
892
  }
893
- function formatJSON(entries, sep) {
894
- return JSON.stringify(formatObject(entries, sep), null, 2);
893
+ function formatJSON(entries, sep, keyPrefix = "") {
894
+ return JSON.stringify(formatObject(entries, sep, keyPrefix), null, 2);
895
895
  }
896
896
  function declsFromEntries(entries, sep, prefix, indent) {
897
897
  return entries.map((e) => `${indent}${prefix}${toFlatKey(e, sep)}: ${e.value};`).join("\n");
@@ -950,15 +950,16 @@ function format(palette, options, standaloneTokens) {
950
950
  const entries = buildTokenEntries(palette, options);
951
951
  if (standaloneTokens) entries.push(...standaloneTokens);
952
952
  const sep = options?.separator ?? "-";
953
+ const keyPrefix = options?.keyPrefix ?? "";
953
954
  switch (options?.as) {
954
955
  case "scss":
955
956
  return formatSCSS(entries, sep);
956
957
  case "tailwind":
957
958
  return formatTailwind(entries);
958
959
  case "json":
959
- return formatJSON(entries, sep);
960
+ return formatJSON(entries, sep, keyPrefix);
960
961
  default:
961
- return formatObject(entries, sep);
962
+ return formatObject(entries, sep, keyPrefix);
962
963
  }
963
964
  }
964
965
  function formatStylesheet(lightPalette, darkPalette, options, lightStandalone, darkStandalone) {
@@ -1268,9 +1269,9 @@ function generateAccent(accent, themeType, options) {
1268
1269
  }
1269
1270
 
1270
1271
  // src/generate/generateSemanticColors.ts
1271
- var POSITIVE_RANGE = [135, 160];
1272
- var NEGATIVE_RANGE = [5, 25];
1273
- var WARNING_RANGE = [45, 65];
1272
+ var POSITIVE_RANGE = [120, 160];
1273
+ var NEGATIVE_RANGE = [5, 30];
1274
+ var WARNING_RANGE = [45, 70];
1274
1275
  function generateSemanticColors(color, themeType, options) {
1275
1276
  const positiveBaseColor = parse(
1276
1277
  options?.semanticColors?.positive ?? _determineBaseColorFromRange(
package/dist/cli.js CHANGED
@@ -876,10 +876,10 @@ function toFlatKey(entry, sep) {
876
876
  if (entry.isDefault && entry.variant === "DEFAULT") return entry.role;
877
877
  return `${entry.role}${sep}${entry.variant}`;
878
878
  }
879
- function formatObject(entries, sep) {
879
+ function formatObject(entries, sep, keyPrefix = "") {
880
880
  const result = {};
881
881
  for (const entry of entries) {
882
- result[toFlatKey(entry, sep)] = entry.value;
882
+ result[`${keyPrefix}${toFlatKey(entry, sep)}`] = entry.value;
883
883
  }
884
884
  return result;
885
885
  }
@@ -898,8 +898,8 @@ function formatTailwind(entries) {
898
898
  }
899
899
  return result;
900
900
  }
901
- function formatJSON(entries, sep) {
902
- return JSON.stringify(formatObject(entries, sep), null, 2);
901
+ function formatJSON(entries, sep, keyPrefix = "") {
902
+ return JSON.stringify(formatObject(entries, sep, keyPrefix), null, 2);
903
903
  }
904
904
  function declsFromEntries(entries, sep, prefix, indent) {
905
905
  return entries.map((e) => `${indent}${prefix}${toFlatKey(e, sep)}: ${e.value};`).join("\n");
@@ -958,15 +958,16 @@ function format(palette, options, standaloneTokens) {
958
958
  const entries = buildTokenEntries(palette, options);
959
959
  if (standaloneTokens) entries.push(...standaloneTokens);
960
960
  const sep = options?.separator ?? "-";
961
+ const keyPrefix = options?.keyPrefix ?? "";
961
962
  switch (options?.as) {
962
963
  case "scss":
963
964
  return formatSCSS(entries, sep);
964
965
  case "tailwind":
965
966
  return formatTailwind(entries);
966
967
  case "json":
967
- return formatJSON(entries, sep);
968
+ return formatJSON(entries, sep, keyPrefix);
968
969
  default:
969
- return formatObject(entries, sep);
970
+ return formatObject(entries, sep, keyPrefix);
970
971
  }
971
972
  }
972
973
  function formatStylesheet(lightPalette, darkPalette, options, lightStandalone, darkStandalone) {
@@ -1276,9 +1277,9 @@ function generateAccent(accent, themeType, options) {
1276
1277
  }
1277
1278
 
1278
1279
  // src/generate/generateSemanticColors.ts
1279
- var POSITIVE_RANGE = [135, 160];
1280
- var NEGATIVE_RANGE = [5, 25];
1281
- var WARNING_RANGE = [45, 65];
1280
+ var POSITIVE_RANGE = [120, 160];
1281
+ var NEGATIVE_RANGE = [5, 30];
1282
+ var WARNING_RANGE = [45, 70];
1282
1283
  function generateSemanticColors(color, themeType, options) {
1283
1284
  const positiveBaseColor = parse(
1284
1285
  options?.semanticColors?.positive ?? _determineBaseColorFromRange(
@@ -2339,6 +2340,7 @@ Format options:
2339
2340
  --dark-mode <strategy> media | class | data-attribute | off (css/tailwind-css only, default: media)
2340
2341
  --selector <css> Root selector for css output (default: :root)
2341
2342
  --separator <char> Token separator (default: -)
2343
+ --key-prefix <str> Prepend to keys (object/json only); use -- for CSS vars (default: empty)
2342
2344
  --exclude-role <name> Omit a role from output (repeatable)
2343
2345
  --exclude-variant <name> Omit a variant from output (repeatable)
2344
2346
 
@@ -2398,6 +2400,7 @@ function run() {
2398
2400
  "dark-mode": { type: "string" },
2399
2401
  selector: { type: "string" },
2400
2402
  separator: { type: "string" },
2403
+ "key-prefix": { type: "string" },
2401
2404
  "exclude-role": { type: "string", multiple: true },
2402
2405
  "exclude-variant": { type: "string", multiple: true },
2403
2406
  "surface-color": { type: "string" },
@@ -2566,6 +2569,9 @@ function run() {
2566
2569
  } else if (!hasPreset) {
2567
2570
  formatOptions.separator = "-";
2568
2571
  }
2572
+ if (values["key-prefix"] !== void 0) {
2573
+ formatOptions.keyPrefix = values["key-prefix"];
2574
+ }
2569
2575
  if (values["exclude-role"]?.length) {
2570
2576
  formatOptions.excludeRoles = values["exclude-role"];
2571
2577
  }
@@ -1,4 +1,4 @@
1
- import { h as HextimatePreset } from './HextimatePaletteBuilder-Bc-GHsBy.js';
1
+ import { h as HextimatePreset } from './HextimatePaletteBuilder-doYcUGMD.js';
2
2
 
3
3
  /**
4
4
  * Darker accents on light themes, lighter accents on dark themes.
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-Bc-GHsBy.js';
2
- export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimateOptions, h as HextimatePreset, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-Bc-GHsBy.js';
3
- export { i as presets } from './index-B9eHpF-F.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-doYcUGMD.js';
2
+ export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimateOptions, h as HextimatePreset, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-doYcUGMD.js';
3
+ export { i as presets } from './index-rFqBuFuF.js';
4
4
 
5
5
  /**
6
6
  * Daltonize a color for a specific type of color vision deficiency (CVD).
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  hextimate,
7
7
  parse,
8
8
  simulateColor
9
- } from "./chunk-4WWRI5QJ.js";
9
+ } from "./chunk-PJSNOIIB.js";
10
10
  import {
11
11
  presets_exports
12
12
  } from "./chunk-NTF3K3U3.js";
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-B9eHpF-F.js';
2
- export { h as HextimatePreset } from './HextimatePaletteBuilder-Bc-GHsBy.js';
1
+ export { b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-rFqBuFuF.js';
2
+ export { h as HextimatePreset } from './HextimatePaletteBuilder-doYcUGMD.js';
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { j as HextimateStyleOptions, h as HextimatePreset, H as HextimatePaletteBuilder, i as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-Bc-GHsBy.js';
1
+ import { j as HextimateStyleOptions, h as HextimatePreset, H as HextimatePaletteBuilder, i as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-doYcUGMD.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-4WWRI5QJ.js";
3
+ } from "./chunk-PJSNOIIB.js";
4
4
  import "./chunk-NTF3K3U3.js";
5
5
 
6
6
  // src/react/hextimator-provider.tsx
package/llms.txt CHANGED
@@ -57,18 +57,19 @@ Tune how the palette is built with `.style(partial)` (`HextimateStyleOptions`, s
57
57
  | `roleNames` | `Record<string, string>` — rename roles in output keys | built-in names |
58
58
  | `variantNames` | `Record<string, string>` — rename variant suffixes | built-in names |
59
59
  | `separator` | `string` — between role and variant in keys | `"-"` |
60
+ | `keyPrefix` | `string` — prepended to each key (`object` / `json` only); e.g. `"--"` for CSS vars | `""` |
60
61
  | `darkMode` | `"media"`, `"class"`, `"data-attribute"`, `false` (stylesheet outputs only) | `"media"` |
61
62
  | `selector` | `string` — root selector for `as: "css"` | `":root"` |
62
63
  | `excludeRoles` | `string[]` — role keys to omit entirely from output (by internal name, before `roleNames`) | `[]` |
63
64
  | `excludeVariants` | `string[]` — variant keys to omit from every role's output (by internal name, before `variantNames`) | `[]` |
64
65
 
65
66
  Output shape depends on `as`:
66
- - `"object"` → `{ light, dark }` flat maps: `{ accent: "#...", "accent-strong": "#..." }`
67
+ - `"object"` → `{ light, dark }` flat maps: `{ accent: "#...", "accent-strong": "#..." }` (with `keyPrefix: "--"`: `{ "--accent": "...", "--accent-strong": "..." }`)
67
68
  - `"css"` → `string` — ready-to-paste CSS stylesheet with `:root {}` and a dark-mode wrapper
68
69
  - `"tailwind"` → `{ light, dark }` nested maps: `{ accent: { DEFAULT: "#...", strong: "#..." } }`
69
70
  - `"tailwind-css"` → `string` — Tailwind v4 stylesheet: single `@theme { --color-accent: #...; }` block plus dark overrides
70
71
  - `"scss"` → `{ light, dark }` flat maps: `{ "$accent": "#...", "$accent-strong": "#..." }`
71
- - `"json"` → `{ light, dark }` JSON strings
72
+ - `"json"` → `{ light, dark }` JSON strings (`keyPrefix` applies like `"object"`)
72
73
 
73
74
  Pick the dark wrapper with `darkMode`: `"media"` (default) wraps dark tokens in `@media (prefers-color-scheme: dark)`; `"class"` uses `.dark`; `"data-attribute"` uses `[data-theme="dark"]`; `false` omits dark entirely. For `as: "css"`, change the root selector with `selector` (e.g. `selector: "[data-theme]"`).
74
75
 
@@ -80,7 +81,7 @@ Pick the dark wrapper with `darkMode`: `"media"` (default) wraps dark tokens in
80
81
  | `surfaceHueShift` | degrees | `0` | Rotate surface hue relative to accent. Ignored if `surfaceColor` set |
81
82
  | `invertDarkModeSurfaceAccent` | boolean | `false` | Swap surface/accent hues in dark mode. Useful when the accent should become the background in dark mode. Requires `surfaceColor` |
82
83
  | `semanticColors` | `{ positive?, negative?, warning? }` | auto | Override semantic colors (green/red/amber) |
83
- | `semanticColorRanges` | `{ positive?: [start,end], ... }` | greens, reds, ambers | Hue ranges for semantic detection |
84
+ | `semanticColorRanges` | `{ positive?: [start,end], ... }` | `positive: [120,160]`, `negative: [5,30]`, `warning: [45,70]` | OKLCH hue degree arcs for picking semantic bases (clockwise; `[350,10]` wraps) |
84
85
  | `surfaceMaxChroma` | number | `0.01` | Max chroma for surface colors |
85
86
  | `foregroundMaxChroma` | number | `0.01` | Max chroma for foreground colors |
86
87
  | `light` | `{ baseLightness?, maxChroma? }` | `{ baseLightness: 0.7 }` | Light theme adjustments. `baseLightness` is the absolute OKLCH anchor for the accent (distinct from the relative `lightness` offset on derived tokens) |
@@ -181,6 +182,10 @@ const myPreset: HextimatePreset = {
181
182
  // Derive a secondary role by rotating the accent hue
182
183
  { name: "secondary", color: { from: "accent", hue: 180 } },
183
184
  ],
185
+ variants: [
186
+ { name: "muted", placement: { from: "weak" } },
187
+ { name: "emphasis", placement: { from: "strong" } },
188
+ ],
184
189
  tokens: [
185
190
  // Canvas tokens derived from surface
186
191
  { name: "canvas", value: { from: "surface" } },
@@ -298,6 +303,7 @@ Both commands are identical. Use whichever you prefer.
298
303
  | `-t, --theme` | `light`, `dark`, `both` (ignored for `css`/`tailwind-css` — both always combine into one string) | `both` |
299
304
  | `-p, --preset` | Apply preset (repeatable, applied in order): `shadcn`, `mui`, `muted`, `vibrant`, `tinted` | — |
300
305
  | `--separator` | Token separator between role and variant | `-` |
306
+ | `--key-prefix` | Prepend to keys (`object` / `json` only); pass `--` for CSS custom properties | empty |
301
307
  | `--dark-mode` | `media`, `class`, `data-attribute`, `false` (stylesheet outputs only) | `media` |
302
308
  | `--selector` | Root selector for `--format css` | `:root` |
303
309
  | `--exclude-role` | Omit a role from output by internal name (repeatable) | — |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hextimator",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Runtime theming for multi-tenant apps: per-tenant branded themes from a single brand color, with WCAG contrast guarantees.",
5
5
  "keywords": [
6
6
  "runtime-theming",