weapp-tailwindcss 5.0.0 → 5.0.2

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 (54) hide show
  1. package/dist/{bundle-state-DgGEhk_z.js → bundle-state-Bvj01pW7.js} +35 -3
  2. package/dist/{bundle-state-CnaJxkFY.mjs → bundle-state-DY3eq4Gz.mjs} +24 -4
  3. package/dist/bundlers/shared/generated-css-marker.d.ts +6 -0
  4. package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
  5. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -5
  6. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +2 -0
  7. package/dist/bundlers/shared/generator-css.d.ts +1 -0
  8. package/dist/bundlers/vite/bundle-state.d.ts +5 -1
  9. package/dist/bundlers/vite/css-finalizer.d.ts +12 -3
  10. package/dist/bundlers/vite/generate-bundle.d.ts +22 -6
  11. package/dist/bundlers/vite/processed-css-assets.d.ts +10 -2
  12. package/dist/bundlers/vite/source-candidates.d.ts +2 -0
  13. package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +8 -0
  14. package/dist/cli.js +1 -0
  15. package/dist/cli.mjs +1 -0
  16. package/dist/core.js +1 -1
  17. package/dist/core.mjs +1 -1
  18. package/dist/{generator--0-ekuVO.js → generator-Bd1LntD3.js} +1 -1
  19. package/dist/{generator-B76ovqsv.mjs → generator-DRHWC1t-.mjs} +1 -1
  20. package/dist/generator.js +2 -2
  21. package/dist/generator.mjs +2 -2
  22. package/dist/gulp.js +16 -10
  23. package/dist/gulp.mjs +14 -8
  24. package/dist/{incremental-runtime-class-set-CN6K_97P.js → incremental-runtime-class-set-Bl18sFqt.js} +540 -694
  25. package/dist/{incremental-runtime-class-set-x10M9bn_.mjs → incremental-runtime-class-set-CAEuUesH.mjs} +495 -619
  26. package/dist/index.js +4 -4
  27. package/dist/index.mjs +4 -4
  28. package/dist/{postcss-CR9UCaIK.mjs → postcss-CJrmfXvi.mjs} +4 -4
  29. package/dist/{postcss-hYimKoN_.js → postcss-DfnqZ4Bm.js} +4 -4
  30. package/dist/postcss.js +1 -1
  31. package/dist/postcss.mjs +1 -1
  32. package/dist/{precheck-DPtJjZmV.js → precheck-Bj5ReSOU.js} +2 -2
  33. package/dist/{precheck-BrNwLG2e.mjs → precheck-CUr1DYyy.mjs} +2 -2
  34. package/dist/presets.js +2 -2
  35. package/dist/presets.mjs +2 -2
  36. package/dist/{source-candidates-DN1mihlU.mjs → source-candidates-D7b-Jzsx.mjs} +44 -11
  37. package/dist/{source-candidates-DSxme_O2.js → source-candidates-DQxvGPSw.js} +49 -10
  38. package/dist/tailwindcss/source-scan.d.ts +3 -1
  39. package/dist/{tailwindcss-DWtPieNE.mjs → tailwindcss-D5RogwtV.mjs} +14 -49
  40. package/dist/{tailwindcss-glCm_d3H.js → tailwindcss-jvoYizzX.js} +19 -48
  41. package/dist/{v3-engine-DCxNPBVs.mjs → v3-engine-BCUGX3gX.mjs} +644 -36
  42. package/dist/{v3-engine-D3BMLVAN.js → v3-engine-CmIF_gsq.js} +775 -35
  43. package/dist/{vite-Ec0uX6kF.js → vite-D1ZdgbWa.js} +533 -290
  44. package/dist/{vite-DOprpdH-.mjs → vite-jBTi5CwO.mjs} +532 -289
  45. package/dist/vite.js +1 -1
  46. package/dist/vite.mjs +1 -1
  47. package/dist/{runtime-registry-DpcR3IHI.js → watch-dependencies-zwx4EhBn.js} +39 -0
  48. package/dist/weapp-tw-css-import-rewrite-loader.js +1953 -1630
  49. package/dist/weapp-tw-runtime-classset-loader.js +6 -6
  50. package/dist/{webpack-DFlZcqAU.mjs → webpack-CChDqRrl.mjs} +6 -6
  51. package/dist/{webpack-Ccohlg3A.js → webpack-vk2uqSnK.js} +7 -7
  52. package/dist/webpack.js +1 -1
  53. package/dist/webpack.mjs +1 -1
  54. package/package.json +2 -2
@@ -174,6 +174,11 @@ function createDefaultResolvePaths(basedir) {
174
174
  appendNodeModules(paths, packageRoot);
175
175
  fallbackCandidates.push(packageRoot);
176
176
  }
177
+ const workspaceRoot = findWorkspaceRoot(resolvedBase);
178
+ if (workspaceRoot) {
179
+ appendNodeModules(paths, workspaceRoot);
180
+ fallbackCandidates.push(workspaceRoot);
181
+ }
177
182
  }
178
183
  const cwd = node_process.default.cwd();
179
184
  appendNodeModules(paths, cwd);
@@ -270,9 +275,6 @@ function createFallbackTailwindcssPatcher() {
270
275
  let hasLoggedMissingTailwind = false;
271
276
  const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
272
277
  const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
273
- function isTailwindcssV4PackageName(packageName) {
274
- return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
275
- }
276
278
  function createTailwindcssPatcher(options) {
277
279
  const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
278
280
  const cache = { driver: "memory" };
@@ -291,7 +293,7 @@ function createTailwindcssPatcher(options) {
291
293
  resolve: { paths: resolvePaths }
292
294
  }));
293
295
  if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
294
- if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
296
+ if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = "tailwindcss";
295
297
  if (typeof baseTailwindOptions.postcssPlugin === "string") {
296
298
  const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
297
299
  if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
@@ -309,7 +311,7 @@ function createTailwindcssPatcher(options) {
309
311
  const resolvedTailwindOptions = resolvedOptions.tailwindcss;
310
312
  if (resolvedTailwindOptions) {
311
313
  const existingResolve = resolvedTailwindOptions.resolve ?? {};
312
- const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? existingResolve.paths : resolvePaths;
314
+ const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths, ...resolvePaths] : resolvePaths;
313
315
  resolvedTailwindOptions.resolve = {
314
316
  ...existingResolve,
315
317
  paths: [...new Set(sourcePaths)]
@@ -631,7 +633,7 @@ function collectCssInlineSourceCandidates(root) {
631
633
  excluded
632
634
  };
633
635
  }
634
- function normalizeLegacyContentEntries(content, base) {
636
+ function normalizeLegacyContentEntries(content, base, options = {}) {
635
637
  if (typeof content === "string") {
636
638
  const negated = content.startsWith("!");
637
639
  return [{
@@ -640,8 +642,8 @@ function normalizeLegacyContentEntries(content, base) {
640
642
  pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
641
643
  }];
642
644
  }
643
- if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base));
644
- if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, base);
645
+ if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
646
+ if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
645
647
  return [];
646
648
  }
647
649
  async function pathExistsAsDirectory(file) {
@@ -1714,9 +1716,10 @@ function parseImportSourceParam$1(params) {
1714
1716
  };
1715
1717
  }
1716
1718
  function isTailwindCssImport$1(params) {
1717
- return /^\s*(['"])tailwindcss(?:\/[^'"]*)?\1/.test(params);
1719
+ const specifier = parseCssImportSpecifier$2(params);
1720
+ return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
1718
1721
  }
1719
- function parseCssImportSpecifier$1(params) {
1722
+ function parseCssImportSpecifier$2(params) {
1720
1723
  const value = params.trim();
1721
1724
  const quoted = /^(['"])(.*?)\1/.exec(value);
1722
1725
  if (quoted) return quoted[2];
@@ -1724,7 +1727,7 @@ function parseCssImportSpecifier$1(params) {
1724
1727
  return url?.[2] ?? url?.[3];
1725
1728
  }
1726
1729
  function isTailwindCssPreflightImport(params) {
1727
- const specifier = parseCssImportSpecifier$1(params);
1730
+ const specifier = parseCssImportSpecifier$2(params);
1728
1731
  return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
1729
1732
  }
1730
1733
  function hasImportLayerOption(params) {
@@ -1959,7 +1962,520 @@ function createTailwindV4Engine(source) {
1959
1962
  };
1960
1963
  }
1961
1964
  //#endregion
1965
+ //#region src/bundlers/shared/generator-css/config-directive.ts
1966
+ function quoteCssString(value) {
1967
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
1968
+ }
1969
+ function toCssPath(value) {
1970
+ return value.replaceAll("\\", "/");
1971
+ }
1972
+ function prependConfigDirective(css, config) {
1973
+ if (!config || /@config\s+/.test(css)) return css;
1974
+ return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
1975
+ }
1976
+ function normalizeConfigDirective(css, config) {
1977
+ if (!config || !/@config\s+/.test(css)) return css;
1978
+ return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
1979
+ }
1980
+ //#endregion
1981
+ //#region src/bundlers/shared/generator-css/markers.ts
1982
+ const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
1983
+ const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
1984
+ const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
1985
+ const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
1986
+ const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
1987
+ const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
1988
+ const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
1989
+ const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
1990
+ function createCssAppend(base, extra) {
1991
+ if (!base) return extra;
1992
+ if (!extra) return base;
1993
+ return `${base}\n${extra}`;
1994
+ }
1995
+ function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
1996
+ const trimmedRaw = rawSource.trim();
1997
+ const trimmedTailwind = rawTailwindCss.trim();
1998
+ if (trimmedRaw === trimmedTailwind) return {
1999
+ before: "",
2000
+ after: ""
2001
+ };
2002
+ if (trimmedTailwind.startsWith(trimmedRaw)) return {
2003
+ before: "",
2004
+ after: ""
2005
+ };
2006
+ const start = rawSource.indexOf(rawTailwindCss);
2007
+ if (start === -1) return;
2008
+ return {
2009
+ before: rawSource.slice(0, start),
2010
+ after: rawSource.slice(start + rawTailwindCss.length)
2011
+ };
2012
+ }
2013
+ function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
2014
+ const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
2015
+ if (!match || match.index === void 0) return;
2016
+ let afterStart = match.index + match[0].length;
2017
+ while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
2018
+ if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
2019
+ afterStart += rawTailwindCss.length;
2020
+ while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
2021
+ }
2022
+ return {
2023
+ before: rawSource.slice(0, match.index),
2024
+ after: rawSource.slice(afterStart)
2025
+ };
2026
+ }
2027
+ function splitTailwindGeneratedCssByBanner(rawSource, start) {
2028
+ const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
2029
+ if (!match || match.index === void 0) return;
2030
+ return {
2031
+ before: rawSource.slice(0, match.index),
2032
+ after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
2033
+ };
2034
+ }
2035
+ function stripTailwindBanner(css) {
2036
+ return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
2037
+ }
2038
+ function stripTailwindBanners(css) {
2039
+ return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
2040
+ }
2041
+ function stripGeneratorPlaceholderMarkers(css) {
2042
+ return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
2043
+ }
2044
+ function hasTailwindGeneratedCss(rawSource) {
2045
+ return TAILWIND_V4_BANNER_RE.test(rawSource);
2046
+ }
2047
+ function hasTailwindGeneratedCssMarkers(rawSource) {
2048
+ return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
2049
+ }
2050
+ //#endregion
2051
+ //#region src/bundlers/shared/generator-css/directives.ts
2052
+ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
2053
+ "config",
2054
+ "custom-variant",
2055
+ "layer",
2056
+ "plugin",
2057
+ "reference",
2058
+ "source",
2059
+ "tailwind",
2060
+ "theme",
2061
+ "utility",
2062
+ "variant"
2063
+ ]);
2064
+ const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
2065
+ "config",
2066
+ "custom-variant",
2067
+ "plugin",
2068
+ "source",
2069
+ "tailwind",
2070
+ "theme",
2071
+ "utility",
2072
+ "variant"
2073
+ ]);
2074
+ const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
2075
+ const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
2076
+ const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
2077
+ const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant)\b[\s\S]*\{/;
2078
+ const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
2079
+ ["tailwindcss/base", "base"],
2080
+ ["tailwindcss/components", "components"],
2081
+ ["tailwindcss/utilities", "utilities"]
2082
+ ]);
2083
+ function parseImportRequest(params) {
2084
+ return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
2085
+ }
2086
+ function parseConfigRequest(params) {
2087
+ return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
2088
+ }
2089
+ function isPackageJsonImportRequest(request) {
2090
+ return typeof request === "string" && request.startsWith("#");
2091
+ }
2092
+ function isWeappTailwindcssImportRequest(request) {
2093
+ return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
2094
+ }
2095
+ function normalizeTailwindImportRequest(request, options = {}) {
2096
+ if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
2097
+ return request;
2098
+ }
2099
+ function replaceImportRequest(params, request, replacement) {
2100
+ const index = params.indexOf(request);
2101
+ if (index === -1) return params;
2102
+ return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
2103
+ }
2104
+ function normalizeTailwindImportAtRules(root, options = {}) {
2105
+ if (!options.importFallback) return false;
2106
+ let changed = false;
2107
+ const seenCanonicalImports = /* @__PURE__ */ new Set();
2108
+ root.walkAtRules("import", (node) => {
2109
+ const request = parseImportRequest(node.params);
2110
+ const normalizedRequest = normalizeTailwindImportRequest(request, options);
2111
+ if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
2112
+ const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
2113
+ const normalizedKey = normalizedParams.trim();
2114
+ if (seenCanonicalImports.has(normalizedKey)) {
2115
+ node.remove();
2116
+ changed = true;
2117
+ return;
2118
+ }
2119
+ seenCanonicalImports.add(normalizedKey);
2120
+ if (normalizedParams !== node.params) {
2121
+ node.params = normalizedParams;
2122
+ changed = true;
2123
+ }
2124
+ });
2125
+ return changed;
2126
+ }
2127
+ function normalizeTailwindDirectiveLine(line, options = {}) {
2128
+ const trimmed = line.trimStart();
2129
+ if (/^@(?:use|forward)\b/.test(trimmed)) {
2130
+ const request = parseImportRequest(trimmed.replace(/^@(?:use|forward)\b/, ""));
2131
+ if (isTailwindImportRequest(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
2132
+ const normalizedRequest = normalizeTailwindImportRequest(request, options);
2133
+ return replaceImportRequest(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
2134
+ }
2135
+ return line;
2136
+ }
2137
+ if (!options.importFallback || !trimmed.startsWith("@import")) return line;
2138
+ const request = parseImportRequest(trimmed.replace(/^@import\b/, ""));
2139
+ if (!request || !isWeappTailwindcssImportRequest(request)) return line;
2140
+ return replaceImportRequest(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
2141
+ }
2142
+ function extractTailwindDirectiveLines(rawSource, options = {}) {
2143
+ const directives = [];
2144
+ const seenImports = /* @__PURE__ */ new Set();
2145
+ for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
2146
+ const trimmed = line.trim();
2147
+ if (!trimmed || trimmed.startsWith("//")) continue;
2148
+ const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
2149
+ if (!directive) continue;
2150
+ const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
2151
+ const normalizedTrimmed = normalized.trim();
2152
+ if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
2153
+ const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
2154
+ if (request && !isTailwindImportRequest(request) && !isPackageJsonImportRequest(request)) continue;
2155
+ if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
2156
+ if (request && isTailwindImportRequest(request)) {
2157
+ const key = normalizedTrimmed;
2158
+ if (seenImports.has(key)) continue;
2159
+ seenImports.add(key);
2160
+ }
2161
+ directives.push(normalized);
2162
+ }
2163
+ return directives;
2164
+ }
2165
+ function stripPreprocessorLineComment(line) {
2166
+ let quote;
2167
+ let escaped = false;
2168
+ for (let index = 0; index < line.length; index++) {
2169
+ const char = line[index];
2170
+ if (escaped) {
2171
+ escaped = false;
2172
+ continue;
2173
+ }
2174
+ if (char === "\\") {
2175
+ escaped = true;
2176
+ continue;
2177
+ }
2178
+ if (quote) {
2179
+ if (char === quote) quote = void 0;
2180
+ continue;
2181
+ }
2182
+ if (char === "\"" || char === "'") {
2183
+ quote = char;
2184
+ continue;
2185
+ }
2186
+ if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
2187
+ }
2188
+ return line;
2189
+ }
2190
+ function countBlockBraceDelta(line) {
2191
+ let quote;
2192
+ let escaped = false;
2193
+ let delta = 0;
2194
+ for (let index = 0; index < line.length; index++) {
2195
+ const char = line[index];
2196
+ if (escaped) {
2197
+ escaped = false;
2198
+ continue;
2199
+ }
2200
+ if (char === "\\") {
2201
+ escaped = true;
2202
+ continue;
2203
+ }
2204
+ if (quote) {
2205
+ if (char === quote) quote = void 0;
2206
+ continue;
2207
+ }
2208
+ if (char === "\"" || char === "'") {
2209
+ quote = char;
2210
+ continue;
2211
+ }
2212
+ if (char === "{") delta++;
2213
+ else if (char === "}") delta--;
2214
+ }
2215
+ return delta;
2216
+ }
2217
+ function extractTailwindFallbackBlocks(rawSource) {
2218
+ const blocks = [];
2219
+ let current;
2220
+ let depth = 0;
2221
+ for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
2222
+ const line = stripPreprocessorLineComment(rawLine);
2223
+ if (!line.trim()) continue;
2224
+ if (!current) {
2225
+ if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
2226
+ current = [line];
2227
+ depth = countBlockBraceDelta(line);
2228
+ if (depth <= 0) {
2229
+ blocks.push(current.join("\n"));
2230
+ current = void 0;
2231
+ depth = 0;
2232
+ }
2233
+ continue;
2234
+ }
2235
+ current.push(line);
2236
+ depth += countBlockBraceDelta(line);
2237
+ if (depth <= 0) {
2238
+ blocks.push(current.join("\n"));
2239
+ current = void 0;
2240
+ depth = 0;
2241
+ }
2242
+ }
2243
+ return blocks;
2244
+ }
2245
+ function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
2246
+ const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
2247
+ return directives.length > 0 ? directives.join("\n") : void 0;
2248
+ }
2249
+ function extractConfigRequestFromSource(rawSource) {
2250
+ for (const line of rawSource.split(/\r?\n/)) {
2251
+ const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
2252
+ const request = match ? parseConfigRequest(match[1] ?? "") : void 0;
2253
+ if (request) return request;
2254
+ }
2255
+ }
2256
+ function resolveConfigPath$1(base, configPath) {
2257
+ if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
2258
+ return node_path.default.resolve(base, configPath);
2259
+ }
2260
+ function normalizeTailwindConfigDirectives(rawSource, base) {
2261
+ return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
2262
+ if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
2263
+ return `@config ${quote}${node_path.default.resolve(base, request).replace(/\\/g, "/")}${quote};`;
2264
+ });
2265
+ }
2266
+ function hasPreprocessorOnlySyntax(rawSource) {
2267
+ return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
2268
+ }
2269
+ function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
2270
+ return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
2271
+ }
2272
+ function normalizeTailwindV3CssEntrySource(rawSource) {
2273
+ try {
2274
+ const root = postcss.default.parse(rawSource);
2275
+ let changed = false;
2276
+ root.walkAtRules("import", (node) => {
2277
+ const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
2278
+ if (!layer) return;
2279
+ node.replaceWith(postcss.default.atRule({
2280
+ name: "tailwind",
2281
+ params: layer
2282
+ }));
2283
+ changed = true;
2284
+ });
2285
+ return changed ? root.toString() : rawSource;
2286
+ } catch {
2287
+ return rawSource;
2288
+ }
2289
+ }
2290
+ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
2291
+ if (!options.importFallback) return rawSource;
2292
+ try {
2293
+ const root = postcss.default.parse(rawSource);
2294
+ return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
2295
+ } catch {
2296
+ return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
2297
+ }
2298
+ }
2299
+ function isTailwindImportRequest(request) {
2300
+ return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
2301
+ }
2302
+ function isTailwindImportAtRule(node, options = {}) {
2303
+ if (node.name === "tailwind") return true;
2304
+ if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
2305
+ return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
2306
+ }
2307
+ function isTailwindSourceDirective(node, options = {}) {
2308
+ if (node.type !== "atrule") return false;
2309
+ const atRule = node;
2310
+ if (isTailwindImportAtRule(atRule, options)) return true;
2311
+ if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
2312
+ if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
2313
+ return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
2314
+ }
2315
+ function hasGeneratedCssArtifacts(rawSource) {
2316
+ return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
2317
+ }
2318
+ function isTailwindGenerationDirective(node, options = {}) {
2319
+ if (node.type !== "atrule") return false;
2320
+ const atRule = node;
2321
+ const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
2322
+ return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
2323
+ }
2324
+ function removeTailwindSourceDirectives(rawSource, options = {}) {
2325
+ try {
2326
+ const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
2327
+ if (!source) return "";
2328
+ const root = postcss.default.parse(source);
2329
+ let removed = false;
2330
+ root.walk((node) => {
2331
+ if (isTailwindSourceDirective(node, options)) {
2332
+ node.remove();
2333
+ removed = true;
2334
+ }
2335
+ });
2336
+ return removed ? root.toString() : source;
2337
+ } catch {
2338
+ return stripGeneratorPlaceholderMarkers(rawSource);
2339
+ }
2340
+ }
2341
+ function hasTailwindSourceDirectives(rawSource, options = {}) {
2342
+ try {
2343
+ if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
2344
+ const root = postcss.default.parse(rawSource);
2345
+ let found = false;
2346
+ const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
2347
+ root.walk((node) => {
2348
+ if (isTailwindGenerationDirective(node, {
2349
+ ...options,
2350
+ ignoreLayer
2351
+ })) {
2352
+ found = true;
2353
+ return false;
2354
+ }
2355
+ });
2356
+ return found;
2357
+ } catch {
2358
+ return extractTailwindDirectiveLines(rawSource, options).length > 0;
2359
+ }
2360
+ }
2361
+ function hasTailwindRootDirectives(rawSource, options = {}) {
2362
+ if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
2363
+ try {
2364
+ const root = postcss.default.parse(rawSource);
2365
+ let found = false;
2366
+ root.walkAtRules((node) => {
2367
+ const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
2368
+ if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
2369
+ found = true;
2370
+ return false;
2371
+ }
2372
+ });
2373
+ return found;
2374
+ } catch {
2375
+ return extractTailwindDirectiveLines(rawSource, options).length > 0;
2376
+ }
2377
+ }
2378
+ function hasTailwindApplyDirective(rawSource) {
2379
+ if (!rawSource.includes("@apply")) return false;
2380
+ try {
2381
+ const root = postcss.default.parse(rawSource);
2382
+ let found = false;
2383
+ root.walkAtRules("apply", () => {
2384
+ found = true;
2385
+ return false;
2386
+ });
2387
+ return found;
2388
+ } catch {
2389
+ return false;
2390
+ }
2391
+ }
2392
+ function resolveCssEntrySource(rawSource, base, options = {}) {
2393
+ try {
2394
+ const root = postcss.default.parse(rawSource);
2395
+ const normalizedImports = normalizeTailwindImportAtRules(root, options);
2396
+ let found = false;
2397
+ let config;
2398
+ let configRequest;
2399
+ let removedConfig = false;
2400
+ const removeConfig = options.removeConfig ?? true;
2401
+ const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
2402
+ root.walk((node) => {
2403
+ if (isTailwindGenerationDirective(node, {
2404
+ ...options,
2405
+ ignoreLayer
2406
+ })) found = true;
2407
+ if (node.type === "atrule" && node.name === "config") {
2408
+ const configPath = parseConfigRequest(node.params);
2409
+ if (configPath && !config) {
2410
+ configRequest = configPath;
2411
+ config = resolveConfigPath$1(base, configPath);
2412
+ }
2413
+ if (removeConfig) {
2414
+ node.remove();
2415
+ removedConfig = true;
2416
+ }
2417
+ }
2418
+ });
2419
+ if (!found) return;
2420
+ if (hasPreprocessorOnlySyntax(rawSource)) {
2421
+ const css = extractTailwindSourceForPostcssFallback(rawSource, {
2422
+ ...options,
2423
+ removeConfig
2424
+ });
2425
+ if (css) return {
2426
+ css,
2427
+ config,
2428
+ configRequest,
2429
+ base
2430
+ };
2431
+ }
2432
+ return {
2433
+ css: removedConfig || normalizedImports ? root.toString() : rawSource,
2434
+ config,
2435
+ configRequest,
2436
+ base
2437
+ };
2438
+ } catch {
2439
+ const css = extractTailwindSourceForPostcssFallback(rawSource, options);
2440
+ const configRequest = extractConfigRequestFromSource(rawSource);
2441
+ const config = configRequest ? resolveConfigPath$1(base, configRequest) : void 0;
2442
+ return css ? {
2443
+ css,
2444
+ config,
2445
+ configRequest,
2446
+ base
2447
+ } : void 0;
2448
+ }
2449
+ }
2450
+ //#endregion
1962
2451
  //#region src/tailwindcss/v4-engine/source.ts
2452
+ const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2453
+ function isCssEntryPoint(file) {
2454
+ return typeof file === "string" && node_path.default.basename(file) === "index.css" && (0, node_fs.existsSync)(file);
2455
+ }
2456
+ function resolvePackageCssEntryPoint(specifier) {
2457
+ try {
2458
+ const resolved = require$2.resolve(specifier);
2459
+ if (isCssEntryPoint(resolved)) return resolved;
2460
+ } catch {}
2461
+ const packageName = specifier.replace(/\/index\.css$/, "");
2462
+ if (packageName !== "tailwindcss") return;
2463
+ try {
2464
+ const packageJson = require$2.resolve(`${packageName}/package.json`);
2465
+ const cssEntry = node_path.default.resolve(node_path.default.dirname(packageJson), "index.css");
2466
+ if (isCssEntryPoint(cssEntry)) return cssEntry;
2467
+ } catch {}
2468
+ try {
2469
+ let current = node_path.default.dirname(require$2.resolve("tailwindcss-patch"));
2470
+ while (true) {
2471
+ const cssEntry = node_path.default.resolve(current, "..", "tailwindcss", "index.css");
2472
+ if (isCssEntryPoint(cssEntry)) return cssEntry;
2473
+ const parent = node_path.default.dirname(current);
2474
+ if (parent === current) break;
2475
+ current = parent;
2476
+ }
2477
+ } catch {}
2478
+ }
1963
2479
  function isPostcssPluginImportTarget(value) {
1964
2480
  if (!value) return false;
1965
2481
  return value === "@tailwindcss/postcss" || value.includes("/postcss");
@@ -1981,7 +2497,7 @@ function resolveConfigDir(config, projectRoot) {
1981
2497
  function isBarePackageSpecifier(specifier) {
1982
2498
  return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
1983
2499
  }
1984
- function parseCssImportSpecifier(params) {
2500
+ function parseCssImportSpecifier$1(params) {
1985
2501
  const value = params.trim();
1986
2502
  const quoted = /^(['"])(.*?)\1/.exec(value);
1987
2503
  if (quoted) {
@@ -2022,13 +2538,69 @@ function normalizeTailwindV4CssPackageImports(css, packageName) {
2022
2538
  const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
2023
2539
  let changed = false;
2024
2540
  root.walkAtRules("import", (rule) => {
2025
- const parsed = parseCssImportSpecifier(rule.params);
2541
+ const parsed = parseCssImportSpecifier$1(rule.params);
2026
2542
  if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
2027
- rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(`${parsed.specifier}/index.css`, parsed.quote));
2543
+ const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
2544
+ if (!cssEntryPoint) return;
2545
+ rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
2028
2546
  changed = true;
2029
2547
  });
2030
2548
  return changed ? root.toString() : css;
2031
2549
  }
2550
+ function normalizeTailwindV4CssSources(cssSources, packageName) {
2551
+ if (!cssSources?.length) return cssSources;
2552
+ let changed = false;
2553
+ const normalizedCssSources = cssSources.map((cssSource) => {
2554
+ if (typeof cssSource.css !== "string") return cssSource;
2555
+ const css = normalizeTailwindV4CssPackageImports(cssSource.css, packageName);
2556
+ if (css === cssSource.css) return cssSource;
2557
+ changed = true;
2558
+ return {
2559
+ ...cssSource,
2560
+ css
2561
+ };
2562
+ });
2563
+ return changed ? normalizedCssSources : cssSources;
2564
+ }
2565
+ function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
2566
+ if (!cssEntries?.length) return;
2567
+ const remainingCssEntries = [];
2568
+ const cssSources = [];
2569
+ for (const cssEntry of cssEntries) {
2570
+ const file = node_path.default.resolve(cssEntry);
2571
+ if (!(0, node_fs.existsSync)(file)) {
2572
+ remainingCssEntries.push(cssEntry);
2573
+ continue;
2574
+ }
2575
+ const base = node_path.default.dirname(file);
2576
+ const rawCss = (0, node_fs.readFileSync)(file, "utf8");
2577
+ const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, resolveCssEntrySource(rawCss, base, { removeConfig: false })?.config), packageName);
2578
+ cssSources.push({
2579
+ file,
2580
+ base,
2581
+ css,
2582
+ dependencies: [file]
2583
+ });
2584
+ }
2585
+ return {
2586
+ cssEntries: remainingCssEntries,
2587
+ cssSources
2588
+ };
2589
+ }
2590
+ function normalizeTailwindV4SourceOptions(options) {
2591
+ if (!options) return options;
2592
+ const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(options.css, options.packageName);
2593
+ const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
2594
+ const cssSources = normalizeTailwindV4CssSources(options.cssSources || entrySources?.cssSources ? [...options.cssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName);
2595
+ const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
2596
+ if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
2597
+ return {
2598
+ ...options,
2599
+ ...css === void 0 ? {} : { css },
2600
+ ...cssEntries === void 0 ? {} : { cssEntries },
2601
+ ...cssSources === void 0 ? {} : { cssSources }
2602
+ };
2603
+ }
2032
2604
  function resolveTailwindCssImportTarget(patcher) {
2033
2605
  const configuredPackageName = resolveTailwindcssOptions(patcher.options)?.packageName;
2034
2606
  if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
@@ -2079,10 +2651,7 @@ function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
2079
2651
  });
2080
2652
  }
2081
2653
  function resolveTailwindV4Source(options) {
2082
- return (0, tailwindcss_patch.resolveTailwindV4Source)(options?.css === void 0 ? options : {
2083
- ...options,
2084
- css: normalizeTailwindV4CssPackageImports(options.css, options.packageName)
2085
- });
2654
+ return (0, tailwindcss_patch.resolveTailwindV4Source)(normalizeTailwindV4SourceOptions(options));
2086
2655
  }
2087
2656
  async function resolveTailwindV4SourceFromPatcher(patcher) {
2088
2657
  return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromPatcher(patcher));
@@ -2270,22 +2839,22 @@ function parseImportSourceParam(params) {
2270
2839
  sourcePath: match[3]
2271
2840
  };
2272
2841
  }
2842
+ function parseCssImportSpecifier(params) {
2843
+ const value = params.trim();
2844
+ const quoted = /^(['"])(.*?)\1/.exec(value);
2845
+ if (quoted) return quoted[2];
2846
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
2847
+ return url?.[2] ?? url?.[3];
2848
+ }
2273
2849
  function isTailwindCssImport(params) {
2274
- return /^\s*(['"])tailwindcss(?:\/[^'"]*)?\1/.test(params);
2850
+ const specifier = parseCssImportSpecifier(params);
2851
+ return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
2275
2852
  }
2276
2853
  function resolveSourceBase(base, sourcePath) {
2277
2854
  return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
2278
2855
  }
2279
2856
  function resolveConfigPath(base, configPath) {
2280
2857
  if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
2281
- let current = node_path.default.resolve(base);
2282
- while (true) {
2283
- const candidate = node_path.default.resolve(current, configPath);
2284
- if ((0, node_fs.existsSync)(candidate)) return candidate;
2285
- const parent = node_path.default.dirname(current);
2286
- if (parent === current) break;
2287
- current = parent;
2288
- }
2289
2858
  return node_path.default.resolve(base, configPath);
2290
2859
  }
2291
2860
  function createCssEntriesCacheKey(css, base, dependencies) {
@@ -2307,6 +2876,11 @@ function createResolvedViteSourceScan(input, dependencies) {
2307
2876
  ...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
2308
2877
  };
2309
2878
  }
2879
+ function createMergedCssEntrySourceScanEntries(entries, options) {
2880
+ if (options.sourceCount <= 1) return entries;
2881
+ const positiveEntries = entries.filter((entry) => !entry.negated);
2882
+ return positiveEntries.length > 0 ? positiveEntries : entries;
2883
+ }
2310
2884
  async function statConfigDependency(file) {
2311
2885
  try {
2312
2886
  const stats = await (0, node_fs_promises.stat)(file);
@@ -2356,7 +2930,7 @@ async function resolveConfigContentEntries(root, base) {
2356
2930
  for (const configPath of configPaths) {
2357
2931
  const staticContent = readStaticConfigContent(configPath);
2358
2932
  if (staticContent !== void 0) {
2359
- entries.push(...normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath)));
2933
+ entries.push(...normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
2360
2934
  continue;
2361
2935
  }
2362
2936
  try {
@@ -2364,7 +2938,7 @@ async function resolveConfigContentEntries(root, base) {
2364
2938
  config: configPath,
2365
2939
  cwd: node_path.default.dirname(configPath)
2366
2940
  });
2367
- entries.push(...normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath)));
2941
+ entries.push(...normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
2368
2942
  } catch {}
2369
2943
  }
2370
2944
  return {
@@ -2438,6 +3012,37 @@ function collectExistingCssEntries(options) {
2438
3012
  ...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries ?? []
2439
3013
  ].filter((item) => typeof item === "string" && item.length > 0).map((item) => node_path.default.resolve(item)).filter((item) => (0, node_fs.existsSync)(item));
2440
3014
  }
3015
+ async function resolveTailwindV3CssEntryScan(options, patcher) {
3016
+ const cssEntries = collectExistingCssEntries(options);
3017
+ const entries = [];
3018
+ const dependencies = /* @__PURE__ */ new Set();
3019
+ if (cssEntries.length === 0) return {
3020
+ entries,
3021
+ dependencies
3022
+ };
3023
+ const sourceOptions = resolveTailwindV3SourceOptionsFromPatcher(patcher);
3024
+ await Promise.all(cssEntries.map(async (cssEntry) => {
3025
+ addSourceScanDependency(dependencies, cssEntry);
3026
+ let css;
3027
+ try {
3028
+ css = (0, node_fs.readFileSync)(cssEntry, "utf8");
3029
+ } catch {
3030
+ return;
3031
+ }
3032
+ const source = await resolveTailwindV3Source({
3033
+ ...sourceOptions,
3034
+ base: node_path.default.dirname(cssEntry),
3035
+ css
3036
+ });
3037
+ addSourceScanDependency(dependencies, source.config);
3038
+ addSourceScanDependencies(dependencies, source.dependencies);
3039
+ entries.push(...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd }));
3040
+ }));
3041
+ return {
3042
+ entries,
3043
+ dependencies
3044
+ };
3045
+ }
2441
3046
  async function pathExistsAsFile(file) {
2442
3047
  try {
2443
3048
  return (await (0, node_fs_promises.stat)(file)).isFile();
@@ -2491,10 +3096,11 @@ function collectConfiguredCssSources(options) {
2491
3096
  }
2492
3097
  async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
2493
3098
  if (patcher.majorVersion === 3) {
2494
- const source = await resolveTailwindV3SourceFromPatcher(patcher);
2495
- const contentEntries = normalizeLegacyContentEntries(source.configObject?.content, source.config ? node_path.default.dirname(source.config) : source.cwd);
3099
+ const [source, cssEntryScan] = await Promise.all([resolveTailwindV3SourceFromPatcher(patcher), resolveTailwindV3CssEntryScan(options, patcher)]);
3100
+ const contentEntries = [...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd }), ...cssEntryScan.entries];
2496
3101
  const dependencies = /* @__PURE__ */ new Set();
2497
3102
  addSourceScanDependency(dependencies, source.config);
3103
+ for (const dependency of cssEntryScan.dependencies) dependencies.add(dependency);
2498
3104
  return contentEntries.length > 0 ? createResolvedViteSourceScan({ entries: contentEntries }, dependencies) : void 0;
2499
3105
  }
2500
3106
  if (patcher.majorVersion === 4) {
@@ -2531,8 +3137,9 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
2531
3137
  }
2532
3138
  }
2533
3139
  const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
2534
- if (entries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedViteSourceScan({
2535
- entries: explicit ? entries : entries.length > 0 ? entries : void 0,
3140
+ const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
3141
+ if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedViteSourceScan({
3142
+ entries: explicit ? scanEntries : scanEntries.length > 0 ? scanEntries : void 0,
2536
3143
  explicit,
2537
3144
  inlineCandidates
2538
3145
  }, dependencies);
@@ -2559,8 +3166,9 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
2559
3166
  }
2560
3167
  }
2561
3168
  const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
2562
- if (entries.length > 0 || cssSourceInlineCandidates || explicit || sourceOptions.cssSources?.length || configuredCssSources.length > 0) return createResolvedViteSourceScan({
2563
- entries: explicit ? entries : entries.length > 0 ? entries : void 0,
3169
+ const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length });
3170
+ if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit || sourceOptions.cssSources?.length || configuredCssSources.length > 0) return createResolvedViteSourceScan({
3171
+ entries: explicit ? cssSourceScanEntries : cssSourceScanEntries.length > 0 ? cssSourceScanEntries : void 0,
2564
3172
  explicit,
2565
3173
  inlineCandidates: cssSourceInlineCandidates
2566
3174
  }, dependencies);
@@ -3434,12 +4042,24 @@ Object.defineProperty(exports, "FULL_SOURCE_SCAN_EXTENSION_RE", {
3434
4042
  return FULL_SOURCE_SCAN_EXTENSION_RE;
3435
4043
  }
3436
4044
  });
4045
+ Object.defineProperty(exports, "VITE_MARKER_RE", {
4046
+ enumerable: true,
4047
+ get: function() {
4048
+ return VITE_MARKER_RE;
4049
+ }
4050
+ });
3437
4051
  Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
3438
4052
  enumerable: true,
3439
4053
  get: function() {
3440
4054
  return collectCssInlineSourceCandidates;
3441
4055
  }
3442
4056
  });
4057
+ Object.defineProperty(exports, "createCssAppend", {
4058
+ enumerable: true,
4059
+ get: function() {
4060
+ return createCssAppend;
4061
+ }
4062
+ });
3443
4063
  Object.defineProperty(exports, "createDebug", {
3444
4064
  enumerable: true,
3445
4065
  get: function() {
@@ -3542,6 +4162,36 @@ Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
3542
4162
  return getRuntimeClassSetSignatureWithSources;
3543
4163
  }
3544
4164
  });
4165
+ Object.defineProperty(exports, "hasTailwindApplyDirective", {
4166
+ enumerable: true,
4167
+ get: function() {
4168
+ return hasTailwindApplyDirective;
4169
+ }
4170
+ });
4171
+ Object.defineProperty(exports, "hasTailwindGeneratedCss", {
4172
+ enumerable: true,
4173
+ get: function() {
4174
+ return hasTailwindGeneratedCss;
4175
+ }
4176
+ });
4177
+ Object.defineProperty(exports, "hasTailwindGeneratedCssMarkers", {
4178
+ enumerable: true,
4179
+ get: function() {
4180
+ return hasTailwindGeneratedCssMarkers;
4181
+ }
4182
+ });
4183
+ Object.defineProperty(exports, "hasTailwindRootDirectives", {
4184
+ enumerable: true,
4185
+ get: function() {
4186
+ return hasTailwindRootDirectives;
4187
+ }
4188
+ });
4189
+ Object.defineProperty(exports, "hasTailwindSourceDirectives", {
4190
+ enumerable: true,
4191
+ get: function() {
4192
+ return hasTailwindSourceDirectives;
4193
+ }
4194
+ });
3545
4195
  Object.defineProperty(exports, "invalidateRuntimeClassSet", {
3546
4196
  enumerable: true,
3547
4197
  get: function() {
@@ -3554,6 +4204,12 @@ Object.defineProperty(exports, "isFileMatchedByTailwindSourceEntries", {
3554
4204
  return isFileMatchedByTailwindSourceEntries;
3555
4205
  }
3556
4206
  });
4207
+ Object.defineProperty(exports, "normalizeConfigDirective", {
4208
+ enumerable: true,
4209
+ get: function() {
4210
+ return normalizeConfigDirective;
4211
+ }
4212
+ });
3557
4213
  Object.defineProperty(exports, "normalizeLegacyContentEntries", {
3558
4214
  enumerable: true,
3559
4215
  get: function() {
@@ -3566,6 +4222,30 @@ Object.defineProperty(exports, "normalizeStringListOption", {
3566
4222
  return normalizeStringListOption;
3567
4223
  }
3568
4224
  });
4225
+ Object.defineProperty(exports, "normalizeTailwindConfigDirectives", {
4226
+ enumerable: true,
4227
+ get: function() {
4228
+ return normalizeTailwindConfigDirectives;
4229
+ }
4230
+ });
4231
+ Object.defineProperty(exports, "normalizeTailwindSourceDirectives", {
4232
+ enumerable: true,
4233
+ get: function() {
4234
+ return normalizeTailwindSourceDirectives;
4235
+ }
4236
+ });
4237
+ Object.defineProperty(exports, "normalizeTailwindSourceForGenerator", {
4238
+ enumerable: true,
4239
+ get: function() {
4240
+ return normalizeTailwindSourceForGenerator;
4241
+ }
4242
+ });
4243
+ Object.defineProperty(exports, "normalizeTailwindV3CssEntrySource", {
4244
+ enumerable: true,
4245
+ get: function() {
4246
+ return normalizeTailwindV3CssEntrySource;
4247
+ }
4248
+ });
3569
4249
  Object.defineProperty(exports, "omitUndefined", {
3570
4250
  enumerable: true,
3571
4251
  get: function() {
@@ -3578,18 +4258,42 @@ Object.defineProperty(exports, "parseConfigParam", {
3578
4258
  return parseConfigParam$1;
3579
4259
  }
3580
4260
  });
4261
+ Object.defineProperty(exports, "parseImportRequest", {
4262
+ enumerable: true,
4263
+ get: function() {
4264
+ return parseImportRequest;
4265
+ }
4266
+ });
4267
+ Object.defineProperty(exports, "prependConfigDirective", {
4268
+ enumerable: true,
4269
+ get: function() {
4270
+ return prependConfigDirective;
4271
+ }
4272
+ });
3581
4273
  Object.defineProperty(exports, "readInstalledPackageMajorVersion", {
3582
4274
  enumerable: true,
3583
4275
  get: function() {
3584
4276
  return readInstalledPackageMajorVersion;
3585
4277
  }
3586
4278
  });
4279
+ Object.defineProperty(exports, "removeTailwindSourceDirectives", {
4280
+ enumerable: true,
4281
+ get: function() {
4282
+ return removeTailwindSourceDirectives;
4283
+ }
4284
+ });
3587
4285
  Object.defineProperty(exports, "resolveBooleanObjectOption", {
3588
4286
  enumerable: true,
3589
4287
  get: function() {
3590
4288
  return resolveBooleanObjectOption;
3591
4289
  }
3592
4290
  });
4291
+ Object.defineProperty(exports, "resolveCssEntrySource", {
4292
+ enumerable: true,
4293
+ get: function() {
4294
+ return resolveCssEntrySource;
4295
+ }
4296
+ });
3593
4297
  Object.defineProperty(exports, "resolveCssSourceEntries", {
3594
4298
  enumerable: true,
3595
4299
  get: function() {
@@ -3680,6 +4384,42 @@ Object.defineProperty(exports, "runtimeSignaturePatchersSymbol", {
3680
4384
  return runtimeSignaturePatchersSymbol;
3681
4385
  }
3682
4386
  });
4387
+ Object.defineProperty(exports, "splitGeneratorPlaceholderCssBySourceOrder", {
4388
+ enumerable: true,
4389
+ get: function() {
4390
+ return splitGeneratorPlaceholderCssBySourceOrder;
4391
+ }
4392
+ });
4393
+ Object.defineProperty(exports, "splitTailwindGeneratedCssByBanner", {
4394
+ enumerable: true,
4395
+ get: function() {
4396
+ return splitTailwindGeneratedCssByBanner;
4397
+ }
4398
+ });
4399
+ Object.defineProperty(exports, "splitTailwindV4GeneratedCssBySourceOrder", {
4400
+ enumerable: true,
4401
+ get: function() {
4402
+ return splitTailwindV4GeneratedCssBySourceOrder;
4403
+ }
4404
+ });
4405
+ Object.defineProperty(exports, "stripGeneratorPlaceholderMarkers", {
4406
+ enumerable: true,
4407
+ get: function() {
4408
+ return stripGeneratorPlaceholderMarkers;
4409
+ }
4410
+ });
4411
+ Object.defineProperty(exports, "stripTailwindBanner", {
4412
+ enumerable: true,
4413
+ get: function() {
4414
+ return stripTailwindBanner;
4415
+ }
4416
+ });
4417
+ Object.defineProperty(exports, "stripTailwindBanners", {
4418
+ enumerable: true,
4419
+ get: function() {
4420
+ return stripTailwindBanners;
4421
+ }
4422
+ });
3683
4423
  Object.defineProperty(exports, "toPosixPath", {
3684
4424
  enumerable: true,
3685
4425
  get: function() {