@lgtm-hq/turbo-themes 0.31.0 → 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.
Files changed (26) hide show
  1. package/dist/adapters/tailwind/{colors-C59xB8zn.js → colors-Bz6MUnF4.js} +15 -8
  2. package/dist/adapters/tailwind/colors.js +1 -1
  3. package/dist/adapters/tailwind/preset.js +1 -1
  4. package/dist/tokens/style-dictionary/themes.json +2 -2
  5. package/dist/tokens/style-dictionary/tokens.json +2 -2
  6. package/package.json +13 -5
  7. package/packages/adapters/home-assistant/dist/index.d.ts +122 -0
  8. package/packages/adapters/home-assistant/dist/index.js +796 -0
  9. package/packages/adapters/home-assistant/dist/index.js.map +1 -0
  10. package/packages/adapters/tailwind/dist/{colors-C59xB8zn.js → colors-Bz6MUnF4.js} +15 -8
  11. package/packages/adapters/tailwind/dist/colors-Bz6MUnF4.js.map +1 -0
  12. package/packages/adapters/tailwind/dist/colors.js +1 -1
  13. package/packages/adapters/tailwind/dist/preset.js +1 -1
  14. package/packages/core/dist/themes/generated/metadata.d.ts +154 -0
  15. package/packages/core/dist/themes/generated/metadata.d.ts.map +1 -0
  16. package/packages/core/dist/themes/generated/metadata.js +195 -0
  17. package/packages/core/dist/themes/generated/metadata.js.map +1 -0
  18. package/packages/core/dist/themes/metadata.d.ts +6 -1
  19. package/packages/core/dist/themes/metadata.d.ts.map +1 -1
  20. package/packages/core/dist/themes/metadata.js +8 -15
  21. package/packages/core/dist/themes/metadata.js.map +1 -1
  22. package/packages/core/dist/themes/tokens.json +2 -2
  23. package/packages/theme-selector/dist/index.d.ts +2 -1
  24. package/packages/theme-selector/dist/index.js +135 -130
  25. package/packages/theme-selector/dist/index.js.map +1 -1
  26. package/packages/adapters/tailwind/dist/colors-C59xB8zn.js.map +0 -1
@@ -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.0",
7
- $generated: "198842d2a7520c69132dfc9b5e52842c0bb23445c6c0b70a72516c41726ffb58",
6
+ $version: "0.32.0",
7
+ $generated: "bc7967eb4d4221a64b2b156dfb9ca8a00be42bc3be06dc1e2d43368b1d8cd0ea",
8
8
  meta: {
9
9
  "themeIds": [
10
10
  "bulma-dark",
@@ -181,13 +181,13 @@ function getTheme(id) {
181
181
  */
182
182
  var themeIds = /* @__PURE__ */ flavors.map((f) => f.id);
183
183
  [...new Set(flavors.map((f) => f.vendor))];
184
- flavors.map((f) => [f.id, f.label]);
185
- flavors.map((f) => [f.id, f.appearance]);
184
+ //#endregion
185
+ //#region ../../core/dist/themes/generated/metadata.js
186
186
  /**
187
187
  * Ordered list of vendor IDs controlling display order in dropdowns.
188
- * New vendors should be appended here.
188
+ * Source: schema/tokens/_vendors.json
189
189
  */
190
- var VENDOR_ORDER = [
190
+ var VENDOR_ORDER$1 = [
191
191
  "catppuccin",
192
192
  "dracula",
193
193
  "gruvbox",
@@ -200,8 +200,15 @@ var VENDOR_ORDER = [
200
200
  "one-dark",
201
201
  "turbo"
202
202
  ];
203
+ flavors.map((f) => [f.id, f.label]);
204
+ flavors.map((f) => [f.id, f.appearance]);
205
+ /**
206
+ * Ordered list of vendor IDs controlling display order in dropdowns.
207
+ * Generated from schema/tokens/_vendors.json — do not edit by hand.
208
+ */
209
+ var VENDOR_ORDER = VENDOR_ORDER$1;
203
210
  var _missingFromOrder = Object.keys(packages).filter((id) => !VENDOR_ORDER.includes(id));
204
- if (_missingFromOrder.length > 0) console.warn(`[metadata] VENDOR_ORDER is missing vendor IDs present in packages: ${_missingFromOrder.join(", ")}. Append them to VENDOR_ORDER so their themes are included in VENDOR_GROUPS.`);
211
+ if (_missingFromOrder.length > 0) console.warn(`[metadata] VENDOR_ORDER is missing vendor IDs present in packages: ${_missingFromOrder.join(", ")}. Append them to schema/tokens/_vendors.json and regenerate metadata.`);
205
212
  var VENDOR_GROUPS = /* @__PURE__ */ VENDOR_ORDER.filter((id) => id in packages).map((id) => {
206
213
  const pkg = packages[id];
207
214
  return {
@@ -449,4 +456,4 @@ function createThemeCssVariables(themeId) {
449
456
  //#endregion
450
457
  export { themeIds as a, getTheme as i, createThemeCssVariables as n, themesById as o, getAllThemeColors as r, createColorMappings as t };
451
458
 
452
- //# sourceMappingURL=colors-C59xB8zn.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-C59xB8zn.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-C59xB8zn.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.0",
5
- "$generated": "c49ad6dfccbeac0986065363d20922d6b4aea60499fd96b6548379a76b57439e",
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.0",
5
- "$generated": "198842d2a7520c69132dfc9b5e52842c0bb23445c6c0b70a72516c41726ffb58",
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.0",
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",
@@ -110,14 +114,14 @@
110
114
  ],
111
115
  "scripts": {
112
116
  "build": "bun run build:tokens && bun run build:packages && bun run theme:sync && bun run build:root && node scripts/copy-adapters.mjs && bun run generate:css",
113
- "build:tokens": "node scripts/codegen/validate-schema.mjs && node scripts/prepare-style-dictionary.mjs && node scripts/codegen/generate-catalog.mjs && node scripts/build-style-dictionary.mjs && bun run build:tokens:copy",
117
+ "build:tokens": "bun scripts/codegen/validate-schema.mjs && bun scripts/prepare-style-dictionary.mjs && bun scripts/codegen/generate-metadata.mjs && bun scripts/codegen/generate-catalog.mjs && bun scripts/build-style-dictionary.mjs && bun run build:tokens:copy",
114
118
  "build:tokens:copy": "cp dist/tokens/style-dictionary/tokens.json packages/core/src/themes/tokens.json && cp dist/tokens/style-dictionary/tokens.json python/src/turbo_themes/tokens.json && cp dist/tokens/style-dictionary/tokens.json swift/Sources/TurboThemes/Resources/tokens.json",
115
- "build:sd": "node scripts/prepare-style-dictionary.mjs && node scripts/codegen/generate-catalog.mjs && node scripts/build-style-dictionary.mjs",
119
+ "build:sd": "bun scripts/prepare-style-dictionary.mjs && bun scripts/codegen/generate-metadata.mjs && bun scripts/codegen/generate-catalog.mjs && bun scripts/build-style-dictionary.mjs",
116
120
  "build:packages": "bun run build:core && bun run build:selector && bun run build:css-pkg && bun run build:adapters",
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",
@@ -177,7 +181,9 @@
177
181
  "prepare": "husky || true",
178
182
  "prepublishOnly": "bun run build && bun run build:themes && bun run test",
179
183
  "build:tokens:css": "bun run build:tokens",
180
- "build:tokens:python": "bun run build:tokens"
184
+ "build:tokens:python": "bun run build:tokens",
185
+ "generate:metadata": "bun scripts/codegen/generate-metadata.mjs",
186
+ "check:generated": "./scripts/ci/verify-generated-tokens.sh"
181
187
  },
182
188
  "lint-staged": {
183
189
  "*.{js,jsx,ts,tsx,mjs,cjs,json,md,yml,yaml,css,html}": [
@@ -194,6 +200,7 @@
194
200
  "@primer/primitives": "11.7.1",
195
201
  "@rose-pine/palette": "4.0.1",
196
202
  "@testing-library/react": "16.3.2",
203
+ "@types/js-yaml": "4.0.9",
197
204
  "@types/react": "19.2.14",
198
205
  "@types/react-dom": "19.2.3",
199
206
  "@vitest/coverage-v8": "4.1.5",
@@ -205,6 +212,7 @@
205
212
  "happy-dom": "20.9.0",
206
213
  "http-server": "14.1.1",
207
214
  "husky": "9.1.7",
215
+ "js-yaml": "4.2.0",
208
216
  "lightningcss": "1.32.0",
209
217
  "lint-staged": "16.4.0",
210
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 { }