tailwind-styled-v4 5.1.4 → 5.1.6

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.
@@ -1008,10 +1008,26 @@ function injectTokensToRoot(tokens, prefix) {
1008
1008
  }
1009
1009
  function _buildTokenCss(tokens, prefix) {
1010
1010
  const binding = getNativeBinding();
1011
- if (!binding?.generateSystemTokenCss) {
1012
- throw new Error("FATAL: Native binding 'generateSystemTokenCss' is required but not available.");
1011
+ if (binding?.generateSystemTokenCss) {
1012
+ return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
1013
1013
  }
1014
- return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
1014
+ return _buildTokenCssJs(tokens, prefix);
1015
+ }
1016
+ function _buildTokenCssJs(tokens, prefix) {
1017
+ const groupKeys = Object.keys(tokens);
1018
+ if (groupKeys.length === 0) return ":root {}\n";
1019
+ const lines = [":root {"];
1020
+ for (const group of groupKeys.slice().sort()) {
1021
+ const map = tokens[group];
1022
+ if (!map || typeof map !== "object" || Object.keys(map).length === 0) continue;
1023
+ for (const name of Object.keys(map).sort()) {
1024
+ const value = map[name];
1025
+ if (typeof value !== "string") continue;
1026
+ lines.push(` --${prefix}-${group}-${name}: ${value};`);
1027
+ }
1028
+ }
1029
+ lines.push("}");
1030
+ return lines.join("\n") + "\n";
1015
1031
  }
1016
1032
  function resolveComponentConfig(config, tokens, prefix) {
1017
1033
  const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);