tailwind-styled-v4 5.1.5 → 5.1.7

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
@@ -1274,10 +1274,26 @@ function injectTokensToRoot(tokens, prefix) {
1274
1274
  }
1275
1275
  function _buildTokenCss(tokens, prefix) {
1276
1276
  const binding = getNativeBinding();
1277
- if (!binding?.generateSystemTokenCss) {
1278
- throw new Error("FATAL: Native binding 'generateSystemTokenCss' is required but not available.");
1277
+ if (binding?.generateSystemTokenCss) {
1278
+ return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
1279
+ }
1280
+ return _buildTokenCssJs(tokens, prefix);
1281
+ }
1282
+ function _buildTokenCssJs(tokens, prefix) {
1283
+ const groupKeys = Object.keys(tokens);
1284
+ if (groupKeys.length === 0) return ":root {}\n";
1285
+ const lines = [":root {"];
1286
+ for (const group of groupKeys.slice().sort()) {
1287
+ const map = tokens[group];
1288
+ if (!map || typeof map !== "object" || Object.keys(map).length === 0) continue;
1289
+ for (const name of Object.keys(map).sort()) {
1290
+ const value = map[name];
1291
+ if (typeof value !== "string") continue;
1292
+ lines.push(` --${prefix}-${group}-${name}: ${value};`);
1293
+ }
1279
1294
  }
1280
- return binding.generateSystemTokenCss(JSON.stringify(tokens), prefix);
1295
+ lines.push("}");
1296
+ return lines.join("\n") + "\n";
1281
1297
  }
1282
1298
  function resolveComponentConfig(config, tokens, prefix) {
1283
1299
  const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);