tailwind-styled-v4 5.0.34 → 5.0.36

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.
Files changed (50) hide show
  1. package/README.md +458 -339
  2. package/dist/cli.js +9 -6
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +9 -6
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/compiler.js +60 -8
  7. package/dist/compiler.js.map +1 -1
  8. package/dist/compiler.mjs +60 -8
  9. package/dist/compiler.mjs.map +1 -1
  10. package/dist/engine.js +60 -8
  11. package/dist/engine.js.map +1 -1
  12. package/dist/engine.mjs +60 -8
  13. package/dist/engine.mjs.map +1 -1
  14. package/dist/index.browser.mjs +689 -508
  15. package/dist/index.browser.mjs.map +1 -1
  16. package/dist/index.js +98 -28
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +98 -28
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/next.js +304 -182
  21. package/dist/next.js.map +1 -1
  22. package/dist/next.mjs +304 -182
  23. package/dist/next.mjs.map +1 -1
  24. package/dist/shared.js +60 -8
  25. package/dist/shared.js.map +1 -1
  26. package/dist/shared.mjs +60 -8
  27. package/dist/shared.mjs.map +1 -1
  28. package/dist/svelte.js +4 -4
  29. package/dist/svelte.js.map +1 -1
  30. package/dist/svelte.mjs +4 -4
  31. package/dist/svelte.mjs.map +1 -1
  32. package/dist/turbopackLoader.js +60 -8
  33. package/dist/turbopackLoader.js.map +1 -1
  34. package/dist/turbopackLoader.mjs +60 -8
  35. package/dist/turbopackLoader.mjs.map +1 -1
  36. package/dist/tw.js +9 -6
  37. package/dist/tw.js.map +1 -1
  38. package/dist/tw.mjs +9 -6
  39. package/dist/tw.mjs.map +1 -1
  40. package/dist/vite.js +60 -8
  41. package/dist/vite.js.map +1 -1
  42. package/dist/vite.mjs +60 -8
  43. package/dist/vite.mjs.map +1 -1
  44. package/dist/vue.js +4 -4
  45. package/dist/vue.js.map +1 -1
  46. package/dist/vue.mjs +4 -4
  47. package/dist/vue.mjs.map +1 -1
  48. package/native/tailwind-styled-native.linux-x64-gnu.node +0 -0
  49. package/native/tailwind-styled-native.node +0 -0
  50. package/package.json +7 -5
package/dist/shared.mjs CHANGED
@@ -1585,6 +1585,56 @@ var init_streamingNative = __esm({
1585
1585
  init_nativeBridge();
1586
1586
  }
1587
1587
  });
1588
+ function loadTailwindEngine() {
1589
+ if (_twEngine) return _twEngine;
1590
+ if (_twEngineError) throw _twEngineError;
1591
+ try {
1592
+ const tw = require2("tailwindcss");
1593
+ if (typeof tw.compile !== "function") {
1594
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1595
+ }
1596
+ _twEngine = tw;
1597
+ return _twEngine;
1598
+ } catch (e) {
1599
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
1600
+ throw _twEngineError;
1601
+ }
1602
+ }
1603
+ async function generateRawCss(classes, cssEntryContent, root) {
1604
+ if (classes.length === 0) return "";
1605
+ const tw = loadTailwindEngine();
1606
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
1607
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
1608
+ const { dirname, resolve: resolve2 } = await import('path');
1609
+ const projectRoot = root ?? process.cwd();
1610
+ const req = createRequire(resolve2(projectRoot, "package.json"));
1611
+ const loadStylesheet = async (id, base) => {
1612
+ try {
1613
+ const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
1614
+ const pkgPath = req.resolve(cssId);
1615
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1616
+ } catch {
1617
+ try {
1618
+ const absPath = resolve2(base, id);
1619
+ if (existsSync3(absPath)) {
1620
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1621
+ }
1622
+ } catch {
1623
+ }
1624
+ return { content: "", base };
1625
+ }
1626
+ };
1627
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1628
+ return compiler.build(classes);
1629
+ }
1630
+ var require2, _twEngine, _twEngineError;
1631
+ var init_tailwindEngine = __esm({
1632
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
1633
+ require2 = createRequire(import.meta.url);
1634
+ _twEngine = null;
1635
+ _twEngineError = null;
1636
+ }
1637
+ });
1588
1638
 
1589
1639
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
1590
1640
  var tailwindEngine_exports = {};
@@ -1718,10 +1768,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1718
1768
  }
1719
1769
  _cacheMisses++;
1720
1770
  let rawCss;
1721
- let usedRustCompiler = false;
1722
- const theme = getThemeConfig();
1723
- rawCss = await generateCssNative(unique, { theme });
1724
- usedRustCompiler = true;
1771
+ try {
1772
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1773
+ } catch {
1774
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1775
+ }
1725
1776
  let finalCss = rawCss;
1726
1777
  if (minify) {
1727
1778
  if (minifier === "fast") {
@@ -1732,7 +1783,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1732
1783
  }
1733
1784
  if (process.env.DEBUG?.includes("compiler")) {
1734
1785
  console.log(
1735
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1786
+ `[Compiler] Generated CSS from ${unique.length} classes`,
1736
1787
  `Size: ${finalCss.length} bytes`
1737
1788
  );
1738
1789
  }
@@ -1761,11 +1812,12 @@ function processTailwindCssWithTargets(css, targets) {
1761
1812
  return result.css;
1762
1813
  }
1763
1814
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1764
- var init_tailwindEngine = __esm({
1815
+ var init_tailwindEngine2 = __esm({
1765
1816
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1766
1817
  init_nativeBridge();
1767
1818
  init_cssGeneratorNative();
1768
1819
  init_cssCompilationNative();
1820
+ init_tailwindEngine();
1769
1821
  createRequire(import.meta.url);
1770
1822
  _cssCache = /* @__PURE__ */ new Map();
1771
1823
  _cacheHits = 0;
@@ -2803,7 +2855,7 @@ var init_src = __esm({
2803
2855
  };
2804
2856
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2805
2857
  try {
2806
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2858
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
2807
2859
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2808
2860
  return result.css;
2809
2861
  } catch {
@@ -3313,7 +3365,7 @@ __export(internal_exports, {
3313
3365
  var init_internal = __esm({
3314
3366
  "packages/domain/compiler/src/internal.ts"() {
3315
3367
  init_src();
3316
- init_tailwindEngine();
3368
+ init_tailwindEngine2();
3317
3369
  init_compiler();
3318
3370
  init_parser();
3319
3371
  init_analyzer();