tailwind-styled-v4 5.1.5 → 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.
package/dist/index.mjs CHANGED
@@ -1208,10 +1208,26 @@ function injectTokensToRoot(tokens, prefix) {
1208
1208
  }
1209
1209
  function _buildTokenCss(tokens, prefix) {
1210
1210
  const binding = getNativeBinding();
1211
- if (!binding?.generateSystemTokenCss) {
1212
- throw new Error("FATAL: Native binding 'generateSystemTokenCss' is required but not available.");
1211
+ if (binding?.generateSystemTokenCss) {
1212
+ return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
1213
+ }
1214
+ return _buildTokenCssJs(tokens, prefix);
1215
+ }
1216
+ function _buildTokenCssJs(tokens, prefix) {
1217
+ const groupKeys = Object.keys(tokens);
1218
+ if (groupKeys.length === 0) return ":root {}\n";
1219
+ const lines = [":root {"];
1220
+ for (const group of groupKeys.slice().sort()) {
1221
+ const map = tokens[group];
1222
+ if (!map || typeof map !== "object" || Object.keys(map).length === 0) continue;
1223
+ for (const name of Object.keys(map).sort()) {
1224
+ const value = map[name];
1225
+ if (typeof value !== "string") continue;
1226
+ lines.push(` --${prefix}-${group}-${name}: ${value};`);
1227
+ }
1213
1228
  }
1214
- return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
1229
+ lines.push("}");
1230
+ return lines.join("\n") + "\n";
1215
1231
  }
1216
1232
  function resolveComponentConfig(config, tokens, prefix) {
1217
1233
  const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);