tailwind-styled-v4 5.0.33 → 5.0.35

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
@@ -1614,6 +1614,56 @@ var init_streamingNative = __esm({
1614
1614
  init_nativeBridge();
1615
1615
  }
1616
1616
  });
1617
+ function loadTailwindEngine() {
1618
+ if (_twEngine) return _twEngine;
1619
+ if (_twEngineError) throw _twEngineError;
1620
+ try {
1621
+ const tw2 = require2("tailwindcss");
1622
+ if (typeof tw2.compile !== "function") {
1623
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1624
+ }
1625
+ _twEngine = tw2;
1626
+ return _twEngine;
1627
+ } catch (e) {
1628
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
1629
+ throw _twEngineError;
1630
+ }
1631
+ }
1632
+ async function generateRawCss(classes, cssEntryContent, root) {
1633
+ if (classes.length === 0) return "";
1634
+ const tw2 = loadTailwindEngine();
1635
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
1636
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
1637
+ const { dirname: dirname2, resolve: resolve2 } = await import('path');
1638
+ const projectRoot = root ?? process.cwd();
1639
+ const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
1640
+ const loadStylesheet = async (id, base) => {
1641
+ try {
1642
+ 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;
1643
+ const pkgPath = req.resolve(cssId);
1644
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname2(pkgPath) };
1645
+ } catch {
1646
+ try {
1647
+ const absPath = resolve2(base, id);
1648
+ if (existsSync3(absPath)) {
1649
+ return { content: readFileSync(absPath, "utf-8"), base: dirname2(absPath) };
1650
+ }
1651
+ } catch {
1652
+ }
1653
+ return { content: "", base };
1654
+ }
1655
+ };
1656
+ const compiler = await Promise.resolve(tw2.compile(input, { loadStylesheet }));
1657
+ return compiler.build(classes);
1658
+ }
1659
+ var require2, _twEngine, _twEngineError;
1660
+ var init_tailwindEngine = __esm({
1661
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
1662
+ require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
1663
+ _twEngine = null;
1664
+ _twEngineError = null;
1665
+ }
1666
+ });
1617
1667
 
1618
1668
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
1619
1669
  var tailwindEngine_exports = {};
@@ -1747,10 +1797,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1747
1797
  }
1748
1798
  _cacheMisses++;
1749
1799
  let rawCss;
1750
- let usedRustCompiler = false;
1751
- const theme = getThemeConfig();
1752
- rawCss = await generateCssNative(unique, { theme });
1753
- usedRustCompiler = true;
1800
+ try {
1801
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1802
+ } catch {
1803
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1804
+ }
1754
1805
  let finalCss = rawCss;
1755
1806
  if (minify) {
1756
1807
  if (minifier === "fast") {
@@ -1761,7 +1812,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1761
1812
  }
1762
1813
  if (process.env.DEBUG?.includes("compiler")) {
1763
1814
  console.log(
1764
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1815
+ `[Compiler] Generated CSS from ${unique.length} classes`,
1765
1816
  `Size: ${finalCss.length} bytes`
1766
1817
  );
1767
1818
  }
@@ -1790,11 +1841,12 @@ function processTailwindCssWithTargets(css, targets) {
1790
1841
  return result.css;
1791
1842
  }
1792
1843
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1793
- var init_tailwindEngine = __esm({
1844
+ var init_tailwindEngine2 = __esm({
1794
1845
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1795
1846
  init_nativeBridge();
1796
1847
  init_cssGeneratorNative();
1797
1848
  init_cssCompilationNative();
1849
+ init_tailwindEngine();
1798
1850
  module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
1799
1851
  _cssCache = /* @__PURE__ */ new Map();
1800
1852
  _cacheHits = 0;
@@ -2832,7 +2884,7 @@ var init_src = __esm({
2832
2884
  };
2833
2885
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2834
2886
  try {
2835
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2887
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
2836
2888
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2837
2889
  return result.css;
2838
2890
  } catch {
@@ -3342,7 +3394,7 @@ __export(internal_exports, {
3342
3394
  var init_internal = __esm({
3343
3395
  "packages/domain/compiler/src/internal.ts"() {
3344
3396
  init_src();
3345
- init_tailwindEngine();
3397
+ init_tailwindEngine2();
3346
3398
  init_compiler();
3347
3399
  init_parser();
3348
3400
  init_analyzer();