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/compiler.mjs CHANGED
@@ -751,6 +751,56 @@ var init_streamingNative = __esm({
751
751
  init_nativeBridge();
752
752
  }
753
753
  });
754
+ function loadTailwindEngine() {
755
+ if (_twEngine) return _twEngine;
756
+ if (_twEngineError) throw _twEngineError;
757
+ try {
758
+ const tw = require2("tailwindcss");
759
+ if (typeof tw.compile !== "function") {
760
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
761
+ }
762
+ _twEngine = tw;
763
+ return _twEngine;
764
+ } catch (e) {
765
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
766
+ throw _twEngineError;
767
+ }
768
+ }
769
+ async function generateRawCss(classes, cssEntryContent, root) {
770
+ if (classes.length === 0) return "";
771
+ const tw = loadTailwindEngine();
772
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
773
+ const { readFileSync, existsSync: existsSync2 } = await import('fs');
774
+ const { dirname, resolve: resolve2 } = await import('path');
775
+ const projectRoot = root ?? process.cwd();
776
+ const req = createRequire(resolve2(projectRoot, "package.json"));
777
+ const loadStylesheet = async (id, base) => {
778
+ try {
779
+ 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;
780
+ const pkgPath = req.resolve(cssId);
781
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
782
+ } catch {
783
+ try {
784
+ const absPath = resolve2(base, id);
785
+ if (existsSync2(absPath)) {
786
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
787
+ }
788
+ } catch {
789
+ }
790
+ return { content: "", base };
791
+ }
792
+ };
793
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
794
+ return compiler.build(classes);
795
+ }
796
+ var require2, _twEngine, _twEngineError;
797
+ var init_tailwindEngine = __esm({
798
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
799
+ require2 = createRequire(import.meta.url);
800
+ _twEngine = null;
801
+ _twEngineError = null;
802
+ }
803
+ });
754
804
 
755
805
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
756
806
  var tailwindEngine_exports = {};
@@ -884,10 +934,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
884
934
  }
885
935
  _cacheMisses++;
886
936
  let rawCss;
887
- let usedRustCompiler = false;
888
- const theme = getThemeConfig();
889
- rawCss = await generateCssNative(unique, { theme });
890
- usedRustCompiler = true;
937
+ try {
938
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
939
+ } catch {
940
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
941
+ }
891
942
  let finalCss = rawCss;
892
943
  if (minify) {
893
944
  if (minifier === "fast") {
@@ -898,7 +949,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
898
949
  }
899
950
  if (process.env.DEBUG?.includes("compiler")) {
900
951
  console.log(
901
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
952
+ `[Compiler] Generated CSS from ${unique.length} classes`,
902
953
  `Size: ${finalCss.length} bytes`
903
954
  );
904
955
  }
@@ -927,11 +978,12 @@ function processTailwindCssWithTargets(css, targets) {
927
978
  return result.css;
928
979
  }
929
980
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
930
- var init_tailwindEngine = __esm({
981
+ var init_tailwindEngine2 = __esm({
931
982
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
932
983
  init_nativeBridge();
933
984
  init_cssGeneratorNative();
934
985
  init_cssCompilationNative();
986
+ init_tailwindEngine();
935
987
  createRequire(import.meta.url);
936
988
  _cssCache = /* @__PURE__ */ new Map();
937
989
  _cacheHits = 0;
@@ -948,7 +1000,7 @@ var init_compiler = __esm({
948
1000
  init_cssCompilationNative();
949
1001
  init_idRegistryNative();
950
1002
  init_streamingNative();
951
- init_tailwindEngine();
1003
+ init_tailwindEngine2();
952
1004
  }
953
1005
  });
954
1006
 
@@ -1970,7 +2022,7 @@ var init_src2 = __esm({
1970
2022
  };
1971
2023
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
1972
2024
  try {
1973
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2025
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
1974
2026
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
1975
2027
  return result.css;
1976
2028
  } catch {