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