tailwind-styled-v4 5.1.22 → 5.1.24

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 (61) hide show
  1. package/README.md +216 -0
  2. package/dist/atomic.js +34 -4
  3. package/dist/atomic.js.map +1 -1
  4. package/dist/atomic.mjs +31 -2
  5. package/dist/atomic.mjs.map +1 -1
  6. package/dist/cli.js +132 -97
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cli.mjs +129 -95
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/compiler.d.mts +195 -1
  11. package/dist/compiler.d.ts +195 -1
  12. package/dist/compiler.js +356 -12
  13. package/dist/compiler.js.map +1 -1
  14. package/dist/compiler.mjs +340 -10
  15. package/dist/compiler.mjs.map +1 -1
  16. package/dist/engine.js +194 -164
  17. package/dist/engine.js.map +1 -1
  18. package/dist/engine.mjs +184 -155
  19. package/dist/engine.mjs.map +1 -1
  20. package/dist/index.browser.mjs +136 -14
  21. package/dist/index.browser.mjs.map +1 -1
  22. package/dist/index.d.mts +45 -4
  23. package/dist/index.d.ts +45 -4
  24. package/dist/index.js +166 -9
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +177 -21
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/next.js +489 -158
  29. package/dist/next.js.map +1 -1
  30. package/dist/next.mjs +483 -153
  31. package/dist/next.mjs.map +1 -1
  32. package/dist/runtime-css.js +1 -1
  33. package/dist/runtime-css.js.map +1 -1
  34. package/dist/runtime-css.mjs +1 -1
  35. package/dist/runtime-css.mjs.map +1 -1
  36. package/dist/runtime.js +17 -0
  37. package/dist/runtime.js.map +1 -1
  38. package/dist/runtime.mjs +23 -0
  39. package/dist/runtime.mjs.map +1 -1
  40. package/dist/shared.js +91 -61
  41. package/dist/shared.js.map +1 -1
  42. package/dist/shared.mjs +85 -56
  43. package/dist/shared.mjs.map +1 -1
  44. package/dist/turbopackLoader.js +79 -49
  45. package/dist/turbopackLoader.js.map +1 -1
  46. package/dist/turbopackLoader.mjs +76 -47
  47. package/dist/turbopackLoader.mjs.map +1 -1
  48. package/dist/tw.js +132 -97
  49. package/dist/tw.js.map +1 -1
  50. package/dist/tw.mjs +129 -95
  51. package/dist/tw.mjs.map +1 -1
  52. package/dist/vite.js +157 -127
  53. package/dist/vite.js.map +1 -1
  54. package/dist/vite.mjs +150 -121
  55. package/dist/vite.mjs.map +1 -1
  56. package/dist/webpackLoader.js +39 -9
  57. package/dist/webpackLoader.js.map +1 -1
  58. package/dist/webpackLoader.mjs +36 -7
  59. package/dist/webpackLoader.mjs.map +1 -1
  60. package/package.json +1 -1
  61. package/CHANGELOG.md +0 -182
@@ -186,7 +186,7 @@ var init_nativeBridge = __esm({
186
186
  "use strict";
187
187
  init_cjs_shims();
188
188
  init_src();
189
- _loadNative = (path6) => require(path6);
189
+ _loadNative = (path7) => require(path7);
190
190
  log = (...args) => {
191
191
  if (process.env.DEBUG?.includes("compiler:native")) {
192
192
  console.log("[compiler:native]", ...args);
@@ -2023,6 +2023,33 @@ var init_routeGraph = __esm({
2023
2023
  }
2024
2024
  });
2025
2025
 
2026
+ // packages/domain/compiler/src/semanticComponentAnalyzer.ts
2027
+ var init_semanticComponentAnalyzer = __esm({
2028
+ "packages/domain/compiler/src/semanticComponentAnalyzer.ts"() {
2029
+ "use strict";
2030
+ init_cjs_shims();
2031
+ }
2032
+ });
2033
+
2034
+ // packages/domain/compiler/src/typeGeneratorFromMetadata.ts
2035
+ var init_typeGeneratorFromMetadata = __esm({
2036
+ "packages/domain/compiler/src/typeGeneratorFromMetadata.ts"() {
2037
+ "use strict";
2038
+ init_cjs_shims();
2039
+ }
2040
+ });
2041
+
2042
+ // packages/domain/compiler/src/typeGenerationPlugin.ts
2043
+ var import_node_fs3, import_node_path3;
2044
+ var init_typeGenerationPlugin = __esm({
2045
+ "packages/domain/compiler/src/typeGenerationPlugin.ts"() {
2046
+ "use strict";
2047
+ init_cjs_shims();
2048
+ import_node_fs3 = __toESM(require("fs"), 1);
2049
+ import_node_path3 = __toESM(require("path"), 1);
2050
+ }
2051
+ });
2052
+
2026
2053
  // packages/domain/compiler/src/index.ts
2027
2054
  function _layoutClassesToCss(classes) {
2028
2055
  const native = getNativeBridge();
@@ -2058,13 +2085,13 @@ function extractContainerCssFromSource(source) {
2058
2085
  }
2059
2086
  return rules.join("\n");
2060
2087
  }
2061
- var import_node_fs3, import_node_path3, import_node_module5, _require3, transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, _fileClassesMap, _globalClasses, getRouteClasses, getAllRegisteredClasses, registerFileClasses, registerGlobalClasses, resetRouteClassRegistry, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
2088
+ var import_node_fs4, import_node_path4, import_node_module5, _require3, transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, _fileClassesMap, _globalClasses, getRouteClasses, getAllRegisteredClasses, registerFileClasses, registerGlobalClasses, resetRouteClassRegistry, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
2062
2089
  var init_src2 = __esm({
2063
2090
  "packages/domain/compiler/src/index.ts"() {
2064
2091
  "use strict";
2065
2092
  init_cjs_shims();
2066
- import_node_fs3 = __toESM(require("fs"), 1);
2067
- import_node_path3 = __toESM(require("path"), 1);
2093
+ import_node_fs4 = __toESM(require("fs"), 1);
2094
+ import_node_path4 = __toESM(require("path"), 1);
2068
2095
  import_node_module5 = require("module");
2069
2096
  init_nativeBridge();
2070
2097
  init_compiler();
@@ -2074,6 +2101,9 @@ var init_src2 = __esm({
2074
2101
  init_redis();
2075
2102
  init_watch();
2076
2103
  init_routeGraph();
2104
+ init_semanticComponentAnalyzer();
2105
+ init_typeGeneratorFromMetadata();
2106
+ init_typeGenerationPlugin();
2077
2107
  _require3 = (0, import_node_module5.createRequire)(
2078
2108
  typeof require !== "undefined" ? typeof __filename !== "undefined" ? `file://${__filename}` : "file://unknown" : importMetaUrl
2079
2109
  );
@@ -2168,7 +2198,7 @@ var init_src2 = __esm({
2168
2198
  };
2169
2199
  scanProjectUsage = (dirs, cwd) => {
2170
2200
  const { batchExtractClasses: batchExtractClasses2 } = _require3("./parser");
2171
- const files = dirs.map((dir) => import_node_path3.default.resolve(cwd, dir));
2201
+ const files = dirs.map((dir) => import_node_path4.default.resolve(cwd, dir));
2172
2202
  const results = batchExtractClasses2(files) || [];
2173
2203
  const combined = {};
2174
2204
  for (const result of results) {
@@ -2185,13 +2215,13 @@ var init_src2 = __esm({
2185
2215
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2186
2216
  const allClasses = Object.keys(classes).sort();
2187
2217
  if (outputPath) {
2188
- import_node_fs3.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2218
+ import_node_fs4.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2189
2219
  }
2190
2220
  return allClasses;
2191
2221
  };
2192
2222
  loadSafelist = (safelistPath) => {
2193
2223
  try {
2194
- const content = import_node_fs3.default.readFileSync(safelistPath, "utf-8");
2224
+ const content = import_node_fs4.default.readFileSync(safelistPath, "utf-8");
2195
2225
  return JSON.parse(content);
2196
2226
  } catch {
2197
2227
  return [];
@@ -2205,8 +2235,8 @@ var init_src2 = __esm({
2205
2235
  "tailwind.config.cjs"
2206
2236
  ];
2207
2237
  for (const file of configFiles) {
2208
- const fullPath = import_node_path3.default.join(cwd, file);
2209
- if (import_node_fs3.default.existsSync(fullPath)) {
2238
+ const fullPath = import_node_path4.default.join(cwd, file);
2239
+ if (import_node_fs4.default.existsSync(fullPath)) {
2210
2240
  const mod = require(fullPath);
2211
2241
  return mod.default || mod;
2212
2242
  }
@@ -2216,9 +2246,9 @@ var init_src2 = __esm({
2216
2246
  getContentPaths = (cwd = process.cwd()) => {
2217
2247
  return {
2218
2248
  content: [
2219
- import_node_path3.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2220
- import_node_path3.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2221
- import_node_path3.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2249
+ import_node_path4.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2250
+ import_node_path4.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2251
+ import_node_path4.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2222
2252
  ]
2223
2253
  };
2224
2254
  };
@@ -2683,12 +2713,12 @@ __export(turbopackLoader_exports, {
2683
2713
  module.exports = __toCommonJS(turbopackLoader_exports);
2684
2714
  init_cjs_shims();
2685
2715
  init_internal();
2686
- var import_node_fs4 = __toESM(require("fs"), 1);
2687
- var import_node_path4 = __toESM(require("path"), 1);
2716
+ var import_node_fs5 = __toESM(require("fs"), 1);
2717
+ var import_node_path5 = __toESM(require("path"), 1);
2688
2718
  var _writtenRules = /* @__PURE__ */ new Set();
2689
2719
  function appendStaticCssToFile(staticCss, safelistPath) {
2690
2720
  if (!staticCss.trim() || !safelistPath) return;
2691
- const stateFilePath = import_node_path4.default.join(import_node_path4.default.dirname(safelistPath), "_tw-state-static.css");
2721
+ const stateFilePath = import_node_path5.default.join(import_node_path5.default.dirname(safelistPath), "_tw-state-static.css");
2692
2722
  const newRules = [];
2693
2723
  for (const chunk of staticCss.split(/(?<=\})\s*/)) {
2694
2724
  const rule = chunk.trim();
@@ -2699,9 +2729,9 @@ function appendStaticCssToFile(staticCss, safelistPath) {
2699
2729
  }
2700
2730
  if (newRules.length === 0) return;
2701
2731
  try {
2702
- import_node_fs4.default.mkdirSync(import_node_path4.default.dirname(stateFilePath), { recursive: true });
2703
- if (!import_node_fs4.default.existsSync(stateFilePath)) {
2704
- import_node_fs4.default.writeFileSync(
2732
+ import_node_fs5.default.mkdirSync(import_node_path5.default.dirname(stateFilePath), { recursive: true });
2733
+ if (!import_node_fs5.default.existsSync(stateFilePath)) {
2734
+ import_node_fs5.default.writeFileSync(
2705
2735
  stateFilePath,
2706
2736
  `/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
2707
2737
  * Import di globals.css: @import "./_tw-state-static.css";
@@ -2712,7 +2742,7 @@ function appendStaticCssToFile(staticCss, safelistPath) {
2712
2742
  "utf-8"
2713
2743
  );
2714
2744
  }
2715
- import_node_fs4.default.appendFileSync(stateFilePath, newRules.join("\n") + "\n", "utf-8");
2745
+ import_node_fs5.default.appendFileSync(stateFilePath, newRules.join("\n") + "\n", "utf-8");
2716
2746
  } catch {
2717
2747
  }
2718
2748
  }
@@ -2751,11 +2781,11 @@ var CYCLE_SENTINEL = "_cycle.txt";
2751
2781
  var START_SENTINEL = "_start.txt";
2752
2782
  var _workerCache = /* @__PURE__ */ new Map();
2753
2783
  function getTwClassesDir(safelistPath) {
2754
- return import_node_path4.default.join(import_node_path4.default.dirname(safelistPath), "tw-classes");
2784
+ return import_node_path5.default.join(import_node_path5.default.dirname(safelistPath), "tw-classes");
2755
2785
  }
2756
2786
  function readSentinel(filePath) {
2757
2787
  try {
2758
- return import_node_fs4.default.readFileSync(filePath, "utf-8").trim();
2788
+ return import_node_fs5.default.readFileSync(filePath, "utf-8").trim();
2759
2789
  } catch {
2760
2790
  return "";
2761
2791
  }
@@ -2765,36 +2795,36 @@ function clearAndMarkCycle(twClassesDir, startId) {
2765
2795
  if (_clearLock) return;
2766
2796
  _clearLock = true;
2767
2797
  try {
2768
- if (import_node_fs4.default.existsSync(twClassesDir)) {
2798
+ if (import_node_fs5.default.existsSync(twClassesDir)) {
2769
2799
  const tempDir = `${twClassesDir}_clearing_${Date.now()}`;
2770
2800
  try {
2771
- import_node_fs4.default.renameSync(twClassesDir, tempDir);
2772
- import_node_fs4.default.mkdirSync(twClassesDir, { recursive: true });
2773
- const startFile = import_node_path4.default.join(tempDir, START_SENTINEL);
2774
- if (import_node_fs4.default.existsSync(startFile)) {
2775
- import_node_fs4.default.copyFileSync(startFile, import_node_path4.default.join(twClassesDir, START_SENTINEL));
2801
+ import_node_fs5.default.renameSync(twClassesDir, tempDir);
2802
+ import_node_fs5.default.mkdirSync(twClassesDir, { recursive: true });
2803
+ const startFile = import_node_path5.default.join(tempDir, START_SENTINEL);
2804
+ if (import_node_fs5.default.existsSync(startFile)) {
2805
+ import_node_fs5.default.copyFileSync(startFile, import_node_path5.default.join(twClassesDir, START_SENTINEL));
2776
2806
  }
2777
- const mergedFile = import_node_path4.default.join(tempDir, "_webpack-merged.css");
2778
- if (import_node_fs4.default.existsSync(mergedFile)) {
2779
- import_node_fs4.default.copyFileSync(mergedFile, import_node_path4.default.join(twClassesDir, "_webpack-merged.css"));
2807
+ const mergedFile = import_node_path5.default.join(tempDir, "_webpack-merged.css");
2808
+ if (import_node_fs5.default.existsSync(mergedFile)) {
2809
+ import_node_fs5.default.copyFileSync(mergedFile, import_node_path5.default.join(twClassesDir, "_webpack-merged.css"));
2780
2810
  }
2781
- import_node_fs4.default.writeFileSync(import_node_path4.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2811
+ import_node_fs5.default.writeFileSync(import_node_path5.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2782
2812
  _workerCache.set(twClassesDir, startId);
2783
- import_node_fs4.default.rmSync(tempDir, { recursive: true, force: true });
2813
+ import_node_fs5.default.rmSync(tempDir, { recursive: true, force: true });
2784
2814
  } catch {
2785
- for (const file of import_node_fs4.default.readdirSync(twClassesDir)) {
2815
+ for (const file of import_node_fs5.default.readdirSync(twClassesDir)) {
2786
2816
  if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
2787
2817
  try {
2788
- import_node_fs4.default.unlinkSync(import_node_path4.default.join(twClassesDir, file));
2818
+ import_node_fs5.default.unlinkSync(import_node_path5.default.join(twClassesDir, file));
2789
2819
  } catch {
2790
2820
  }
2791
2821
  }
2792
- import_node_fs4.default.writeFileSync(import_node_path4.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2822
+ import_node_fs5.default.writeFileSync(import_node_path5.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2793
2823
  _workerCache.set(twClassesDir, startId);
2794
2824
  }
2795
2825
  } else {
2796
- import_node_fs4.default.mkdirSync(twClassesDir, { recursive: true });
2797
- import_node_fs4.default.writeFileSync(import_node_path4.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2826
+ import_node_fs5.default.mkdirSync(twClassesDir, { recursive: true });
2827
+ import_node_fs5.default.writeFileSync(import_node_path5.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2798
2828
  _workerCache.set(twClassesDir, startId);
2799
2829
  }
2800
2830
  } catch {
@@ -2805,41 +2835,41 @@ function clearAndMarkCycle(twClassesDir, startId) {
2805
2835
  function getPerFileSafelistPath(safelistDir, resourcePath) {
2806
2836
  const normalized = resourcePath.replace(/\\/g, "/");
2807
2837
  const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
2808
- return import_node_path4.default.join(safelistDir, `${slug}.css`);
2838
+ return import_node_path5.default.join(safelistDir, `${slug}.css`);
2809
2839
  }
2810
2840
  function writePerFileSafelist(safelistPath, resourcePath, classes) {
2811
2841
  if (!safelistPath || classes.length === 0) return;
2812
2842
  try {
2813
2843
  const twClassesDir = getTwClassesDir(safelistPath);
2814
- const startId = readSentinel(import_node_path4.default.join(twClassesDir, START_SENTINEL));
2815
- const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(import_node_path4.default.join(twClassesDir, CYCLE_SENTINEL));
2844
+ const startId = readSentinel(import_node_path5.default.join(twClassesDir, START_SENTINEL));
2845
+ const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(import_node_path5.default.join(twClassesDir, CYCLE_SENTINEL));
2816
2846
  if (startId && cachedCycle !== startId) {
2817
2847
  clearAndMarkCycle(twClassesDir, startId);
2818
- } else if (!import_node_fs4.default.existsSync(twClassesDir)) {
2819
- import_node_fs4.default.mkdirSync(twClassesDir, { recursive: true });
2848
+ } else if (!import_node_fs5.default.existsSync(twClassesDir)) {
2849
+ import_node_fs5.default.mkdirSync(twClassesDir, { recursive: true });
2820
2850
  }
2821
2851
  const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
2822
2852
  const sorted = [...new Set(classes)].sort();
2823
2853
  const css = [
2824
- `/* tw-safelist: ${import_node_path4.default.basename(resourcePath)} \u2014 auto-generated */`,
2854
+ `/* tw-safelist: ${import_node_path5.default.basename(resourcePath)} \u2014 auto-generated */`,
2825
2855
  "@layer utilities {",
2826
2856
  sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
2827
2857
  "}"
2828
2858
  ].join("\n");
2829
2859
  try {
2830
- if (import_node_fs4.default.readFileSync(outPath, "utf-8") === css) return;
2860
+ if (import_node_fs5.default.readFileSync(outPath, "utf-8") === css) return;
2831
2861
  } catch {
2832
2862
  }
2833
2863
  const tmpPath = `${outPath}.tmp`;
2834
2864
  try {
2835
- import_node_fs4.default.writeFileSync(tmpPath, css, "utf-8");
2836
- import_node_fs4.default.renameSync(tmpPath, outPath);
2865
+ import_node_fs5.default.writeFileSync(tmpPath, css, "utf-8");
2866
+ import_node_fs5.default.renameSync(tmpPath, outPath);
2837
2867
  } catch {
2838
2868
  try {
2839
- import_node_fs4.default.unlinkSync(tmpPath);
2869
+ import_node_fs5.default.unlinkSync(tmpPath);
2840
2870
  } catch {
2841
2871
  }
2842
- import_node_fs4.default.writeFileSync(outPath, css, "utf-8");
2872
+ import_node_fs5.default.writeFileSync(outPath, css, "utf-8");
2843
2873
  }
2844
2874
  } catch {
2845
2875
  }
@@ -2853,7 +2883,7 @@ function turbopackLoader(source, options = {}) {
2853
2883
  const router = detectRouter(this.resourcePath);
2854
2884
  const nextMajor = parseNum(options.nextMajor);
2855
2885
  const debug = parseBool(options.debug);
2856
- const filename = import_node_path4.default.basename(this.resourcePath);
2886
+ const filename = import_node_path5.default.basename(this.resourcePath);
2857
2887
  const effective = {
2858
2888
  addDataAttr: parseBool(options.addDataAttr),
2859
2889
  // App Router: selalu auto-detect client boundary