weapp-tailwindcss 5.1.5 → 5.1.6

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 (48) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/bundlers/shared/generator-css/types.d.ts +1 -0
  4. package/dist/bundlers/shared/generator-css/user-css.d.ts +4 -1
  5. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +1 -0
  6. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
  7. package/dist/bundlers/vite/processed-css-assets.d.ts +7 -0
  8. package/dist/{context-rrYZuUBU.mjs → context-3GGqW9vw.mjs} +3 -3
  9. package/dist/{context-BziwyWy1.js → context-BCSk_YnL.js} +3 -3
  10. package/dist/core.js +1 -1
  11. package/dist/core.mjs +1 -1
  12. package/dist/{generator-24-HgU9F.mjs → generator-CoT5vu9w.mjs} +2 -2
  13. package/dist/{generator-CilgHtxb.js → generator-CqWzj2Z1.js} +2 -2
  14. package/dist/generator.js +2 -2
  15. package/dist/generator.mjs +2 -2
  16. package/dist/{gulp-ygWfmOqh.mjs → gulp-Bss4wJ8t.mjs} +4 -4
  17. package/dist/{gulp-CuVsZdO9.js → gulp-hXE1U4Cu.js} +4 -4
  18. package/dist/gulp.js +1 -1
  19. package/dist/gulp.mjs +1 -1
  20. package/dist/{hmr-timing-Dh_nn3w5.mjs → hmr-timing-Cfu-4Bnf.mjs} +24 -511
  21. package/dist/{hmr-timing-BKdCeIrn.js → hmr-timing-Df4203aI.js} +48 -565
  22. package/dist/index.js +4 -4
  23. package/dist/index.mjs +4 -4
  24. package/dist/postcss.js +2 -2
  25. package/dist/postcss.mjs +2 -2
  26. package/dist/presets.js +6 -3
  27. package/dist/presets.mjs +6 -3
  28. package/dist/rspack.js +1 -1
  29. package/dist/rspack.mjs +1 -1
  30. package/dist/runtime-branch/generator-target-env.d.ts +1 -0
  31. package/dist/{source-candidate-scan-signature-DIj9m4wB.js → source-candidate-scan-signature-5Uk6U72B.js} +3 -3
  32. package/dist/{source-candidate-scan-signature-DATRnS1X.mjs → source-candidate-scan-signature-BbCmW975.mjs} +3 -3
  33. package/dist/{tailwindcss-C-uM4rB8.mjs → tailwindcss-Bjr3aphG.mjs} +15 -2
  34. package/dist/{tailwindcss-BwoNQ3t8.js → tailwindcss-DYJ3HZD2.js} +15 -2
  35. package/dist/{transform-DHLemtaX.mjs → transform--155BmeJ.mjs} +1 -1
  36. package/dist/{transform-KLD1tJdb.js → transform-B6_y_yCB.js} +1 -1
  37. package/dist/{v4-engine-CKtsdKxK.js → v4-engine-C9cmNlP8.js} +610 -3
  38. package/dist/{v4-engine-BuuYDXt1.mjs → v4-engine-DRQaCFMm.mjs} +529 -6
  39. package/dist/{vite-Yp14HNyS.js → vite-Baw9qNrc.js} +560 -112
  40. package/dist/{vite-cH0tTMHc.mjs → vite-PdxjaqhO.mjs} +561 -113
  41. package/dist/vite.js +1 -1
  42. package/dist/vite.mjs +1 -1
  43. package/dist/weapp-tw-css-import-rewrite-loader.js +2994 -2958
  44. package/dist/{webpack-DBhmJ-_P.mjs → webpack-BffTDmod.mjs} +12 -13
  45. package/dist/{webpack-DN3tgLbF.js → webpack-C9u7mfGE.js} +18 -19
  46. package/dist/webpack.js +1 -1
  47. package/dist/webpack.mjs +1 -1
  48. package/package.json +3 -3
@@ -46,6 +46,9 @@ function inferGeneratorTargetFromExplicitEnv() {
46
46
  function shouldUseWebGeneratorTargetFromEnv() {
47
47
  return uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5";
48
48
  }
49
+ function shouldUseUniAppViteWebViewGeneratorTarget(appType, platform = getEnvValue("UNI_PLATFORM")) {
50
+ return appType === "uni-app-vite" && isUniAppWebViewPlatform(platform);
51
+ }
49
52
  function inferGeneratorTargetFromEnv() {
50
53
  return inferGeneratorTargetFromExplicitEnv() ?? (shouldUseWebGeneratorTargetFromEnv() ? "web" : "weapp");
51
54
  }
@@ -1860,6 +1863,526 @@ function resolveCssEntrySource(rawSource, base, options = {}) {
1860
1863
  }
1861
1864
  }
1862
1865
  //#endregion
1866
+ //#region src/bundlers/shared/generator-css/user-css.ts
1867
+ const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
1868
+ "config",
1869
+ "custom-variant",
1870
+ "plugin",
1871
+ "source",
1872
+ "theme",
1873
+ "utility",
1874
+ "variant"
1875
+ ]);
1876
+ function removeBalancedAtRuleBlock(source, atRuleStart) {
1877
+ const blockStart = source.indexOf("{", atRuleStart);
1878
+ if (blockStart === -1) {
1879
+ const semicolon = source.indexOf(";", atRuleStart);
1880
+ return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
1881
+ }
1882
+ let depth = 0;
1883
+ for (let index = blockStart; index < source.length; index++) {
1884
+ const char = source[index];
1885
+ if (char === "{") {
1886
+ depth++;
1887
+ continue;
1888
+ }
1889
+ if (char !== "}") continue;
1890
+ depth--;
1891
+ if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
1892
+ }
1893
+ return source.slice(0, atRuleStart);
1894
+ }
1895
+ function removeTailwindV4GeneratorAtRulesFallback(source) {
1896
+ let next = source;
1897
+ let changed = false;
1898
+ const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
1899
+ for (;;) {
1900
+ sourceMediaRE.lastIndex = 0;
1901
+ const match = sourceMediaRE.exec(next);
1902
+ if (!match) break;
1903
+ next = removeBalancedAtRuleBlock(next, match.index);
1904
+ changed = true;
1905
+ }
1906
+ const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
1907
+ for (;;) {
1908
+ atRuleRE.lastIndex = 0;
1909
+ const match = atRuleRE.exec(next);
1910
+ if (!match) break;
1911
+ next = removeBalancedAtRuleBlock(next, match.index);
1912
+ changed = true;
1913
+ }
1914
+ return changed ? next : source;
1915
+ }
1916
+ function isTailwindGeneratedPreflightComment(text) {
1917
+ return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
1918
+ }
1919
+ function isTailwindGeneratedThemeRule(selector, node) {
1920
+ if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
1921
+ return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
1922
+ }
1923
+ function isTailwindGeneratedPreflightRule(selector, node) {
1924
+ if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
1925
+ if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
1926
+ if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
1927
+ return false;
1928
+ }
1929
+ function removeTailwindV4GeneratedUserCssArtifacts(source) {
1930
+ try {
1931
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
1932
+ let changed = false;
1933
+ root.walkComments((comment) => {
1934
+ if (!isTailwindGeneratedPreflightComment(comment.text)) return;
1935
+ comment.remove();
1936
+ changed = true;
1937
+ });
1938
+ root.walkRules((rule) => {
1939
+ const selector = rule.selector.replace(/\s+/g, " ").trim();
1940
+ if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
1941
+ rule.remove();
1942
+ changed = true;
1943
+ }
1944
+ });
1945
+ root.walkAtRules((rule) => {
1946
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) {
1947
+ rule.remove();
1948
+ changed = true;
1949
+ }
1950
+ });
1951
+ return changed ? root.toString() : source;
1952
+ } catch {
1953
+ return source;
1954
+ }
1955
+ }
1956
+ function removeTailwindSourceMediaBlocks(source) {
1957
+ let next = source;
1958
+ let changed = false;
1959
+ const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
1960
+ for (;;) {
1961
+ sourceMediaRE.lastIndex = 0;
1962
+ const match = sourceMediaRE.exec(next);
1963
+ if (!match) break;
1964
+ const blockStart = next.indexOf("{", match.index);
1965
+ if (blockStart === -1) break;
1966
+ let depth = 0;
1967
+ let blockEnd = -1;
1968
+ for (let index = blockStart; index < next.length; index++) {
1969
+ const char = next[index];
1970
+ if (char === "{") {
1971
+ depth++;
1972
+ continue;
1973
+ }
1974
+ if (char !== "}") continue;
1975
+ depth--;
1976
+ if (depth === 0) {
1977
+ blockEnd = index;
1978
+ break;
1979
+ }
1980
+ }
1981
+ if (blockEnd === -1) break;
1982
+ next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
1983
+ changed = true;
1984
+ }
1985
+ for (;;) {
1986
+ const atRuleStart = findTailwindSourceWrapperBlockStart(next);
1987
+ if (atRuleStart === -1) break;
1988
+ next = removeBalancedAtRuleBlock(next, atRuleStart);
1989
+ changed = true;
1990
+ }
1991
+ return changed ? next : source;
1992
+ }
1993
+ function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
1994
+ if (!source.includes("@source")) return source;
1995
+ let next = "";
1996
+ let searchIndex = 0;
1997
+ for (;;) {
1998
+ const atRuleStart = source.indexOf("@source", searchIndex);
1999
+ if (atRuleStart === -1) {
2000
+ next += source.slice(searchIndex);
2001
+ break;
2002
+ }
2003
+ const nextChar = source[atRuleStart + 7];
2004
+ if (nextChar && /[\w-]/.test(nextChar)) {
2005
+ next += source.slice(searchIndex, atRuleStart + 7);
2006
+ searchIndex = atRuleStart + 7;
2007
+ continue;
2008
+ }
2009
+ next += source.slice(searchIndex, atRuleStart);
2010
+ let quote;
2011
+ let parenDepth = 0;
2012
+ let terminated = false;
2013
+ let index = atRuleStart + 7;
2014
+ for (; index < source.length; index++) {
2015
+ const char = source[index];
2016
+ if (quote) {
2017
+ if (char === "\\") {
2018
+ index++;
2019
+ continue;
2020
+ }
2021
+ if (char === quote) quote = void 0;
2022
+ continue;
2023
+ }
2024
+ if (char === "\"" || char === "'") {
2025
+ quote = char;
2026
+ continue;
2027
+ }
2028
+ if (char === "(") {
2029
+ parenDepth++;
2030
+ continue;
2031
+ }
2032
+ if (char === ")" && parenDepth > 0) {
2033
+ parenDepth--;
2034
+ continue;
2035
+ }
2036
+ if (parenDepth > 0) continue;
2037
+ if (char === ";" || char === "{") {
2038
+ terminated = true;
2039
+ index++;
2040
+ break;
2041
+ }
2042
+ if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
2043
+ }
2044
+ const segment = source.slice(atRuleStart, index);
2045
+ const trimmedSegment = segment.trimEnd();
2046
+ next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
2047
+ searchIndex = index;
2048
+ }
2049
+ return next;
2050
+ }
2051
+ function findTailwindSourceWrapperBlockStart(source) {
2052
+ let searchIndex = 0;
2053
+ for (;;) {
2054
+ const atRuleStart = source.indexOf("@source", searchIndex);
2055
+ if (atRuleStart === -1) return -1;
2056
+ const nextChar = source[atRuleStart + 7];
2057
+ if (nextChar && /[\w-]/.test(nextChar)) {
2058
+ searchIndex = atRuleStart + 7;
2059
+ continue;
2060
+ }
2061
+ let quote;
2062
+ let parenDepth = 0;
2063
+ for (let index = atRuleStart + 7; index < source.length; index++) {
2064
+ const char = source[index];
2065
+ if (quote) {
2066
+ if (char === "\\") {
2067
+ index++;
2068
+ continue;
2069
+ }
2070
+ if (char === quote) quote = void 0;
2071
+ continue;
2072
+ }
2073
+ if (char === "\"" || char === "'") {
2074
+ quote = char;
2075
+ continue;
2076
+ }
2077
+ if (char === "(") {
2078
+ parenDepth++;
2079
+ continue;
2080
+ }
2081
+ if (char === ")" && parenDepth > 0) {
2082
+ parenDepth--;
2083
+ continue;
2084
+ }
2085
+ if (parenDepth > 0) continue;
2086
+ if (char === ";") {
2087
+ searchIndex = index + 1;
2088
+ break;
2089
+ }
2090
+ if (char === "{") return atRuleStart;
2091
+ }
2092
+ if (searchIndex <= atRuleStart) return -1;
2093
+ }
2094
+ }
2095
+ function removeTailwindApplyAtRules(source) {
2096
+ if (!source.includes("@apply")) return source;
2097
+ try {
2098
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2099
+ let changed = false;
2100
+ root.walkAtRules("apply", (rule) => {
2101
+ rule.remove();
2102
+ changed = true;
2103
+ });
2104
+ root.walk((node) => {
2105
+ if ("nodes" in node && node.nodes?.length === 0) node.remove();
2106
+ });
2107
+ return changed ? root.toString() : source;
2108
+ } catch {
2109
+ return source;
2110
+ }
2111
+ }
2112
+ function removeTailwindV4GeneratorAtRules(source) {
2113
+ try {
2114
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2115
+ let changed = false;
2116
+ root.walkAtRules((rule) => {
2117
+ if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
2118
+ rule.remove();
2119
+ changed = true;
2120
+ return;
2121
+ }
2122
+ if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
2123
+ rule.remove();
2124
+ changed = true;
2125
+ });
2126
+ return changed ? root.toString() : source;
2127
+ } catch {
2128
+ return removeTailwindV4GeneratorAtRulesFallback(source);
2129
+ }
2130
+ }
2131
+ function isCommentOnlyCss(source) {
2132
+ try {
2133
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2134
+ return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
2135
+ } catch {
2136
+ return false;
2137
+ }
2138
+ }
2139
+ function removeMiniProgramHoverSelectors(source, enabled = true) {
2140
+ if (!enabled || !source.includes(":hover")) return source;
2141
+ try {
2142
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2143
+ let changed = false;
2144
+ root.walkRules((rule) => {
2145
+ const selectors = rule.selectors ?? [rule.selector];
2146
+ const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
2147
+ if (keptSelectors.length === selectors.length) return;
2148
+ changed = true;
2149
+ if (keptSelectors.length === 0) {
2150
+ rule.remove();
2151
+ return;
2152
+ }
2153
+ rule.selectors = keptSelectors;
2154
+ });
2155
+ root.walk((node) => {
2156
+ if ("nodes" in node && node.nodes?.length === 0) {
2157
+ node.remove();
2158
+ changed = true;
2159
+ }
2160
+ });
2161
+ return changed ? root.toString() : source;
2162
+ } catch {
2163
+ return source;
2164
+ }
2165
+ }
2166
+ function removeProcessedMiniProgramUnsupportedCss(source, options) {
2167
+ return removeMiniProgramHoverSelectors((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(source), options.cssRemoveHoverPseudoClass);
2168
+ }
2169
+ function unwrapMiniProgramCascadeLayers(source) {
2170
+ if (!source.includes("@layer")) return source;
2171
+ try {
2172
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2173
+ (0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
2174
+ return root.toString();
2175
+ } catch {
2176
+ return source;
2177
+ }
2178
+ }
2179
+ function stripTailwindSourceMediaFragments(source) {
2180
+ let removedSourceMediaStart = false;
2181
+ return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
2182
+ if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
2183
+ removedSourceMediaStart = true;
2184
+ return false;
2185
+ }
2186
+ if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
2187
+ if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
2188
+ removedSourceMediaStart = false;
2189
+ return false;
2190
+ }
2191
+ return true;
2192
+ }).join("\n");
2193
+ }
2194
+ function stripLeadingTailwindSourceMediaCloseFragment(source) {
2195
+ return source.replace(/^\s*\}\s*(?:\n|$)/, "");
2196
+ }
2197
+ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
2198
+ try {
2199
+ _weapp_tailwindcss_postcss.postcss.parse(source);
2200
+ return source;
2201
+ } catch {
2202
+ return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
2203
+ }
2204
+ }
2205
+ function splitUserCssLayerBlocks(source) {
2206
+ if (!source.includes("@layer")) return {
2207
+ layer: "",
2208
+ rest: source
2209
+ };
2210
+ try {
2211
+ const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2212
+ const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
2213
+ const restRoot = _weapp_tailwindcss_postcss.postcss.root();
2214
+ for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
2215
+ return {
2216
+ layer: layerRoot.toString(),
2217
+ rest: restRoot.toString()
2218
+ };
2219
+ } catch {
2220
+ return {
2221
+ layer: source,
2222
+ rest: ""
2223
+ };
2224
+ }
2225
+ }
2226
+ function hasUserCssLayerBlocks(source) {
2227
+ if (!source.includes("@layer")) return false;
2228
+ try {
2229
+ let hasLayerBlock = false;
2230
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
2231
+ if (node.nodes?.length) hasLayerBlock = true;
2232
+ });
2233
+ return hasLayerBlock;
2234
+ } catch {
2235
+ return true;
2236
+ }
2237
+ }
2238
+ function collectUserLayerSelectors(source) {
2239
+ const selectors = /* @__PURE__ */ new Set();
2240
+ try {
2241
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
2242
+ for (const selector of rule.selectors ?? [rule.selector]) {
2243
+ const normalized = selector.trim();
2244
+ if (normalized) selectors.add(normalized);
2245
+ }
2246
+ });
2247
+ } catch {}
2248
+ return selectors;
2249
+ }
2250
+ function matchesUserLayerSelector(selector, userLayerSelector) {
2251
+ if (selector === userLayerSelector) return true;
2252
+ if (!selector.startsWith(userLayerSelector)) return false;
2253
+ const next = selector[userLayerSelector.length];
2254
+ return next === ":" || next === "[";
2255
+ }
2256
+ function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
2257
+ const selectors = collectUserLayerSelectors(userLayerSource);
2258
+ if (selectors.size === 0) return {
2259
+ layer: "",
2260
+ rest: css
2261
+ };
2262
+ try {
2263
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
2264
+ const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
2265
+ const selectorList = [...selectors];
2266
+ root.walkRules((rule) => {
2267
+ if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
2268
+ layerRoot.append(rule.clone());
2269
+ rule.remove();
2270
+ }
2271
+ });
2272
+ return {
2273
+ layer: layerRoot.toString(),
2274
+ rest: root.toString()
2275
+ };
2276
+ } catch {
2277
+ return {
2278
+ layer: "",
2279
+ rest: css
2280
+ };
2281
+ }
2282
+ }
2283
+ function normalizeGeneratedSelector(selector) {
2284
+ return selector.replace(/:not\(#\\#\)/g, "").trim();
2285
+ }
2286
+ function collectApplyOnlySourceSelectors(source) {
2287
+ const selectors = /* @__PURE__ */ new Set();
2288
+ try {
2289
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
2290
+ if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
2291
+ for (const selector of rule.selectors ?? [rule.selector]) {
2292
+ const normalized = normalizeGeneratedSelector(selector);
2293
+ if (normalized) selectors.add(normalized);
2294
+ }
2295
+ });
2296
+ } catch {}
2297
+ return selectors;
2298
+ }
2299
+ function hasOnlyApplyBackedSourceRules(source) {
2300
+ let hasApplyRule = false;
2301
+ let hasNonApplyRule = false;
2302
+ try {
2303
+ _weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
2304
+ if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
2305
+ else hasNonApplyRule = true;
2306
+ });
2307
+ } catch {
2308
+ return false;
2309
+ }
2310
+ return hasApplyRule && !hasNonApplyRule;
2311
+ }
2312
+ function removeCssComments(css) {
2313
+ return css.replace(/\/\*[\s\S]*?\*\//g, "");
2314
+ }
2315
+ function isEmptyCustomVariantBlock(rule) {
2316
+ if (rule.name !== "custom-variant") return false;
2317
+ if (!/^[\w-]+$/.test(rule.params.trim())) return false;
2318
+ if (rule.nodes === void 0) return true;
2319
+ return rule.nodes.every((node) => node.type === "comment");
2320
+ }
2321
+ function normalizeEmptyTailwindCustomVariants(css) {
2322
+ if (!css.includes("@custom-variant")) return css;
2323
+ try {
2324
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
2325
+ let changed = false;
2326
+ root.walkAtRules("custom-variant", (rule) => {
2327
+ if (!isEmptyCustomVariantBlock(rule)) return;
2328
+ rule.remove();
2329
+ changed = true;
2330
+ });
2331
+ return changed ? root.toString() : css;
2332
+ } catch {
2333
+ return css;
2334
+ }
2335
+ }
2336
+ function filterApplyOnlyGeneratedCss(css, source, options = {}) {
2337
+ const selectors = collectApplyOnlySourceSelectors(source);
2338
+ if (selectors.size === 0) return css;
2339
+ const selectorList = [...selectors];
2340
+ const preserveVariables = options.preserveVariables !== false;
2341
+ try {
2342
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
2343
+ root.walkRules((rule) => {
2344
+ const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
2345
+ const normalized = normalizeGeneratedSelector(selector);
2346
+ return selectorList.some((sourceSelector) => {
2347
+ if (normalized === sourceSelector) return true;
2348
+ if (!normalized.startsWith(sourceSelector)) return false;
2349
+ const next = normalized[sourceSelector.length];
2350
+ return next === ":" || next === "[" || next === ".";
2351
+ });
2352
+ });
2353
+ const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
2354
+ if (!isApplySelector && (!preserveVariables || !isVariableRule)) rule.remove();
2355
+ });
2356
+ root.walkAtRules((rule) => {
2357
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
2358
+ });
2359
+ return removeCssComments(root.toString()).trim();
2360
+ } catch {
2361
+ return css;
2362
+ }
2363
+ }
2364
+ function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
2365
+ return (target === "weapp" || target === "web") && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
2366
+ }
2367
+ async function transformGeneratorUserCss(source, options) {
2368
+ if (source.trim().length === 0) return "";
2369
+ if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
2370
+ ...options.generatorStyleOptions,
2371
+ ...options.cssUserHandlerOptions
2372
+ })) : source)));
2373
+ const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
2374
+ if (cleanedSource.trim().length === 0) return "";
2375
+ const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
2376
+ if (userSource.trim().length === 0) return "";
2377
+ if (isCommentOnlyCss(userSource)) return userSource;
2378
+ if (options.generatorTarget !== "weapp") return userSource;
2379
+ const { css } = await options.styleHandler(userSource, {
2380
+ ...options.generatorStyleOptions,
2381
+ ...options.cssUserHandlerOptions
2382
+ });
2383
+ return removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
2384
+ }
2385
+ //#endregion
1863
2386
  //#region src/utils/options.ts
1864
2387
  function resolveBooleanObjectOption(value, enabledValue) {
1865
2388
  if (!value) return false;
@@ -2198,7 +2721,7 @@ function normalizeTailwindV4CssSources(cssSources, packageName, projectRoot) {
2198
2721
  };
2199
2722
  }
2200
2723
  const configBase = base ?? projectRoot ?? node_process.default.cwd();
2201
- const css = normalizeTailwindV4CssPackageImports(normalizeTailwindConfigDirectives(cssSource.css, configBase), packageName);
2724
+ const css = normalizeTailwindV4CssPackageImports(normalizeEmptyTailwindCustomVariants(normalizeTailwindConfigDirectives(cssSource.css, configBase)), packageName);
2202
2725
  if (css === cssSource.css && file === cssSource.file && base === cssSource.base) return cssSource;
2203
2726
  changed = true;
2204
2727
  return {
@@ -2223,7 +2746,7 @@ function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
2223
2746
  const base = node_path.default.dirname(file);
2224
2747
  const rawCss = (0, node_fs.readFileSync)(file, "utf8");
2225
2748
  const entrySource = resolveCssEntrySource(rawCss, base, { removeConfig: false });
2226
- const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, entrySource?.config && (0, node_fs.existsSync)(entrySource.config) ? entrySource.config : entrySource?.configRequest && !node_path.default.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? node_path.default.resolve(base, entrySource.configRequest) : entrySource?.config), packageName);
2749
+ const css = normalizeTailwindV4CssPackageImports(normalizeEmptyTailwindCustomVariants(normalizeConfigDirective(rawCss, entrySource?.config && (0, node_fs.existsSync)(entrySource.config) ? entrySource.config : entrySource?.configRequest && !node_path.default.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? node_path.default.resolve(base, entrySource.configRequest) : entrySource?.config)), packageName);
2227
2750
  cssSources.push({
2228
2751
  file,
2229
2752
  base,
@@ -2239,7 +2762,7 @@ function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
2239
2762
  function normalizeTailwindV4SourceOptions(options) {
2240
2763
  if (!options) return options;
2241
2764
  const cssBase = resolveBase(options.base, options.projectRoot ?? options.cwd ?? node_process.default.cwd());
2242
- const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(normalizeTailwindConfigDirectives(options.css, cssBase), options.packageName);
2765
+ const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(normalizeEmptyTailwindCustomVariants(normalizeTailwindConfigDirectives(options.css, cssBase)), options.packageName);
2243
2766
  const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
2244
2767
  const configuredCssSources = filterTailwindV4CssSourceRoots(options.cssSources);
2245
2768
  const cssSources = normalizeTailwindV4CssSources(configuredCssSources || entrySources?.cssSources ? [...configuredCssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName, options.projectRoot);
@@ -2372,6 +2895,18 @@ Object.defineProperty(exports, "expandTailwindSourceEntries", {
2372
2895
  return expandTailwindSourceEntries;
2373
2896
  }
2374
2897
  });
2898
+ Object.defineProperty(exports, "extractGeneratedCssForUserLayerSelectors", {
2899
+ enumerable: true,
2900
+ get: function() {
2901
+ return extractGeneratedCssForUserLayerSelectors;
2902
+ }
2903
+ });
2904
+ Object.defineProperty(exports, "filterApplyOnlyGeneratedCss", {
2905
+ enumerable: true,
2906
+ get: function() {
2907
+ return filterApplyOnlyGeneratedCss;
2908
+ }
2909
+ });
2375
2910
  Object.defineProperty(exports, "filterTailwindV4CssSourceRoots", {
2376
2911
  enumerable: true,
2377
2912
  get: function() {
@@ -2468,12 +3003,24 @@ Object.defineProperty(exports, "hasTailwindSourceDirectives", {
2468
3003
  return hasTailwindSourceDirectives;
2469
3004
  }
2470
3005
  });
3006
+ Object.defineProperty(exports, "hasUserCssLayerBlocks", {
3007
+ enumerable: true,
3008
+ get: function() {
3009
+ return hasUserCssLayerBlocks;
3010
+ }
3011
+ });
2471
3012
  Object.defineProperty(exports, "inferGeneratorTargetFromEnv", {
2472
3013
  enumerable: true,
2473
3014
  get: function() {
2474
3015
  return inferGeneratorTargetFromEnv;
2475
3016
  }
2476
3017
  });
3018
+ Object.defineProperty(exports, "isCommentOnlyCss", {
3019
+ enumerable: true,
3020
+ get: function() {
3021
+ return isCommentOnlyCss;
3022
+ }
3023
+ });
2477
3024
  Object.defineProperty(exports, "isFileMatchedByTailwindSourceEntries", {
2478
3025
  enumerable: true,
2479
3026
  get: function() {
@@ -2498,6 +3045,12 @@ Object.defineProperty(exports, "normalizeCssEntries", {
2498
3045
  return normalizeCssEntries;
2499
3046
  }
2500
3047
  });
3048
+ Object.defineProperty(exports, "normalizeEmptyTailwindCustomVariants", {
3049
+ enumerable: true,
3050
+ get: function() {
3051
+ return normalizeEmptyTailwindCustomVariants;
3052
+ }
3053
+ });
2501
3054
  Object.defineProperty(exports, "normalizeExtendLengthUnits", {
2502
3055
  enumerable: true,
2503
3056
  get: function() {
@@ -2564,12 +3117,30 @@ Object.defineProperty(exports, "prependConfigDirective", {
2564
3117
  return prependConfigDirective;
2565
3118
  }
2566
3119
  });
3120
+ Object.defineProperty(exports, "removeMiniProgramHoverSelectors", {
3121
+ enumerable: true,
3122
+ get: function() {
3123
+ return removeMiniProgramHoverSelectors;
3124
+ }
3125
+ });
2567
3126
  Object.defineProperty(exports, "removeTailwindSourceDirectives", {
2568
3127
  enumerable: true,
2569
3128
  get: function() {
2570
3129
  return removeTailwindSourceDirectives;
2571
3130
  }
2572
3131
  });
3132
+ Object.defineProperty(exports, "removeTailwindV4GeneratedUserCssArtifacts", {
3133
+ enumerable: true,
3134
+ get: function() {
3135
+ return removeTailwindV4GeneratedUserCssArtifacts;
3136
+ }
3137
+ });
3138
+ Object.defineProperty(exports, "removeTailwindV4GeneratorAtRules", {
3139
+ enumerable: true,
3140
+ get: function() {
3141
+ return removeTailwindV4GeneratorAtRules;
3142
+ }
3143
+ });
2573
3144
  Object.defineProperty(exports, "resolveBooleanObjectOption", {
2574
3145
  enumerable: true,
2575
3146
  get: function() {
@@ -2636,6 +3207,18 @@ Object.defineProperty(exports, "resolveTailwindcssOptions", {
2636
3207
  return resolveTailwindcssOptions;
2637
3208
  }
2638
3209
  });
3210
+ Object.defineProperty(exports, "shouldFilterApplyOnlyGeneratedCss", {
3211
+ enumerable: true,
3212
+ get: function() {
3213
+ return shouldFilterApplyOnlyGeneratedCss;
3214
+ }
3215
+ });
3216
+ Object.defineProperty(exports, "shouldUseUniAppViteWebViewGeneratorTarget", {
3217
+ enumerable: true,
3218
+ get: function() {
3219
+ return shouldUseUniAppViteWebViewGeneratorTarget;
3220
+ }
3221
+ });
2639
3222
  Object.defineProperty(exports, "splitGeneratorPlaceholderCssBySourceOrder", {
2640
3223
  enumerable: true,
2641
3224
  get: function() {
@@ -2654,6 +3237,12 @@ Object.defineProperty(exports, "splitTailwindV4GeneratedCssBySourceOrder", {
2654
3237
  return splitTailwindV4GeneratedCssBySourceOrder;
2655
3238
  }
2656
3239
  });
3240
+ Object.defineProperty(exports, "splitUserCssLayerBlocks", {
3241
+ enumerable: true,
3242
+ get: function() {
3243
+ return splitUserCssLayerBlocks;
3244
+ }
3245
+ });
2657
3246
  Object.defineProperty(exports, "stripGeneratorPlaceholderMarkers", {
2658
3247
  enumerable: true,
2659
3248
  get: function() {
@@ -2672,12 +3261,30 @@ Object.defineProperty(exports, "stripTailwindBanners", {
2672
3261
  return stripTailwindBanners;
2673
3262
  }
2674
3263
  });
3264
+ Object.defineProperty(exports, "stripTailwindSourceMediaFragments", {
3265
+ enumerable: true,
3266
+ get: function() {
3267
+ return stripTailwindSourceMediaFragments;
3268
+ }
3269
+ });
3270
+ Object.defineProperty(exports, "stripUnmatchedTailwindSourceMediaCloseFragments", {
3271
+ enumerable: true,
3272
+ get: function() {
3273
+ return stripUnmatchedTailwindSourceMediaCloseFragments;
3274
+ }
3275
+ });
2675
3276
  Object.defineProperty(exports, "toPosixPath", {
2676
3277
  enumerable: true,
2677
3278
  get: function() {
2678
3279
  return toPosixPath;
2679
3280
  }
2680
3281
  });
3282
+ Object.defineProperty(exports, "transformGeneratorUserCss", {
3283
+ enumerable: true,
3284
+ get: function() {
3285
+ return transformGeneratorUserCss;
3286
+ }
3287
+ });
2681
3288
  Object.defineProperty(exports, "transformTailwindV4CssByTarget", {
2682
3289
  enumerable: true,
2683
3290
  get: function() {