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.js CHANGED
@@ -1607,6 +1607,56 @@ var init_streamingNative = __esm({
1607
1607
  init_nativeBridge();
1608
1608
  }
1609
1609
  });
1610
+ function loadTailwindEngine() {
1611
+ if (_twEngine) return _twEngine;
1612
+ if (_twEngineError) throw _twEngineError;
1613
+ try {
1614
+ const tw = require2("tailwindcss");
1615
+ if (typeof tw.compile !== "function") {
1616
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1617
+ }
1618
+ _twEngine = tw;
1619
+ return _twEngine;
1620
+ } catch (e) {
1621
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
1622
+ throw _twEngineError;
1623
+ }
1624
+ }
1625
+ async function generateRawCss(classes, cssEntryContent, root) {
1626
+ if (classes.length === 0) return "";
1627
+ const tw = loadTailwindEngine();
1628
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
1629
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
1630
+ const { dirname, resolve: resolve2 } = await import('path');
1631
+ const projectRoot = root ?? process.cwd();
1632
+ const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
1633
+ const loadStylesheet = async (id, base) => {
1634
+ try {
1635
+ 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;
1636
+ const pkgPath = req.resolve(cssId);
1637
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1638
+ } catch {
1639
+ try {
1640
+ const absPath = resolve2(base, id);
1641
+ if (existsSync3(absPath)) {
1642
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1643
+ }
1644
+ } catch {
1645
+ }
1646
+ return { content: "", base };
1647
+ }
1648
+ };
1649
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1650
+ return compiler.build(classes);
1651
+ }
1652
+ var require2, _twEngine, _twEngineError;
1653
+ var init_tailwindEngine = __esm({
1654
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
1655
+ require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
1656
+ _twEngine = null;
1657
+ _twEngineError = null;
1658
+ }
1659
+ });
1610
1660
 
1611
1661
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
1612
1662
  var tailwindEngine_exports = {};
@@ -1740,10 +1790,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1740
1790
  }
1741
1791
  _cacheMisses++;
1742
1792
  let rawCss;
1743
- let usedRustCompiler = false;
1744
- const theme = getThemeConfig();
1745
- rawCss = await generateCssNative(unique, { theme });
1746
- usedRustCompiler = true;
1793
+ try {
1794
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1795
+ } catch {
1796
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1797
+ }
1747
1798
  let finalCss = rawCss;
1748
1799
  if (minify) {
1749
1800
  if (minifier === "fast") {
@@ -1754,7 +1805,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1754
1805
  }
1755
1806
  if (process.env.DEBUG?.includes("compiler")) {
1756
1807
  console.log(
1757
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1808
+ `[Compiler] Generated CSS from ${unique.length} classes`,
1758
1809
  `Size: ${finalCss.length} bytes`
1759
1810
  );
1760
1811
  }
@@ -1783,11 +1834,12 @@ function processTailwindCssWithTargets(css, targets) {
1783
1834
  return result.css;
1784
1835
  }
1785
1836
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1786
- var init_tailwindEngine = __esm({
1837
+ var init_tailwindEngine2 = __esm({
1787
1838
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1788
1839
  init_nativeBridge();
1789
1840
  init_cssGeneratorNative();
1790
1841
  init_cssCompilationNative();
1842
+ init_tailwindEngine();
1791
1843
  module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
1792
1844
  _cssCache = /* @__PURE__ */ new Map();
1793
1845
  _cacheHits = 0;
@@ -2825,7 +2877,7 @@ var init_src = __esm({
2825
2877
  };
2826
2878
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2827
2879
  try {
2828
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2880
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
2829
2881
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2830
2882
  return result.css;
2831
2883
  } catch {
@@ -3335,7 +3387,7 @@ __export(internal_exports, {
3335
3387
  var init_internal = __esm({
3336
3388
  "packages/domain/compiler/src/internal.ts"() {
3337
3389
  init_src();
3338
- init_tailwindEngine();
3390
+ init_tailwindEngine2();
3339
3391
  init_compiler();
3340
3392
  init_parser();
3341
3393
  init_analyzer();