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.
@@ -766,6 +766,56 @@ var init_streamingNative = __esm({
766
766
  init_nativeBridge();
767
767
  }
768
768
  });
769
+ function loadTailwindEngine() {
770
+ if (_twEngine) return _twEngine;
771
+ if (_twEngineError) throw _twEngineError;
772
+ try {
773
+ const tw = require2("tailwindcss");
774
+ if (typeof tw.compile !== "function") {
775
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
776
+ }
777
+ _twEngine = tw;
778
+ return _twEngine;
779
+ } catch (e) {
780
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
781
+ throw _twEngineError;
782
+ }
783
+ }
784
+ async function generateRawCss(classes, cssEntryContent, root) {
785
+ if (classes.length === 0) return "";
786
+ const tw = loadTailwindEngine();
787
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
788
+ const { readFileSync, existsSync: existsSync2 } = await import('fs');
789
+ const { dirname, resolve: resolve2 } = await import('path');
790
+ const projectRoot = root ?? process.cwd();
791
+ const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
792
+ const loadStylesheet = async (id, base) => {
793
+ try {
794
+ 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;
795
+ const pkgPath = req.resolve(cssId);
796
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
797
+ } catch {
798
+ try {
799
+ const absPath = resolve2(base, id);
800
+ if (existsSync2(absPath)) {
801
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
802
+ }
803
+ } catch {
804
+ }
805
+ return { content: "", base };
806
+ }
807
+ };
808
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
809
+ return compiler.build(classes);
810
+ }
811
+ var require2, _twEngine, _twEngineError;
812
+ var init_tailwindEngine = __esm({
813
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
814
+ require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
815
+ _twEngine = null;
816
+ _twEngineError = null;
817
+ }
818
+ });
769
819
 
770
820
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
771
821
  var tailwindEngine_exports = {};
@@ -899,10 +949,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
899
949
  }
900
950
  _cacheMisses++;
901
951
  let rawCss;
902
- let usedRustCompiler = false;
903
- const theme = getThemeConfig();
904
- rawCss = await generateCssNative(unique, { theme });
905
- usedRustCompiler = true;
952
+ try {
953
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
954
+ } catch {
955
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
956
+ }
906
957
  let finalCss = rawCss;
907
958
  if (minify) {
908
959
  if (minifier === "fast") {
@@ -913,7 +964,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
913
964
  }
914
965
  if (process.env.DEBUG?.includes("compiler")) {
915
966
  console.log(
916
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
967
+ `[Compiler] Generated CSS from ${unique.length} classes`,
917
968
  `Size: ${finalCss.length} bytes`
918
969
  );
919
970
  }
@@ -942,11 +993,12 @@ function processTailwindCssWithTargets(css, targets) {
942
993
  return result.css;
943
994
  }
944
995
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
945
- var init_tailwindEngine = __esm({
996
+ var init_tailwindEngine2 = __esm({
946
997
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
947
998
  init_nativeBridge();
948
999
  init_cssGeneratorNative();
949
1000
  init_cssCompilationNative();
1001
+ init_tailwindEngine();
950
1002
  module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
951
1003
  _cssCache = /* @__PURE__ */ new Map();
952
1004
  _cacheHits = 0;
@@ -1984,7 +2036,7 @@ var init_src2 = __esm({
1984
2036
  };
1985
2037
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
1986
2038
  try {
1987
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2039
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
1988
2040
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
1989
2041
  return result.css;
1990
2042
  } catch {
@@ -2494,7 +2546,7 @@ __export(internal_exports, {
2494
2546
  var init_internal = __esm({
2495
2547
  "packages/domain/compiler/src/internal.ts"() {
2496
2548
  init_src2();
2497
- init_tailwindEngine();
2549
+ init_tailwindEngine2();
2498
2550
  init_compiler();
2499
2551
  init_parser();
2500
2552
  init_analyzer();