@lgtm-hq/turbo-themes 0.31.1 → 0.32.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.
@@ -3,8 +3,8 @@
3
3
  var tokens = {
4
4
  $schema: "https://design-tokens.org/schema.json",
5
5
  $description: "Turbo Themes - Flat tokens for 27 themes",
6
- $version: "0.31.1",
7
- $generated: "bd0d207423eeb729df7a9e1be1fdd01821b2fa02b214ee1df6f0dd1440aef300",
6
+ $version: "0.32.0",
7
+ $generated: "bc7967eb4d4221a64b2b156dfb9ca8a00be42bc3be06dc1e2d43368b1d8cd0ea",
8
8
  meta: {
9
9
  "themeIds": [
10
10
  "bulma-dark",
@@ -456,4 +456,4 @@ function createThemeCssVariables(themeId) {
456
456
  //#endregion
457
457
  export { themeIds as a, getTheme as i, createThemeCssVariables as n, themesById as o, getAllThemeColors as r, createColorMappings as t };
458
458
 
459
- //# sourceMappingURL=colors-DqaAtzaI.js.map
459
+ //# sourceMappingURL=colors-Bz6MUnF4.js.map
@@ -1,2 +1,2 @@
1
- import { n as createThemeCssVariables, r as getAllThemeColors, t as createColorMappings } from "./colors-DqaAtzaI.js";
1
+ import { n as createThemeCssVariables, r as getAllThemeColors, t as createColorMappings } from "./colors-Bz6MUnF4.js";
2
2
  export { createColorMappings, createThemeCssVariables, getAllThemeColors };
@@ -1,4 +1,4 @@
1
- import { a as themeIds, i as getTheme, o as themesById, t as createColorMappings } from "./colors-DqaAtzaI.js";
1
+ import { a as themeIds, i as getTheme, o as themesById, t as createColorMappings } from "./colors-Bz6MUnF4.js";
2
2
  //#region preset.ts
3
3
  /**
4
4
  * Tailwind CSS preset for Turbo Themes
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://design-tokens.org/schema.json",
3
3
  "$description": "Turbo Themes - Design tokens for 27 themes",
4
- "$version": "0.31.1",
5
- "$generated": "11eac89550fb538f6e88ec4c02f22b744acba351f1ead37db2757786fefb5c66",
4
+ "$version": "0.32.0",
5
+ "$generated": "4ce70bff7096b0a99deb989139e9f1a9789eeaa2b3f9258d358f2161dd4b0b8b",
6
6
  "meta": {
7
7
  "themeIds": [
8
8
  "bulma-dark",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://design-tokens.org/schema.json",
3
3
  "$description": "Turbo Themes - Flat tokens for 27 themes",
4
- "$version": "0.31.1",
5
- "$generated": "bd0d207423eeb729df7a9e1be1fdd01821b2fa02b214ee1df6f0dd1440aef300",
4
+ "$version": "0.32.0",
5
+ "$generated": "bc7967eb4d4221a64b2b156dfb9ca8a00be42bc3be06dc1e2d43368b1d8cd0ea",
6
6
  "meta": {
7
7
  "themeIds": [
8
8
  "bulma-dark",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lgtm-hq/turbo-themes",
3
- "version": "0.31.1",
3
+ "version": "0.32.0",
4
4
  "description": "Universal theme packs and an accessible theme selector.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -92,6 +92,10 @@
92
92
  "./adapters/bulma.css": {
93
93
  "types": "./packages/adapters/bulma/dist/bulma-adapter.css.d.ts",
94
94
  "default": "./packages/adapters/bulma/dist/bulma-adapter.css"
95
+ },
96
+ "./adapters/home-assistant": {
97
+ "types": "./packages/adapters/home-assistant/dist/index.d.ts",
98
+ "import": "./packages/adapters/home-assistant/dist/index.js"
95
99
  }
96
100
  },
97
101
  "types": "./dist/index.d.ts",
@@ -117,7 +121,7 @@
117
121
  "build:core": "cd packages/core && bun run build",
118
122
  "build:selector": "cd packages/theme-selector && bun run build",
119
123
  "build:css-pkg": "cd packages/css && bun run build",
120
- "build:adapters": "cd packages/adapters/tailwind && bun run build && cd ../bulma && bun run build",
124
+ "build:adapters": "cd packages/adapters/tailwind && bun run build && cd ../bulma && bun run build && cd ../home-assistant && bun run build",
121
125
  "build:root": "tsc -p tsconfig.json",
122
126
  "generate:all": "bun run build:tokens && bun run generate:types",
123
127
  "generate:css": "cd packages/css && bun run build:css && cd ../.. && bun run generate:css-dts",
@@ -196,6 +200,7 @@
196
200
  "@primer/primitives": "11.7.1",
197
201
  "@rose-pine/palette": "4.0.1",
198
202
  "@testing-library/react": "16.3.2",
203
+ "@types/js-yaml": "4.0.9",
199
204
  "@types/react": "19.2.14",
200
205
  "@types/react-dom": "19.2.3",
201
206
  "@vitest/coverage-v8": "4.1.5",
@@ -207,6 +212,7 @@
207
212
  "happy-dom": "20.9.0",
208
213
  "http-server": "14.1.1",
209
214
  "husky": "9.1.7",
215
+ "js-yaml": "4.2.0",
210
216
  "lightningcss": "1.32.0",
211
217
  "lint-staged": "16.4.0",
212
218
  "oxfmt": "0.48.0",
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Home Assistant theme adapter for Turbo Themes.
3
+ *
4
+ * Emits a single Home Assistant `themes.yaml`-compatible YAML string that maps
5
+ * Turbo theme tokens onto Home Assistant frontend theme variables. Every value is
6
+ * a concrete hex color or `R, G, B` triplet, so the artifact is self-contained.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+
11
+ import { ThemeTokens } from '../../../core/dist/index.js/themes/types';
12
+
13
+ /**
14
+ * Validate every pairing, throwing on the first problem.
15
+ *
16
+ * @param pairings - Pairings to validate (defaults to {@link AUTO_THEME_PAIRINGS}).
17
+ * @throws If any pairing is invalid; see {@link resolveAutoTheme}.
18
+ */
19
+ export declare function assertPairingsValid(pairings?: readonly AutoThemePairing[]): void;
20
+
21
+ /** Dark/light flavor pairings, one per vendor family, emitted as auto themes. */
22
+ export declare const AUTO_THEME_PAIRINGS: readonly AutoThemePairing[];
23
+
24
+ /** A dark/light pairing that becomes a single Home Assistant auto theme. */
25
+ export declare interface AutoThemePairing {
26
+ /** Human-readable Home Assistant theme name, e.g. `"Catppuccin (Auto)"`. */
27
+ readonly name: string;
28
+ /** Registry id of the dark flavor (also used for the flat top-level keys). */
29
+ readonly dark: string;
30
+ /** Registry id of the light flavor. */
31
+ readonly light: string;
32
+ }
33
+
34
+ /**
35
+ * Fixed card-mod hook value. This is an inert marker unless the optional
36
+ * `card-mod` custom component is installed; it never affects core Home Assistant.
37
+ */
38
+ export declare const CARD_MOD_THEME = "turbo-themes";
39
+
40
+ /**
41
+ * YAML emitter for the Home Assistant adapter.
42
+ *
43
+ * Hand-rolls a deterministic Home Assistant `themes.yaml` document from the Turbo
44
+ * theme registry. js-yaml is intentionally not used at runtime so the adapter has
45
+ * no serialization dependency; tests parse the output with js-yaml to validate it.
46
+ */
47
+ /**
48
+ * Generate the Home Assistant themes YAML document.
49
+ *
50
+ * Flat themes are emitted first, sorted alphabetically by theme id for
51
+ * determinism, followed by the auto (dark/light paired) themes in
52
+ * {@link AUTO_THEME_PAIRINGS} order.
53
+ *
54
+ * @returns The full YAML document as a string.
55
+ * @throws If any auto-theme pairing is invalid (see {@link assertPairingsValid}).
56
+ */
57
+ export declare function generateHomeAssistantThemes(): string;
58
+
59
+ /**
60
+ * Color helpers for the Home Assistant adapter.
61
+ *
62
+ * Home Assistant expects some frontend variables (the `rgb-*` family) to be a
63
+ * bare `"R, G, B"` triplet rather than a `rgb()`/hex value, because it composes
64
+ * them into `rgba(var(--rgb-primary-color), 0.5)` style expressions internally.
65
+ */
66
+ /**
67
+ * Parse a `#rgb` or `#rrggbb` hex string into its red/green/blue components.
68
+ *
69
+ * @param hex - Hex color string, with a leading `#`.
70
+ * @returns The `[r, g, b]` channel values (0-255).
71
+ * @throws If the input is not a valid 3- or 6-digit hex color.
72
+ */
73
+ export declare function hexToRgb(hex: string): [number, number, number];
74
+
75
+ /**
76
+ * Convert a hex color to a bare `"R, G, B"` triplet string (no `rgb()` wrapper).
77
+ *
78
+ * @param hex - Hex color string, with a leading `#`.
79
+ * @returns The comma-separated triplet, e.g. `"137, 180, 250"`.
80
+ * @throws If the input is not a valid 3- or 6-digit hex color.
81
+ */
82
+ export declare function hexToRgbTriplet(hex: string): string;
83
+
84
+ /**
85
+ * Map a single theme's tokens onto Home Assistant frontend variables.
86
+ *
87
+ * All color values are concrete hex strings (no CSS `var()` references), and the
88
+ * `rgb-*` family is emitted as bare `"R, G, B"` triplets as Home Assistant expects.
89
+ *
90
+ * @param tokens - The platform-agnostic Turbo theme tokens.
91
+ * @returns A record of Home Assistant variable name → value, ordered to match
92
+ * {@link REQUIRED_KEYS}.
93
+ */
94
+ export declare function mapTokensToHomeAssistant(tokens: ThemeTokens): Record<string, string>;
95
+
96
+ /**
97
+ * Every Home Assistant variable key emitted per theme, in deterministic order.
98
+ *
99
+ * The emitter walks this list to serialize each theme, and
100
+ * {@link mapTokensToHomeAssistant} produces a record whose keys match this list
101
+ * exactly (verified in tests).
102
+ */
103
+ export declare const REQUIRED_KEYS: readonly string[];
104
+
105
+ /**
106
+ * Resolve a pairing to its concrete dark/light tokens, validating as it goes.
107
+ *
108
+ * @param pairing - The pairing to resolve.
109
+ * @returns The pairing name plus the resolved dark and light token sets.
110
+ * @throws If either id is missing from the registry, or an id's appearance does
111
+ * not match the slot it occupies (dark slot must be dark, light slot light).
112
+ */
113
+ export declare function resolveAutoTheme(pairing: AutoThemePairing): ResolvedAutoTheme;
114
+
115
+ /** A pairing whose dark/light flavors have been resolved to concrete tokens. */
116
+ export declare interface ResolvedAutoTheme {
117
+ readonly name: string;
118
+ readonly darkTokens: ThemeTokens;
119
+ readonly lightTokens: ThemeTokens;
120
+ }
121
+
122
+ export { }