@koehler8/cms 1.0.0-beta.5

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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +202 -0
  3. package/bin/cms-generate-public-assets.js +27 -0
  4. package/bin/cms-validate-extensions.js +18 -0
  5. package/bin/cms-validate-themes.js +7 -0
  6. package/extensions/manifest.schema.json +125 -0
  7. package/package.json +84 -0
  8. package/public/img/preloaders/preloader-black.svg +1 -0
  9. package/public/img/preloaders/preloader-white.svg +1 -0
  10. package/public/robots.txt +5 -0
  11. package/scripts/check-overflow.mjs +33 -0
  12. package/scripts/generate-public-assets.js +401 -0
  13. package/scripts/patch-lru-cache-tla.js +164 -0
  14. package/scripts/validate-extensions.mjs +392 -0
  15. package/scripts/validate-themes.mjs +64 -0
  16. package/src/App.vue +3 -0
  17. package/src/components/About.vue +481 -0
  18. package/src/components/AboutValue.vue +361 -0
  19. package/src/components/BackToTop.vue +42 -0
  20. package/src/components/ComingSoon.vue +411 -0
  21. package/src/components/ComingSoonModal.vue +230 -0
  22. package/src/components/Contact.vue +518 -0
  23. package/src/components/Footer.vue +65 -0
  24. package/src/components/FooterMinimal.vue +153 -0
  25. package/src/components/Header.vue +583 -0
  26. package/src/components/Hero.vue +327 -0
  27. package/src/components/Home.vue +144 -0
  28. package/src/components/Intro.vue +130 -0
  29. package/src/components/IntroGate.vue +444 -0
  30. package/src/components/Plan.vue +116 -0
  31. package/src/components/Portfolio.vue +459 -0
  32. package/src/components/Preloader.vue +20 -0
  33. package/src/components/Principles.vue +67 -0
  34. package/src/components/Spacer15.vue +9 -0
  35. package/src/components/Spacer30.vue +9 -0
  36. package/src/components/Spacer40.vue +9 -0
  37. package/src/components/Spacer60.vue +9 -0
  38. package/src/components/StickyCTA.vue +263 -0
  39. package/src/components/Team.vue +432 -0
  40. package/src/components/icons/IconLinkedIn.vue +22 -0
  41. package/src/components/icons/IconX.vue +22 -0
  42. package/src/components/ui/SbCard.vue +52 -0
  43. package/src/components/ui/SkeletonPulse.vue +117 -0
  44. package/src/components/ui/UnitChip.vue +69 -0
  45. package/src/composables/useComingSoonConfig.js +120 -0
  46. package/src/composables/useComingSoonInterstitial.js +27 -0
  47. package/src/composables/useComponentResolver.js +196 -0
  48. package/src/composables/useEngagementTracking.js +187 -0
  49. package/src/composables/useIntroGate.js +46 -0
  50. package/src/composables/useLazyImage.js +77 -0
  51. package/src/composables/usePageConfig.js +184 -0
  52. package/src/composables/usePageMeta.js +76 -0
  53. package/src/composables/usePromoBackgroundStyles.js +67 -0
  54. package/src/constants/locales.js +20 -0
  55. package/src/extensions/extensionLoader.js +512 -0
  56. package/src/main.js +175 -0
  57. package/src/router/index.js +112 -0
  58. package/src/styles/base.css +896 -0
  59. package/src/styles/layout.css +342 -0
  60. package/src/styles/theme-base.css +84 -0
  61. package/src/themes/themeLoader.js +124 -0
  62. package/src/themes/themeManager.js +257 -0
  63. package/src/themes/themeValidator.js +380 -0
  64. package/src/utils/analytics.js +100 -0
  65. package/src/utils/appInfo.js +9 -0
  66. package/src/utils/assetResolver.js +162 -0
  67. package/src/utils/componentRegistry.js +46 -0
  68. package/src/utils/contentRequirements.js +67 -0
  69. package/src/utils/cookieConsent.js +281 -0
  70. package/src/utils/ctaCopy.js +58 -0
  71. package/src/utils/formatNumber.js +115 -0
  72. package/src/utils/imageSources.js +179 -0
  73. package/src/utils/inflateFlatConfig.js +30 -0
  74. package/src/utils/loadConfig.js +271 -0
  75. package/src/utils/semver.js +49 -0
  76. package/src/utils/siteStyles.js +40 -0
  77. package/src/utils/themeColors.js +65 -0
  78. package/src/utils/trackingContext.js +142 -0
  79. package/src/utils/unwrapDefault.js +14 -0
  80. package/src/utils/useScrollReveal.js +48 -0
  81. package/templates/index.html +36 -0
  82. package/themes/base/README.md +23 -0
  83. package/themes/base/theme.config.js +214 -0
  84. package/vite-plugin.js +637 -0
@@ -0,0 +1,257 @@
1
+ import { resolveThemeManifest } from './themeLoader.js';
2
+
3
+ const toKebab = (value = '') =>
4
+ value
5
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
6
+ .replace(/[\s_]+/g, '-')
7
+ .toLowerCase();
8
+
9
+ const withPx = (value) => {
10
+ if (value === undefined || value === null) return undefined;
11
+ if (typeof value === 'number') return `${value}px`;
12
+ return value;
13
+ };
14
+
15
+ const setVar = (vars, name, value) => {
16
+ if (value === undefined || value === null || value === '') return;
17
+ vars[name] = String(value);
18
+ };
19
+
20
+ const assignPrefixed = (vars, entries = {}, prefix) => {
21
+ Object.entries(entries).forEach(([key, value]) => {
22
+ setVar(vars, `${prefix}${key}`, value);
23
+ });
24
+ };
25
+
26
+ function setSurfaceVars(vars, prefix, surface = {}) {
27
+ if (!surface) return;
28
+ setVar(vars, `${prefix}-bg`, surface.background);
29
+ setVar(vars, `${prefix}-before`, surface.before);
30
+ setVar(vars, `${prefix}-after`, surface.after);
31
+ }
32
+
33
+ function coerceSurface(value, defaults = {}) {
34
+ if (value && typeof value === 'object') return value;
35
+ if (!value) return defaults;
36
+ return { ...defaults, background: value };
37
+ }
38
+
39
+ function coerceArray(value) {
40
+ if (!value) return undefined;
41
+ return Array.isArray(value) ? value.filter(Boolean).join(', ') : value;
42
+ }
43
+
44
+ function buildCssVarMap(manifest) {
45
+ if (!manifest) return {};
46
+ const vars = {};
47
+ const tokens = manifest.tokens || {};
48
+ const palette = tokens.palette || {};
49
+ const text = tokens.text || {};
50
+ const surfaces = tokens.surfaces || {};
51
+ const helper = surfaces.helper || {};
52
+ const tabs = surfaces.tabs || {};
53
+ const field = surfaces.field || {};
54
+ const strip = surfaces.strip || {};
55
+ const chrome = surfaces.chrome || {};
56
+ const heroSurface = surfaces.backdropPrimary || {};
57
+ const promoSurface = surfaces.backdropSecondary || {};
58
+ const typography = tokens.typography || {};
59
+ const ctas = tokens.ctas || {};
60
+ const chips = tokens.chips || {};
61
+ const focus = tokens.focus || {};
62
+ const radii = tokens.radii || {};
63
+ const elevation = tokens.elevation || {};
64
+ const utility = tokens.utility || {};
65
+
66
+ assignPrefixed(
67
+ vars,
68
+ Object.fromEntries(
69
+ Object.entries(palette).map(([key, value]) => [`--brand-${toKebab(key)}`, value])
70
+ )
71
+ );
72
+
73
+ setVar(vars, '--brand-accent-electric', palette.primary || palette.accent);
74
+ setVar(vars, '--brand-accent-electric-soft', palette.accentSoft);
75
+ setVar(vars, '--brand-accent-warm', palette.accent || palette.warning);
76
+
77
+ setVar(vars, '--brand-fg-100', text.primary);
78
+ setVar(vars, '--brand-fg-200', text.muted);
79
+ setVar(vars, '--brand-fg-300', text.mutedStrong);
80
+ setVar(vars, '--brand-fg-050', text.inverse);
81
+ setVar(vars, '--brand-bg-900', surfaces.base);
82
+ setVar(vars, '--brand-bg-800', surfaces.baseAlt);
83
+ setVar(vars, '--brand-bg-700', surfaces.raised);
84
+ setVar(vars, '--brand-bg-600', surfaces.sunken);
85
+
86
+ Object.entries(radii).forEach(([key, value]) => {
87
+ setVar(vars, `--brand-radius-${toKebab(key)}`, withPx(value));
88
+ });
89
+ setVar(vars, '--brand-card-radius', withPx(radii.lg || radii.md));
90
+ setVar(vars, '--brand-button-radius', withPx(radii.md || radii.sm));
91
+
92
+ setVar(vars, '--brand-shadow-glow', elevation.raised);
93
+ setVar(vars, '--brand-shadow-glow-strong', elevation.overlay);
94
+ setVar(vars, '--brand-card-shadow', elevation.raised);
95
+ setVar(vars, '--brand-surface-card-shadow', elevation.raised);
96
+
97
+ const cardTextColor = text.card || text.primary;
98
+ setVar(vars, '--brand-card-soft', surfaces.card);
99
+ setVar(vars, '--brand-surface-card-bg', surfaces.card);
100
+ setVar(vars, '--brand-card-border', surfaces.border);
101
+ setVar(vars, '--brand-surface-card-border', surfaces.border);
102
+ setVar(vars, '--brand-card-text', cardTextColor);
103
+ setVar(vars, '--brand-surface-helper-bg', helper.background || surfaces.callout);
104
+ setVar(vars, '--brand-surface-helper-hover-bg', helper.hover || helper.background);
105
+ setVar(vars, '--brand-icon-badge-bg', surfaces.chipAccent || surfaces.chip);
106
+ setVar(vars, '--brand-icon-badge-color', palette.primary || text.primary);
107
+
108
+ setVar(vars, '--brand-border-highlight', surfaces.border);
109
+ setVar(vars, '--brand-border-glow', surfaces.border);
110
+
111
+ setVar(vars, '--brand-status-success', palette.success);
112
+ setVar(vars, '--brand-status-error', palette.critical);
113
+ setVar(vars, '--brand-status-error-soft', palette.criticalSoft);
114
+
115
+ setVar(vars, '--brand-input-bg', field.background || surfaces.input);
116
+ setVar(vars, '--brand-input-border', field.border || utility.inputBorder);
117
+ setVar(vars, '--brand-input-border-active', focus.ring);
118
+ setVar(vars, '--brand-input-text', field.inputColor || utility.inputText || text.primary);
119
+ setVar(
120
+ vars,
121
+ '--brand-input-placeholder',
122
+ field.inputPlaceholder || utility.inputPlaceholder || text.muted
123
+ );
124
+ setVar(vars, '--brand-focus-ring', focus.ring);
125
+ setVar(vars, '--brand-focus-glow', focus.shadowInset);
126
+
127
+ setVar(vars, '--brand-modal-backdrop', surfaces.backdrop);
128
+ setVar(vars, '--brand-modal-surface', utility.modalSurface);
129
+ setVar(vars, '--brand-modal-border', utility.modalBorder);
130
+ setVar(vars, '--brand-modal-shadow', utility.modalShadow);
131
+ setVar(vars, '--brand-modal-radius', withPx(utility.modalRadius));
132
+
133
+ setVar(vars, '--brand-chart-track', utility.chartTrack);
134
+ setVar(vars, '--brand-chart-center-text', utility.chartCenterText);
135
+
136
+ setVar(vars, '--brand-header-bg', chrome.background);
137
+ setVar(vars, '--brand-header-text', chrome.text);
138
+ setVar(vars, '--site-header-shadow', chrome.shadow);
139
+ setVar(vars, '--site-header-shadow-compact', chrome.compactShadow);
140
+
141
+ const primaryCta = ctas.primary || {};
142
+ setVar(vars, '--brand-primary-cta-gradient', primaryCta.bg);
143
+ setVar(vars, '--brand-primary-cta-text', primaryCta.text);
144
+ setVar(vars, '--brand-primary-cta-border', primaryCta.border);
145
+ setVar(vars, '--brand-primary-cta-shadow', primaryCta.shadow);
146
+ setVar(vars, '--brand-primary-cta-hover-shadow', primaryCta.shadow);
147
+ setVar(vars, '--brand-primary-cta-hover-translate', 'translateY(-1px)');
148
+ setVar(vars, '--brand-cta-text', primaryCta.text);
149
+
150
+ setVar(vars, '--helper-strip-bg', helper.background || surfaces.callout);
151
+ setVar(vars, '--helper-strip-border', helper.border || surfaces.border);
152
+ setVar(vars, '--helper-strip-color', helper.text || text.primary);
153
+ setVar(vars, '--helper-strip-hover-bg', helper.hover || helper.background);
154
+ setVar(vars, '--helper-strip-hover-color', helper.hoverColor || helper.text || text.primary);
155
+ setVar(vars, '--helper-strip-link-hover', helper.linkHover || palette.primary);
156
+ setVar(vars, '--helper-strip-heading-color', helper.heading || text.primary);
157
+ setVar(vars, '--helper-strip-body-color', helper.body || text.mutedStrong || text.muted);
158
+
159
+ setVar(vars, '--tabs-bg', tabs.background);
160
+ setVar(vars, '--tabs-border', tabs.border || surfaces.border);
161
+ setVar(vars, '--tabs-shadow', tabs.shadow || elevation.flat);
162
+ setVar(vars, '--tab-color', tabs.tabColor || text.muted);
163
+ setVar(vars, '--tab-active-bg', tabs.activeBackground || palette.primary);
164
+ setVar(vars, '--tab-active-color', tabs.activeColor || palette.inverse || '#fff');
165
+ setVar(vars, '--tab-active-shadow', tabs.activeShadow || elevation.raised);
166
+ setVar(vars, '--tab-step-bg', tabs.stepBackground || helper.background);
167
+ setVar(vars, '--tab-step-border', tabs.stepBorder || helper.border);
168
+ setVar(vars, '--tab-step-color', tabs.stepColor || palette.primary);
169
+ setVar(vars, '--tab-active-step-bg', tabs.activeStepBackground || palette.primary);
170
+ setVar(vars, '--tab-active-step-border', tabs.activeStepBorder || tabs.stepBorder);
171
+ setVar(vars, '--tab-active-step-color', tabs.activeStepColor || palette.inverse || '#fff');
172
+
173
+ setVar(vars, '--field-bg', field.background);
174
+ setVar(vars, '--field-border', field.border || utility.inputBorder);
175
+ setVar(vars, '--field-shadow', field.shadow || elevation.flat);
176
+ setVar(vars, '--field-addon-bg', field.addonBackground || helper.background);
177
+ setVar(vars, '--field-addon-border', field.addonBorder || helper.border);
178
+ setVar(vars, '--field-addon-color', field.addonColor || helper.text || text.primary);
179
+ setVar(vars, '--field-input-color', field.inputColor || text.primary);
180
+ setVar(vars, '--field-input-placeholder', field.inputPlaceholder || text.muted);
181
+
182
+ setVar(vars, '--community-strip-bg', strip.background || surfaces.card);
183
+ setVar(vars, '--community-strip-border', strip.border || surfaces.border);
184
+ setVar(vars, '--community-strip-color', strip.text || text.primary);
185
+
186
+ setVar(vars, '--ui-text-primary', text.primary);
187
+ setVar(vars, '--ui-text-muted', text.muted);
188
+ setVar(vars, '--ui-field-label', text.muted);
189
+ setVar(vars, '--ui-field-value', text.primary);
190
+ setVar(vars, '--ui-status-heading-color', text.accent || palette.primary);
191
+
192
+ setVar(vars, '--brand-countdown-digit', palette.primary);
193
+ setVar(vars, '--brand-countdown-label', text.muted);
194
+
195
+ const secondaryCta = ctas.secondary || {};
196
+ setVar(vars, '--brand-pill-gradient', primaryCta.bg);
197
+ setVar(vars, '--brand-pill-alt-gradient', secondaryCta.bg || primaryCta.bg);
198
+ setVar(vars, '--brand-pill-contrast', primaryCta.text);
199
+
200
+ setVar(vars, '--brand-chip-neutral-bg', chips.neutral?.bg);
201
+ setVar(vars, '--brand-chip-neutral-color', chips.neutral?.text);
202
+ setVar(vars, '--brand-chip-neutral-border', chips.neutral?.border);
203
+
204
+ const heroBg = coerceArray(utility.gradientHero || heroSurface.background);
205
+ const promoBg = coerceArray(utility.gradientPromo || promoSurface.background);
206
+ if (heroBg) setVar(vars, '--brand-gradient-hero', heroBg);
207
+ if (promoBg) setVar(vars, '--brand-gradient-promo', promoBg);
208
+
209
+ setSurfaceVars(vars, '--hero-surface', heroSurface);
210
+ setSurfaceVars(vars, '--promo-surface', promoSurface);
211
+ const bodyBackground = coerceArray(utility.bodyBackground);
212
+ if (bodyBackground) {
213
+ setVar(vars, '--theme-body-background', bodyBackground);
214
+ }
215
+
216
+ const statusHeadline = coerceSurface(utility.statusHeadline, {
217
+ color: palette.primary || text.primary,
218
+ shadow: elevation.raised,
219
+ });
220
+
221
+ setVar(vars, '--status-headline-bg', statusHeadline.background);
222
+ setVar(vars, '--status-headline-color', statusHeadline.color);
223
+ setVar(vars, '--status-headline-shadow', statusHeadline.shadow);
224
+
225
+ setVar(vars, '--status-price-value-color', palette.accent || palette.primary || text.primary);
226
+ setVar(vars, '--status-price-value-shadow', elevation.raised);
227
+
228
+ return vars;
229
+ }
230
+
231
+ export function applyThemeVariables(themeKey) {
232
+ const manifest = resolveThemeManifest(themeKey);
233
+ if (typeof document === 'undefined') {
234
+ return manifest;
235
+ }
236
+ const vars = buildCssVarMap(manifest);
237
+ const root = document.documentElement;
238
+
239
+ // Remove inline assignments from previous calls so normal cascade can apply.
240
+ Object.keys(vars).forEach((name) => root.style.removeProperty(name));
241
+
242
+ let styleTag = document.getElementById('theme-vars');
243
+ if (!styleTag) {
244
+ styleTag = document.createElement('style');
245
+ styleTag.id = 'theme-vars';
246
+ // Insert early so site/theme overrides loaded later can win via cascade.
247
+ const head = document.head || root;
248
+ head.insertBefore(styleTag, head.firstChild);
249
+ }
250
+
251
+ const cssBody = Object.entries(vars)
252
+ .map(([name, value]) => `${name}: ${value};`)
253
+ .join('\n ');
254
+ styleTag.textContent = `:root {\n ${cssBody}\n}`;
255
+
256
+ return manifest;
257
+ }
@@ -0,0 +1,380 @@
1
+ const COLOR_PATTERN =
2
+ /^(#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})\b|rgba?\(|hsla?\(|var\(--|linear-gradient\(|radial-gradient\(|conic-gradient\(|color-mix\()/i;
3
+ const CSS_UNIT_PATTERN = /^-?\d*\.?\d+(px|rem|em|vh|vw|%)$/i;
4
+
5
+ const CTA_KEYS = ['bg', 'text', 'border', 'hoverBg', 'hoverBorder', 'shadow'];
6
+ const CHIP_KEYS = ['bg', 'text', 'border'];
7
+
8
+ const REQUIRED_BLOCKS = {
9
+ palette: [
10
+ 'primary',
11
+ 'primaryAccent',
12
+ 'secondary',
13
+ 'accent',
14
+ 'accentSoft',
15
+ 'neutral',
16
+ 'neutralStrong',
17
+ 'inverse',
18
+ 'success',
19
+ 'info',
20
+ 'warning',
21
+ 'critical',
22
+ ],
23
+ text: ['primary', 'muted', 'mutedStrong', 'inverse', 'accent', 'onAccent'],
24
+ surfaces: [
25
+ 'base',
26
+ 'baseAlt',
27
+ 'raised',
28
+ 'sunken',
29
+ 'callout',
30
+ 'card',
31
+ 'cardAlt',
32
+ 'overlay',
33
+ 'backdrop',
34
+ 'border',
35
+ 'divider',
36
+ 'input',
37
+ 'chip',
38
+ 'chipAccent',
39
+ ],
40
+ typography: [
41
+ 'bodyFamily',
42
+ 'headingFamily',
43
+ 'monoFamily',
44
+ 'baseSize',
45
+ 'scale',
46
+ 'weightRegular',
47
+ 'weightMedium',
48
+ 'weightBold',
49
+ 'letterSpacingTight',
50
+ 'letterSpacingWide',
51
+ ],
52
+ ctas: ['primary', 'secondary', 'ghost', 'link'],
53
+ chips: ['neutral', 'accent', 'outline'],
54
+ focus: ['ring', 'ringMuted', 'outline', 'shadowInset'],
55
+ radii: ['sm', 'md', 'lg', 'pill', 'full'],
56
+ elevation: ['flat', 'raised', 'overlay'],
57
+ utility: [
58
+ 'divider',
59
+ 'inputBorder',
60
+ 'inputText',
61
+ 'inputPlaceholder',
62
+ 'selectionBg',
63
+ 'selectionText',
64
+ 'gradientHero',
65
+ 'gradientPromo',
66
+ 'bodyBackground',
67
+ 'modalSurface',
68
+ 'modalBorder',
69
+ 'modalShadow',
70
+ 'modalRadius',
71
+ 'chartTrack',
72
+ 'chartCenterText',
73
+ 'statusHeadline',
74
+ ],
75
+ };
76
+
77
+ const NESTED_SURFACES = {
78
+ helper: ['background', 'hover', 'text', 'border', 'heading', 'body'],
79
+ tabs: [
80
+ 'background',
81
+ 'border',
82
+ 'shadow',
83
+ 'tabColor',
84
+ 'activeBackground',
85
+ 'activeColor',
86
+ 'activeShadow',
87
+ 'stepBackground',
88
+ 'stepBorder',
89
+ 'stepColor',
90
+ 'activeStepBackground',
91
+ 'activeStepBorder',
92
+ 'activeStepColor',
93
+ ],
94
+ field: [
95
+ 'background',
96
+ 'border',
97
+ 'shadow',
98
+ 'addonBackground',
99
+ 'addonBorder',
100
+ 'addonColor',
101
+ 'inputColor',
102
+ 'inputPlaceholder',
103
+ ],
104
+ strip: ['background', 'border', 'text'],
105
+ chrome: ['background', 'text', 'shadow', 'compactShadow'],
106
+ backdropPrimary: ['background', 'before', 'after'],
107
+ backdropSecondary: ['background', 'before', 'after'],
108
+ };
109
+
110
+ const CTA_OVERRIDES = {
111
+ primary: { border: ensureString, hoverBorder: ensureString, shadow: ensureString },
112
+ secondary: { border: ensureString, hoverBorder: ensureString, shadow: ensureString },
113
+ ghost: { border: ensureString, hoverBorder: ensureString, shadow: ensureString },
114
+ link: { underline: ensureColor },
115
+ };
116
+
117
+ const CHIP_OVERRIDES = {
118
+ outline: { border: ensureString },
119
+ };
120
+
121
+ const SURFACE_NESTED_OVERRIDES = {
122
+ tabs: {
123
+ border: ensureString,
124
+ shadow: ensureString,
125
+ activeShadow: ensureString,
126
+ stepBorder: ensureString,
127
+ activeStepBorder: ensureString,
128
+ },
129
+ field: {
130
+ shadow: ensureString,
131
+ addonBorder: ensureString,
132
+ },
133
+ chrome: {
134
+ shadow: ensureString,
135
+ compactShadow: ensureString,
136
+ },
137
+ };
138
+
139
+ const UTILITY_VALIDATORS = {
140
+ divider: ensureColor,
141
+ inputBorder: ensureColor,
142
+ inputText: ensureColor,
143
+ inputPlaceholder: ensureColor,
144
+ selectionBg: ensureColor,
145
+ selectionText: ensureColor,
146
+ gradientHero: ensureColor,
147
+ gradientPromo: ensureColor,
148
+ bodyBackground: ensureColor,
149
+ modalSurface: ensureColor,
150
+ modalBorder: ensureColor,
151
+ modalShadow: ensureString,
152
+ modalRadius: (value, path, errors) => {
153
+ if (!isCssSize(value)) errors.push(`${path} must be a CSS size`);
154
+ },
155
+ chartTrack: ensureColor,
156
+ chartCenterText: ensureColor,
157
+ statusHeadline: ensureSurfaceOrColor,
158
+ };
159
+
160
+ function isString(value) {
161
+ return typeof value === 'string' && value.trim().length > 0;
162
+ }
163
+
164
+ function isColor(value) {
165
+ if (!isString(value)) return false;
166
+ const normalized = value.trim().toLowerCase();
167
+ if (normalized === 'transparent' || normalized === 'currentcolor' || normalized === 'none') {
168
+ return true;
169
+ }
170
+ return COLOR_PATTERN.test(normalized);
171
+ }
172
+
173
+ function isCssSize(value) {
174
+ if (typeof value === 'number') return true;
175
+ if (!isString(value)) return false;
176
+ const normalized = value.trim();
177
+ if (normalized === '0') return true;
178
+ return CSS_UNIT_PATTERN.test(normalized);
179
+ }
180
+
181
+ function ensureColor(value, path, errors) {
182
+ if (Array.isArray(value)) {
183
+ value.forEach((entry, index) => ensureColor(entry, `${path}[${index}]`, errors));
184
+ return;
185
+ }
186
+ if (!isColor(value)) {
187
+ errors.push(`${path} must be a CSS color/gradient value`);
188
+ }
189
+ }
190
+
191
+ function ensureSurfaceOrColor(value, path, errors) {
192
+ if (value && typeof value === 'object') {
193
+ if (!value.background) {
194
+ errors.push(`${path}.background is required`);
195
+ } else {
196
+ ensureColor(value.background, `${path}.background`, errors);
197
+ }
198
+ if (value.color) ensureColor(value.color, `${path}.color`, errors);
199
+ if (value.shadow) ensureString(value.shadow, `${path}.shadow`, errors);
200
+ if (value.border) ensureColor(value.border, `${path}.border`, errors);
201
+ if (value.valueColor) ensureColor(value.valueColor, `${path}.valueColor`, errors);
202
+ if (value.valueShadow) ensureString(value.valueShadow, `${path}.valueShadow`, errors);
203
+ return;
204
+ }
205
+ ensureColor(value, path, errors);
206
+ }
207
+
208
+ function ensureString(value, path, errors) {
209
+ if (!isString(value)) {
210
+ errors.push(`${path} must be a non-empty string`);
211
+ }
212
+ }
213
+
214
+ function ensureObject(value, path, errors) {
215
+ if (!value || typeof value !== 'object') {
216
+ errors.push(`${path} must be an object`);
217
+ return false;
218
+ }
219
+ return true;
220
+ }
221
+
222
+ function ensureKeys(obj, keys, path, errors, validator = ensureColor, overrides = {}) {
223
+ keys.forEach((key) => {
224
+ if (!(key in obj)) {
225
+ errors.push(`${path}.${key} is required`);
226
+ return;
227
+ }
228
+ const fieldValidator = overrides[key] || validator;
229
+ fieldValidator(obj[key], `${path}.${key}`, errors);
230
+ });
231
+ }
232
+
233
+ function validatePaletteBlock(tokens, errors) {
234
+ if (!ensureObject(tokens.palette, 'tokens.palette', errors)) return;
235
+ ensureKeys(tokens.palette, REQUIRED_BLOCKS.palette, 'tokens.palette', errors, ensureColor);
236
+ }
237
+
238
+ function validateTextBlock(tokens, errors) {
239
+ if (!ensureObject(tokens.text, 'tokens.text', errors)) return;
240
+ ensureKeys(tokens.text, REQUIRED_BLOCKS.text, 'tokens.text', errors, ensureColor);
241
+ }
242
+
243
+ function validateSurfaceBlock(tokens, errors) {
244
+ if (!ensureObject(tokens.surfaces, 'tokens.surfaces', errors)) return;
245
+ ensureKeys(tokens.surfaces, REQUIRED_BLOCKS.surfaces, 'tokens.surfaces', errors, ensureColor);
246
+ Object.entries(NESTED_SURFACES).forEach(([key, nestedKeys]) => {
247
+ const node = tokens.surfaces[key];
248
+ if (!ensureObject(node, `tokens.surfaces.${key}`, errors)) return;
249
+ ensureKeys(
250
+ node,
251
+ nestedKeys,
252
+ `tokens.surfaces.${key}`,
253
+ errors,
254
+ ensureColor,
255
+ SURFACE_NESTED_OVERRIDES[key] || {}
256
+ );
257
+ });
258
+ }
259
+
260
+ function validateTypography(tokens, errors) {
261
+ if (!ensureObject(tokens.typography, 'tokens.typography', errors)) return;
262
+ ensureKeys(tokens.typography, REQUIRED_BLOCKS.typography, 'tokens.typography', errors, (value, path) => {
263
+ if (typeof value === 'number') return;
264
+ if (!isString(value)) {
265
+ errors.push(`${path} must be a string or number`);
266
+ }
267
+ });
268
+ }
269
+
270
+ function validateCtas(tokens, errors) {
271
+ if (!ensureObject(tokens.ctas, 'tokens.ctas', errors)) return;
272
+ REQUIRED_BLOCKS.ctas.forEach((ctaKey) => {
273
+ const block = tokens.ctas[ctaKey];
274
+ if (!ensureObject(block, `tokens.ctas.${ctaKey}`, errors)) return;
275
+ const keys = ctaKey === 'link' ? ['text', 'hoverText', 'underline'] : CTA_KEYS;
276
+ ensureKeys(
277
+ block,
278
+ keys,
279
+ `tokens.ctas.${ctaKey}`,
280
+ errors,
281
+ ensureColor,
282
+ CTA_OVERRIDES[ctaKey] || {}
283
+ );
284
+ });
285
+ }
286
+
287
+ function validateChips(tokens, errors) {
288
+ if (!ensureObject(tokens.chips, 'tokens.chips', errors)) return;
289
+ REQUIRED_BLOCKS.chips.forEach((chipKey) => {
290
+ const block = tokens.chips[chipKey];
291
+ if (!ensureObject(block, `tokens.chips.${chipKey}`, errors)) return;
292
+ ensureKeys(
293
+ block,
294
+ CHIP_KEYS,
295
+ `tokens.chips.${chipKey}`,
296
+ errors,
297
+ ensureColor,
298
+ CHIP_OVERRIDES[chipKey] || {}
299
+ );
300
+ });
301
+ }
302
+
303
+ function validateFocus(tokens, errors) {
304
+ if (!ensureObject(tokens.focus, 'tokens.focus', errors)) return;
305
+ ensureKeys(tokens.focus, REQUIRED_BLOCKS.focus, 'tokens.focus', errors, ensureString);
306
+ }
307
+
308
+ function validateRadii(tokens, errors) {
309
+ if (!ensureObject(tokens.radii, 'tokens.radii', errors)) return;
310
+ ensureKeys(tokens.radii, REQUIRED_BLOCKS.radii, 'tokens.radii', errors, (value, path) => {
311
+ if (!isCssSize(value)) {
312
+ errors.push(`${path} must be a CSS size (px, rem, etc.)`);
313
+ }
314
+ });
315
+ }
316
+
317
+ function validateElevation(tokens, errors) {
318
+ if (!ensureObject(tokens.elevation, 'tokens.elevation', errors)) return;
319
+ ensureKeys(tokens.elevation, REQUIRED_BLOCKS.elevation, 'tokens.elevation', errors, ensureString);
320
+ }
321
+
322
+ function validateUtility(tokens, errors) {
323
+ if (!ensureObject(tokens.utility, 'tokens.utility', errors)) return;
324
+ REQUIRED_BLOCKS.utility.forEach((key) => {
325
+ const value = tokens.utility[key];
326
+ if (value === undefined || value === null || value === '') {
327
+ errors.push(`tokens.utility.${key} is required`);
328
+ return;
329
+ }
330
+ const validator = UTILITY_VALIDATORS[key] || ensureColor;
331
+ if (Array.isArray(value)) {
332
+ value.forEach((entry, index) => validator(entry, `tokens.utility.${key}[${index}]`, errors));
333
+ return;
334
+ }
335
+ validator(value, `tokens.utility.${key}`, errors);
336
+ });
337
+ }
338
+
339
+ export function validateThemeManifest(manifest, options = {}) {
340
+ const { throwOnError = true } = options;
341
+ const errors = [];
342
+ if (!manifest || typeof manifest !== 'object') {
343
+ errors.push('Theme manifest must be an object');
344
+ } else {
345
+ if (!isString(manifest.slug)) {
346
+ errors.push('manifest.slug must be a non-empty string');
347
+ }
348
+ if (!ensureObject(manifest.meta, 'manifest.meta', errors)) {
349
+ // no-op
350
+ } else {
351
+ if (!isString(manifest.meta.name)) errors.push('manifest.meta.name is required');
352
+ if (!isString(manifest.meta.version)) errors.push('manifest.meta.version is required');
353
+ }
354
+ if (!ensureObject(manifest.tokens, 'manifest.tokens', errors)) {
355
+ // no-op
356
+ } else {
357
+ validatePaletteBlock(manifest.tokens, errors);
358
+ validateTextBlock(manifest.tokens, errors);
359
+ validateSurfaceBlock(manifest.tokens, errors);
360
+ validateTypography(manifest.tokens, errors);
361
+ validateCtas(manifest.tokens, errors);
362
+ validateChips(manifest.tokens, errors);
363
+ validateFocus(manifest.tokens, errors);
364
+ validateRadii(manifest.tokens, errors);
365
+ validateElevation(manifest.tokens, errors);
366
+ validateUtility(manifest.tokens, errors);
367
+ }
368
+ }
369
+
370
+ if (errors.length && throwOnError) {
371
+ const slug = manifest?.slug || 'unknown';
372
+ const error = new Error(
373
+ `Theme manifest "${slug}" is invalid:\n- ${errors.join('\n- ')}`
374
+ );
375
+ error.errors = errors;
376
+ throw error;
377
+ }
378
+
379
+ return { valid: errors.length === 0, errors };
380
+ }