@webmate-studio/builder 0.2.90 → 0.2.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmate-studio/builder",
3
- "version": "0.2.90",
3
+ "version": "0.2.91",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
@@ -66,8 +66,7 @@ export function deduplicateCSS(cssArray) {
66
66
  base: new Set(),
67
67
  properties: new Set(),
68
68
  theme: new Set(),
69
- components: new Set(), // Component utilities (wrapped from utilities layer)
70
- utilities: new Set() // Design token utilities (should override components)
69
+ utilities: new Set()
71
70
  };
72
71
  const regularRules = {
73
72
  charset: [], // @charset declarations
@@ -158,9 +157,6 @@ export function deduplicateCSS(cssArray) {
158
157
  parts.push(...regularRules.imports);
159
158
  }
160
159
 
161
- // Layer order declaration (MUST be first to define precedence)
162
- parts.push('@layer base, components, utilities;');
163
-
164
160
  // Tailwind layers in correct order
165
161
  if (tailwindLayers.base.size > 0) {
166
162
  parts.push(`@layer base {\n${Array.from(tailwindLayers.base).join('\n\n')}\n}`);
@@ -171,11 +167,6 @@ export function deduplicateCSS(cssArray) {
171
167
  if (tailwindLayers.theme.size > 0) {
172
168
  parts.push(`@layer theme {\n${Array.from(tailwindLayers.theme).join('\n\n')}\n}`);
173
169
  }
174
- if (tailwindLayers.components.size > 0) {
175
- // Sort component utilities by breakpoint before joining
176
- const sortedComponents = sortUtilityRules(Array.from(tailwindLayers.components));
177
- parts.push(`@layer components {\n${sortedComponents.join('\n\n')}\n}`);
178
- }
179
170
  if (tailwindLayers.utilities.size > 0) {
180
171
  // Sort utilities by breakpoint before joining
181
172
  const sortedUtilities = sortUtilityRules(Array.from(tailwindLayers.utilities));
@@ -7,7 +7,7 @@ function generateSemanticColorUtilities(tokens) {
7
7
  if (!tokens.colors) return '';
8
8
 
9
9
  let utilities = '\n/* Color Utilities */';
10
- utilities += '\n@layer utilities {';
10
+ utilities += '\n@layer components {';
11
11
 
12
12
  // Map of all colors: token name -> utility class base name
13
13
  const colorMap = {
@@ -1008,11 +1008,7 @@ export function generateTailwindConfig(tokens) {
1008
1008
  * Generate CSS Variables from Design Tokens
1009
1009
  */
1010
1010
  export function generateCSSFromTokens(tokens) {
1011
- const lines = [];
1012
-
1013
- // NOTE: @layer order declaration is now handled by css-deduplicator.js
1014
- // to ensure it appears only once and in the correct position
1015
- lines.push(':root {');
1011
+ const lines = [':root {'];
1016
1012
 
1017
1013
  // Colors
1018
1014
  for (const [key, value] of Object.entries(tokens.colors || {})) {
@@ -1317,6 +1313,7 @@ export function generateCSSFromTokens(tokens) {
1317
1313
  if (tokens.buttons) {
1318
1314
  lines.push('');
1319
1315
  lines.push('/* Button Utilities */');
1316
+ lines.push('@layer components {');
1320
1317
 
1321
1318
  // Helper to convert hex to rgba with opacity
1322
1319
  const hexToRgba = (hex, alpha) => {
@@ -1475,6 +1472,8 @@ export function generateCSSFromTokens(tokens) {
1475
1472
 
1476
1473
  lines.push('}');
1477
1474
  }
1475
+
1476
+ lines.push('}'); // Close @layer components
1478
1477
  }
1479
1478
 
1480
1479
  // Add semantic color utilities
@@ -68,33 +68,6 @@ function stripNonUtilityLayers(css) {
68
68
  return css.trim();
69
69
  }
70
70
 
71
- /**
72
- * Wraps utility classes in @layer components, preserving base/theme/properties layers
73
- * This allows design token utilities (@layer utilities) to override component utilities
74
- * @param {string} css - Full Tailwind CSS
75
- * @returns {string} CSS with utilities wrapped in @layer components
76
- */
77
- function wrapUtilitiesInComponentsLayer(css) {
78
- // Extract @layer utilities content
79
- const utilitiesMatch = css.match(/@layer\s+utilities\s*\{([\s\S]*?)\n\}/);
80
-
81
- if (!utilitiesMatch) {
82
- console.log('[Tailwind Generator] No @layer utilities found, returning CSS as-is');
83
- return css;
84
- }
85
-
86
- const utilitiesContent = utilitiesMatch[1].trim();
87
-
88
- // Replace @layer utilities with @layer components
89
- const result = css.replace(
90
- /@layer\s+utilities\s*\{[\s\S]*?\n\}/,
91
- `@layer components {\n${utilitiesContent}\n}`
92
- );
93
-
94
- console.log('[Tailwind Generator] Wrapped utilities in @layer components');
95
- return result;
96
- }
97
-
98
71
  /**
99
72
  * Extract Tailwind classes from HTML content
100
73
  * Supports: class="...", class='...', class={...}, and Svelte's class:xxx={...}
@@ -428,24 +401,16 @@ ${themeCSS}
428
401
  let result = await compiler.build(classArray);
429
402
 
430
403
  console.log(`[Tailwind Generator] includeBaseLayers = ${includeBaseLayers}`);
431
- console.log(`[Tailwind Generator] Generated CSS length: ${result.length}`);
404
+ console.log(`[Tailwind Generator] Generated CSS length BEFORE stripping: ${result.length}`);
432
405
  console.log(`[Tailwind Generator] CSS contains @layer base: ${result.includes('@layer base')}`);
433
- console.log(`[Tailwind Generator] CSS contains @layer utilities: ${result.includes('@layer utilities')}`);
406
+ console.log(`[Tailwind Generator] CSS contains @layer theme: ${result.includes('@layer theme')}`);
434
407
 
435
- // If includeBaseLayers is false, strip out base/theme/properties layers and return unwrapped utilities
408
+ // If includeBaseLayers is false, strip out base/theme/properties layers
436
409
  if (!includeBaseLayers) {
437
410
  console.log('[Tailwind Generator] Stripping non-utility layers...');
438
411
  result = stripNonUtilityLayers(result);
439
412
  console.log(`[Tailwind Generator] Generated CSS length AFTER stripping: ${result.length}`);
440
-
441
- // Wrap stripped utilities in @layer components
442
- result = `@layer components {\n${result}\n}`;
443
- console.log('[Tailwind Generator] Wrapped stripped utilities in @layer components');
444
- } else {
445
- // Keep base/theme/properties layers, but wrap utilities in @layer components
446
- // This preserves CSS custom properties while allowing utilities override
447
- console.log('[Tailwind Generator] Preserving base/theme/properties, wrapping utilities in @layer components...');
448
- result = wrapUtilitiesInComponentsLayer(result);
413
+ console.log(`[Tailwind Generator] CSS contains @layer base: ${result.includes('@layer base')}`);
449
414
  }
450
415
 
451
416
  return result;