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/engine.mjs CHANGED
@@ -1588,6 +1588,56 @@ var init_streamingNative = __esm({
1588
1588
  init_nativeBridge();
1589
1589
  }
1590
1590
  });
1591
+ function loadTailwindEngine() {
1592
+ if (_twEngine) return _twEngine;
1593
+ if (_twEngineError) throw _twEngineError;
1594
+ try {
1595
+ const tw = require2("tailwindcss");
1596
+ if (typeof tw.compile !== "function") {
1597
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1598
+ }
1599
+ _twEngine = tw;
1600
+ return _twEngine;
1601
+ } catch (e) {
1602
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
1603
+ throw _twEngineError;
1604
+ }
1605
+ }
1606
+ async function generateRawCss(classes, cssEntryContent, root) {
1607
+ if (classes.length === 0) return "";
1608
+ const tw = loadTailwindEngine();
1609
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
1610
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
1611
+ const { dirname, resolve: resolve2 } = await import('path');
1612
+ const projectRoot = root ?? process.cwd();
1613
+ const req = createRequire(resolve2(projectRoot, "package.json"));
1614
+ const loadStylesheet = async (id, base) => {
1615
+ try {
1616
+ 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;
1617
+ const pkgPath = req.resolve(cssId);
1618
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1619
+ } catch {
1620
+ try {
1621
+ const absPath = resolve2(base, id);
1622
+ if (existsSync3(absPath)) {
1623
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1624
+ }
1625
+ } catch {
1626
+ }
1627
+ return { content: "", base };
1628
+ }
1629
+ };
1630
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1631
+ return compiler.build(classes);
1632
+ }
1633
+ var require2, _twEngine, _twEngineError;
1634
+ var init_tailwindEngine = __esm({
1635
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
1636
+ require2 = createRequire(import.meta.url);
1637
+ _twEngine = null;
1638
+ _twEngineError = null;
1639
+ }
1640
+ });
1591
1641
 
1592
1642
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
1593
1643
  var tailwindEngine_exports = {};
@@ -1721,10 +1771,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1721
1771
  }
1722
1772
  _cacheMisses++;
1723
1773
  let rawCss;
1724
- let usedRustCompiler = false;
1725
- const theme = getThemeConfig();
1726
- rawCss = await generateCssNative(unique, { theme });
1727
- usedRustCompiler = true;
1774
+ try {
1775
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1776
+ } catch {
1777
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1778
+ }
1728
1779
  let finalCss = rawCss;
1729
1780
  if (minify) {
1730
1781
  if (minifier === "fast") {
@@ -1735,7 +1786,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1735
1786
  }
1736
1787
  if (process.env.DEBUG?.includes("compiler")) {
1737
1788
  console.log(
1738
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1789
+ `[Compiler] Generated CSS from ${unique.length} classes`,
1739
1790
  `Size: ${finalCss.length} bytes`
1740
1791
  );
1741
1792
  }
@@ -1764,11 +1815,12 @@ function processTailwindCssWithTargets(css, targets) {
1764
1815
  return result.css;
1765
1816
  }
1766
1817
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1767
- var init_tailwindEngine = __esm({
1818
+ var init_tailwindEngine2 = __esm({
1768
1819
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1769
1820
  init_nativeBridge();
1770
1821
  init_cssGeneratorNative();
1771
1822
  init_cssCompilationNative();
1823
+ init_tailwindEngine();
1772
1824
  createRequire(import.meta.url);
1773
1825
  _cssCache = /* @__PURE__ */ new Map();
1774
1826
  _cacheHits = 0;
@@ -2806,7 +2858,7 @@ var init_src = __esm({
2806
2858
  };
2807
2859
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2808
2860
  try {
2809
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2861
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
2810
2862
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2811
2863
  return result.css;
2812
2864
  } catch {
@@ -3316,7 +3368,7 @@ __export(internal_exports, {
3316
3368
  var init_internal = __esm({
3317
3369
  "packages/domain/compiler/src/internal.ts"() {
3318
3370
  init_src();
3319
- init_tailwindEngine();
3371
+ init_tailwindEngine2();
3320
3372
  init_compiler();
3321
3373
  init_parser();
3322
3374
  init_analyzer();