tailwind-styled-v4 5.0.26 → 5.0.27

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/dist/engine.mjs CHANGED
@@ -3487,6 +3487,19 @@ function extractStaticStateCss(srcDir, options = {}) {
3487
3487
  const decl = r.declarations.trim();
3488
3488
  return decl.length === 0 || !decl.includes(":");
3489
3489
  }).length;
3490
+ function sanitizeCssRule(cssRule, declarations) {
3491
+ const segments = declarations.split(/[;\n]/).map((s) => s.trim()).filter(Boolean);
3492
+ const validSegs = segments.filter((s) => s.includes(":"));
3493
+ const invalidSegs = segments.filter((s) => !s.includes(":"));
3494
+ if (invalidSegs.length === 0) return cssRule;
3495
+ if (validSegs.length === 0) return null;
3496
+ const braceIdx = cssRule.indexOf("{");
3497
+ if (braceIdx === -1) return null;
3498
+ const selector = cssRule.slice(0, braceIdx).trim();
3499
+ return `${selector} {
3500
+ ${validSegs.join(";\n ")};
3501
+ }`;
3502
+ }
3490
3503
  const byComponent = /* @__PURE__ */ new Map();
3491
3504
  for (const rule of allRules) {
3492
3505
  const existing = byComponent.get(rule.componentName) ?? [];
@@ -3498,11 +3511,18 @@ function extractStaticStateCss(srcDir, options = {}) {
3498
3511
  cssBlocks.push(`/* ${componentName} */`);
3499
3512
  for (const rule of rules) {
3500
3513
  cssBlocks.push(`/* state: ${rule.stateName} */`);
3501
- const isUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3502
- if (isUnresolved) {
3503
- cssBlocks.push(`/* SKIPPED (unresolved): ${rule.declarations} \u2014 akan di-inject runtime */`);
3514
+ const isFullyUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3515
+ if (isFullyUnresolved) {
3516
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3517
+ cssBlocks.push(`/* SKIP [unresolved]: ${encoded} */`);
3504
3518
  } else {
3505
- cssBlocks.push(rule.cssRule);
3519
+ const sanitized = sanitizeCssRule(rule.cssRule, rule.declarations);
3520
+ if (sanitized !== null) {
3521
+ cssBlocks.push(sanitized);
3522
+ } else {
3523
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3524
+ cssBlocks.push(`/* SKIP [sanitized-empty]: ${encoded} */`);
3525
+ }
3506
3526
  }
3507
3527
  }
3508
3528
  cssBlocks.push("");