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/vite.js CHANGED
@@ -3027,6 +3027,19 @@ function extractStaticStateCss(srcDir, options = {}) {
3027
3027
  const decl = r.declarations.trim();
3028
3028
  return decl.length === 0 || !decl.includes(":");
3029
3029
  }).length;
3030
+ function sanitizeCssRule(cssRule, declarations) {
3031
+ const segments = declarations.split(/[;\n]/).map((s) => s.trim()).filter(Boolean);
3032
+ const validSegs = segments.filter((s) => s.includes(":"));
3033
+ const invalidSegs = segments.filter((s) => !s.includes(":"));
3034
+ if (invalidSegs.length === 0) return cssRule;
3035
+ if (validSegs.length === 0) return null;
3036
+ const braceIdx = cssRule.indexOf("{");
3037
+ if (braceIdx === -1) return null;
3038
+ const selector = cssRule.slice(0, braceIdx).trim();
3039
+ return `${selector} {
3040
+ ${validSegs.join(";\n ")};
3041
+ }`;
3042
+ }
3030
3043
  const byComponent = /* @__PURE__ */ new Map();
3031
3044
  for (const rule of allRules) {
3032
3045
  const existing = byComponent.get(rule.componentName) ?? [];
@@ -3038,11 +3051,18 @@ function extractStaticStateCss(srcDir, options = {}) {
3038
3051
  cssBlocks.push(`/* ${componentName} */`);
3039
3052
  for (const rule of rules) {
3040
3053
  cssBlocks.push(`/* state: ${rule.stateName} */`);
3041
- const isUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3042
- if (isUnresolved) {
3043
- cssBlocks.push(`/* SKIPPED (unresolved): ${rule.declarations} \u2014 akan di-inject runtime */`);
3054
+ const isFullyUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3055
+ if (isFullyUnresolved) {
3056
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3057
+ cssBlocks.push(`/* SKIP [unresolved]: ${encoded} */`);
3044
3058
  } else {
3045
- cssBlocks.push(rule.cssRule);
3059
+ const sanitized = sanitizeCssRule(rule.cssRule, rule.declarations);
3060
+ if (sanitized !== null) {
3061
+ cssBlocks.push(sanitized);
3062
+ } else {
3063
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3064
+ cssBlocks.push(`/* SKIP [sanitized-empty]: ${encoded} */`);
3065
+ }
3046
3066
  }
3047
3067
  }
3048
3068
  cssBlocks.push("");