@fluid-app/rep-core 0.1.0 → 0.1.2

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 (179) hide show
  1. package/dist/chunk-2IFFXFJL.js +621 -0
  2. package/dist/chunk-2IFFXFJL.js.map +1 -0
  3. package/dist/chunk-2SIG55BD.cjs +131 -0
  4. package/dist/chunk-2SIG55BD.cjs.map +1 -0
  5. package/dist/chunk-2SPTFZRC.js +72 -0
  6. package/dist/chunk-2SPTFZRC.js.map +1 -0
  7. package/dist/chunk-3I5Y3PEO.js +23 -0
  8. package/dist/chunk-3I5Y3PEO.js.map +1 -0
  9. package/dist/chunk-46PUWB7C.cjs +69 -0
  10. package/dist/chunk-46PUWB7C.cjs.map +1 -0
  11. package/dist/chunk-4WFDFEHC.js +134 -0
  12. package/dist/chunk-4WFDFEHC.js.map +1 -0
  13. package/dist/chunk-5NYM4UTW.cjs +58 -0
  14. package/dist/chunk-5NYM4UTW.cjs.map +1 -0
  15. package/dist/chunk-BWHUEED3.cjs +32 -0
  16. package/dist/chunk-BWHUEED3.cjs.map +1 -0
  17. package/dist/chunk-CMXYKDHC.cjs +666 -0
  18. package/dist/chunk-CMXYKDHC.cjs.map +1 -0
  19. package/dist/chunk-ESYAYVNK.cjs +136 -0
  20. package/dist/chunk-ESYAYVNK.cjs.map +1 -0
  21. package/dist/{chunk-6QLUUNJL.cjs → chunk-GDY76JA6.cjs} +2 -2
  22. package/dist/chunk-GDY76JA6.cjs.map +1 -0
  23. package/dist/chunk-HGVSPZEL.cjs +119 -0
  24. package/dist/chunk-HGVSPZEL.cjs.map +1 -0
  25. package/dist/chunk-HIDJYVKJ.js +54 -0
  26. package/dist/chunk-HIDJYVKJ.js.map +1 -0
  27. package/dist/chunk-HUR3MSO4.js +25 -0
  28. package/dist/chunk-HUR3MSO4.js.map +1 -0
  29. package/dist/chunk-LVLNO2YQ.cjs +28 -0
  30. package/dist/chunk-LVLNO2YQ.cjs.map +1 -0
  31. package/dist/chunk-N2K6W7FX.cjs +169 -0
  32. package/dist/chunk-N2K6W7FX.cjs.map +1 -0
  33. package/dist/chunk-NAMNXRI5.js +129 -0
  34. package/dist/chunk-NAMNXRI5.js.map +1 -0
  35. package/dist/chunk-OWU7MFJ2.cjs +15 -0
  36. package/dist/chunk-OWU7MFJ2.cjs.map +1 -0
  37. package/dist/chunk-PVTQWD4I.js +166 -0
  38. package/dist/chunk-PVTQWD4I.js.map +1 -0
  39. package/dist/chunk-PZ6BM57A.js +30 -0
  40. package/dist/chunk-PZ6BM57A.js.map +1 -0
  41. package/dist/chunk-SJQPHJL4.cjs +26 -0
  42. package/dist/chunk-SJQPHJL4.cjs.map +1 -0
  43. package/dist/chunk-V7D3QUE6.cjs +42 -0
  44. package/dist/chunk-V7D3QUE6.cjs.map +1 -0
  45. package/dist/chunk-VRF7QEID.js +67 -0
  46. package/dist/chunk-VRF7QEID.js.map +1 -0
  47. package/dist/chunk-WASVMCZB.js +13 -0
  48. package/dist/chunk-WASVMCZB.js.map +1 -0
  49. package/dist/chunk-WYOHFNNW.js +117 -0
  50. package/dist/chunk-WYOHFNNW.js.map +1 -0
  51. package/dist/chunk-XCNBVV4T.js +38 -0
  52. package/dist/chunk-XCNBVV4T.js.map +1 -0
  53. package/dist/{chunk-EWR5EIBP.js → chunk-YKF5ZFF5.js} +2 -2
  54. package/dist/chunk-YKF5ZFF5.js.map +1 -0
  55. package/dist/chunk-YXJMBVXO.cjs +76 -0
  56. package/dist/chunk-YXJMBVXO.cjs.map +1 -0
  57. package/dist/data-sources/DataAwareWidget.cjs +59 -0
  58. package/dist/data-sources/DataAwareWidget.cjs.map +1 -0
  59. package/dist/data-sources/DataAwareWidget.d.cts +30 -0
  60. package/dist/data-sources/DataAwareWidget.d.ts +30 -0
  61. package/dist/data-sources/DataAwareWidget.js +57 -0
  62. package/dist/data-sources/DataAwareWidget.js.map +1 -0
  63. package/dist/data-sources/ErrorState.cjs +12 -0
  64. package/dist/data-sources/ErrorState.cjs.map +1 -0
  65. package/dist/data-sources/ErrorState.d.cts +5 -0
  66. package/dist/data-sources/ErrorState.d.ts +5 -0
  67. package/dist/data-sources/ErrorState.js +3 -0
  68. package/dist/data-sources/ErrorState.js.map +1 -0
  69. package/dist/data-sources/context.cjs +10 -20
  70. package/dist/data-sources/context.cjs.map +1 -1
  71. package/dist/data-sources/context.d.cts +2 -2
  72. package/dist/data-sources/context.d.ts +2 -2
  73. package/dist/data-sources/context.js +1 -21
  74. package/dist/data-sources/context.js.map +1 -1
  75. package/dist/data-sources/fetchers/api.cjs +12 -0
  76. package/dist/data-sources/fetchers/api.cjs.map +1 -0
  77. package/dist/data-sources/fetchers/api.d.cts +8 -0
  78. package/dist/data-sources/fetchers/api.d.ts +8 -0
  79. package/dist/data-sources/fetchers/api.js +3 -0
  80. package/dist/data-sources/fetchers/api.js.map +1 -0
  81. package/dist/data-sources/fetchers/custom.cjs +12 -0
  82. package/dist/data-sources/fetchers/custom.cjs.map +1 -0
  83. package/dist/data-sources/fetchers/custom.d.cts +15 -0
  84. package/dist/data-sources/fetchers/custom.d.ts +15 -0
  85. package/dist/data-sources/fetchers/custom.js +3 -0
  86. package/dist/data-sources/fetchers/custom.js.map +1 -0
  87. package/dist/data-sources/fetchers/static.cjs +16 -0
  88. package/dist/data-sources/fetchers/static.cjs.map +1 -0
  89. package/dist/data-sources/fetchers/static.d.cts +38 -0
  90. package/dist/data-sources/fetchers/static.d.ts +38 -0
  91. package/dist/data-sources/fetchers/static.js +3 -0
  92. package/dist/data-sources/fetchers/static.js.map +1 -0
  93. package/dist/data-sources/registry-context.cjs +26 -0
  94. package/dist/data-sources/registry-context.cjs.map +1 -0
  95. package/dist/data-sources/registry-context.d.cts +41 -0
  96. package/dist/data-sources/registry-context.d.ts +41 -0
  97. package/dist/data-sources/registry-context.js +9 -0
  98. package/dist/data-sources/registry-context.js.map +1 -0
  99. package/dist/data-sources/registry.cjs +20 -0
  100. package/dist/data-sources/registry.cjs.map +1 -0
  101. package/dist/data-sources/registry.d.cts +17 -0
  102. package/dist/data-sources/registry.d.ts +17 -0
  103. package/dist/data-sources/registry.js +7 -0
  104. package/dist/data-sources/registry.js.map +1 -0
  105. package/dist/data-sources/transformers.cjs +12 -0
  106. package/dist/data-sources/transformers.cjs.map +1 -0
  107. package/dist/data-sources/transformers.d.cts +23 -0
  108. package/dist/data-sources/transformers.d.ts +23 -0
  109. package/dist/data-sources/transformers.js +3 -0
  110. package/dist/data-sources/transformers.js.map +1 -0
  111. package/dist/data-sources/types.d.cts +37 -2
  112. package/dist/data-sources/types.d.ts +37 -2
  113. package/dist/data-sources/use-widget-data.cjs +19 -0
  114. package/dist/data-sources/use-widget-data.cjs.map +1 -0
  115. package/dist/data-sources/use-widget-data.d.cts +16 -0
  116. package/dist/data-sources/use-widget-data.d.ts +16 -0
  117. package/dist/data-sources/use-widget-data.js +10 -0
  118. package/dist/data-sources/use-widget-data.js.map +1 -0
  119. package/dist/registries/index.cjs +8 -15
  120. package/dist/registries/index.cjs.map +1 -1
  121. package/dist/registries/index.d.cts +20 -7
  122. package/dist/registries/index.d.ts +20 -7
  123. package/dist/registries/index.js +8 -15
  124. package/dist/registries/index.js.map +1 -1
  125. package/dist/shareable-item-DkgWpwoU.d.cts +21 -0
  126. package/dist/shareable-item-DkgWpwoU.d.ts +21 -0
  127. package/dist/shell/AppShellLayout.cjs +14 -0
  128. package/dist/shell/AppShellLayout.cjs.map +1 -0
  129. package/dist/shell/AppShellLayout.d.cts +30 -0
  130. package/dist/shell/AppShellLayout.d.ts +30 -0
  131. package/dist/shell/AppShellLayout.js +5 -0
  132. package/dist/shell/AppShellLayout.js.map +1 -0
  133. package/dist/shell/ThemeModeContext.cjs +20 -0
  134. package/dist/shell/ThemeModeContext.cjs.map +1 -0
  135. package/dist/shell/ThemeModeContext.d.cts +27 -0
  136. package/dist/shell/ThemeModeContext.d.ts +27 -0
  137. package/dist/shell/ThemeModeContext.js +3 -0
  138. package/dist/shell/ThemeModeContext.js.map +1 -0
  139. package/dist/shell/index.cjs +135 -0
  140. package/dist/shell/index.cjs.map +1 -0
  141. package/dist/shell/index.d.cts +8 -0
  142. package/dist/shell/index.d.ts +8 -0
  143. package/dist/shell/index.js +6 -0
  144. package/dist/shell/index.js.map +1 -0
  145. package/dist/shell/sidebar.cjs +105 -0
  146. package/dist/shell/sidebar.cjs.map +1 -0
  147. package/dist/shell/sidebar.d.cts +73 -0
  148. package/dist/shell/sidebar.d.ts +73 -0
  149. package/dist/shell/sidebar.js +4 -0
  150. package/dist/shell/sidebar.js.map +1 -0
  151. package/dist/shell/use-mobile.cjs +20 -0
  152. package/dist/shell/use-mobile.cjs.map +1 -0
  153. package/dist/shell/use-mobile.d.cts +5 -0
  154. package/dist/shell/use-mobile.d.ts +5 -0
  155. package/dist/shell/use-mobile.js +3 -0
  156. package/dist/shell/use-mobile.js.map +1 -0
  157. package/dist/theme/index.cjs +599 -970
  158. package/dist/theme/index.cjs.map +1 -1
  159. package/dist/theme/index.d.cts +106 -2655
  160. package/dist/theme/index.d.ts +106 -2655
  161. package/dist/theme/index.js +570 -917
  162. package/dist/theme/index.js.map +1 -1
  163. package/dist/types/index.cjs +17 -17
  164. package/dist/types/index.d.cts +28 -4
  165. package/dist/types/index.d.ts +28 -4
  166. package/dist/types/index.js +1 -1
  167. package/dist/types-R1kV_DKF.d.cts +80 -0
  168. package/dist/types-R1kV_DKF.d.ts +80 -0
  169. package/dist/{shareable-item-DPmNZkE1.d.cts → widget-schema-36uGUTWL.d.cts} +5 -21
  170. package/dist/{shareable-item-DPmNZkE1.d.ts → widget-schema-DxdlJD8E.d.ts} +5 -21
  171. package/dist/widget-utils/index.cjs +3 -3
  172. package/dist/widget-utils/index.d.cts +3 -1
  173. package/dist/widget-utils/index.d.ts +3 -1
  174. package/dist/widget-utils/index.js +1 -1
  175. package/package.json +84 -13
  176. package/dist/chunk-6QLUUNJL.cjs.map +0 -1
  177. package/dist/chunk-EWR5EIBP.js.map +0 -1
  178. package/dist/theme-DrMUYZTO.d.cts +0 -22
  179. package/dist/theme-DrMUYZTO.d.ts +0 -22
@@ -1,228 +1,336 @@
1
1
  'use strict';
2
2
 
3
- // src/theme/theme-engine.ts
4
- var oklchString = (c) => `oklch(${c.l.toFixed(3)} ${c.c.toFixed(3)} ${c.h.toFixed(1)})`;
5
- var parseOklch = (oklchStr) => {
6
- const match = oklchStr.match(/oklch\(([\d.]+)\s+([\d.]+)\s+([\d.]+)\)/);
7
- if (!match) {
8
- return { l: 0, c: 0, h: 0 };
9
- }
10
- return {
11
- l: parseFloat(match[1] || "0"),
12
- c: parseFloat(match[2] || "0"),
13
- h: parseFloat(match[3] || "0")
14
- };
15
- };
16
- var mod = (c, dl = 0, dc = 0, dh = 0) => ({
17
- l: Math.max(0, Math.min(1, c.l + dl)),
18
- c: Math.max(0, c.c + dc),
19
- h: (c.h + dh + 360) % 360
20
- });
21
- var rotateHue = (c, degrees) => mod(c, 0, 0, degrees);
22
- var clampChroma = (c, maxC = 0.15) => ({
23
- ...c,
24
- c: Math.min(c.c, maxC)
25
- });
26
- var rotateSoft = (c, deg, maxC = 0.15) => clampChroma(rotateHue(c, deg), maxC);
27
- var getForegroundColor = (foreground, color) => {
28
- const contrast = Math.abs(foreground.l - color.l);
29
- if (contrast < 0.7) {
30
- foreground.l = 1 - foreground.l;
31
- return oklchString(foreground);
3
+ var Color2 = require('colorjs.io');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var Color2__default = /*#__PURE__*/_interopDefault(Color2);
8
+
9
+ // src/theme/color-engine.ts
10
+
11
+ // src/theme/types.ts
12
+ var SEMANTIC_COLOR_NAMES = [
13
+ "background",
14
+ "foreground",
15
+ "primary",
16
+ "secondary",
17
+ "accent",
18
+ "muted",
19
+ "destructive"
20
+ ];
21
+ var SHADE_STEPS = [
22
+ 100,
23
+ 200,
24
+ 300,
25
+ 400,
26
+ 500,
27
+ 600,
28
+ 700,
29
+ 800,
30
+ 900
31
+ ];
32
+ var FONT_SIZE_KEYS = [
33
+ "extraSmall",
34
+ "small",
35
+ "regular",
36
+ "large",
37
+ "extraLarge",
38
+ "giant"
39
+ ];
40
+ var FONT_FAMILY_KEYS = ["header", "body"];
41
+ var RADIUS_KEYS = ["small", "medium", "large", "extraLarge"];
42
+
43
+ // src/theme/color-engine.ts
44
+ function parseColor(value) {
45
+ if (value.length === 6) {
46
+ value = `#${value}`;
32
47
  }
33
- return oklchString(foreground);
34
- };
35
- var shadeColor = (color, lightnessShift, chromaShift) => {
36
- return oklchString({
37
- l: color.l + lightnessShift,
38
- c: color.c > 3e-3 ? color.c + chromaShift : color.c,
39
- h: color.h
40
- });
41
- };
42
- function generateColorSwatches(oklchString2) {
43
48
  try {
44
- const color = parseOklch(oklchString2);
45
- const safeMax = color.l >= 0.885 ? 0.995 : 0.97;
46
- const safeMin = color.l <= 0.33 ? 0 : 0.21;
47
- const lightBase = (safeMax - color.l) / 5;
48
- const darkBase = -(color.l - safeMin) / 8;
49
- return [
50
- // Light shades
51
- shadeColor(color, 5 * lightBase, -375e-5),
52
- shadeColor(color, 4 * lightBase, -375e-5),
53
- shadeColor(color, 3 * lightBase, -375e-5),
54
- shadeColor(color, 2 * lightBase, -375e-5),
55
- shadeColor(color, lightBase, -375e-5),
56
- // Dark shades
57
- shadeColor(color, 1.6 * darkBase, 0.025),
58
- shadeColor(color, 1.875 * 2 * darkBase, 0.05),
59
- shadeColor(color, 3 * 2 * darkBase, 0.075),
60
- shadeColor(color, 4 * 2 * darkBase, 0.1)
61
- ];
49
+ return new Color2__default.default(value);
62
50
  } catch (error) {
63
- console.error(`Failed to generate swatches for ${oklchString2}:`, error);
64
- return [
65
- "#f5f5f5",
66
- "#e0e0e0",
67
- "#cccccc",
68
- "#b3b3b3",
69
- "#999999",
70
- "#666666",
71
- "#4d4d4d",
72
- "#333333",
73
- "#1a1a1a"
74
- ];
51
+ console.warn("[theme] Failed to parse color:", value, error);
52
+ return new Color2__default.default("oklch", [0.5, 0, 0]);
75
53
  }
76
54
  }
77
- var CORE_COLOR_KEYS = [
78
- "base",
79
- "text",
80
- "body",
81
- "muted",
82
- "mutedForeground",
83
- "primary",
84
- "primaryForeground",
85
- "secondary",
86
- "secondaryForeground",
87
- "accent",
88
- "accentForeground",
89
- "destructive",
90
- "destructiveForeground"
91
- ];
92
- var DEFAULT_CORE_COLORS = {
93
- base: { l: 1, c: 0, h: 0 },
94
- text: { l: 0, c: 0, h: 0 },
95
- body: { l: 0.2046, c: 0, h: 0 },
96
- muted: { l: 0.94, c: 0, h: 0 },
97
- mutedForeground: { l: 0.4997, c: 0, h: 0 },
98
- primary: { l: 0.6231, c: 0.188, h: 259.81 },
99
- primaryForeground: { l: 1, c: 0, h: 0 },
100
- secondary: { l: 0.6056, c: 0.2189, h: 292.72 },
101
- secondaryForeground: { l: 1, c: 0, h: 0 },
102
- accent: { l: 0.6959, c: 0.1491, h: 162.48 },
103
- accentForeground: { l: 1, c: 0, h: 0 },
104
- destructive: { l: 0.6368, c: 0.2078, h: 25.33 },
105
- destructiveForeground: { l: 1, c: 0, h: 0 }
106
- };
107
- var themeConfigToCoreColors = (config) => ({
108
- base: parseOklch(
109
- config.background || config.base || oklchString(DEFAULT_CORE_COLORS.base)
110
- ),
111
- text: parseOklch(
112
- config.foreground || config.text || oklchString(DEFAULT_CORE_COLORS.text)
113
- ),
114
- body: parseOklch(config.body || oklchString(DEFAULT_CORE_COLORS.body)),
115
- muted: parseOklch(config.muted || oklchString(DEFAULT_CORE_COLORS.muted)),
116
- mutedForeground: parseOklch(
117
- config.mutedForeground || config.muted_foreground || oklchString(DEFAULT_CORE_COLORS.mutedForeground)
118
- ),
119
- primary: parseOklch(
120
- config.primary || oklchString(DEFAULT_CORE_COLORS.primary)
121
- ),
122
- primaryForeground: parseOklch(
123
- config.primaryForeground || config.primary_foreground || oklchString(DEFAULT_CORE_COLORS.primaryForeground)
124
- ),
125
- secondary: parseOklch(
126
- config.secondary || oklchString(DEFAULT_CORE_COLORS.secondary)
127
- ),
128
- secondaryForeground: parseOklch(
129
- config.secondaryForeground || config.secondary_foreground || oklchString(DEFAULT_CORE_COLORS.secondaryForeground)
130
- ),
131
- accent: parseOklch(config.accent || oklchString(DEFAULT_CORE_COLORS.accent)),
132
- accentForeground: parseOklch(
133
- config.accentForeground || config.accent_foreground || oklchString(DEFAULT_CORE_COLORS.accentForeground)
134
- ),
135
- destructive: parseOklch(
136
- config.destructive || oklchString(DEFAULT_CORE_COLORS.destructive)
137
- ),
138
- destructiveForeground: parseOklch(
139
- config.destructiveForeground || config.destructive_foreground || oklchString(DEFAULT_CORE_COLORS.destructiveForeground)
140
- )
141
- });
142
- var coreColorsToConfig = (colors) => {
143
- const config = {};
144
- for (const key of CORE_COLOR_KEYS) {
145
- config[key] = oklchString(colors[key]);
55
+ function getForegroundColor(foreground, color) {
56
+ if (foreground.oklch.l == null || color.oklch.l == null) {
57
+ return foreground;
146
58
  }
147
- return config;
148
- };
149
- var DEFAULT_CORE_COLORS_CONFIG = coreColorsToConfig(DEFAULT_CORE_COLORS);
150
- var THEME_MODES = {
151
- light: "light",
152
- dark: "dark"
153
- };
154
- var detectThemeMode = (core) => {
155
- return core.base.l < 0.5 ? THEME_MODES.dark : THEME_MODES.light;
156
- };
157
- var toDarkMode = (core) => {
158
- const isDark = core.base.l < 0.5;
159
- if (isDark) return core;
59
+ const contrast = color.contrastAPCA(foreground);
60
+ if (contrast < 50) {
61
+ return new Color2__default.default("oklch", [
62
+ color.oklch.l < 0.7 ? 0.95 : 0.15,
63
+ foreground.oklch.c || 0,
64
+ foreground.oklch.h || 0
65
+ ]);
66
+ }
67
+ return foreground;
68
+ }
69
+ function generateShades(base) {
70
+ const l = base.oklch.l ?? 0;
71
+ const c = base.oklch.c ?? 0;
72
+ const h = base.oklch.h ?? 0;
73
+ const safeMax = l >= 0.885 ? 0.995 : 0.97;
74
+ const safeMin = l <= 0.33 ? 0 : 0.21;
75
+ const lightStep = (safeMax - l) / 5;
76
+ const darkStep = -(l - safeMin) / 8;
77
+ const shade = (lDelta, cDelta) => {
78
+ return new Color2__default.default("oklch", [
79
+ Math.max(0, Math.min(1, l + lDelta)),
80
+ c <= 1e-3 ? c : Math.max(0, c + cDelta),
81
+ h
82
+ ]);
83
+ };
160
84
  return {
161
- // Base
162
- base: mod(core.base, 1 - core.base.l * 2),
163
- // Make base dark
164
- text: mod(core.text, core.text.l > 0.5 ? 0 : 0.5),
165
- // Ensure text is light
166
- body: mod(core.body, core.body.l > 0.5 ? 0 : 0.5),
167
- muted: mod(core.muted, 1 - core.muted.l * 2),
168
- mutedForeground: mod(
169
- core.mutedForeground,
170
- core.mutedForeground.l > 0.5 ? 0 : 0.4
171
- ),
172
- // Color
173
- primary: core.primary,
174
- primaryForeground: core.primaryForeground,
175
- secondary: core.secondary,
176
- secondaryForeground: core.secondaryForeground,
177
- accent: core.accent,
178
- accentForeground: core.accentForeground,
179
- destructive: core.destructive,
180
- destructiveForeground: core.destructiveForeground
85
+ 100: shade(5 * lightStep, -375e-5),
86
+ 200: shade(4 * lightStep, -375e-5),
87
+ 300: shade(3 * lightStep, -375e-5),
88
+ 400: shade(2 * lightStep, -375e-5),
89
+ 500: new Color2__default.default("oklch", [l, c, h]),
90
+ 600: shade(1.6 * darkStep, 0.025),
91
+ 700: shade(1.875 * 2 * darkStep, 0.05),
92
+ 800: shade(3 * 2 * darkStep, 0.075),
93
+ 900: shade(4 * 2 * darkStep, 0.1)
181
94
  };
95
+ }
96
+ var DARK_DERIVATION_CONFIG = {
97
+ background: { baseLightness: 0.15, fgLightness: 0.93 },
98
+ foreground: { baseLightness: 0.93, fgLightness: 0.15 },
99
+ muted: { baseLightness: 0.22, fgLightness: 0.75 },
100
+ primary: { baseLightness: "invert", fgLightness: 0.95, chromaScale: 0.9 },
101
+ secondary: { baseLightness: "invert", fgLightness: 0.93, chromaScale: 0.85 },
102
+ accent: { baseLightness: "invert", fgLightness: 0.95, chromaScale: 0.9 },
103
+ destructive: {
104
+ baseLightness: "invert",
105
+ fgLightness: 0.95,
106
+ chromaScale: 0.95
107
+ }
182
108
  };
183
- var toLightMode = (core) => {
184
- const isLight = core.base.l > 0.5;
185
- if (isLight) return core;
109
+ function invertLightness(l) {
110
+ const inverted = 1 - l;
111
+ return Math.max(0.35, Math.min(0.75, inverted));
112
+ }
113
+ function deriveDarkVariant(name, light) {
114
+ const config = DARK_DERIVATION_CONFIG[name];
115
+ const chromaScale = config.chromaScale ?? 1;
116
+ const baseLightness = config.baseLightness === "invert" ? invertLightness(light.base.oklch.l ?? 0) : config.baseLightness;
117
+ const fgLightness = config.fgLightness === "invert" ? invertLightness(light.foreground.oklch.l ?? 0) : config.fgLightness;
186
118
  return {
187
- // Base
188
- base: mod(core.base, 1 - core.base.l * 2),
189
- // Make base light
190
- text: mod(core.text, core.text.l < 0.5 ? 0.5 : -0.5),
191
- // Ensure text is dark
192
- body: mod(core.body, core.body.l < 0.5 ? 0.5 : -0.5),
193
- muted: mod(core.muted, 1 - core.muted.l * 2),
194
- mutedForeground: mod(
195
- core.mutedForeground,
196
- core.mutedForeground.l < 0.5 ? 0.5 : -0.4
197
- ),
198
- // Color
199
- primary: core.primary,
200
- primaryForeground: core.primaryForeground,
201
- secondary: core.secondary,
202
- secondaryForeground: core.secondaryForeground,
203
- accent: core.accent,
204
- accentForeground: core.accentForeground,
205
- destructive: core.destructive,
206
- destructiveForeground: core.destructiveForeground
119
+ base: new Color2__default.default("oklch", [
120
+ baseLightness,
121
+ (light.base.oklch.c || 0) * chromaScale,
122
+ light.base.oklch.h || 0
123
+ ]),
124
+ foreground: new Color2__default.default("oklch", [
125
+ fgLightness,
126
+ (light.foreground.oklch.c || 0) * chromaScale,
127
+ light.foreground.oklch.h || 0
128
+ ])
207
129
  };
130
+ }
131
+ function mergeDarkOverrides(def) {
132
+ const darkColors = {};
133
+ for (const name of SEMANTIC_COLOR_NAMES) {
134
+ const lightInput = def.light[name];
135
+ const darkOverride = def.dark[name];
136
+ if (darkOverride?.base && darkOverride?.foreground) {
137
+ darkColors[name] = darkOverride;
138
+ } else if (darkOverride) {
139
+ const base = darkOverride.base ?? deriveDarkVariant(name, lightInput).base;
140
+ darkColors[name] = {
141
+ base,
142
+ foreground: darkOverride.foreground ?? getForegroundColor(def.light.foreground.base, base)
143
+ };
144
+ } else {
145
+ darkColors[name] = deriveDarkVariant(name, lightInput);
146
+ }
147
+ }
148
+ return darkColors;
149
+ }
150
+ function resolveColorSet(colors) {
151
+ const resolved = {};
152
+ for (const name of SEMANTIC_COLOR_NAMES) {
153
+ const input = colors[name];
154
+ const shades = generateShades(input.base);
155
+ const resolvedShades = {};
156
+ for (const step of SHADE_STEPS) {
157
+ resolvedShades[step] = shades[step];
158
+ }
159
+ resolved[name] = {
160
+ base: input.base.clone(),
161
+ foreground: input.foreground.clone(),
162
+ shades: resolvedShades
163
+ };
164
+ }
165
+ return resolved;
166
+ }
167
+ function resolveTheme(def) {
168
+ return {
169
+ id: def.id,
170
+ name: def.name,
171
+ light: resolveColorSet(def.light),
172
+ dark: resolveColorSet(mergeDarkOverrides(def)),
173
+ fontSizes: { ...def.fontSizes },
174
+ fontFamilies: { ...def.fontFamilies },
175
+ spacing: def.spacing,
176
+ radii: { ...def.radii }
177
+ };
178
+ }
179
+
180
+ // src/theme/tailwind-overrides.ts
181
+ var OVERRIDES = {
182
+ "--color-gray-50": "var(--color-muted)",
183
+ "--color-gray-100": "var(--color-muted-600)",
184
+ "--color-gray-200": "var(--color-border)"
208
185
  };
209
- var FONT_OPTIONS = {
210
- Inter: "var(--font-inter)",
211
- Eina: "var(--font-eina)"
212
- };
213
- var CORE_FONT_KEYS = [
214
- "headerFont",
215
- "bodyFont",
216
- "extraSmall",
217
- "small",
218
- "regular",
219
- "large",
220
- "extraLarge",
221
- "giant"
186
+ function getInvertedStep(shade) {
187
+ const shadeIndex = SHADE_STEPS.indexOf(shade);
188
+ const invertedIndex = SHADE_STEPS.length - 1 - shadeIndex;
189
+ return SHADE_STEPS[invertedIndex] || 500;
190
+ }
191
+ function emitTailwindOverrides(darkMode = false) {
192
+ const TAILWIND_COLOR_MAP = {
193
+ gray: "foreground",
194
+ red: "destructive",
195
+ blue: "primary",
196
+ green: "accent"
197
+ };
198
+ const TAILWIND_SHADES = [
199
+ 50,
200
+ 100,
201
+ 200,
202
+ 300,
203
+ 400,
204
+ 500,
205
+ 600,
206
+ 700,
207
+ 800,
208
+ 900,
209
+ 950
210
+ ];
211
+ const SHADE_REMAP = {
212
+ 50: 100,
213
+ 950: 900
214
+ };
215
+ const lines = [];
216
+ for (const [twName, semantic] of Object.entries(TAILWIND_COLOR_MAP)) {
217
+ for (const shade of TAILWIND_SHADES) {
218
+ const step = SHADE_REMAP[shade] ?? shade;
219
+ const override = OVERRIDES[`--color-${twName}-${shade}`];
220
+ lines.push(
221
+ `--color-${twName}-${shade}: ${override ? override : `var(--color-${semantic}-${semantic === "foreground" && darkMode === true ? getInvertedStep(step) : step})`};`
222
+ );
223
+ }
224
+ }
225
+ lines.push("--color-white: var(--color-background);");
226
+ lines.push("--color-black: var(--color-foreground);");
227
+ return lines;
228
+ }
229
+
230
+ // src/theme/css-generator.ts
231
+ function colorToCSS(color) {
232
+ const result = color.toString({ format: "oklch" });
233
+ if (result.includes("NaN")) {
234
+ console.warn(
235
+ "[theme] colorToCSS produced NaN, using neutral fallback:",
236
+ result
237
+ );
238
+ return "oklch(0.5 0 0)";
239
+ }
240
+ return result;
241
+ }
242
+ function camelToKebab(str) {
243
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
244
+ }
245
+ function emitColorVars(colors) {
246
+ const lines = [];
247
+ for (const name of SEMANTIC_COLOR_NAMES) {
248
+ const color = colors[name];
249
+ lines.push(`--color-${name}: ${colorToCSS(color.base)};`);
250
+ lines.push(`--color-${name}-foreground: ${colorToCSS(color.foreground)};`);
251
+ for (const step of SHADE_STEPS) {
252
+ lines.push(`--color-${name}-${step}: ${colorToCSS(color.shades[step])};`);
253
+ }
254
+ }
255
+ return lines;
256
+ }
257
+ function emitNonColorVars(theme) {
258
+ const lines = [];
259
+ for (const key of FONT_SIZE_KEYS) {
260
+ lines.push(`--font-size-${camelToKebab(key)}: ${theme.fontSizes[key]};`);
261
+ }
262
+ for (const key of FONT_FAMILY_KEYS) {
263
+ lines.push(`--font-${key}: ${theme.fontFamilies[key]};`);
264
+ }
265
+ lines.push(`--spacing: ${theme.spacing};`);
266
+ for (const key of RADIUS_KEYS) {
267
+ lines.push(`--radius-${camelToKebab(key)}: ${theme.radii[key]};`);
268
+ }
269
+ return lines;
270
+ }
271
+ var globalCSSOverride = [
272
+ "--color-background-foreground: var(--color-foreground);",
273
+ "--color-foreground-foreground: var(--color-background);",
274
+ ...SEMANTIC_COLOR_NAMES.map((value) => `--${value}: var(--color-${value});`),
275
+ ...SEMANTIC_COLOR_NAMES.map(
276
+ (value) => `--${value}-foreground: var(--color-${value}-foreground);`
277
+ ),
278
+ "--sidebar-ring: var(--color-primary);",
279
+ "--sidebar-border: var(--color-border);",
280
+ "--sidebar-accent-foreground: var(--color-accent-foreground);",
281
+ "--sidebar-accent: var(--color-accent);",
282
+ "--sidebar-primary-foreground: var(--color-primary-foreground);",
283
+ "--sidebar-primary: var(--color-primary);",
284
+ "--sidebar-foreground: var(--color-muted-foreground);",
285
+ "--sidebar: var(--color-muted);",
286
+ "--border: var(--color-background-600);",
287
+ "--ring: var(--color-primary);",
288
+ "--popover: var(--color-background);",
289
+ "--popover-foreground: var(--color-foreground);",
290
+ "--card: var(--color-muted);",
291
+ "--card-foreground: var(--color-muted-foreground);",
292
+ "--radius-sm: var(--radius-small);",
293
+ "--radius-md: var(--radius-medium);",
294
+ "--radius-lg: var(--radius-large);",
295
+ "--radius-xl: var(--radius-extra-large);",
296
+ "--text-xs: var(--font-size-extra-small);",
297
+ "--text-sm: var(--font-size-small);",
298
+ "--text-base: var(--font-size-regular);",
299
+ "--text-lg: var(--font-size-large);",
300
+ "--text-xl: var(--font-size-extra-large);",
301
+ "--text-2xl: var(--font-size-giant);",
302
+ "--font-sans: var(--font-body);",
303
+ // Tailwind's font-mono is repurposed as the display/header font
304
+ "--font-mono: var(--font-header);"
222
305
  ];
223
- var DEFAULT_FONT = {
224
- headerFont: FONT_OPTIONS.Inter,
225
- bodyFont: FONT_OPTIONS.Inter,
306
+ var globalDarkCSSOverride = ["--border: var(--color-background-400);"];
307
+ function generateThemeCSS(theme, options = {}) {
308
+ const sel = `[data-theme="${theme.id}"]`;
309
+ const tw = options.mapTailwindColors ?? true;
310
+ const blocks = [];
311
+ blocks.push(`${sel} {`);
312
+ blocks.push(...globalCSSOverride);
313
+ blocks.push(...emitNonColorVars(theme));
314
+ blocks.push(...emitColorVars(theme.light));
315
+ if (tw) blocks.push(...emitTailwindOverrides());
316
+ blocks.push(`}`);
317
+ blocks.push(`${sel}[data-theme-mode="dark"] {`);
318
+ blocks.push(...globalDarkCSSOverride);
319
+ blocks.push(...emitColorVars(theme.dark));
320
+ if (tw) blocks.push(...emitTailwindOverrides(true));
321
+ blocks.push(`}`);
322
+ if (!options.disableAutoTheme) {
323
+ blocks.push(`@media (prefers-color-scheme: dark) {`);
324
+ blocks.push(`${sel}:not([data-theme-mode]) {`);
325
+ blocks.push(...globalDarkCSSOverride);
326
+ blocks.push(...emitColorVars(theme.dark).map((l) => `${l}`));
327
+ if (tw) blocks.push(...emitTailwindOverrides(true).map((l) => `${l}`));
328
+ blocks.push(`}`);
329
+ blocks.push(`}`);
330
+ }
331
+ return blocks.join("\n");
332
+ }
333
+ var DEFAULT_FONT_SIZES = {
226
334
  extraSmall: "0.75rem",
227
335
  small: "0.875rem",
228
336
  regular: "1rem",
@@ -230,784 +338,305 @@ var DEFAULT_FONT = {
230
338
  extraLarge: "1.25rem",
231
339
  giant: "1.5rem"
232
340
  };
233
- var fontConfigToCoreFont = (config) => {
234
- return {
235
- headerFont: config.headerFont || DEFAULT_FONT.headerFont,
236
- bodyFont: config.bodyFont || DEFAULT_FONT.bodyFont,
237
- extraSmall: config.extraSmall || DEFAULT_FONT.extraSmall,
238
- small: config.small || DEFAULT_FONT.small,
239
- regular: config.regular || DEFAULT_FONT.regular,
240
- large: config.large || DEFAULT_FONT.large,
241
- extraLarge: config.extraLarge || DEFAULT_FONT.extraLarge,
242
- giant: config.giant || DEFAULT_FONT.giant
243
- };
341
+ var DEFAULT_FONT_FAMILIES = {
342
+ header: "var(--font-inter)",
343
+ body: "var(--font-inter)"
244
344
  };
245
- var CORE_SPACING_KEYS = [
246
- "globalSpacing",
247
- "radiusSmall",
248
- "radiusMedium",
249
- "radiusLarge",
250
- "radiusExtraLarge"
251
- ];
252
- var DEFAULT_SPACING = {
253
- globalSpacing: "0.25rem",
254
- radiusSmall: "0.25rem",
255
- radiusMedium: "0.375rem",
256
- radiusLarge: "0.5rem",
257
- radiusExtraLarge: "0.75rem"
345
+ var DEFAULT_SPACING = "0.25rem";
346
+ var DEFAULT_RADII = {
347
+ small: "0.25rem",
348
+ medium: "0.5rem",
349
+ large: "0.75rem",
350
+ extraLarge: "1rem"
258
351
  };
259
- var spacingConfigToCoreSpacing = (config) => {
260
- return {
261
- globalSpacing: config.globalSpacing || DEFAULT_SPACING.globalSpacing,
262
- radiusSmall: config.radiusSmall || DEFAULT_SPACING.radiusSmall,
263
- radiusMedium: config.radiusMedium || DEFAULT_SPACING.radiusMedium,
264
- radiusLarge: config.radiusLarge || DEFAULT_SPACING.radiusLarge,
265
- radiusExtraLarge: config.radiusExtraLarge || DEFAULT_SPACING.radiusExtraLarge
266
- };
352
+ var DEFAULT_COLORS = {
353
+ background: "#ffffff",
354
+ foreground: "#1a1a1a",
355
+ primary: "#3b82f6",
356
+ secondary: "#6b7280",
357
+ accent: "#10b981",
358
+ muted: "#f3f4f6",
359
+ destructive: "#ef4444",
360
+ mutedForeground: "#6b7280"
267
361
  };
268
- var CORE_NON_COLOR_KEYS = [
269
- ...CORE_FONT_KEYS,
270
- ...CORE_SPACING_KEYS
271
- ];
272
- var separatedThemeConfig = (config) => {
273
- const ensuredConfig = [
274
- ...CORE_NON_COLOR_KEYS,
275
- ...CORE_COLOR_KEYS
276
- ].reduce((acc, key) => {
277
- acc[key] = config[key] || DEFAULT_CORE_COLORS_CONFIG[key] || DEFAULT_FONT[key] || DEFAULT_SPACING[key];
278
- return acc;
279
- }, {});
280
- const colorConfig = Object.fromEntries(
281
- Object.entries(ensuredConfig).filter(
282
- ([key]) => CORE_COLOR_KEYS.includes(key)
283
- )
284
- );
285
- const otherConfig = Object.fromEntries(
286
- Object.entries(ensuredConfig).filter(
287
- ([key]) => CORE_NON_COLOR_KEYS.includes(key)
288
- )
289
- );
362
+ var DEFAULT_THEME_ID = "default";
363
+ var DEFAULT_THEME_NAME = "Default Theme";
364
+ function getDefaultThemeDefinition() {
365
+ const bg = new Color2__default.default(DEFAULT_COLORS.background);
366
+ const fg = new Color2__default.default(DEFAULT_COLORS.foreground);
367
+ const primary = new Color2__default.default(DEFAULT_COLORS.primary);
368
+ const secondary = new Color2__default.default(DEFAULT_COLORS.secondary);
369
+ const accent = new Color2__default.default(DEFAULT_COLORS.accent);
370
+ const muted = new Color2__default.default(DEFAULT_COLORS.muted);
371
+ const destructive = new Color2__default.default(DEFAULT_COLORS.destructive);
372
+ const mutedFg = new Color2__default.default(DEFAULT_COLORS.mutedForeground);
373
+ const darkBg = new Color2__default.default("#0a0a0a");
374
+ const darkFg = new Color2__default.default("#fafafa");
375
+ const darkMuted = new Color2__default.default("#171717");
376
+ const darkMutedForeground = new Color2__default.default("#dddddd");
290
377
  return {
291
- colorConfig,
292
- otherConfig
378
+ id: DEFAULT_THEME_ID,
379
+ name: DEFAULT_THEME_NAME,
380
+ light: {
381
+ background: { base: bg, foreground: fg },
382
+ foreground: { base: fg, foreground: bg },
383
+ primary: {
384
+ base: primary,
385
+ foreground: getForegroundColor(fg, primary)
386
+ },
387
+ secondary: {
388
+ base: secondary,
389
+ foreground: getForegroundColor(fg, secondary)
390
+ },
391
+ accent: {
392
+ base: accent,
393
+ foreground: getForegroundColor(fg, accent)
394
+ },
395
+ muted: { base: muted, foreground: mutedFg },
396
+ destructive: {
397
+ base: destructive,
398
+ foreground: getForegroundColor(fg, destructive)
399
+ }
400
+ },
401
+ dark: {
402
+ background: { base: darkBg, foreground: darkFg },
403
+ foreground: { base: darkFg, foreground: darkBg },
404
+ muted: { base: darkMuted, foreground: darkMutedForeground }
405
+ },
406
+ fontSizes: { ...DEFAULT_FONT_SIZES },
407
+ fontFamilies: { ...DEFAULT_FONT_FAMILIES },
408
+ spacing: DEFAULT_SPACING,
409
+ radii: { ...DEFAULT_RADII }
293
410
  };
294
- };
295
- var themeConfigToCoreNonColorFields = (config) => {
411
+ }
412
+
413
+ // src/theme/serialisation.ts
414
+ function colorToPlain(color) {
296
415
  return {
297
- ...fontConfigToCoreFont(config),
298
- ...spacingConfigToCoreSpacing(config)
416
+ l: color.oklch.l ?? 0,
417
+ c: color.oklch.c ?? 0,
418
+ h: color.oklch.h ?? 0
299
419
  };
300
- };
301
- var globalCSSOverride = {
302
- "--color-background-foreground": "var(--color-foreground)",
303
- "--color-foreground-foreground": "var(--color-background)",
304
- "--sidebar-ring": "var(--color-primary)",
305
- "--sidebar-border": "var(--color-border)",
306
- "--sidebar-accent-foreground": "var(--color-accent-foreground)",
307
- "--sidebar-accent": "var(--color-accent)",
308
- "--sidebar-primary-foreground": "var(--color-primary-foreground)",
309
- "--sidebar-primary": "var(--color-primary)",
310
- "--sidebar-foreground": "var(--color-muted-foreground)",
311
- "--sidebar": "var(--color-muted)",
312
- "--ring": "var(--color-primary)",
313
- "--popover": "var(--color-background)",
314
- "--popover-foreground": "var(--color-foreground)",
315
- "--card": "var(--color-muted)",
316
- "--card-foreground": "var(--color-muted-foreground)",
317
- "--spacing": "var(--global-spacing)",
318
- "--radius-sm": "var(--radius-small)",
319
- "--radius-md": "var(--radius-medium)",
320
- "--radius-lg": "var(--radius-large)",
321
- "--radius-xl": "var(--radius-extra-large)",
322
- "--text-xs": "var(--text-extra-small)",
323
- "--text-sm": "var(--text-small)",
324
- "--text-base": "var(--text-regular)",
325
- "--text-lg": "var(--text-large)",
326
- "--text-xl": "var(--text-extra-large)",
327
- "--text-2xl": "var(--text-giant)",
328
- "--font-sans": "var(--font-body)",
329
- "--font-mono": "var(--font-header)"
330
- };
331
- function generateThemeCssVars(config, mode) {
332
- const coreColors = themeConfigToCoreColors(config);
333
- const coreOther = themeConfigToCoreNonColorFields(config);
334
- const theme = generateTheme("preview", coreColors, mode, coreOther);
335
- const cssVars = { ...globalCSSOverride };
336
- Object.entries(theme.config).forEach(([key, value]) => {
337
- const cssKey = `--${key.replace(/_/g, "-")}`;
338
- cssVars[cssKey] = String(value);
339
- if (value.startsWith("oklch(")) {
340
- const colorVariable = cssKey.replace(/^--/, "--color-");
341
- cssVars[colorVariable] = String(value);
342
- const swatches = generateColorSwatches(value);
343
- swatches.forEach((swatch, index) => {
344
- const swatchKey = `--color-${key.replace(/_/g, "-")}-${index + 1}00`;
345
- cssVars[swatchKey] = String(swatch);
346
- });
347
- }
348
- });
349
- return cssVars;
350
420
  }
351
- var generateTheme = (name, colorFields, mode = THEME_MODES.dark, otherFields) => {
352
- const modeCore = mode === "dark" ? toDarkMode(colorFields) : toLightMode(colorFields);
353
- const surface = mod(modeCore.base, (1 - modeCore.base.l) * 0.1);
354
- const normalize = (c) => c;
355
- const base = normalize(modeCore.base);
356
- const text = normalize(modeCore.text);
357
- const body = normalize(modeCore.body);
358
- const muted = normalize(modeCore.muted);
359
- const mutedForeground = normalize(modeCore.mutedForeground);
360
- const primary = normalize(modeCore.primary);
361
- const primaryForeground = normalize(modeCore.primaryForeground);
362
- const secondary = normalize(modeCore.secondary);
363
- const secondaryForeground = normalize(modeCore.secondaryForeground);
364
- const accent = normalize(modeCore.accent);
365
- const accentForeground = normalize(modeCore.accentForeground);
366
- const destructive = normalize(modeCore.destructive);
367
- const destructiveForeground = normalize(modeCore.destructiveForeground);
368
- const chart1 = accent;
369
- const chart2 = primary;
370
- const chart3 = secondary;
371
- const chart4 = rotateSoft(primary, 60);
372
- const chart5 = rotateSoft(primary, 120);
373
- const otherConfig = otherFields ?? {
374
- ...DEFAULT_FONT,
375
- ...DEFAULT_SPACING
376
- };
421
+ function plainToColor(plain) {
422
+ return new Color2__default.default("oklch", [plain.l, plain.c, plain.h]);
423
+ }
424
+ function serialiseTheme(def) {
425
+ const light = {};
426
+ for (const name of SEMANTIC_COLOR_NAMES) {
427
+ light[name] = {
428
+ base: colorToPlain(def.light[name].base),
429
+ foreground: colorToPlain(def.light[name].foreground)
430
+ };
431
+ }
432
+ const dark = {};
433
+ for (const [name, value] of Object.entries(def.dark)) {
434
+ if (!value) continue;
435
+ dark[name] = {
436
+ ...value.base ? { base: colorToPlain(value.base) } : {},
437
+ ...value.foreground ? { foreground: colorToPlain(value.foreground) } : {}
438
+ };
439
+ }
377
440
  return {
378
- name,
379
- mode,
380
- config: {
381
- // Base
382
- background: oklchString(base),
383
- foreground: oklchString(text),
384
- // Body
385
- body: oklchString(body),
386
- // Popover
387
- popover: oklchString(base),
388
- popover_foreground: oklchString(text),
389
- // Primary
390
- primary: oklchString(primary),
391
- primary_foreground: oklchString(primaryForeground),
392
- // Secondary
393
- secondary: oklchString(secondary),
394
- secondary_foreground: oklchString(secondaryForeground),
395
- // muted
396
- muted: oklchString(muted),
397
- muted_foreground: oklchString(mutedForeground),
398
- // Accent
399
- accent: oklchString(accent),
400
- accent_foreground: oklchString(accentForeground),
401
- // Destructive
402
- destructive: oklchString(destructive),
403
- destructive_foreground: oklchString(destructiveForeground),
404
- // Border / input / ring
405
- border: oklchString(surface),
406
- input: oklchString(surface),
407
- // Charts
408
- chart_1: oklchString(chart1),
409
- chart_2: oklchString(chart2),
410
- chart_3: oklchString(chart3),
411
- chart_4: oklchString(chart4),
412
- chart_5: oklchString(chart5),
413
- // Font
414
- font_header: otherConfig.headerFont || DEFAULT_FONT.headerFont,
415
- font_body: otherConfig.bodyFont || DEFAULT_FONT.bodyFont,
416
- text_extra_small: otherConfig.extraSmall || DEFAULT_FONT.extraSmall,
417
- text_small: otherConfig.small || DEFAULT_FONT.small,
418
- text_regular: otherConfig.regular || DEFAULT_FONT.regular,
419
- text_large: otherConfig.large || DEFAULT_FONT.large,
420
- text_extra_large: otherConfig.extraLarge || DEFAULT_FONT.extraLarge,
421
- text_giant: otherConfig.giant || DEFAULT_FONT.giant,
422
- // Spacing
423
- global_spacing: otherConfig.globalSpacing || DEFAULT_SPACING.globalSpacing,
424
- radius_small: otherConfig.radiusSmall || DEFAULT_SPACING.radiusSmall,
425
- radius_medium: otherConfig.radiusMedium || DEFAULT_SPACING.radiusMedium,
426
- radius_large: otherConfig.radiusLarge || DEFAULT_SPACING.radiusLarge,
427
- radius_extra_large: otherConfig.radiusExtraLarge || DEFAULT_SPACING.radiusExtraLarge
428
- },
429
- default: false
441
+ id: def.id,
442
+ name: def.name,
443
+ light,
444
+ dark,
445
+ fontSizes: { ...def.fontSizes },
446
+ fontFamilies: { ...def.fontFamilies },
447
+ spacing: def.spacing,
448
+ radii: { ...def.radii }
430
449
  };
431
- };
432
- var generateDualTheme = (name, core) => {
450
+ }
451
+ function deserialiseTheme(payload) {
452
+ const lightRaw = payload.light ?? {};
453
+ const darkRaw = payload.dark ?? {};
454
+ const defaults = getDefaultThemeDefinition();
455
+ const light = {};
456
+ for (const name of SEMANTIC_COLOR_NAMES) {
457
+ const entry = lightRaw[name];
458
+ if (entry) {
459
+ light[name] = {
460
+ base: plainToColor(entry.base),
461
+ foreground: plainToColor(entry.foreground)
462
+ };
463
+ } else {
464
+ console.warn(
465
+ `[theme] deserialiseTheme: missing light color "${name}", using default`
466
+ );
467
+ light[name] = defaults.light[name];
468
+ }
469
+ }
470
+ const dark = {};
471
+ for (const [name, value] of Object.entries(darkRaw)) {
472
+ if (!value) continue;
473
+ dark[name] = {
474
+ ...value.base ? { base: plainToColor(value.base) } : {},
475
+ ...value.foreground ? { foreground: plainToColor(value.foreground) } : {}
476
+ };
477
+ }
433
478
  return {
434
- light: generateTheme(name, core, "light"),
435
- dark: generateTheme(name, core, "dark")
479
+ id: payload.id,
480
+ name: payload.name,
481
+ light,
482
+ dark,
483
+ fontSizes: payload.fontSizes ?? DEFAULT_FONT_SIZES,
484
+ fontFamilies: payload.fontFamilies ?? DEFAULT_FONT_FAMILIES,
485
+ spacing: payload.spacing ?? DEFAULT_SPACING,
486
+ radii: payload.radii ?? DEFAULT_RADII
436
487
  };
437
- };
438
- var generateSmartDualTheme = (name, core) => {
439
- const detectedMode = detectThemeMode(core);
488
+ }
489
+
490
+ // src/theme/transforms.ts
491
+ function isNewThemeFormat(config) {
492
+ return config.light != null && typeof config.light === "object";
493
+ }
494
+ function legacyConfigToDefinition(id, name, config) {
495
+ const bg = parseColor(
496
+ config.base ?? config.background ?? DEFAULT_COLORS.background
497
+ );
498
+ const fg = parseColor(
499
+ config.text ?? config.foreground ?? DEFAULT_COLORS.foreground
500
+ );
501
+ const primary = parseColor(config.primary ?? DEFAULT_COLORS.primary);
502
+ const secondary = parseColor(config.secondary ?? DEFAULT_COLORS.secondary);
503
+ const accent = parseColor(config.accent ?? DEFAULT_COLORS.accent);
504
+ const muted = parseColor(config.muted ?? DEFAULT_COLORS.muted);
505
+ const destructive = parseColor(
506
+ config.destructive ?? DEFAULT_COLORS.destructive
507
+ );
508
+ const mutedFg = parseColor(
509
+ config.mutedForeground ?? DEFAULT_COLORS.mutedForeground
510
+ );
440
511
  return {
441
- light: generateTheme(name, core, "light"),
442
- dark: generateTheme(name, core, "dark"),
443
- detectedMode
444
- // Returns which mode the original core colors represent
512
+ id: String(id),
513
+ name,
514
+ light: {
515
+ background: { base: bg, foreground: fg },
516
+ foreground: { base: fg, foreground: bg },
517
+ primary: {
518
+ base: primary,
519
+ foreground: getForegroundColor(fg, primary)
520
+ },
521
+ secondary: {
522
+ base: secondary,
523
+ foreground: getForegroundColor(fg, secondary)
524
+ },
525
+ accent: {
526
+ base: accent,
527
+ foreground: getForegroundColor(fg, accent)
528
+ },
529
+ muted: { base: muted, foreground: mutedFg },
530
+ destructive: {
531
+ base: destructive,
532
+ foreground: getForegroundColor(fg, destructive)
533
+ }
534
+ },
535
+ dark: {},
536
+ fontSizes: {
537
+ extraSmall: config.extraSmall ?? DEFAULT_FONT_SIZES.extraSmall,
538
+ small: config.small ?? DEFAULT_FONT_SIZES.small,
539
+ regular: config.regular ?? DEFAULT_FONT_SIZES.regular,
540
+ large: config.large ?? DEFAULT_FONT_SIZES.large,
541
+ extraLarge: config.extraLarge ?? DEFAULT_FONT_SIZES.extraLarge,
542
+ giant: config.giant ?? DEFAULT_FONT_SIZES.giant
543
+ },
544
+ fontFamilies: {
545
+ header: config.headerFont ?? DEFAULT_FONT_FAMILIES.header,
546
+ body: config.bodyFont ?? DEFAULT_FONT_FAMILIES.body
547
+ },
548
+ spacing: config.globalSpacing ?? DEFAULT_SPACING,
549
+ radii: {
550
+ small: config.radiusSmall ?? DEFAULT_RADII.small,
551
+ medium: config.radiusMedium ?? DEFAULT_RADII.medium,
552
+ large: config.radiusLarge ?? DEFAULT_RADII.large,
553
+ extraLarge: config.radiusExtraLarge ?? DEFAULT_RADII.extraLarge
554
+ }
445
555
  };
446
- };
447
- var getThemeIdentifier = (theme) => {
448
- return theme.id !== void 0 ? theme.id.toString() : theme.name;
449
- };
450
- var findThemeByIdentifier = (themes, identifier) => {
451
- if (typeof identifier === "number") {
452
- return themes.find((t) => t.id === identifier);
453
- }
454
- const numericId = parseInt(identifier, 10);
455
- if (!isNaN(numericId)) {
456
- const byId = themes.find((t) => t.id === numericId);
457
- if (byId) return byId;
458
- }
459
- return themes.find((t) => t.name === identifier);
460
- };
461
- var isSameTheme = (theme1, theme2) => {
462
- if (!theme1) return false;
463
- if (theme1.id !== void 0 && theme2.id !== void 0) {
464
- return theme1.id === theme2.id;
556
+ }
557
+ function buildThemeDefinition(theme) {
558
+ const config = theme.config ?? {};
559
+ if (isNewThemeFormat(config)) {
560
+ return deserialiseTheme({
561
+ ...config,
562
+ id: String(theme.id),
563
+ name: theme.name ?? "Untitled Theme"
564
+ });
465
565
  }
466
- return theme1.name === theme2.name;
467
- };
566
+ return legacyConfigToDefinition(
567
+ theme.id,
568
+ theme.name ?? "Untitled Theme",
569
+ config
570
+ );
571
+ }
572
+ function transformThemes(themes) {
573
+ return themes.flatMap((theme) => {
574
+ try {
575
+ return [buildThemeDefinition(theme)];
576
+ } catch (error) {
577
+ console.error(`[theme] Failed to build theme id=${theme.id}:`, error);
578
+ return [];
579
+ }
580
+ });
581
+ }
582
+ function getActiveThemeId(themes) {
583
+ const active = themes.find((t) => t.active) ?? themes[0];
584
+ return active ? String(active.id) : void 0;
585
+ }
468
586
 
469
- // src/theme/index.ts
470
- var dracula = generateTheme("Dracula", {
471
- // Base - Official: draculatheme.com/spec
472
- base: { l: 0.2882, c: 0.0221, h: 277.51 },
473
- // Official: #282A36 (Background)
474
- text: { l: 0.9775, c: 79e-4, h: 106.55 },
475
- // Official: #F8F8F2 (Foreground)
476
- body: { l: 0.75, c: 0.02, h: 300 },
477
- // Body text
478
- muted: { l: 0.4028, c: 0.0322, h: 277.83 },
479
- // Surface/Card bg - Official: #44475A (Current Line)
480
- mutedForeground: { l: 0.5598, c: 0.0803, h: 270.09 },
481
- // Official: #6272A4 (Comment)
482
- // Color
483
- primary: { l: 0.742, c: 0.1485, h: 301.88 },
484
- // Official: #BD93F9 (Purple)
485
- primaryForeground: { l: 0.15, c: 0.01, h: 275 },
486
- secondary: { l: 0.5598, c: 0.0803, h: 270.09 },
487
- // Official: #6272A4 (Comment)
488
- secondaryForeground: { l: 0.15, c: 0.01, h: 245 },
489
- accent: { l: 0.871, c: 0.2195, h: 148.02 },
490
- // Official: #50FA7B (Green)
491
- accentForeground: { l: 0.15, c: 0.01, h: 110 },
492
- destructive: { l: 0.6822, c: 0.2063, h: 24.43 },
493
- // Official: #FF5555 (Red)
494
- destructiveForeground: { l: 0.15, c: 0.01, h: 30 }
495
- });
496
- var solarized = generateTheme(
497
- "Solarized",
498
- {
499
- // Base - Official: ethanschoonover.com/solarized
500
- base: { l: 0.9735, c: 0.0261, h: 90.1 },
501
- // Official: #fdf6e3 (base3)
502
- text: { l: 0.3092, c: 0.0518, h: 219.65 },
503
- // Official: #073642 (base02)
504
- body: { l: 0.523, c: 0.0283, h: 219.14 },
505
- // Official: #586e75 (base01)
506
- muted: { l: 0.9306, c: 0.026, h: 92.4 },
507
- // Surface/Card bg - Official: #eee8d5 (base2)
508
- mutedForeground: { l: 0.5682, c: 0.0285, h: 221.9 },
509
- // Official: #657b83 (base00)
510
- // Color
511
- primary: { l: 0.6437, c: 0.1019, h: 187.38 },
512
- // Official: #2aa198 (cyan)
513
- primaryForeground: { l: 0.98, c: 0.01, h: 180 },
514
- secondary: { l: 0.6444, c: 0.1508, h: 118.6 },
515
- // Official: #859900 (green)
516
- secondaryForeground: { l: 0.15, c: 0.01, h: 145 },
517
- accent: { l: 0.6545, c: 0.134, h: 85.72 },
518
- // Official: #b58900 (yellow)
519
- accentForeground: { l: 0.15, c: 0.01, h: 85 },
520
- destructive: { l: 0.5863, c: 0.2064, h: 27.12 },
521
- // Official: #dc322f (red)
522
- destructiveForeground: { l: 0.98, c: 0.01, h: 30 }
523
- },
524
- "light"
525
- );
526
- var gruvbox = generateTheme(
527
- "Gruvbox",
528
- {
529
- // Base - Official: github.com/morhetz/gruvbox (Light mode)
530
- base: { l: 0.9555, c: 0.0555, h: 96.15 },
531
- // Official: #fbf1c7 (bg0 light)
532
- text: { l: 0.3441, c: 66e-4, h: 48.52 },
533
- // Official: #3c3836 (fg1 light)
534
- body: { l: 0.411, c: 0.0115, h: 51.87 },
535
- // Official: #504945 (fg2 light)
536
- muted: { l: 0.8941, c: 0.0566, h: 89.24 },
537
- // Surface/Card bg - Official: #ebdbb2 (bg1 light)
538
- mutedForeground: { l: 0.5505, c: 0.0234, h: 62.57 },
539
- // Official: #7c6f64 (gray)
540
- // Color
541
- primary: { l: 0.7251, c: 0.1429, h: 77.71 },
542
- // Official: #d79921 (yellow)
543
- primaryForeground: { l: 0.15, c: 0.01, h: 80 },
544
- secondary: { l: 0.6564, c: 0.1354, h: 109.12 },
545
- // Official: #98971a (green)
546
- secondaryForeground: { l: 0.15, c: 0.01, h: 145 },
547
- accent: { l: 0.6217, c: 0.1707, h: 45.81 },
548
- // Official: #d65d0e (orange)
549
- accentForeground: { l: 0.15, c: 0.01, h: 35 },
550
- destructive: { l: 0.5458, c: 0.203, h: 28.66 },
551
- // Official: #cc241d (red)
552
- destructiveForeground: { l: 0.98, c: 0.01, h: 30 }
553
- },
554
- "light"
555
- );
556
- var monokai = generateTheme("Monokai", {
557
- // Base - Official: Sublime Text Monokai
558
- base: { l: 0.2737, c: 0.0109, h: 114.8 },
559
- // Official: #272822 (Background)
560
- text: { l: 0.9775, c: 79e-4, h: 106.55 },
561
- // Official: #F8F8F2 (Foreground)
562
- body: { l: 0.75, c: 0.04, h: 90 },
563
- // Body text
564
- muted: { l: 0.3574, c: 0.0184, h: 103 },
565
- // Surface/Card bg - Official: #3E3D32 (Line hig
566
- mutedForeground: { l: 0.5467, c: 0.0288, h: 97.39 },
567
- // Official: #75715E (Comment)
568
- // Color
569
- primary: { l: 0.8792, c: 0.1255, h: 103.18 },
570
- // Official: #E6DB74 (Yellow)
571
- primaryForeground: { l: 0.15, c: 0.01, h: 60 },
572
- secondary: { l: 0.6416, c: 0.24, h: 7.47 },
573
- // Official: #F92672 (Pink)
574
- secondaryForeground: { l: 0.15, c: 0.01, h: 300 },
575
- accent: { l: 0.8414, c: 0.2044, h: 127.29 },
576
- // Official: #A6E22E (Green)
577
- accentForeground: { l: 0.15, c: 0.01, h: 110 },
578
- destructive: { l: 0.6416, c: 0.24, h: 7.47 },
579
- // Official: #F92672 (Red/Pink)
580
- destructiveForeground: { l: 0.98, c: 0.01, h: 20 }
581
- });
582
- var tokyoNight = generateTheme("Tokyo Night", {
583
- // Base - Official: github.com/folke/tokyonight.nvim
584
- base: { l: 0.2263, c: 0.0214, h: 280.49 },
585
- // Official: #1a1b26 (bg)
586
- text: { l: 0.8456, c: 0.0611, h: 274.76 },
587
- // Official: #c0caf5 (fg)
588
- body: { l: 0.7666, c: 0.0537, h: 275.49 },
589
- // Official: #a9b1d6 (fg_dark)
590
- muted: { l: 0.2819, c: 0.0355, h: 274.75 },
591
- // Surface/Card bg - Official: #24283b (bg_highlight)
592
- mutedForeground: { l: 0.4955, c: 0.0682, h: 274.37 },
593
- // Official: #565f89 (comment)
594
- // Color
595
- primary: { l: 0.719, c: 0.1322, h: 264.2 },
596
- // Official: #7aa2f7 (blue)
597
- primaryForeground: { l: 0.15, c: 0.01, h: 260 },
598
- secondary: { l: 0.7515, c: 0.1344, h: 299.5 },
599
- // Official: #bb9af7 (magenta)
600
- secondaryForeground: { l: 0.15, c: 0.01, h: 295 },
601
- accent: { l: 0.7839, c: 0.1057, h: 75.43 },
602
- // Official: #e0af68 (yellow)
603
- accentForeground: { l: 0.15, c: 0.01, h: 80 },
604
- destructive: { l: 0.7227, c: 0.1589, h: 10.28 },
605
- // Official: #f7768e (red)
606
- destructiveForeground: { l: 0.15, c: 0.01, h: 20 }
607
- });
608
- var rosePine = generateTheme("Rose Pine", {
609
- // Base - Official: rosepinetheme.com/palette
610
- base: { l: 0.2134, c: 0.0255, h: 291.13 },
611
- // Official: #191724 (Base)
612
- text: { l: 0.9088, c: 0.0299, h: 289.97 },
613
- // Official: #e0def4 (Text)
614
- body: { l: 0.6539, c: 0.0444, h: 291.23 },
615
- // Official: #908caa (Subtle)
616
- muted: { l: 0.2413, c: 0.0322, h: 289.14 },
617
- // Surface/Card bg - Official: #1f1d2e (Surface)
618
- mutedForeground: { l: 0.5383, c: 0.0435, h: 291.41 },
619
- // Official: #6e6a86 (Muted)
620
- // Color
621
- primary: { l: 0.8363, c: 0.0544, h: 21.14 },
622
- // Official: #ebbcba (Rose)
623
- primaryForeground: { l: 0.15, c: 0.01, h: 345 },
624
- secondary: { l: 0.5277, c: 0.0793, h: 227.72 },
625
- // Official: #31748f (Pine)
626
- secondaryForeground: { l: 0.15, c: 0.01, h: 155 },
627
- accent: { l: 0.776, c: 0.0945, h: 304.99 },
628
- // Official: #c4a7e7 (Iris)
629
- accentForeground: { l: 0.15, c: 0.01, h: 270 },
630
- destructive: { l: 0.6977, c: 0.1565, h: 4.22 },
631
- // Official: #eb6f92 (Love)
632
- destructiveForeground: { l: 0.15, c: 0.01, h: 25 }
633
- });
634
- var everforest = generateTheme(
635
- "Everforest",
636
- {
637
- // Base - Official: github.com/sainnhe/everforest (Light mode)
638
- base: { l: 0.9735, c: 0.0261, h: 90.1 },
639
- // Official: #fdf6e3 (bg0 light medium)
640
- text: { l: 0.5154, c: 0.0212, h: 232.87 },
641
- // Official: #5c6a72 (fg)
642
- body: { l: 0.6398, c: 0.0292, h: 143.51 },
643
- // Official: #829181 (grey2)
644
- muted: { l: 0.9522, c: 0.0306, h: 98.86 },
645
- // Surface/Card bg - Official: #f4f0d9 (bg1 light)
646
- mutedForeground: { l: 0.6888, c: 0.0243, h: 141.21 },
647
- // Official: #939f91 (grey1)
648
- // Color
649
- primary: { l: 0.6697, c: 0.156, h: 118.23 },
650
- // Official: #8da101 (green)
651
- primaryForeground: { l: 0.98, c: 0.01, h: 140 },
652
- secondary: { l: 0.7466, c: 0.1545, h: 80.27 },
653
- // Official: #dfa000 (yellow)
654
- secondaryForeground: { l: 0.15, c: 0.01, h: 60 },
655
- accent: { l: 0.7147, c: 0.1729, h: 50.75 },
656
- // Official: #f57d26 (orange)
657
- accentForeground: { l: 0.15, c: 0.01, h: 30 },
658
- destructive: { l: 0.6707, c: 0.1996, h: 25.2 },
659
- // Official: #f85552 (red)
660
- destructiveForeground: { l: 0.98, c: 0.01, h: 20 }
661
- },
662
- "light"
663
- );
664
- var nord = generateTheme("Nord", {
665
- // Base - Official: nordtheme.com
666
- base: { l: 0.3244, c: 0.0229, h: 264.18 },
667
- // Official: #2e3440 (nord0 - Polar Night)
668
- text: { l: 0.9513, c: 74e-4, h: 260.73 },
669
- // Official: #eceff4 (nord6 - Snow Storm)
670
- body: { l: 0.8993, c: 0.0164, h: 262.75 },
671
- // Official: #d8dee9 (nord4 - Snow Storm)
672
- muted: { l: 0.3792, c: 0.029, h: 266.47 },
673
- // Surface/Card bg - Official: #3b4252 (nord1)
674
- mutedForeground: { l: 0.4523, c: 0.0352, h: 264.13 },
675
- // Official: #4c566a (nord3)
676
- // Color
677
- primary: { l: 0.7746, c: 0.0622, h: 217.47 },
678
- // Official: #88c0d0 (nord8 - Frost)
679
- primaryForeground: { l: 0.15, c: 0.01, h: 210 },
680
- secondary: { l: 0.7629, c: 0.0477, h: 194.49 },
681
- // Official: #8fbcbb (nord7 - Frost)
682
- secondaryForeground: { l: 0.15, c: 0.01, h: 190 },
683
- accent: { l: 0.6921, c: 0.0625, h: 332.66 },
684
- // Official: #b48ead (nord15 - Aurora)
685
- accentForeground: { l: 0.15, c: 0.01, h: 250 },
686
- destructive: { l: 0.6061, c: 0.1206, h: 15.34 },
687
- // Official: #bf616a (nord11 - Aurora)
688
- destructiveForeground: { l: 0.98, c: 0.01, h: 25 }
689
- });
690
- var catppuccinMocha = generateTheme("Catppuccin Mocha", {
691
- // Base - Official: catppuccin.com/palette (Mocha variant)
692
- base: { l: 0.2429, c: 0.0304, h: 283.91 },
693
- // Official: #1e1e2e (Base)
694
- text: { l: 0.8787, c: 0.0426, h: 272.28 },
695
- // Official: #cdd6f4 (Text)
696
- body: { l: 0.8168, c: 0.0403, h: 272.86 },
697
- // Official: #bac2de (Subtext 1)
698
- muted: { l: 0.2155, c: 0.0254, h: 284.06 },
699
- // Surface/Card bg - Official: #181825 (Mantle)
700
- mutedForeground: { l: 0.751, c: 0.0396, h: 273.93 },
701
- // Official: #a6adc8 (Subtext 0)
702
- // Color
703
- primary: { l: 0.7664, c: 0.1113, h: 259.88 },
704
- // Official: #89b4fa (Blue)
705
- primaryForeground: { l: 0.15, c: 0.01, h: 255 },
706
- secondary: { l: 0.7871, c: 0.1187, h: 304.77 },
707
- // Official: #cba6f7 (Mauve)
708
- secondaryForeground: { l: 0.15, c: 0.01, h: 294 },
709
- accent: { l: 0.9193, c: 0.0704, h: 86.53 },
710
- // Official: #f9e2af (Yellow)
711
- accentForeground: { l: 0.15, c: 0.01, h: 72 },
712
- destructive: { l: 0.7556, c: 0.1297, h: 2.76 },
713
- // Official: #f38ba8 (Red)
714
- destructiveForeground: { l: 0.15, c: 0.01, h: 22 }
715
- });
716
- var nordifiedCatppuccin = generateTheme("Nordified Catppuccin", {
717
- // Base - Custom hybrid: Nord backgrounds + Catppuccin accents
718
- base: parseOklch(nord.config.background),
719
- text: parseOklch(nord.config.foreground),
720
- body: parseOklch(nord.config.body),
721
- muted: parseOklch(nord.config.muted),
722
- mutedForeground: parseOklch(nord.config.muted_foreground),
723
- // Color - Catppuccin accent colors
724
- primary: parseOklch(catppuccinMocha.config.primary),
725
- primaryForeground: parseOklch(catppuccinMocha.config.primary_foreground),
726
- secondary: parseOklch(catppuccinMocha.config.secondary),
727
- secondaryForeground: parseOklch(catppuccinMocha.config.secondary_foreground),
728
- accent: parseOklch(catppuccinMocha.config.accent),
729
- accentForeground: parseOklch(catppuccinMocha.config.accent_foreground),
730
- destructive: parseOklch(catppuccinMocha.config.destructive),
731
- destructiveForeground: parseOklch(
732
- catppuccinMocha.config.destructive_foreground
733
- )
734
- });
735
- var christmas = generateTheme("Christmas", {
736
- // Base - Custom holiday theme
737
- base: { l: 0.22, c: 0.04, h: 150 },
738
- // Dark forest green
739
- text: { l: 0.95, c: 0.02, h: 100 },
740
- // Snow white
741
- body: { l: 0.85, c: 0.02, h: 100 },
742
- // Body text
743
- muted: { l: 0.15, c: 0.04, h: 150 },
744
- // Surface/Card bg - Darker green
745
- mutedForeground: { l: 0.65, c: 0.02, h: 100 },
746
- // Muted snow
747
- // Color
748
- primary: { l: 0.6, c: 0.15, h: 30 },
749
- // Christmas red
750
- primaryForeground: { l: 0.98, c: 0.01, h: 30 },
751
- secondary: { l: 0.7, c: 0.12, h: 140 },
752
- // Bright holiday green
753
- secondaryForeground: { l: 0.15, c: 0.01, h: 140 },
754
- accent: { l: 0.85, c: 0.12, h: 90 },
755
- // Warm gold highlight
756
- accentForeground: { l: 0.15, c: 0.01, h: 90 },
757
- destructive: { l: 0.55, c: 0.18, h: 25 },
758
- // Stronger red
759
- destructiveForeground: { l: 0.98, c: 0.01, h: 25 }
760
- });
761
- var pastel = generateTheme("Pastel", {
762
- // Base - Custom soft pastel theme
763
- base: { l: 0.95, c: 0.03, h: 210 },
764
- // Soft light blue-tinted base
765
- text: { l: 0.25, c: 0.03, h: 210 },
766
- // Soft dark text
767
- body: { l: 0.35, c: 0.03, h: 210 },
768
- // Body text
769
- muted: { l: 0.89, c: 0.03, h: 210 },
770
- // Surface/Card bg - Slightly darker
771
- mutedForeground: { l: 0.5, c: 0.03, h: 210 },
772
- // Muted foreground
773
- // Color
774
- primary: { l: 0.55, c: 0.12, h: 200 },
775
- // Pastel blue
776
- primaryForeground: { l: 0.98, c: 0.01, h: 200 },
777
- secondary: { l: 0.55, c: 0.12, h: 320 },
778
- // Pastel pink
779
- secondaryForeground: { l: 0.98, c: 0.01, h: 320 },
780
- accent: { l: 0.6, c: 0.13, h: 80 },
781
- // Pastel yellow
782
- accentForeground: { l: 0.98, c: 0.01, h: 80 },
783
- destructive: { l: 0.5, c: 0.15, h: 25 },
784
- // Pastel red
785
- destructiveForeground: { l: 0.98, c: 0.01, h: 25 }
786
- });
787
- var neon = generateTheme("Neon", {
788
- // Base - Custom vibrant neon theme
789
- base: { l: 0.1, c: 0.03, h: 260 },
790
- // Deep dark purple-tinted base
791
- text: { l: 0.9, c: 0.05, h: 260 },
792
- // Bright neon text
793
- body: { l: 0.8, c: 0.04, h: 260 },
794
- // Body text
795
- muted: { l: 0.18, c: 0.02, h: 260 },
796
- // Surface/Card bg - Slightly lighter
797
- mutedForeground: { l: 0.55, c: 0.04, h: 260 },
798
- // Muted foreground
799
- // Color - High saturation neon accents
800
- primary: { l: 0.6, c: 0.2, h: 180 },
801
- // Neon cyan
802
- primaryForeground: { l: 0.1, c: 0.01, h: 180 },
803
- secondary: { l: 0.6, c: 0.2, h: 300 },
804
- // Neon magenta
805
- secondaryForeground: { l: 0.1, c: 0.01, h: 300 },
806
- accent: { l: 0.55, c: 0.2, h: 90 },
807
- // Neon green
808
- accentForeground: { l: 0.1, c: 0.01, h: 90 },
809
- destructive: { l: 0.55, c: 0.22, h: 20 },
810
- // Neon red
811
- destructiveForeground: { l: 0.1, c: 0.01, h: 20 }
812
- });
813
- var highContrast = generateTheme("High Contrast", {
814
- // Base - Custom accessibility theme (max contrast)
815
- base: { l: 0, c: 0, h: 0 },
816
- // Pure black #000000
817
- text: { l: 1, c: 0, h: 0 },
818
- // Pure white #ffffff
819
- body: { l: 0.9, c: 0, h: 0 },
820
- // Body text
821
- muted: { l: 0.12, c: 0, h: 0 },
822
- // Surface/Card bg - Near black
823
- mutedForeground: { l: 0.6, c: 0, h: 0 },
824
- // Muted gray
825
- // Color - Maximum saturation for visibility
826
- primary: { l: 0.5, c: 0.25, h: 260 },
827
- // Saturated blue
828
- primaryForeground: { l: 1, c: 0, h: 0 },
829
- secondary: { l: 0.5, c: 0.25, h: 120 },
830
- // Saturated green
831
- secondaryForeground: { l: 1, c: 0, h: 0 },
832
- accent: { l: 0.5, c: 0.25, h: 60 },
833
- // Saturated yellow
834
- accentForeground: { l: 0, c: 0, h: 0 },
835
- destructive: { l: 0.5, c: 0.25, h: 0 },
836
- // Saturated red
837
- destructiveForeground: { l: 1, c: 0, h: 0 }
838
- });
839
- var ocean = generateTheme(
840
- "Ocean",
841
- {
842
- // Base - Custom blue ocean theme
843
- base: { l: 0.25, c: 0.03, h: 220 },
844
- // Deep ocean blue
845
- text: { l: 0.85, c: 0.02, h: 220 },
846
- // Light seafoam text
847
- body: { l: 0.75, c: 0.02, h: 220 },
848
- // Body text
849
- muted: { l: 0.33, c: 0.02, h: 220 },
850
- // Surface/Card bg - Lighter ocean
851
- mutedForeground: { l: 0.55, c: 0.02, h: 220 },
852
- // Muted foreground
853
- // Color
854
- primary: { l: 0.65, c: 0.12, h: 200 },
855
- // Ocean blue
856
- primaryForeground: { l: 0.15, c: 0.01, h: 200 },
857
- secondary: { l: 0.7, c: 0.1, h: 180 },
858
- // Teal
859
- secondaryForeground: { l: 0.15, c: 0.01, h: 180 },
860
- accent: { l: 0.75, c: 0.08, h: 160 },
861
- // Aqua
862
- accentForeground: { l: 0.15, c: 0.01, h: 160 },
863
- destructive: { l: 0.6, c: 0.14, h: 25 },
864
- // Coral red
865
- destructiveForeground: { l: 0.98, c: 0.01, h: 25 }
866
- },
867
- "light"
868
- );
869
- var forest = generateTheme(
870
- "Forest",
871
- {
872
- // Base - Custom nature green theme
873
- base: { l: 0.28, c: 0.04, h: 140 },
874
- // Deep forest green
875
- text: { l: 0.88, c: 0.03, h: 100 },
876
- // Light cream text
877
- body: { l: 0.78, c: 0.03, h: 100 },
878
- // Body text
879
- muted: { l: 0.36, c: 0.03, h: 140 },
880
- // Surface/Card bg - Lighter forest
881
- mutedForeground: { l: 0.58, c: 0.03, h: 100 },
882
- // Muted foreground
883
- // Color
884
- primary: { l: 0.65, c: 0.12, h: 145 },
885
- // Forest green
886
- primaryForeground: { l: 0.15, c: 0.01, h: 145 },
887
- secondary: { l: 0.7, c: 0.1, h: 80 },
888
- // Olive
889
- secondaryForeground: { l: 0.15, c: 0.01, h: 80 },
890
- accent: { l: 0.8, c: 0.1, h: 60 },
891
- // Golden
892
- accentForeground: { l: 0.15, c: 0.01, h: 60 },
893
- destructive: { l: 0.6, c: 0.14, h: 30 },
894
- // Burnt orange
895
- destructiveForeground: { l: 0.98, c: 0.01, h: 30 }
896
- },
897
- "light"
898
- );
899
- var sunset = generateTheme(
900
- "Sunset",
901
- {
902
- // Base - Custom warm sunset theme
903
- base: { l: 0.26, c: 0.04, h: 30 },
904
- // Deep warm brown
905
- text: { l: 0.9, c: 0.03, h: 60 },
906
- // Warm cream text
907
- body: { l: 0.8, c: 0.03, h: 60 },
908
- // Body text
909
- muted: { l: 0.34, c: 0.03, h: 30 },
910
- // Surface/Card bg - Lighter warm brown
911
- mutedForeground: { l: 0.58, c: 0.03, h: 60 },
912
- // Muted foreground
913
- // Color
914
- primary: { l: 0.7, c: 0.15, h: 25 },
915
- // Warm orange
916
- primaryForeground: { l: 0.15, c: 0.01, h: 25 },
917
- secondary: { l: 0.68, c: 0.16, h: 350 },
918
- // Pink
919
- secondaryForeground: { l: 0.15, c: 0.01, h: 350 },
920
- accent: { l: 0.75, c: 0.14, h: 50 },
921
- // Yellow-orange
922
- accentForeground: { l: 0.15, c: 0.01, h: 50 },
923
- destructive: { l: 0.6, c: 0.18, h: 20 },
924
- // Red
925
- destructiveForeground: { l: 0.98, c: 0.01, h: 20 }
926
- },
927
- "light"
928
- );
929
- var defaultTheme = generateTheme(
930
- "Default",
931
- DEFAULT_CORE_COLORS,
932
- "light"
933
- );
934
- var BUILT_IN_THEMES = {
935
- Default: defaultTheme,
936
- Dracula: dracula,
937
- Solarized: solarized,
938
- Gruvbox: gruvbox,
939
- Monokai: monokai,
940
- "Tokyo Night": tokyoNight,
941
- "Rose Pine": rosePine,
942
- Everforest: everforest,
943
- Nord: nord,
944
- "Catppuccin Mocha": catppuccinMocha,
945
- "Nordified Catppuccin": nordifiedCatppuccin,
946
- Christmas: christmas,
947
- Pastel: pastel,
948
- Neon: neon,
949
- "High Contrast": highContrast,
950
- Ocean: ocean,
951
- Forest: forest,
952
- Sunset: sunset
953
- };
954
- var allThemes = BUILT_IN_THEMES;
587
+ // src/theme/theme-applicator.ts
588
+ var STYLE_PREFIX = "theme-style-";
589
+ function applyTheme(theme, options) {
590
+ if (typeof document === "undefined") return;
591
+ try {
592
+ const styleId = `${STYLE_PREFIX}${theme.id}`;
593
+ let el = document.getElementById(styleId);
594
+ if (!el) {
595
+ el = document.createElement("style");
596
+ el.id = styleId;
597
+ document.head.appendChild(el);
598
+ }
599
+ el.textContent = generateThemeCSS(theme, options);
600
+ } catch (error) {
601
+ console.error(`[theme] applyTheme failed for "${theme.id}":`, error);
602
+ }
603
+ }
604
+ function removeTheme(themeId) {
605
+ if (typeof document === "undefined") return;
606
+ document.getElementById(`${STYLE_PREFIX}${themeId}`)?.remove();
607
+ }
608
+ function removeAllThemes() {
609
+ if (typeof document === "undefined") return;
610
+ document.querySelectorAll(`style[id^="${STYLE_PREFIX}"]`).forEach((el) => el.remove());
611
+ }
955
612
 
956
- exports.BUILT_IN_THEMES = BUILT_IN_THEMES;
957
- exports.CORE_COLOR_KEYS = CORE_COLOR_KEYS;
958
- exports.CORE_FONT_KEYS = CORE_FONT_KEYS;
959
- exports.CORE_NON_COLOR_KEYS = CORE_NON_COLOR_KEYS;
960
- exports.CORE_SPACING_KEYS = CORE_SPACING_KEYS;
961
- exports.DEFAULT_CORE_COLORS = DEFAULT_CORE_COLORS;
962
- exports.DEFAULT_CORE_COLORS_CONFIG = DEFAULT_CORE_COLORS_CONFIG;
963
- exports.DEFAULT_FONT = DEFAULT_FONT;
613
+ exports.DEFAULT_COLORS = DEFAULT_COLORS;
614
+ exports.DEFAULT_FONT_FAMILIES = DEFAULT_FONT_FAMILIES;
615
+ exports.DEFAULT_FONT_SIZES = DEFAULT_FONT_SIZES;
616
+ exports.DEFAULT_RADII = DEFAULT_RADII;
964
617
  exports.DEFAULT_SPACING = DEFAULT_SPACING;
965
- exports.FONT_OPTIONS = FONT_OPTIONS;
966
- exports.THEME_MODES = THEME_MODES;
967
- exports.allThemes = allThemes;
968
- exports.catppuccinMocha = catppuccinMocha;
969
- exports.christmas = christmas;
970
- exports.clampChroma = clampChroma;
971
- exports.coreColorsToConfig = coreColorsToConfig;
972
- exports.defaultTheme = defaultTheme;
973
- exports.detectThemeMode = detectThemeMode;
974
- exports.dracula = dracula;
975
- exports.everforest = everforest;
976
- exports.findThemeByIdentifier = findThemeByIdentifier;
977
- exports.fontConfigToCoreFont = fontConfigToCoreFont;
978
- exports.forest = forest;
979
- exports.generateColorSwatches = generateColorSwatches;
980
- exports.generateDualTheme = generateDualTheme;
981
- exports.generateSmartDualTheme = generateSmartDualTheme;
982
- exports.generateTheme = generateTheme;
983
- exports.generateThemeCssVars = generateThemeCssVars;
618
+ exports.DEFAULT_THEME_ID = DEFAULT_THEME_ID;
619
+ exports.DEFAULT_THEME_NAME = DEFAULT_THEME_NAME;
620
+ exports.FONT_FAMILY_KEYS = FONT_FAMILY_KEYS;
621
+ exports.FONT_SIZE_KEYS = FONT_SIZE_KEYS;
622
+ exports.RADIUS_KEYS = RADIUS_KEYS;
623
+ exports.SEMANTIC_COLOR_NAMES = SEMANTIC_COLOR_NAMES;
624
+ exports.SHADE_STEPS = SHADE_STEPS;
625
+ exports.applyTheme = applyTheme;
626
+ exports.buildThemeDefinition = buildThemeDefinition;
627
+ exports.deriveDarkVariant = deriveDarkVariant;
628
+ exports.deserialiseTheme = deserialiseTheme;
629
+ exports.generateShades = generateShades;
630
+ exports.generateThemeCSS = generateThemeCSS;
631
+ exports.getActiveThemeId = getActiveThemeId;
632
+ exports.getDefaultThemeDefinition = getDefaultThemeDefinition;
984
633
  exports.getForegroundColor = getForegroundColor;
985
- exports.getThemeIdentifier = getThemeIdentifier;
986
- exports.globalCSSOverride = globalCSSOverride;
987
- exports.gruvbox = gruvbox;
988
- exports.highContrast = highContrast;
989
- exports.isSameTheme = isSameTheme;
990
- exports.mod = mod;
991
- exports.monokai = monokai;
992
- exports.neon = neon;
993
- exports.nord = nord;
994
- exports.nordifiedCatppuccin = nordifiedCatppuccin;
995
- exports.ocean = ocean;
996
- exports.oklchString = oklchString;
997
- exports.parseOklch = parseOklch;
998
- exports.pastel = pastel;
999
- exports.rosePine = rosePine;
1000
- exports.rotateHue = rotateHue;
1001
- exports.rotateSoft = rotateSoft;
1002
- exports.separatedThemeConfig = separatedThemeConfig;
1003
- exports.shadeColor = shadeColor;
1004
- exports.solarized = solarized;
1005
- exports.spacingConfigToCoreSpacing = spacingConfigToCoreSpacing;
1006
- exports.sunset = sunset;
1007
- exports.themeConfigToCoreColors = themeConfigToCoreColors;
1008
- exports.themeConfigToCoreNonColorFields = themeConfigToCoreNonColorFields;
1009
- exports.toDarkMode = toDarkMode;
1010
- exports.toLightMode = toLightMode;
1011
- exports.tokyoNight = tokyoNight;
634
+ exports.mergeDarkOverrides = mergeDarkOverrides;
635
+ exports.parseColor = parseColor;
636
+ exports.removeAllThemes = removeAllThemes;
637
+ exports.removeTheme = removeTheme;
638
+ exports.resolveTheme = resolveTheme;
639
+ exports.serialiseTheme = serialiseTheme;
640
+ exports.transformThemes = transformThemes;
1012
641
  //# sourceMappingURL=index.cjs.map
1013
642
  //# sourceMappingURL=index.cjs.map