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.js CHANGED
@@ -3509,6 +3509,19 @@ function extractStaticStateCss(srcDir, options = {}) {
3509
3509
  const decl = r.declarations.trim();
3510
3510
  return decl.length === 0 || !decl.includes(":");
3511
3511
  }).length;
3512
+ function sanitizeCssRule(cssRule, declarations) {
3513
+ const segments = declarations.split(/[;\n]/).map((s) => s.trim()).filter(Boolean);
3514
+ const validSegs = segments.filter((s) => s.includes(":"));
3515
+ const invalidSegs = segments.filter((s) => !s.includes(":"));
3516
+ if (invalidSegs.length === 0) return cssRule;
3517
+ if (validSegs.length === 0) return null;
3518
+ const braceIdx = cssRule.indexOf("{");
3519
+ if (braceIdx === -1) return null;
3520
+ const selector = cssRule.slice(0, braceIdx).trim();
3521
+ return `${selector} {
3522
+ ${validSegs.join(";\n ")};
3523
+ }`;
3524
+ }
3512
3525
  const byComponent = /* @__PURE__ */ new Map();
3513
3526
  for (const rule of allRules) {
3514
3527
  const existing = byComponent.get(rule.componentName) ?? [];
@@ -3520,11 +3533,18 @@ function extractStaticStateCss(srcDir, options = {}) {
3520
3533
  cssBlocks.push(`/* ${componentName} */`);
3521
3534
  for (const rule of rules) {
3522
3535
  cssBlocks.push(`/* state: ${rule.stateName} */`);
3523
- const isUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3524
- if (isUnresolved) {
3525
- cssBlocks.push(`/* SKIPPED (unresolved): ${rule.declarations} \u2014 akan di-inject runtime */`);
3536
+ const isFullyUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3537
+ if (isFullyUnresolved) {
3538
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3539
+ cssBlocks.push(`/* SKIP [unresolved]: ${encoded} */`);
3526
3540
  } else {
3527
- cssBlocks.push(rule.cssRule);
3541
+ const sanitized = sanitizeCssRule(rule.cssRule, rule.declarations);
3542
+ if (sanitized !== null) {
3543
+ cssBlocks.push(sanitized);
3544
+ } else {
3545
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3546
+ cssBlocks.push(`/* SKIP [sanitized-empty]: ${encoded} */`);
3547
+ }
3528
3548
  }
3529
3549
  }
3530
3550
  cssBlocks.push("");