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