@weapp-tailwindcss/postcss 3.3.3 → 3.3.5
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.
- package/dist/compat/author-selector.d.ts +2 -0
- package/dist/compat/legacy-css/apply.d.ts +2 -0
- package/dist/compat/legacy-css/dedupe.d.ts +2 -0
- package/dist/compat/legacy-css/index.d.ts +4 -0
- package/dist/compat/legacy-css/selectors.d.ts +7 -0
- package/dist/compat/legacy-css/units.d.ts +1 -0
- package/dist/compat/mini-program-css/class-presence.d.ts +3 -0
- package/dist/compat/mini-program-css/content-init.d.ts +3 -0
- package/dist/compat/mini-program-css/empty-blocks.d.ts +3 -0
- package/dist/compat/mini-program-css/index.d.ts +2 -0
- package/dist/compat/tailwindcss-v4/author-functions.d.ts +7 -0
- package/dist/compat/tailwindcss-v4/theme-source.d.ts +4 -0
- package/dist/compat/tailwindcss-v4.d.ts +1 -0
- package/dist/compat/uni-app-x-author-apply.d.ts +10 -0
- package/dist/compat/uni-app-x-border.d.ts +6 -0
- package/dist/compat/uni-app-x-style-value.d.ts +9 -0
- package/dist/framework-pipeline.d.ts +4 -0
- package/dist/generator-plugin/local-imports.d.ts +6 -1
- package/dist/index.cjs +1288 -109
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1241 -101
- package/dist/plugins/applyConfiguredCssCalc.d.ts +9 -0
- package/dist/postcss-runtime.d.ts +1 -1
- package/dist/selectorParser/utils.d.ts +1 -1
- package/dist/syntax/css-import.d.ts +20 -0
- package/dist/syntax/index.d.ts +2 -0
- package/dist/syntax/parse.d.ts +13 -0
- package/dist/types.d.ts +14 -1
- package/package.json +6 -7
package/dist/index.cjs
CHANGED
|
@@ -17,36 +17,65 @@ postcss_value_parser = require_rolldown_runtime.__toESM(postcss_value_parser, 1)
|
|
|
17
17
|
let _csstools_css_color_parser = require("@csstools/css-color-parser");
|
|
18
18
|
let _csstools_css_parser_algorithms = require("@csstools/css-parser-algorithms");
|
|
19
19
|
let _csstools_css_tokenizer = require("@csstools/css-tokenizer");
|
|
20
|
-
let postcss_preset_env = require("postcss-preset-env");
|
|
21
|
-
postcss_preset_env = require_rolldown_runtime.__toESM(postcss_preset_env, 1);
|
|
22
|
-
let _weapp_core_escape = require("@weapp-core/escape");
|
|
23
20
|
let node_path = require("node:path");
|
|
24
21
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
22
|
+
let _weapp_core_escape = require("@weapp-core/escape");
|
|
23
|
+
let postcss_preset_env = require("postcss-preset-env");
|
|
24
|
+
postcss_preset_env = require_rolldown_runtime.__toESM(postcss_preset_env, 1);
|
|
25
25
|
let node_process = require("node:process");
|
|
26
26
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
27
|
+
let node_module = require("node:module");
|
|
28
|
+
let node_url = require("node:url");
|
|
29
|
+
let postcss_load_config = require("postcss-load-config");
|
|
30
|
+
postcss_load_config = require_rolldown_runtime.__toESM(postcss_load_config, 1);
|
|
27
31
|
let node_fs = require("node:fs");
|
|
28
32
|
let node_fs_promises = require("node:fs/promises");
|
|
29
33
|
let micromatch = require("micromatch");
|
|
30
34
|
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
31
35
|
let tailwindcss_config = require("tailwindcss-config");
|
|
36
|
+
let node_perf_hooks = require("node:perf_hooks");
|
|
32
37
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
33
38
|
let lru_cache = require("lru-cache");
|
|
34
39
|
let autoprefixer = require("autoprefixer");
|
|
35
40
|
autoprefixer = require_rolldown_runtime.__toESM(autoprefixer, 1);
|
|
36
|
-
let es_toolkit = require("es-toolkit");
|
|
37
41
|
let postcss_pxtrans = require("postcss-pxtrans");
|
|
38
42
|
postcss_pxtrans = require_rolldown_runtime.__toESM(postcss_pxtrans, 1);
|
|
39
43
|
let postcss_rem_to_responsive_pixel = require("postcss-rem-to-responsive-pixel");
|
|
40
44
|
postcss_rem_to_responsive_pixel = require_rolldown_runtime.__toESM(postcss_rem_to_responsive_pixel, 1);
|
|
41
45
|
let postcss_rule_unit_converter = require("postcss-rule-unit-converter");
|
|
42
46
|
postcss_rule_unit_converter = require_rolldown_runtime.__toESM(postcss_rule_unit_converter, 1);
|
|
43
|
-
let postcss_load_config = require("postcss-load-config");
|
|
44
|
-
postcss_load_config = require_rolldown_runtime.__toESM(postcss_load_config, 1);
|
|
45
47
|
//#region src/branches/mini-program/index.ts
|
|
46
48
|
function postprocessMiniProgramCss(result, _options) {
|
|
47
49
|
return result;
|
|
48
50
|
}
|
|
49
51
|
//#endregion
|
|
52
|
+
//#region src/syntax/parse.ts
|
|
53
|
+
/** 解析标准 CSS;调用方负责处理非法输入。 */
|
|
54
|
+
function parseCssSource(source, from) {
|
|
55
|
+
return postcss.default.parse(source, { from });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 解析 SCSS/Sass 风格源码。
|
|
59
|
+
* `postcss.parse` 不读取 syntax 选项,行注释和插值必须走 SCSS parser。
|
|
60
|
+
*/
|
|
61
|
+
function parseScssSource(source, from) {
|
|
62
|
+
return postcss_scss.default.parse(source, { from });
|
|
63
|
+
}
|
|
64
|
+
function stringifyScssSource(root) {
|
|
65
|
+
return root.toString(postcss_scss.default.stringify);
|
|
66
|
+
}
|
|
67
|
+
/** Harmony 在 Sass 预处理前读取局部样式;必须识别行注释,避免将其并入选择器。 */
|
|
68
|
+
function parseUniAppXStyleSource(source) {
|
|
69
|
+
return parseScssSource(source);
|
|
70
|
+
}
|
|
71
|
+
function isUniAppXStyleSourceEmpty(source) {
|
|
72
|
+
try {
|
|
73
|
+
return parseUniAppXStyleSource(source).nodes.every((node) => node.type === "comment");
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
50
79
|
//#region src/compat/uni-app-x.ts
|
|
51
80
|
/** native Sass 可解析、PostCSS 阶段再还原的 important utility 标记。 */
|
|
52
81
|
const UNI_APP_X_IMPORTANT_APPLY_MARKER = "__weapp_tw_important__";
|
|
@@ -61,7 +90,7 @@ const UNI_APP_X_BASE_CARRIER_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
61
90
|
"::backdrop"
|
|
62
91
|
]);
|
|
63
92
|
const REQUIRED_TW_VAR_RE = /var\(\s*(--tw-[\w-]+)\s*\)/g;
|
|
64
|
-
const CLASS_SELECTOR_RE$
|
|
93
|
+
const CLASS_SELECTOR_RE$2 = /\.[\w-]+/;
|
|
65
94
|
const SELECTOR_WHITESPACE_RE = /\s+/g;
|
|
66
95
|
function rewriteImportantApplyUtility(utility, marker) {
|
|
67
96
|
if (utility.startsWith("!") && !utility.startsWith("\\!")) return `${utility.slice(1)}${marker}`;
|
|
@@ -81,7 +110,7 @@ function rewriteApplyParams(params, marker) {
|
|
|
81
110
|
/** 将 Sass 不可直接解析的 important utility 改写成跨预处理器中间形式。 */
|
|
82
111
|
function normalizeUniAppXImportantApplyForSass(css) {
|
|
83
112
|
try {
|
|
84
|
-
const root =
|
|
113
|
+
const root = parseScssSource(css);
|
|
85
114
|
let changed = false;
|
|
86
115
|
root.walkAtRules("apply", (rule) => {
|
|
87
116
|
const params = rewriteApplyParams(rule.params, UNI_APP_X_IMPORTANT_APPLY_MARKER);
|
|
@@ -90,7 +119,7 @@ function normalizeUniAppXImportantApplyForSass(css) {
|
|
|
90
119
|
changed = true;
|
|
91
120
|
}
|
|
92
121
|
});
|
|
93
|
-
return changed ? root
|
|
122
|
+
return changed ? stringifyScssSource(root) : css;
|
|
94
123
|
} catch {
|
|
95
124
|
return css;
|
|
96
125
|
}
|
|
@@ -114,17 +143,17 @@ function restoreUniAppXImportantApplyMarker(css) {
|
|
|
114
143
|
function isUniAppXEnabled(options) {
|
|
115
144
|
return Boolean(options?.uniAppX);
|
|
116
145
|
}
|
|
117
|
-
function normalizeSelector$
|
|
146
|
+
function normalizeSelector$4(selector) {
|
|
118
147
|
return selector.replace(SELECTOR_WHITESPACE_RE, "").toLowerCase();
|
|
119
148
|
}
|
|
120
149
|
function isBaseCarrierSelector(selector) {
|
|
121
|
-
return UNI_APP_X_BASE_CARRIER_SELECTORS.has(normalizeSelector$
|
|
150
|
+
return UNI_APP_X_BASE_CARRIER_SELECTORS.has(normalizeSelector$4(selector));
|
|
122
151
|
}
|
|
123
152
|
function isBaseCarrierRule(rule) {
|
|
124
153
|
return Array.isArray(rule.selectors) && rule.selectors.length > 0 && rule.selectors.every(isBaseCarrierSelector);
|
|
125
154
|
}
|
|
126
|
-
function hasClassSelector$
|
|
127
|
-
return Array.isArray(rule.selectors) && rule.selectors.some((selector) => CLASS_SELECTOR_RE$
|
|
155
|
+
function hasClassSelector$3(rule) {
|
|
156
|
+
return Array.isArray(rule.selectors) && rule.selectors.some((selector) => CLASS_SELECTOR_RE$2.test(selector));
|
|
128
157
|
}
|
|
129
158
|
function collectRequiredTwVars(value) {
|
|
130
159
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -153,7 +182,7 @@ function extractUniAppXBaseDefaults(result) {
|
|
|
153
182
|
function injectUniAppXBaseDefaults(result, defaults) {
|
|
154
183
|
if (defaults.size === 0) return;
|
|
155
184
|
result.root.walkRules((rule) => {
|
|
156
|
-
if (!hasClassSelector$
|
|
185
|
+
if (!hasClassSelector$3(rule)) return;
|
|
157
186
|
const declaredProps = /* @__PURE__ */ new Set();
|
|
158
187
|
const requiredProps = /* @__PURE__ */ new Set();
|
|
159
188
|
rule.walkDecls((decl) => {
|
|
@@ -800,7 +829,7 @@ const MINI_PROGRAM_NATIVE_ELEMENT_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
800
829
|
"audio"
|
|
801
830
|
]);
|
|
802
831
|
const MINI_PROGRAM_PREFLIGHT_SELECTORS$1 = /* @__PURE__ */ new Set(["*", ...MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS]);
|
|
803
|
-
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
|
|
832
|
+
const MINI_PROGRAM_THEME_SCOPE_SELECTORS$1 = /* @__PURE__ */ new Set([
|
|
804
833
|
":host",
|
|
805
834
|
":root",
|
|
806
835
|
"page",
|
|
@@ -883,11 +912,11 @@ const MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
883
912
|
"video"
|
|
884
913
|
]);
|
|
885
914
|
const MINI_PROGRAM_UNSUPPORTED_BROWSER_PREFLIGHT_SELECTOR_PARTS = /* @__PURE__ */ new Set([...MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS, "::file-selector-button"]);
|
|
886
|
-
function normalizeSelector$
|
|
915
|
+
function normalizeSelector$3(selector) {
|
|
887
916
|
return selector.trim().replace(/\s+/g, "");
|
|
888
917
|
}
|
|
889
918
|
function normalizePseudoElementSelector(selector) {
|
|
890
|
-
return normalizeSelector$
|
|
919
|
+
return normalizeSelector$3(selector).replace(/^:(before|after)$/, "::$1");
|
|
891
920
|
}
|
|
892
921
|
function getRuleSelectors(rule) {
|
|
893
922
|
return rule.selector.split(",").map(normalizePseudoElementSelector).filter(Boolean);
|
|
@@ -896,11 +925,11 @@ function getSortedRuleSelectorKey(rule) {
|
|
|
896
925
|
return getRuleSelectors(rule).sort().join(",");
|
|
897
926
|
}
|
|
898
927
|
function isUnsupportedBrowserSelector(selector) {
|
|
899
|
-
const normalized = normalizeSelector$
|
|
928
|
+
const normalized = normalizeSelector$3(selector);
|
|
900
929
|
return MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS.has(normalized) || MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS.has(normalized) && !MINI_PROGRAM_NATIVE_ELEMENT_SELECTORS.has(normalized);
|
|
901
930
|
}
|
|
902
931
|
function isUnsupportedBrowserPreflightSelector(selector) {
|
|
903
|
-
const normalizedParts = selector.split(",").map(normalizeSelector$
|
|
932
|
+
const normalizedParts = selector.split(",").map(normalizeSelector$3).filter(Boolean);
|
|
904
933
|
return normalizedParts.length > 1 && normalizedParts.every((part) => MINI_PROGRAM_UNSUPPORTED_BROWSER_PREFLIGHT_SELECTOR_PARTS.has(part));
|
|
905
934
|
}
|
|
906
935
|
function isMiniProgramNativeElementSelector(selector) {
|
|
@@ -909,8 +938,8 @@ function isMiniProgramNativeElementSelector(selector) {
|
|
|
909
938
|
function isMiniProgramPreflightSelector(selectors) {
|
|
910
939
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS$1.has(selector)) && selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after");
|
|
911
940
|
}
|
|
912
|
-
function isMiniProgramThemeScopeSelector(selectors) {
|
|
913
|
-
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(selector));
|
|
941
|
+
function isMiniProgramThemeScopeSelector$1(selectors) {
|
|
942
|
+
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS$1.has(selector));
|
|
914
943
|
}
|
|
915
944
|
//#endregion
|
|
916
945
|
//#region src/compat/mini-program-css/predicates.ts
|
|
@@ -964,7 +993,7 @@ function isOnlyTwContentDeclarations$1(rule) {
|
|
|
964
993
|
});
|
|
965
994
|
return hasDeclaration && onlyContentVariable;
|
|
966
995
|
}
|
|
967
|
-
function isPseudoContentInitRule(rule) {
|
|
996
|
+
function isPseudoContentInitRule$1(rule) {
|
|
968
997
|
const selector = rule.selector.replace(/\s+/g, "");
|
|
969
998
|
return PSEUDO_CONTENT_SELECTOR_RE.test(selector) && isOnlyTwContentDeclarations$1(rule);
|
|
970
999
|
}
|
|
@@ -1001,7 +1030,7 @@ function isBrowserElementPreflightRule(node) {
|
|
|
1001
1030
|
}
|
|
1002
1031
|
function isMiniProgramThemeVariableRule(node) {
|
|
1003
1032
|
if (node.type !== "rule") return false;
|
|
1004
|
-
return isMiniProgramThemeScopeSelector(getRuleSelectors(node)) && isCustomPropertyRule(node);
|
|
1033
|
+
return isMiniProgramThemeScopeSelector$1(getRuleSelectors(node)) && isCustomPropertyRule(node);
|
|
1005
1034
|
}
|
|
1006
1035
|
//#endregion
|
|
1007
1036
|
//#region src/compat/mini-program-css/root-cleanups.ts
|
|
@@ -1033,7 +1062,7 @@ function removeRootSpecificityPlaceholders(root) {
|
|
|
1033
1062
|
let changed = false;
|
|
1034
1063
|
const selectors = rule.selectors.map((selector) => {
|
|
1035
1064
|
let next = selector;
|
|
1036
|
-
for (const scopeSelector of MINI_PROGRAM_THEME_SCOPE_SELECTORS) for (const suffix of ROOT_SPECIFICITY_PLACEHOLDER_SUFFIXES) {
|
|
1065
|
+
for (const scopeSelector of MINI_PROGRAM_THEME_SCOPE_SELECTORS$1) for (const suffix of ROOT_SPECIFICITY_PLACEHOLDER_SUFFIXES) {
|
|
1037
1066
|
const target = `${scopeSelector}${suffix}`;
|
|
1038
1067
|
if (next.includes(target)) next = next.split(target).join(scopeSelector);
|
|
1039
1068
|
}
|
|
@@ -1611,6 +1640,151 @@ function isTailwindcssV4DisplayP3Declaration(decl) {
|
|
|
1611
1640
|
return DISPLAY_P3_VALUE_RE$1.test(decl.value);
|
|
1612
1641
|
}
|
|
1613
1642
|
//#endregion
|
|
1643
|
+
//#region src/syntax/css-import.ts
|
|
1644
|
+
function significantTokens(params) {
|
|
1645
|
+
return (0, _csstools_css_tokenizer.tokenize)({ css: params }).filter((token) => token[0] !== _csstools_css_tokenizer.TokenType.Whitespace && token[0] !== _csstools_css_tokenizer.TokenType.Comment);
|
|
1646
|
+
}
|
|
1647
|
+
function isCssWhitespace$2(char) {
|
|
1648
|
+
return char === " " || char === " " || char === "\n" || char === "\r" || char === "\f";
|
|
1649
|
+
}
|
|
1650
|
+
function skipCssWhitespace$1(params, index) {
|
|
1651
|
+
while (index < params.length && isCssWhitespace$2(params[index])) index++;
|
|
1652
|
+
return index;
|
|
1653
|
+
}
|
|
1654
|
+
function parseSimpleQuotedSpecifier(params, start) {
|
|
1655
|
+
const quote = params[start];
|
|
1656
|
+
if (quote !== "\"" && quote !== "'") return;
|
|
1657
|
+
let index = start + 1;
|
|
1658
|
+
while (index < params.length) {
|
|
1659
|
+
const char = params[index];
|
|
1660
|
+
if (char === "\\" || char === "\n" || char === "\r") return;
|
|
1661
|
+
if (char === quote) return {
|
|
1662
|
+
specifier: params.slice(start + 1, index),
|
|
1663
|
+
raw: params.slice(start, index + 1),
|
|
1664
|
+
quote
|
|
1665
|
+
};
|
|
1666
|
+
index++;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
function parseSimpleImportSpecifier(params) {
|
|
1670
|
+
let index = skipCssWhitespace$1(params, 0);
|
|
1671
|
+
const quoted = parseSimpleQuotedSpecifier(params, index);
|
|
1672
|
+
if (quoted) return quoted;
|
|
1673
|
+
if (params.slice(index, index + 4).toLowerCase() !== "url(") return;
|
|
1674
|
+
const urlStart = index;
|
|
1675
|
+
index = skipCssWhitespace$1(params, index + 4);
|
|
1676
|
+
const inner = parseSimpleQuotedSpecifier(params, index);
|
|
1677
|
+
if (!inner) return;
|
|
1678
|
+
index = skipCssWhitespace$1(params, index + inner.raw.length);
|
|
1679
|
+
if (params[index] !== ")") return;
|
|
1680
|
+
return {
|
|
1681
|
+
specifier: inner.specifier,
|
|
1682
|
+
raw: params.slice(urlStart, index + 1),
|
|
1683
|
+
quote: inner.quote
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* 解析 `@import` / `@use` / `@forward` 参数中的请求串。
|
|
1688
|
+
* 无 escape/注释的引号和 `url("...")` 走快路径;复杂输入才使用 CSS tokenizer。
|
|
1689
|
+
*/
|
|
1690
|
+
function parseCssImportSpecifier(params) {
|
|
1691
|
+
const simple = parseSimpleImportSpecifier(params);
|
|
1692
|
+
if (simple) return simple;
|
|
1693
|
+
const tokens = significantTokens(params);
|
|
1694
|
+
const first = tokens[0];
|
|
1695
|
+
if (!first || first[0] === _csstools_css_tokenizer.TokenType.EOF) return;
|
|
1696
|
+
if (first[0] === _csstools_css_tokenizer.TokenType.String || first[0] === _csstools_css_tokenizer.TokenType.URL || first[0] === _csstools_css_tokenizer.TokenType.Ident) return {
|
|
1697
|
+
specifier: first[4].value,
|
|
1698
|
+
raw: first[1],
|
|
1699
|
+
quote: first[0] === _csstools_css_tokenizer.TokenType.String ? first[1][0] : void 0
|
|
1700
|
+
};
|
|
1701
|
+
if (first[0] === _csstools_css_tokenizer.TokenType.Function && first[4].value.toLowerCase() === "url" && (tokens[1]?.[0] === _csstools_css_tokenizer.TokenType.String || tokens[1]?.[0] === _csstools_css_tokenizer.TokenType.Ident) && tokens[2]?.[0] === _csstools_css_tokenizer.TokenType.CloseParen) return {
|
|
1702
|
+
specifier: tokens[1][4].value,
|
|
1703
|
+
raw: params.slice(first[2], tokens[2][3] + 1),
|
|
1704
|
+
quote: tokens[1][0] === _csstools_css_tokenizer.TokenType.String ? tokens[1][1][0] : void 0
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
/** 把文件系统路径写成 CSS 请求串;缓存和读文件仍使用原始路径。 */
|
|
1708
|
+
function quoteCssImportSpecifier(file, quote = "\"") {
|
|
1709
|
+
return `${quote}${(node_path.default.sep === "\\" || /^[a-z]:[\\/]|^\\\\/i.test(file) ? file.replaceAll("\\", "/") : file).replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`).replaceAll("\n", "\\a ").replaceAll("\r", "\\d ")}${quote}`;
|
|
1710
|
+
}
|
|
1711
|
+
/** 判断 import 参数是否指向 Tailwind CSS 包入口。 */
|
|
1712
|
+
function isTailwindCssImport(params) {
|
|
1713
|
+
const specifier = parseCssImportSpecifier(params)?.specifier;
|
|
1714
|
+
if (!specifier) return false;
|
|
1715
|
+
if (specifier === "tailwindcss" || specifier.startsWith("tailwindcss/")) return true;
|
|
1716
|
+
const paths = specifier.includes("\\") ? node_path.default.win32 : node_path.default.posix;
|
|
1717
|
+
return paths.basename(specifier) === "index.css" && paths.basename(paths.dirname(specifier)) === "tailwindcss";
|
|
1718
|
+
}
|
|
1719
|
+
/** 解析 `@import "..." source(...)` 中的 source 参数。 */
|
|
1720
|
+
function parseImportSourceParam(params) {
|
|
1721
|
+
const tokens = significantTokens(params);
|
|
1722
|
+
const index = tokens.findIndex((token) => token[0] === _csstools_css_tokenizer.TokenType.Function && token[4].value === "source");
|
|
1723
|
+
const value = tokens[index + 1];
|
|
1724
|
+
if (index < 0 || tokens[index + 2]?.[0] !== _csstools_css_tokenizer.TokenType.CloseParen) return;
|
|
1725
|
+
if (value?.[0] === _csstools_css_tokenizer.TokenType.Ident && value[4].value === "none") return {
|
|
1726
|
+
none: true,
|
|
1727
|
+
sourcePath: void 0
|
|
1728
|
+
};
|
|
1729
|
+
return value?.[0] === _csstools_css_tokenizer.TokenType.String ? {
|
|
1730
|
+
none: false,
|
|
1731
|
+
sourcePath: value[4].value
|
|
1732
|
+
} : void 0;
|
|
1733
|
+
}
|
|
1734
|
+
//#endregion
|
|
1735
|
+
//#region src/compat/tailwindcss-v4/theme-source.ts
|
|
1736
|
+
function isTailwindCssPreflightImport(params) {
|
|
1737
|
+
const specifier = parseCssImportSpecifier(params)?.specifier;
|
|
1738
|
+
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1739
|
+
}
|
|
1740
|
+
/** 从小程序入口 CSS 中移除 Tailwind v4 preflight import。 */
|
|
1741
|
+
function removeTailwindV4PreflightImports(css) {
|
|
1742
|
+
if (!css.includes("preflight")) return css;
|
|
1743
|
+
let root;
|
|
1744
|
+
try {
|
|
1745
|
+
root = postcss.default.parse(css);
|
|
1746
|
+
} catch {
|
|
1747
|
+
return css;
|
|
1748
|
+
}
|
|
1749
|
+
let changed = false;
|
|
1750
|
+
root.walkAtRules("import", (rule) => {
|
|
1751
|
+
if (isTailwindCssPreflightImport(rule.params)) {
|
|
1752
|
+
rule.remove();
|
|
1753
|
+
changed = true;
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1756
|
+
return changed ? root.toString() : css;
|
|
1757
|
+
}
|
|
1758
|
+
function hasThemeParent(rule) {
|
|
1759
|
+
let parent = rule.parent;
|
|
1760
|
+
while (parent) {
|
|
1761
|
+
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
1762
|
+
parent = parent.parent;
|
|
1763
|
+
}
|
|
1764
|
+
return false;
|
|
1765
|
+
}
|
|
1766
|
+
function isVendorPrefixedKeyframes(rule) {
|
|
1767
|
+
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
1768
|
+
}
|
|
1769
|
+
/** 删除 `@theme` 内不被小程序接受的厂商前缀 keyframes。 */
|
|
1770
|
+
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
1771
|
+
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1772
|
+
let root;
|
|
1773
|
+
try {
|
|
1774
|
+
root = postcss.default.parse(css);
|
|
1775
|
+
} catch {
|
|
1776
|
+
return css;
|
|
1777
|
+
}
|
|
1778
|
+
let changed = false;
|
|
1779
|
+
root.walkAtRules((rule) => {
|
|
1780
|
+
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
1781
|
+
rule.remove();
|
|
1782
|
+
changed = true;
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
return changed ? root.toString() : css;
|
|
1786
|
+
}
|
|
1787
|
+
//#endregion
|
|
1614
1788
|
//#region src/compat/uni-app-x-uvue/scoped-style.ts
|
|
1615
1789
|
const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
1616
1790
|
"view",
|
|
@@ -1814,7 +1988,7 @@ const SYSTEM_ROOT_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
1814
1988
|
"uni-page-body",
|
|
1815
1989
|
"wx-root-portal-content"
|
|
1816
1990
|
]);
|
|
1817
|
-
function normalizeSelector$
|
|
1991
|
+
function normalizeSelector$2(selector) {
|
|
1818
1992
|
return selector.replace(/\s+/g, "").toLowerCase();
|
|
1819
1993
|
}
|
|
1820
1994
|
function isUniAppXSystemRootCarrierRule(rule) {
|
|
@@ -1822,7 +1996,7 @@ function isUniAppXSystemRootCarrierRule(rule) {
|
|
|
1822
1996
|
if (selectors.length === 0) return false;
|
|
1823
1997
|
let hasRootMarker = false;
|
|
1824
1998
|
for (const selector of selectors) {
|
|
1825
|
-
const normalized = normalizeSelector$
|
|
1999
|
+
const normalized = normalizeSelector$2(selector);
|
|
1826
2000
|
if (!SYSTEM_ROOT_SELECTORS.has(normalized)) return false;
|
|
1827
2001
|
if (normalized === ":host" || normalized === ":root" || normalized === ".tw-root") hasRootMarker = true;
|
|
1828
2002
|
}
|
|
@@ -1928,7 +2102,7 @@ function isUniAppXUvueTarget(options) {
|
|
|
1928
2102
|
function normalizeUnsupportedMode(mode) {
|
|
1929
2103
|
return mode ?? "warn";
|
|
1930
2104
|
}
|
|
1931
|
-
function normalizeValue(value) {
|
|
2105
|
+
function normalizeValue$1(value) {
|
|
1932
2106
|
return value.trim().toLowerCase().replace(IMPORTANT_SUFFIX_RE, "");
|
|
1933
2107
|
}
|
|
1934
2108
|
function hasCalcFunction(value) {
|
|
@@ -1982,7 +2156,7 @@ function hasOnlyClassSelectors(rule) {
|
|
|
1982
2156
|
}
|
|
1983
2157
|
function getUnsupportedDeclarationReason(prop, value) {
|
|
1984
2158
|
const normalizedProp = prop.trim().toLowerCase();
|
|
1985
|
-
const normalizedValue = normalizeValue(value);
|
|
2159
|
+
const normalizedValue = normalizeValue$1(value);
|
|
1986
2160
|
if (hasCalcFunction(value)) return `${normalizedProp}: ${value}`;
|
|
1987
2161
|
if (normalizedProp === "display" && !ALLOWED_DISPLAY_VALUES.has(normalizedValue)) return `${normalizedProp}: ${value}`;
|
|
1988
2162
|
if (normalizedProp === "min-height" && normalizedValue === "100vh") return `${normalizedProp}: ${value}`;
|
|
@@ -2184,6 +2358,395 @@ function resolvePostcssStyleBranchProfile(options) {
|
|
|
2184
2358
|
return resolvePostcssFrameworkProfile(options);
|
|
2185
2359
|
}
|
|
2186
2360
|
//#endregion
|
|
2361
|
+
//#region src/compat/author-selector.ts
|
|
2362
|
+
/** 保留作者选择器在变体展开后增加前缀、伪类或主题条件的规则。 */
|
|
2363
|
+
function createAuthorSelectorMatcher(selectors) {
|
|
2364
|
+
const exact = /* @__PURE__ */ new Set();
|
|
2365
|
+
const compounds = [];
|
|
2366
|
+
for (const selector of selectors) {
|
|
2367
|
+
exact.add(selector.trim());
|
|
2368
|
+
(0, postcss_selector_parser.default)().astSync(selector).each((entry) => {
|
|
2369
|
+
if (!entry.nodes.some((node) => node.type === "combinator") && entry.nodes.some((node) => node.type === "class" || node.type === "id")) compounds.push(entry.nodes.map((node) => node.toString().trim()));
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
return (selector) => {
|
|
2373
|
+
if (exact.has(selector.trim())) return true;
|
|
2374
|
+
const entries = (0, postcss_selector_parser.default)().astSync(selector).nodes;
|
|
2375
|
+
return entries.length > 0 && entries.every((entry) => {
|
|
2376
|
+
const lastCombinator = entry.nodes.findLastIndex((node) => node.type === "combinator");
|
|
2377
|
+
const subject = new Set(entry.nodes.slice(lastCombinator + 1).map((node) => node.toString().trim()));
|
|
2378
|
+
return compounds.some((nodes) => nodes.every((node) => subject.has(node)));
|
|
2379
|
+
});
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
//#endregion
|
|
2383
|
+
//#region src/compat/legacy-css/apply.ts
|
|
2384
|
+
/** 删除兼容源中的 `@apply` 规则及其空包装 at-rule。 */
|
|
2385
|
+
function removeTailwindApplyRules(rawSource) {
|
|
2386
|
+
try {
|
|
2387
|
+
const root = postcss.default.parse(rawSource);
|
|
2388
|
+
let removed = false;
|
|
2389
|
+
root.walkAtRules("apply", (rule) => {
|
|
2390
|
+
const parent = rule.parent;
|
|
2391
|
+
if (parent?.type === "rule") parent.remove();
|
|
2392
|
+
else rule.remove();
|
|
2393
|
+
removed = true;
|
|
2394
|
+
});
|
|
2395
|
+
root.walkAtRules((rule) => {
|
|
2396
|
+
if (rule.nodes && rule.nodes.length === 0) rule.remove();
|
|
2397
|
+
});
|
|
2398
|
+
return removed ? root.toString() : rawSource;
|
|
2399
|
+
} catch {
|
|
2400
|
+
return rawSource;
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
//#endregion
|
|
2404
|
+
//#region src/compat/legacy-css/selectors.ts
|
|
2405
|
+
const CLASS_SELECTOR_RE$1 = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
2406
|
+
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
|
|
2407
|
+
":host",
|
|
2408
|
+
"page",
|
|
2409
|
+
".tw-root",
|
|
2410
|
+
"wx-root-portal-content"
|
|
2411
|
+
]);
|
|
2412
|
+
const SPECIFICITY_PLACEHOLDER_RE = /:not\(#(?:\\#|n)\)/g;
|
|
2413
|
+
const SELECTOR_CACHE_LIMIT = 64;
|
|
2414
|
+
const LEGACY_PSEUDO_ELEMENTS = [
|
|
2415
|
+
"before",
|
|
2416
|
+
"after",
|
|
2417
|
+
"first-letter",
|
|
2418
|
+
"first-line"
|
|
2419
|
+
];
|
|
2420
|
+
const generatedSelectorCache = /* @__PURE__ */ new Map();
|
|
2421
|
+
function setGeneratedSelectorCache(css, selectors) {
|
|
2422
|
+
if (generatedSelectorCache.size >= SELECTOR_CACHE_LIMIT) {
|
|
2423
|
+
const firstKey = generatedSelectorCache.keys().next().value;
|
|
2424
|
+
if (firstKey !== void 0) generatedSelectorCache.delete(firstKey);
|
|
2425
|
+
}
|
|
2426
|
+
generatedSelectorCache.set(css, selectors);
|
|
2427
|
+
}
|
|
2428
|
+
function normalizeCompatSelector(selector) {
|
|
2429
|
+
return selector.replace(SPECIFICITY_PLACEHOLDER_RE, "").replace(/\s+/g, " ").trim();
|
|
2430
|
+
}
|
|
2431
|
+
function isLegacyPseudoElementAt(selector, index) {
|
|
2432
|
+
for (const name of LEGACY_PSEUDO_ELEMENTS) {
|
|
2433
|
+
if (!selector.startsWith(name, index)) continue;
|
|
2434
|
+
const next = selector[index + name.length];
|
|
2435
|
+
if (next === void 0 || !/[\w-]/.test(next)) return name;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
function normalizeLegacyPseudoElements(selector) {
|
|
2439
|
+
let result = "";
|
|
2440
|
+
let quote;
|
|
2441
|
+
let bracketDepth = 0;
|
|
2442
|
+
let index = 0;
|
|
2443
|
+
while (index < selector.length) {
|
|
2444
|
+
const char = selector[index];
|
|
2445
|
+
if (char === "\\") {
|
|
2446
|
+
result += selector.slice(index, index + 2);
|
|
2447
|
+
index += 2;
|
|
2448
|
+
continue;
|
|
2449
|
+
}
|
|
2450
|
+
if (quote !== void 0) {
|
|
2451
|
+
result += char;
|
|
2452
|
+
if (char === quote) quote = void 0;
|
|
2453
|
+
index += 1;
|
|
2454
|
+
continue;
|
|
2455
|
+
}
|
|
2456
|
+
if (char === "\"" || char === "'") {
|
|
2457
|
+
quote = char;
|
|
2458
|
+
result += char;
|
|
2459
|
+
index += 1;
|
|
2460
|
+
continue;
|
|
2461
|
+
}
|
|
2462
|
+
if (char === "[") {
|
|
2463
|
+
bracketDepth++;
|
|
2464
|
+
result += char;
|
|
2465
|
+
index += 1;
|
|
2466
|
+
continue;
|
|
2467
|
+
}
|
|
2468
|
+
if (char === "]") {
|
|
2469
|
+
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
2470
|
+
result += char;
|
|
2471
|
+
index += 1;
|
|
2472
|
+
continue;
|
|
2473
|
+
}
|
|
2474
|
+
if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
|
|
2475
|
+
result += "::";
|
|
2476
|
+
index += 2;
|
|
2477
|
+
continue;
|
|
2478
|
+
}
|
|
2479
|
+
if (bracketDepth === 0 && char === ":") {
|
|
2480
|
+
const name = isLegacyPseudoElementAt(selector, index + 1);
|
|
2481
|
+
if (name) {
|
|
2482
|
+
result += `::${name}`;
|
|
2483
|
+
index += name.length + 1;
|
|
2484
|
+
continue;
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
result += char;
|
|
2488
|
+
index += 1;
|
|
2489
|
+
}
|
|
2490
|
+
return result;
|
|
2491
|
+
}
|
|
2492
|
+
function isClassSelectorTerminator(char) {
|
|
2493
|
+
return /[\s>+~#,.:()[\]]/.test(char);
|
|
2494
|
+
}
|
|
2495
|
+
function unescapeSimpleCssIdent(value) {
|
|
2496
|
+
return value.replaceAll(/\\(.)/g, "$1");
|
|
2497
|
+
}
|
|
2498
|
+
function escapeCompatSelectorClasses(selector) {
|
|
2499
|
+
let result = "";
|
|
2500
|
+
let index = 0;
|
|
2501
|
+
let changed = false;
|
|
2502
|
+
while (index < selector.length) {
|
|
2503
|
+
const char = selector[index];
|
|
2504
|
+
if (char !== ".") {
|
|
2505
|
+
result += char;
|
|
2506
|
+
index += 1;
|
|
2507
|
+
continue;
|
|
2508
|
+
}
|
|
2509
|
+
let end = index + 1;
|
|
2510
|
+
let className = "";
|
|
2511
|
+
while (end < selector.length) {
|
|
2512
|
+
const current = selector[end];
|
|
2513
|
+
if (current === void 0) break;
|
|
2514
|
+
if (current === "\\" && end + 1 < selector.length) {
|
|
2515
|
+
const escaped = selector[end + 1];
|
|
2516
|
+
if (escaped === void 0) break;
|
|
2517
|
+
className += current + escaped;
|
|
2518
|
+
end += 2;
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
if (isClassSelectorTerminator(current)) break;
|
|
2522
|
+
className += current;
|
|
2523
|
+
end += 1;
|
|
2524
|
+
}
|
|
2525
|
+
if (className.includes("\\")) {
|
|
2526
|
+
result += `.${(0, _weapp_core_escape.escape)(unescapeSimpleCssIdent(className))}`;
|
|
2527
|
+
changed = true;
|
|
2528
|
+
} else result += `.${className}`;
|
|
2529
|
+
index = end;
|
|
2530
|
+
}
|
|
2531
|
+
return changed ? result : selector;
|
|
2532
|
+
}
|
|
2533
|
+
function normalizeCompatSelectors(selector) {
|
|
2534
|
+
const normalized = normalizeCompatSelector(selector);
|
|
2535
|
+
if (!normalized) return [];
|
|
2536
|
+
const selectors = /* @__PURE__ */ new Set([normalized]);
|
|
2537
|
+
const escaped = normalizeCompatSelector(escapeCompatSelectorClasses(normalized));
|
|
2538
|
+
if (escaped) selectors.add(escaped);
|
|
2539
|
+
return [...selectors];
|
|
2540
|
+
}
|
|
2541
|
+
function normalizeCssSelector(selector) {
|
|
2542
|
+
return normalizeLegacyPseudoElements(selector).trim().replace(/\s+/g, "");
|
|
2543
|
+
}
|
|
2544
|
+
function getCompatSelectorKeys(selector) {
|
|
2545
|
+
return normalizeCompatSelectors(selector).map(normalizeCssSelector);
|
|
2546
|
+
}
|
|
2547
|
+
function getRuleCompatSelectorKeys(rule) {
|
|
2548
|
+
return (rule.selectors?.length ? rule.selectors : [rule.selector]).flatMap((selector) => getCompatSelectorKeys(selector));
|
|
2549
|
+
}
|
|
2550
|
+
function hasClassSelector$2(selector) {
|
|
2551
|
+
return CLASS_SELECTOR_RE$1.test(selector);
|
|
2552
|
+
}
|
|
2553
|
+
function getNormalizedSelectorList(selector) {
|
|
2554
|
+
return selector.split(",").map(normalizeCssSelector).filter(Boolean);
|
|
2555
|
+
}
|
|
2556
|
+
function isMiniProgramThemeScopeSelector(selector) {
|
|
2557
|
+
const selectors = getNormalizedSelectorList(selector);
|
|
2558
|
+
return selectors.length > 0 && selectors.every((item) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(item));
|
|
2559
|
+
}
|
|
2560
|
+
function hasUtilityClassSelector(selector) {
|
|
2561
|
+
return hasClassSelector$2(selector) && !isMiniProgramThemeScopeSelector(selector);
|
|
2562
|
+
}
|
|
2563
|
+
function isCustomPropertyOnlyRule(rule) {
|
|
2564
|
+
let hasDeclaration = false;
|
|
2565
|
+
let allCustomProperties = true;
|
|
2566
|
+
rule.each((node) => {
|
|
2567
|
+
if (node.type !== "decl") return;
|
|
2568
|
+
hasDeclaration = true;
|
|
2569
|
+
if (!node.prop.startsWith("--")) allCustomProperties = false;
|
|
2570
|
+
});
|
|
2571
|
+
return hasDeclaration && allCustomProperties;
|
|
2572
|
+
}
|
|
2573
|
+
function isPseudoContentInitRule(rule) {
|
|
2574
|
+
let hasDeclaration = false;
|
|
2575
|
+
let onlyContentVariable = true;
|
|
2576
|
+
rule.each((node) => {
|
|
2577
|
+
if (node.type !== "decl") return;
|
|
2578
|
+
hasDeclaration = true;
|
|
2579
|
+
if (node.prop !== "--tw-content") onlyContentVariable = false;
|
|
2580
|
+
});
|
|
2581
|
+
return hasDeclaration && onlyContentVariable;
|
|
2582
|
+
}
|
|
2583
|
+
function collectGeneratedSelectors(css) {
|
|
2584
|
+
const cached = generatedSelectorCache.get(css);
|
|
2585
|
+
if (cached) return cached;
|
|
2586
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
2587
|
+
try {
|
|
2588
|
+
postcss.default.parse(css).walkRules((rule) => {
|
|
2589
|
+
if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
|
|
2590
|
+
for (const selector of getRuleCompatSelectorKeys(rule)) selectors.add(selector);
|
|
2591
|
+
});
|
|
2592
|
+
} catch {
|
|
2593
|
+
return selectors;
|
|
2594
|
+
}
|
|
2595
|
+
setGeneratedSelectorCache(css, selectors);
|
|
2596
|
+
return selectors;
|
|
2597
|
+
}
|
|
2598
|
+
//#endregion
|
|
2599
|
+
//#region src/compat/legacy-css/dedupe.ts
|
|
2600
|
+
function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
|
|
2601
|
+
const propsBySelector = /* @__PURE__ */ new Map();
|
|
2602
|
+
try {
|
|
2603
|
+
postcss.default.parse(generatedCss).walkRules((rule) => {
|
|
2604
|
+
const matchedSelectors = getRuleCompatSelectorKeys(rule).filter((selector) => selectors.has(selector));
|
|
2605
|
+
if (matchedSelectors.length === 0) return;
|
|
2606
|
+
const props = /* @__PURE__ */ new Set();
|
|
2607
|
+
rule.walkDecls((decl) => {
|
|
2608
|
+
props.add(decl.prop);
|
|
2609
|
+
});
|
|
2610
|
+
for (const selector of matchedSelectors) {
|
|
2611
|
+
const existing = propsBySelector.get(selector);
|
|
2612
|
+
if (existing) for (const prop of props) existing.add(prop);
|
|
2613
|
+
else propsBySelector.set(selector, new Set(props));
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2616
|
+
} catch {
|
|
2617
|
+
return propsBySelector;
|
|
2618
|
+
}
|
|
2619
|
+
return propsBySelector;
|
|
2620
|
+
}
|
|
2621
|
+
function isRuleCoveredByGeneratedProps(rule, generatedDeclarationPropsBySelector) {
|
|
2622
|
+
const nodeSelectors = getRuleCompatSelectorKeys(rule);
|
|
2623
|
+
if (nodeSelectors.length === 0) return false;
|
|
2624
|
+
const props = /* @__PURE__ */ new Set();
|
|
2625
|
+
rule.walkDecls((decl) => {
|
|
2626
|
+
props.add(decl.prop);
|
|
2627
|
+
});
|
|
2628
|
+
if (props.size === 0) return false;
|
|
2629
|
+
for (const selector of nodeSelectors) {
|
|
2630
|
+
const generatedProps = generatedDeclarationPropsBySelector.get(selector);
|
|
2631
|
+
if (!generatedProps) continue;
|
|
2632
|
+
if ([...props].every((prop) => generatedProps.has(prop))) return true;
|
|
2633
|
+
}
|
|
2634
|
+
return false;
|
|
2635
|
+
}
|
|
2636
|
+
function removeGeneratedSelectorCompatCss(css, generatedCss) {
|
|
2637
|
+
const generatedSelectors = collectGeneratedSelectors(generatedCss);
|
|
2638
|
+
if (generatedSelectors.size === 0) return css;
|
|
2639
|
+
try {
|
|
2640
|
+
const root = postcss.default.parse(css);
|
|
2641
|
+
let removed = false;
|
|
2642
|
+
root.walkRules((rule) => {
|
|
2643
|
+
if (isPseudoContentInitRule(rule)) {
|
|
2644
|
+
rule.remove();
|
|
2645
|
+
removed = true;
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2648
|
+
if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
|
|
2649
|
+
if (getRuleCompatSelectorKeys(rule).some((selector) => generatedSelectors.has(selector))) {
|
|
2650
|
+
rule.remove();
|
|
2651
|
+
removed = true;
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
root.walkAtRules((atRule) => {
|
|
2655
|
+
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
2656
|
+
});
|
|
2657
|
+
return removed ? root.toString() : css;
|
|
2658
|
+
} catch {
|
|
2659
|
+
return css;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
function collectDedupedPostTransformCompatCss(css, generatedCss) {
|
|
2663
|
+
const generatedSelectors = collectGeneratedSelectors(generatedCss);
|
|
2664
|
+
if (generatedSelectors.size === 0) return css;
|
|
2665
|
+
const generatedDeclarationPropsBySelector = collectGeneratedDeclarationPropsBySelector(generatedCss, generatedSelectors);
|
|
2666
|
+
const preservedNodes = [];
|
|
2667
|
+
try {
|
|
2668
|
+
const root = postcss.default.parse(css);
|
|
2669
|
+
root.each((node) => {
|
|
2670
|
+
if (node.type === "rule") {
|
|
2671
|
+
const nodeSelectors = getRuleCompatSelectorKeys(node);
|
|
2672
|
+
if (!nodeSelectors.some((selector) => generatedSelectors.has(selector))) {
|
|
2673
|
+
preservedNodes.push(node.clone());
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
if (isRuleCoveredByGeneratedProps(node, generatedDeclarationPropsBySelector)) return;
|
|
2677
|
+
if (isCustomPropertyOnlyRule(node) && !isPseudoContentInitRule(node) && !hasUtilityClassSelector(node.selector)) {
|
|
2678
|
+
const declarationProps = /* @__PURE__ */ new Set();
|
|
2679
|
+
node.walkDecls((decl) => {
|
|
2680
|
+
declarationProps.add(decl.prop);
|
|
2681
|
+
});
|
|
2682
|
+
for (const selector of nodeSelectors) {
|
|
2683
|
+
const generatedProps = generatedDeclarationPropsBySelector.get(selector);
|
|
2684
|
+
if (!generatedProps) continue;
|
|
2685
|
+
for (const prop of generatedProps) declarationProps.delete(prop);
|
|
2686
|
+
}
|
|
2687
|
+
const nextRule = node.clone();
|
|
2688
|
+
nextRule.walkDecls((decl) => {
|
|
2689
|
+
if (!declarationProps.has(decl.prop)) decl.remove();
|
|
2690
|
+
});
|
|
2691
|
+
if (nextRule.nodes.length > 0) preservedNodes.push(nextRule);
|
|
2692
|
+
}
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
preservedNodes.push(node.clone());
|
|
2696
|
+
});
|
|
2697
|
+
if (preservedNodes.length === root.nodes.length) return css;
|
|
2698
|
+
const nextRoot = postcss.default.root();
|
|
2699
|
+
nextRoot.append(preservedNodes);
|
|
2700
|
+
return nextRoot.toString();
|
|
2701
|
+
} catch {
|
|
2702
|
+
return css;
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
//#endregion
|
|
2706
|
+
//#region src/compat/legacy-css/units.ts
|
|
2707
|
+
const CSS_LENGTH_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)(?:px|rem)\b/i;
|
|
2708
|
+
const RPX_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)rpx\b/i;
|
|
2709
|
+
function createLegacyDeclarationValueMap(css) {
|
|
2710
|
+
const values = /* @__PURE__ */ new Map();
|
|
2711
|
+
postcss.default.parse(css).walkRules((rule) => {
|
|
2712
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
2713
|
+
for (const selector of rule.selectors) {
|
|
2714
|
+
const normalizedSelectors = normalizeCompatSelectors(selector);
|
|
2715
|
+
rule.walkDecls((decl) => {
|
|
2716
|
+
if (RPX_UNIT_RE.test(decl.value)) for (const normalizedSelector of normalizedSelectors) values.set(`${normalizedSelector}\n${decl.prop}`, decl.value);
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
return values;
|
|
2721
|
+
}
|
|
2722
|
+
function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
2723
|
+
try {
|
|
2724
|
+
const legacyValues = createLegacyDeclarationValueMap(legacyCss);
|
|
2725
|
+
if (legacyValues.size === 0) return css;
|
|
2726
|
+
const root = postcss.default.parse(css);
|
|
2727
|
+
let changed = false;
|
|
2728
|
+
root.walkRules((rule) => {
|
|
2729
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
2730
|
+
const selectors = rule.selectors.flatMap((selector) => normalizeCompatSelectors(selector));
|
|
2731
|
+
if (selectors.length === 0) return;
|
|
2732
|
+
rule.walkDecls((decl) => {
|
|
2733
|
+
if (!CSS_LENGTH_UNIT_RE.test(decl.value)) return;
|
|
2734
|
+
for (const selector of selectors) {
|
|
2735
|
+
const legacyValue = legacyValues.get(`${selector}\n${decl.prop}`);
|
|
2736
|
+
if (legacyValue && legacyValue !== decl.value) {
|
|
2737
|
+
decl.value = legacyValue;
|
|
2738
|
+
changed = true;
|
|
2739
|
+
return;
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
});
|
|
2744
|
+
return changed ? root.toString() : css;
|
|
2745
|
+
} catch {
|
|
2746
|
+
return css;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
//#endregion
|
|
2187
2750
|
//#region src/compat/lynx-css.ts
|
|
2188
2751
|
const tailwindThemePropertyPatterns = [
|
|
2189
2752
|
/^--aspect-/,
|
|
@@ -2495,15 +3058,33 @@ function unwrapUnsupportedCascadeLayers(css) {
|
|
|
2495
3058
|
}
|
|
2496
3059
|
}
|
|
2497
3060
|
//#endregion
|
|
3061
|
+
//#region src/compat/mini-program-css/content-init.ts
|
|
3062
|
+
/** 移除候选裁剪后失去消费者的全局 content 初始化,保留用户类规则。 */
|
|
3063
|
+
function removeUnusedMiniProgramContentInit(root) {
|
|
3064
|
+
if (usesTwContentVariable(root)) return false;
|
|
3065
|
+
let changed = false;
|
|
3066
|
+
root.walkRules((rule) => {
|
|
3067
|
+
if (!isMiniProgramPreflightRule(rule) && !isPseudoContentInitRule$1(rule)) return;
|
|
3068
|
+
rule.walkDecls((decl) => {
|
|
3069
|
+
if (isEmptyTwContentDeclaration(decl)) {
|
|
3070
|
+
decl.remove();
|
|
3071
|
+
changed = true;
|
|
3072
|
+
}
|
|
3073
|
+
});
|
|
3074
|
+
if (rule.nodes.length === 0) rule.remove();
|
|
3075
|
+
});
|
|
3076
|
+
return changed;
|
|
3077
|
+
}
|
|
3078
|
+
//#endregion
|
|
2498
3079
|
//#region src/compat/mini-program-css/directives.ts
|
|
2499
3080
|
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
2500
3081
|
const GENERATOR_PLACEHOLDER_COMMENT_RE = /^\s*(?:!\s*)?weapp-tailwindcss generator-placeholder\s*$/i;
|
|
2501
|
-
function isCssWhitespace(code) {
|
|
3082
|
+
function isCssWhitespace$1(code) {
|
|
2502
3083
|
return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
|
|
2503
3084
|
}
|
|
2504
3085
|
function skipCssWhitespace(css, start) {
|
|
2505
3086
|
let index = start;
|
|
2506
|
-
while (index < css.length && isCssWhitespace(css.charCodeAt(index))) index++;
|
|
3087
|
+
while (index < css.length && isCssWhitespace$1(css.charCodeAt(index))) index++;
|
|
2507
3088
|
return index;
|
|
2508
3089
|
}
|
|
2509
3090
|
function findClosingParenthesis(css, openingIndex) {
|
|
@@ -2609,6 +3190,161 @@ function removeTailwindGenerationDirectives(root) {
|
|
|
2609
3190
|
});
|
|
2610
3191
|
}
|
|
2611
3192
|
//#endregion
|
|
3193
|
+
//#region src/compat/mini-program-css/class-presence.ts
|
|
3194
|
+
/** 将已有类约束上的 class 存在条件等价改写为重复类,保留框架提权语义。 */
|
|
3195
|
+
function normalizeClassPresenceSelectors(root) {
|
|
3196
|
+
let changed = false;
|
|
3197
|
+
root.walkRules((rule) => {
|
|
3198
|
+
if (!rule.selector.includes("[")) return;
|
|
3199
|
+
let ruleChanged = false;
|
|
3200
|
+
const next = (0, postcss_selector_parser.default)((selectors) => {
|
|
3201
|
+
selectors.walkAttributes((attribute) => {
|
|
3202
|
+
if (attribute.attribute !== "class" || attribute.operator || attribute.namespace !== void 0) return;
|
|
3203
|
+
const siblings = attribute.parent?.nodes ?? [];
|
|
3204
|
+
const index = siblings.indexOf(attribute);
|
|
3205
|
+
let start = index;
|
|
3206
|
+
let end = index;
|
|
3207
|
+
while (start > 0 && siblings[start - 1].type !== "combinator") start--;
|
|
3208
|
+
while (end + 1 < siblings.length && siblings[end + 1].type !== "combinator") end++;
|
|
3209
|
+
const classNode = siblings.slice(start, end + 1).find((node) => node.type === "class");
|
|
3210
|
+
if (classNode) {
|
|
3211
|
+
attribute.replaceWith(classNode.clone({ spaces: attribute.spaces }));
|
|
3212
|
+
ruleChanged = true;
|
|
3213
|
+
}
|
|
3214
|
+
});
|
|
3215
|
+
}).processSync(rule.selector);
|
|
3216
|
+
if (ruleChanged) {
|
|
3217
|
+
rule.selector = next;
|
|
3218
|
+
changed = true;
|
|
3219
|
+
}
|
|
3220
|
+
});
|
|
3221
|
+
return changed;
|
|
3222
|
+
}
|
|
3223
|
+
//#endregion
|
|
3224
|
+
//#region src/compat/mini-program-css/empty-blocks.ts
|
|
3225
|
+
function isCssWhitespace(code) {
|
|
3226
|
+
return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
|
|
3227
|
+
}
|
|
3228
|
+
function isCssWordChar(code) {
|
|
3229
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95;
|
|
3230
|
+
}
|
|
3231
|
+
const EMPTY_CSS_BLOCK_RE = /\{(?:[\t\n\f\r ]|\/\*(?:[^*]|\*(?!\/))*\*\/)*\}/;
|
|
3232
|
+
function findCssPreludeStart(css, start, end) {
|
|
3233
|
+
let cursor = start;
|
|
3234
|
+
while (cursor < end) {
|
|
3235
|
+
while (cursor < end && isCssWhitespace(css.charCodeAt(cursor))) cursor++;
|
|
3236
|
+
if (css.charCodeAt(cursor) !== 47 || css.charCodeAt(cursor + 1) !== 42) return cursor;
|
|
3237
|
+
const commentEnd = css.indexOf("*/", cursor + 2);
|
|
3238
|
+
if (commentEnd < 0 || commentEnd + 2 > end) return end;
|
|
3239
|
+
cursor = commentEnd + 2;
|
|
3240
|
+
}
|
|
3241
|
+
return end;
|
|
3242
|
+
}
|
|
3243
|
+
function isKeyframesAtRule(css, start, end) {
|
|
3244
|
+
let cursor = start + 1;
|
|
3245
|
+
if (css.charCodeAt(cursor) === 45) {
|
|
3246
|
+
cursor++;
|
|
3247
|
+
const prefixStart = cursor;
|
|
3248
|
+
while (cursor < end && isCssWordChar(css.charCodeAt(cursor))) cursor++;
|
|
3249
|
+
if (cursor === prefixStart || css.charCodeAt(cursor) !== 45) return false;
|
|
3250
|
+
cursor++;
|
|
3251
|
+
}
|
|
3252
|
+
if (cursor + 9 > end || css.slice(cursor, cursor + 9).toLowerCase() !== "keyframes") return false;
|
|
3253
|
+
return !isCssWordChar(css.charCodeAt(cursor + 9));
|
|
3254
|
+
}
|
|
3255
|
+
function hasEmptyCssBlockCandidate(css) {
|
|
3256
|
+
if (!EMPTY_CSS_BLOCK_RE.test(css)) return false;
|
|
3257
|
+
const blocks = [];
|
|
3258
|
+
let parenthesisDepth = 0;
|
|
3259
|
+
let quote = 0;
|
|
3260
|
+
let squareBracketDepth = 0;
|
|
3261
|
+
let statementStart = 0;
|
|
3262
|
+
for (let index = 0; index < css.length; index++) {
|
|
3263
|
+
const code = css.charCodeAt(index);
|
|
3264
|
+
if (quote !== 0) {
|
|
3265
|
+
if (code === 92) index++;
|
|
3266
|
+
else if (code === quote) quote = 0;
|
|
3267
|
+
continue;
|
|
3268
|
+
}
|
|
3269
|
+
if (code === 34 || code === 39) {
|
|
3270
|
+
quote = code;
|
|
3271
|
+
if (blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
|
|
3272
|
+
continue;
|
|
3273
|
+
}
|
|
3274
|
+
if (code === 92) {
|
|
3275
|
+
if (blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
|
|
3276
|
+
index++;
|
|
3277
|
+
continue;
|
|
3278
|
+
}
|
|
3279
|
+
if (code === 47 && css.charCodeAt(index + 1) === 42) {
|
|
3280
|
+
const commentEnd = css.indexOf("*/", index + 2);
|
|
3281
|
+
if (commentEnd < 0) return false;
|
|
3282
|
+
index = commentEnd + 1;
|
|
3283
|
+
continue;
|
|
3284
|
+
}
|
|
3285
|
+
if (code === 40) {
|
|
3286
|
+
parenthesisDepth++;
|
|
3287
|
+
continue;
|
|
3288
|
+
}
|
|
3289
|
+
if (code === 41 && parenthesisDepth > 0) {
|
|
3290
|
+
parenthesisDepth--;
|
|
3291
|
+
continue;
|
|
3292
|
+
}
|
|
3293
|
+
if (code === 91) {
|
|
3294
|
+
squareBracketDepth++;
|
|
3295
|
+
continue;
|
|
3296
|
+
}
|
|
3297
|
+
if (code === 93 && squareBracketDepth > 0) {
|
|
3298
|
+
squareBracketDepth--;
|
|
3299
|
+
continue;
|
|
3300
|
+
}
|
|
3301
|
+
if (code === 123 && parenthesisDepth === 0 && squareBracketDepth === 0) {
|
|
3302
|
+
const preludeStart = findCssPreludeStart(css, statementStart, index);
|
|
3303
|
+
const isAtRule = css.charCodeAt(preludeStart) === 64;
|
|
3304
|
+
const isKeyframesContainer = isAtRule && isKeyframesAtRule(css, preludeStart, index);
|
|
3305
|
+
blocks.push({
|
|
3306
|
+
hasContent: false,
|
|
3307
|
+
isKeyframesContainer,
|
|
3308
|
+
isKeyframeStep: !isAtRule && blocks[blocks.length - 1]?.isKeyframesContainer === true
|
|
3309
|
+
});
|
|
3310
|
+
statementStart = index + 1;
|
|
3311
|
+
continue;
|
|
3312
|
+
}
|
|
3313
|
+
if (code === 125 && parenthesisDepth === 0 && squareBracketDepth === 0) {
|
|
3314
|
+
const block = blocks.pop();
|
|
3315
|
+
if (!block) continue;
|
|
3316
|
+
if (!block.hasContent && !block.isKeyframeStep) return true;
|
|
3317
|
+
if (blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
|
|
3318
|
+
statementStart = index + 1;
|
|
3319
|
+
continue;
|
|
3320
|
+
}
|
|
3321
|
+
if (code === 59 && parenthesisDepth === 0 && squareBracketDepth === 0) {
|
|
3322
|
+
statementStart = index + 1;
|
|
3323
|
+
continue;
|
|
3324
|
+
}
|
|
3325
|
+
if (!isCssWhitespace(code) && blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
|
|
3326
|
+
}
|
|
3327
|
+
return false;
|
|
3328
|
+
}
|
|
3329
|
+
/** 在小程序样式进入最终产物图时规范化等价选择器并递归清理空 CSS 块。 */
|
|
3330
|
+
function finalizeMiniProgramCssStructure(css) {
|
|
3331
|
+
const repaired = repairTrailingUnclosedTailwindSourceMedia(css);
|
|
3332
|
+
if (!/\[\s*class\s*\]/.test(repaired) && !hasEmptyCssBlockCandidate(repaired)) return repaired;
|
|
3333
|
+
try {
|
|
3334
|
+
const root = postcss.default.parse(repaired);
|
|
3335
|
+
const selectorsChanged = normalizeClassPresenceSelectors(root);
|
|
3336
|
+
let removed = 0;
|
|
3337
|
+
let passRemoved = 0;
|
|
3338
|
+
do {
|
|
3339
|
+
passRemoved = removeEmptyRules(root) + removeEmptyAtRules(root);
|
|
3340
|
+
removed += passRemoved;
|
|
3341
|
+
} while (passRemoved > 0);
|
|
3342
|
+
return removed > 0 || selectorsChanged ? root.toString() : repaired;
|
|
3343
|
+
} catch {
|
|
3344
|
+
return repaired;
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
//#endregion
|
|
2612
3348
|
//#region src/compat/mini-program-prefixes.ts
|
|
2613
3349
|
const PRESERVED_WEBKIT_DECLARATION_PROPS = /* @__PURE__ */ new Set([
|
|
2614
3350
|
"-webkit-box-orient",
|
|
@@ -3095,7 +3831,7 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
3095
3831
|
});
|
|
3096
3832
|
root.walkRules((rule) => {
|
|
3097
3833
|
if (isKeyframesRule(rule)) return;
|
|
3098
|
-
if (isPseudoContentInitRule(rule)) {
|
|
3834
|
+
if (isPseudoContentInitRule$1(rule)) {
|
|
3099
3835
|
if (!shouldPreserveContentInit) rule.remove();
|
|
3100
3836
|
return;
|
|
3101
3837
|
}
|
|
@@ -3214,17 +3950,91 @@ function convertTailwindcssRpxDeclarationToRem(decl, options) {
|
|
|
3214
3950
|
decl.value = value;
|
|
3215
3951
|
return true;
|
|
3216
3952
|
}
|
|
3217
|
-
function convertTailwindcssRpxDeclarationsToRem(root, options) {
|
|
3218
|
-
let changed = false;
|
|
3219
|
-
root.walkDecls((decl) => {
|
|
3220
|
-
changed = convertTailwindcssRpxDeclarationToRem(decl, options) || changed;
|
|
3953
|
+
function convertTailwindcssRpxDeclarationsToRem(root, options) {
|
|
3954
|
+
let changed = false;
|
|
3955
|
+
root.walkDecls((decl) => {
|
|
3956
|
+
changed = convertTailwindcssRpxDeclarationToRem(decl, options) || changed;
|
|
3957
|
+
});
|
|
3958
|
+
return changed;
|
|
3959
|
+
}
|
|
3960
|
+
function normalizeTailwindcssWebRpxDeclarations(root, options) {
|
|
3961
|
+
const normalized = normalizeTailwindcssRpxDeclarations(root, options);
|
|
3962
|
+
const converted = convertTailwindcssRpxDeclarationsToRem(root, options);
|
|
3963
|
+
return normalized || converted;
|
|
3964
|
+
}
|
|
3965
|
+
//#endregion
|
|
3966
|
+
//#region src/compat/tailwindcss-v4/author-functions.ts
|
|
3967
|
+
const functionNames = /* @__PURE__ */ new Set([
|
|
3968
|
+
"theme",
|
|
3969
|
+
"--theme",
|
|
3970
|
+
"--spacing",
|
|
3971
|
+
"--alpha"
|
|
3972
|
+
]);
|
|
3973
|
+
const functionPattern = /(?:theme|--theme|--spacing|--alpha)\(/;
|
|
3974
|
+
function hasCompilerFunction(value) {
|
|
3975
|
+
if (!functionPattern.test(value)) return false;
|
|
3976
|
+
let found = false;
|
|
3977
|
+
(0, postcss_value_parser.default)(value).walk((node) => {
|
|
3978
|
+
if (node.type === "function" && functionNames.has(node.value)) {
|
|
3979
|
+
found = true;
|
|
3980
|
+
return false;
|
|
3981
|
+
}
|
|
3982
|
+
});
|
|
3983
|
+
return found;
|
|
3984
|
+
}
|
|
3985
|
+
/** 将编译期函数值交给当前 Tailwind 编译上下文处理,保留声明的顺序与作用域。 */
|
|
3986
|
+
async function compileTailwindAuthorFunctions(css, compileValues) {
|
|
3987
|
+
if (!functionPattern.test(css)) return css;
|
|
3988
|
+
const root = postcss.default.parse(css);
|
|
3989
|
+
const nodes = [];
|
|
3990
|
+
const values = [];
|
|
3991
|
+
root.walk((node) => {
|
|
3992
|
+
const value = node.type === "decl" ? node.value : node.type === "atrule" && [
|
|
3993
|
+
"media",
|
|
3994
|
+
"supports",
|
|
3995
|
+
"container"
|
|
3996
|
+
].includes(node.name) ? node.params : void 0;
|
|
3997
|
+
if (value !== void 0 && hasCompilerFunction(value)) {
|
|
3998
|
+
nodes.push(node);
|
|
3999
|
+
values.push(value);
|
|
4000
|
+
}
|
|
4001
|
+
});
|
|
4002
|
+
if (values.length === 0) return css;
|
|
4003
|
+
const compiled = await compileValues(values);
|
|
4004
|
+
if (compiled.length !== values.length) throw new Error("Tailwind 作者样式函数编译结果数量不匹配。");
|
|
4005
|
+
nodes.forEach((node, index) => {
|
|
4006
|
+
const value = compiled[index];
|
|
4007
|
+
if (hasCompilerFunction(value)) throw new Error(`Tailwind 作者样式函数尚未编译:${value}`);
|
|
4008
|
+
if (node.type === "decl") node.value = value;
|
|
4009
|
+
else node.params = value;
|
|
3221
4010
|
});
|
|
3222
|
-
return
|
|
4011
|
+
return root.toString();
|
|
3223
4012
|
}
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
const
|
|
3227
|
-
|
|
4013
|
+
/** 用唯一选择器承载待编译的值,避免依靠作者选择器或属性名猜测对应关系。 */
|
|
4014
|
+
function createTailwindAuthorFunctionProbe(values, selector) {
|
|
4015
|
+
const root = postcss.default.root();
|
|
4016
|
+
const rule = postcss.default.rule({ selector });
|
|
4017
|
+
values.forEach((value, index) => rule.append(postcss.default.decl({
|
|
4018
|
+
prop: `--value-${index}`,
|
|
4019
|
+
value
|
|
4020
|
+
})));
|
|
4021
|
+
root.append(rule);
|
|
4022
|
+
return {
|
|
4023
|
+
css: root.toString(),
|
|
4024
|
+
read(compiledCss) {
|
|
4025
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
4026
|
+
postcss.default.parse(compiledCss).walkRules(selector, (compiledRule) => {
|
|
4027
|
+
compiledRule.walkDecls((declaration) => {
|
|
4028
|
+
resolved.set(declaration.prop, declaration.value);
|
|
4029
|
+
});
|
|
4030
|
+
});
|
|
4031
|
+
return values.map((_, index) => {
|
|
4032
|
+
const value = resolved.get(`--value-${index}`);
|
|
4033
|
+
if (value === void 0) throw new Error(`Tailwind 作者样式函数编译结果缺少第 ${index} 个值。`);
|
|
4034
|
+
return value;
|
|
4035
|
+
});
|
|
4036
|
+
}
|
|
4037
|
+
};
|
|
3228
4038
|
}
|
|
3229
4039
|
//#endregion
|
|
3230
4040
|
//#region src/compat/tailwindcss-v4/infinity-radius.ts
|
|
@@ -3241,6 +4051,222 @@ function normalizeTailwindcssV4InfinityRadiusCss(css) {
|
|
|
3241
4051
|
return root.toString();
|
|
3242
4052
|
}
|
|
3243
4053
|
//#endregion
|
|
4054
|
+
//#region src/compat/uni-app-x-author-apply.ts
|
|
4055
|
+
/** 判断 Tailwind 的元素级变量初始化,兼容 Vue 已注入的 scoped 属性。 */
|
|
4056
|
+
function isTailwindRuntimePropertyRule(rule) {
|
|
4057
|
+
if (!rule.nodes.some((node) => node.type === "decl") || !rule.nodes.every((node) => node.type === "comment" || node.type === "decl" && node.prop.startsWith("--tw-"))) return false;
|
|
4058
|
+
let valid = true;
|
|
4059
|
+
(0, postcss_selector_parser.default)((selectors) => {
|
|
4060
|
+
selectors.walk((node) => {
|
|
4061
|
+
if (node.type === "selector" || node.type === "universal" || node.type === "attribute" && node.attribute.startsWith("data-v-") || node.type === "pseudo" && [
|
|
4062
|
+
"::before",
|
|
4063
|
+
"::after",
|
|
4064
|
+
"::backdrop",
|
|
4065
|
+
":before",
|
|
4066
|
+
":after"
|
|
4067
|
+
].includes(node.value)) return;
|
|
4068
|
+
valid = false;
|
|
4069
|
+
});
|
|
4070
|
+
}).processSync(rule.selector);
|
|
4071
|
+
return valid;
|
|
4072
|
+
}
|
|
4073
|
+
function normalizeSelector$1(selector) {
|
|
4074
|
+
return selector.replace(/\s+/g, " ").trim();
|
|
4075
|
+
}
|
|
4076
|
+
function atRuleKey(name, params) {
|
|
4077
|
+
return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
|
|
4078
|
+
}
|
|
4079
|
+
/**
|
|
4080
|
+
* `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
|
|
4081
|
+
* utilities 复制进 scoped style 模块;Web 保留实际使用的运行时变量初始化和注册。
|
|
4082
|
+
*/
|
|
4083
|
+
function retainUniAppXAuthorApplyCss(generatedCss, authorCss, options = {}) {
|
|
4084
|
+
try {
|
|
4085
|
+
const authorRoot = postcss.default.parse(authorCss);
|
|
4086
|
+
const authorSelectors = /* @__PURE__ */ new Set();
|
|
4087
|
+
const authorAtRules = /* @__PURE__ */ new Set();
|
|
4088
|
+
authorRoot.walkRules((rule) => {
|
|
4089
|
+
for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector$1(selector));
|
|
4090
|
+
});
|
|
4091
|
+
authorRoot.walkAtRules((atRule) => {
|
|
4092
|
+
if (![
|
|
4093
|
+
"apply",
|
|
4094
|
+
"reference",
|
|
4095
|
+
"import",
|
|
4096
|
+
"tailwind",
|
|
4097
|
+
"theme",
|
|
4098
|
+
"source",
|
|
4099
|
+
"config",
|
|
4100
|
+
"plugin"
|
|
4101
|
+
].includes(atRule.name)) authorAtRules.add(atRuleKey(atRule.name, atRule.params));
|
|
4102
|
+
});
|
|
4103
|
+
const matchesAuthorSelector = createAuthorSelectorMatcher(authorSelectors);
|
|
4104
|
+
const root = postcss.default.parse(generatedCss);
|
|
4105
|
+
const usedProperties = /* @__PURE__ */ new Set();
|
|
4106
|
+
if (options.preserveRuntimeProperties) {
|
|
4107
|
+
const retained = postcss.default.root();
|
|
4108
|
+
root.walkRules((rule) => {
|
|
4109
|
+
if (rule.selectors.every((selector) => matchesAuthorSelector(normalizeSelector$1(selector)))) retained.append(rule.clone());
|
|
4110
|
+
});
|
|
4111
|
+
for (const prop of collectUsedTailwindcssV4Variables(retained)) usedProperties.add(prop);
|
|
4112
|
+
}
|
|
4113
|
+
let changed = false;
|
|
4114
|
+
root.walkRules((rule) => {
|
|
4115
|
+
if ((rule.selectors ?? [rule.selector]).every((selector) => matchesAuthorSelector(normalizeSelector$1(selector)))) return;
|
|
4116
|
+
if (options.preserveRuntimeProperties && isTailwindRuntimePropertyRule(rule)) {
|
|
4117
|
+
rule.walkDecls((decl) => {
|
|
4118
|
+
if (!usedProperties.has(decl.prop)) {
|
|
4119
|
+
decl.remove();
|
|
4120
|
+
changed = true;
|
|
4121
|
+
}
|
|
4122
|
+
});
|
|
4123
|
+
if (rule.nodes.some((node) => node.type === "decl")) return;
|
|
4124
|
+
}
|
|
4125
|
+
rule.remove();
|
|
4126
|
+
changed = true;
|
|
4127
|
+
});
|
|
4128
|
+
root.walkAtRules((atRule) => {
|
|
4129
|
+
if (options.preserveRuntimeProperties && atRule.name === "property" && usedProperties.has(atRule.params.trim())) return;
|
|
4130
|
+
if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
|
|
4131
|
+
if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
|
|
4132
|
+
atRule.remove();
|
|
4133
|
+
changed = true;
|
|
4134
|
+
});
|
|
4135
|
+
root.walkComments((comment) => {
|
|
4136
|
+
if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
|
|
4137
|
+
comment.remove();
|
|
4138
|
+
changed = true;
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
4141
|
+
return changed ? root.toString().trim() : generatedCss;
|
|
4142
|
+
} catch {
|
|
4143
|
+
return generatedCss;
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
//#endregion
|
|
4147
|
+
//#region src/preflight.ts
|
|
4148
|
+
function createInjectPreflight(options) {
|
|
4149
|
+
const result = [];
|
|
4150
|
+
if (options && typeof options === "object") {
|
|
4151
|
+
const entries = Object.entries(options);
|
|
4152
|
+
for (const [prop, value] of entries) if (value !== false) result.push({
|
|
4153
|
+
prop,
|
|
4154
|
+
value: value.toString()
|
|
4155
|
+
});
|
|
4156
|
+
}
|
|
4157
|
+
return () => {
|
|
4158
|
+
return result;
|
|
4159
|
+
};
|
|
4160
|
+
}
|
|
4161
|
+
//#endregion
|
|
4162
|
+
//#region src/compat/uni-app-x-border.ts
|
|
4163
|
+
const UNI_APP_X_BORDER_PREFLIGHT_CLASS = "weapp-tw-border";
|
|
4164
|
+
/** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
|
|
4165
|
+
function hoistUniAppXBorderPreflight(css) {
|
|
4166
|
+
if (!css.includes("weapp-tw-border")) return css;
|
|
4167
|
+
const root = postcss.default.parse(css);
|
|
4168
|
+
const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
|
|
4169
|
+
const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
|
|
4170
|
+
if (!anchor || resets.length === 0) return css;
|
|
4171
|
+
for (const reset of resets) {
|
|
4172
|
+
reset.remove();
|
|
4173
|
+
root.insertBefore(anchor, reset);
|
|
4174
|
+
}
|
|
4175
|
+
return root.toString();
|
|
4176
|
+
}
|
|
4177
|
+
/** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
|
|
4178
|
+
function createUniAppXBorderPreflight(options) {
|
|
4179
|
+
const declarations = createInjectPreflight(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
|
|
4180
|
+
if (declarations.length === 0) return;
|
|
4181
|
+
const rule = postcss.default.rule({ selector: `.${UNI_APP_X_BORDER_PREFLIGHT_CLASS}` });
|
|
4182
|
+
for (const declaration of declarations) rule.append(postcss.default.decl(declaration));
|
|
4183
|
+
return rule.toString();
|
|
4184
|
+
}
|
|
4185
|
+
//#endregion
|
|
4186
|
+
//#region src/compat/uni-app-x-style-value.ts
|
|
4187
|
+
const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
|
|
4188
|
+
const STRING_STYLE_PROPERTIES = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
4189
|
+
function toCamelCase(prop) {
|
|
4190
|
+
return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
4191
|
+
}
|
|
4192
|
+
function normalizeValue(prop, value) {
|
|
4193
|
+
const trimmed = value.trim();
|
|
4194
|
+
if (!STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) && /^-?\d+(?:\.\d+)?px$/.test(trimmed)) return Number(trimmed.slice(0, -2));
|
|
4195
|
+
return trimmed.replace(/\s*,\s*/g, ",");
|
|
4196
|
+
}
|
|
4197
|
+
function unescapeCssClassSelector(className) {
|
|
4198
|
+
return className.replace(/\\([^\n\r\f0-9a-f])/gi, "$1");
|
|
4199
|
+
}
|
|
4200
|
+
function assignClassStyleValue(result, className, declarations) {
|
|
4201
|
+
const unescapedClassName = unescapeCssClassSelector(className);
|
|
4202
|
+
result[className] = { "": declarations };
|
|
4203
|
+
result[unescapedClassName] = { "": declarations };
|
|
4204
|
+
result[(0, _weapp_core_escape.escape)(unescapedClassName)] = { "": declarations };
|
|
4205
|
+
}
|
|
4206
|
+
/** 把 CSS 规则编译成 Harmony/UTS 可消费的 class -> 声明对象。 */
|
|
4207
|
+
function cssToClassStyleValue(source) {
|
|
4208
|
+
let root;
|
|
4209
|
+
try {
|
|
4210
|
+
root = postcss.default.parse(source);
|
|
4211
|
+
} catch {
|
|
4212
|
+
return;
|
|
4213
|
+
}
|
|
4214
|
+
const result = {};
|
|
4215
|
+
root.walkRules((rule) => {
|
|
4216
|
+
const selectors = rule.selectors ?? [];
|
|
4217
|
+
for (const selector of selectors) {
|
|
4218
|
+
const match = selector.trim().match(CLASS_SELECTOR_PREFIX_RE);
|
|
4219
|
+
if (!match?.[1]) continue;
|
|
4220
|
+
const declarations = {};
|
|
4221
|
+
rule.walkDecls((decl) => {
|
|
4222
|
+
declarations[toCamelCase(decl.prop)] = normalizeValue(decl.prop, decl.value);
|
|
4223
|
+
});
|
|
4224
|
+
if (Object.keys(declarations).length > 0) assignClassStyleValue(result, match[1], declarations);
|
|
4225
|
+
}
|
|
4226
|
+
});
|
|
4227
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
4228
|
+
}
|
|
4229
|
+
/** 从 SCSS/CSS 源码收集 `@apply` 工具类。 */
|
|
4230
|
+
function collectCssApplyUtilities(source) {
|
|
4231
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
4232
|
+
let root;
|
|
4233
|
+
try {
|
|
4234
|
+
root = parseUniAppXStyleSource(source);
|
|
4235
|
+
} catch {
|
|
4236
|
+
return utilities;
|
|
4237
|
+
}
|
|
4238
|
+
root.walkAtRules("apply", (rule) => {
|
|
4239
|
+
for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
4240
|
+
});
|
|
4241
|
+
return utilities;
|
|
4242
|
+
}
|
|
4243
|
+
/** 把 `@apply` 规则展开成已有 utility 声明。 */
|
|
4244
|
+
function expandCssApplySourcesToStyleValue(source, utilityStyles) {
|
|
4245
|
+
let root;
|
|
4246
|
+
try {
|
|
4247
|
+
root = parseUniAppXStyleSource(source);
|
|
4248
|
+
} catch {
|
|
4249
|
+
return;
|
|
4250
|
+
}
|
|
4251
|
+
const result = {};
|
|
4252
|
+
root.walkRules((rule) => {
|
|
4253
|
+
const applyRules = rule.nodes?.filter((node) => node.type === "atrule" && node.name === "apply") ?? [];
|
|
4254
|
+
if (applyRules.length === 0) return;
|
|
4255
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
4256
|
+
for (const selector of selectors) {
|
|
4257
|
+
const className = selector.trim().match(CLASS_SELECTOR_PREFIX_RE)?.[1];
|
|
4258
|
+
if (!className) continue;
|
|
4259
|
+
const declarations = {};
|
|
4260
|
+
for (const applyRule of applyRules) for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(applyRule.params)) {
|
|
4261
|
+
const utilityDeclarations = utilityStyles[utility]?.[""] ?? utilityStyles[(0, _weapp_core_escape.escape)(utility)]?.[""];
|
|
4262
|
+
if (utilityDeclarations) Object.assign(declarations, utilityDeclarations);
|
|
4263
|
+
}
|
|
4264
|
+
if (Object.keys(declarations).length > 0) assignClassStyleValue(result, className, declarations);
|
|
4265
|
+
}
|
|
4266
|
+
});
|
|
4267
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
4268
|
+
}
|
|
4269
|
+
//#endregion
|
|
3244
4270
|
//#region src/shared.ts
|
|
3245
4271
|
const escapeOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
3246
4272
|
function getEscapeOptions(escapeMap) {
|
|
@@ -3302,7 +4328,7 @@ function normalizeWebCssCompatOptions(options) {
|
|
|
3302
4328
|
function isWebCssCompatEnabled(options) {
|
|
3303
4329
|
return Object.values(options.features).some(Boolean);
|
|
3304
4330
|
}
|
|
3305
|
-
function collectCustomPropertyValues(root) {
|
|
4331
|
+
function collectCustomPropertyValues$1(root) {
|
|
3306
4332
|
const values = /* @__PURE__ */ new Map();
|
|
3307
4333
|
root.walkRules((rule) => {
|
|
3308
4334
|
if (!rule.selectors.some((selector) => selector.trim() === ":root" || selector.trim() === ":host")) return;
|
|
@@ -3404,7 +4430,7 @@ function usesResolvableTailwindColorVariable(value, customPropertyValues) {
|
|
|
3404
4430
|
}
|
|
3405
4431
|
function normalizeModernColorDeclarations(root, features) {
|
|
3406
4432
|
if (!features.oklch && !features.colorFunctions) return;
|
|
3407
|
-
const customPropertyValues = collectCustomPropertyValues(root);
|
|
4433
|
+
const customPropertyValues = collectCustomPropertyValues$1(root);
|
|
3408
4434
|
root.walkDecls((decl) => {
|
|
3409
4435
|
const value = resolveCustomPropertyVarValue(decl.value, customPropertyValues);
|
|
3410
4436
|
const normalized = normalizeModernColorValue(value, customPropertyValues);
|
|
@@ -3841,6 +4867,93 @@ async function transformCssMacroCss(css, options) {
|
|
|
3841
4867
|
return compileCssMacroConditionalComments(result, options);
|
|
3842
4868
|
}
|
|
3843
4869
|
//#endregion
|
|
4870
|
+
//#region src/postcss-config.ts
|
|
4871
|
+
const tailwindPostcssPluginNames = /* @__PURE__ */ new Set(["tailwindcss", "@tailwindcss/postcss"]);
|
|
4872
|
+
function getPostcssPluginName(plugin) {
|
|
4873
|
+
if (!plugin) return;
|
|
4874
|
+
if (typeof plugin === "function" && "postcss" in plugin) try {
|
|
4875
|
+
return getPostcssPluginName(plugin());
|
|
4876
|
+
} catch {
|
|
4877
|
+
return;
|
|
4878
|
+
}
|
|
4879
|
+
if (typeof plugin !== "object" || !("postcssPlugin" in plugin)) return;
|
|
4880
|
+
const { postcssPlugin } = plugin;
|
|
4881
|
+
return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
|
|
4882
|
+
}
|
|
4883
|
+
function isTailwindPostcssPlugin(plugin) {
|
|
4884
|
+
const name = getPostcssPluginName(plugin);
|
|
4885
|
+
return typeof name === "string" && tailwindPostcssPluginNames.has(name);
|
|
4886
|
+
}
|
|
4887
|
+
function removeTailwindPostcssPlugins(plugins) {
|
|
4888
|
+
let removed = 0;
|
|
4889
|
+
for (let i = plugins.length - 1; i >= 0; i--) if (isTailwindPostcssPlugin(plugins[i])) {
|
|
4890
|
+
plugins.splice(i, 1);
|
|
4891
|
+
removed++;
|
|
4892
|
+
}
|
|
4893
|
+
return removed;
|
|
4894
|
+
}
|
|
4895
|
+
async function resolvePostcssConfig(root, ctx = {}) {
|
|
4896
|
+
try {
|
|
4897
|
+
const loaded = await (0, postcss_load_config.default)(ctx, root);
|
|
4898
|
+
return {
|
|
4899
|
+
options: loaded.options,
|
|
4900
|
+
plugins: Array.isArray(loaded.plugins) ? [...loaded.plugins] : []
|
|
4901
|
+
};
|
|
4902
|
+
} catch (error) {
|
|
4903
|
+
if ((error instanceof Error ? error.message : String(error)).includes("No PostCSS Config found")) return;
|
|
4904
|
+
throw error;
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
async function resolveFilteredPostcssConfig(root) {
|
|
4908
|
+
const loaded = await resolvePostcssConfig(root);
|
|
4909
|
+
if (!loaded) return;
|
|
4910
|
+
const plugins = [...loaded.plugins];
|
|
4911
|
+
const removed = removeTailwindPostcssPlugins(plugins);
|
|
4912
|
+
if (removed === 0) return;
|
|
4913
|
+
return {
|
|
4914
|
+
options: loaded.options,
|
|
4915
|
+
plugins,
|
|
4916
|
+
removed
|
|
4917
|
+
};
|
|
4918
|
+
}
|
|
4919
|
+
//#endregion
|
|
4920
|
+
//#region src/framework-pipeline.ts
|
|
4921
|
+
function unwrapDefault(value) {
|
|
4922
|
+
if (typeof value === "object" && value !== null && "default" in value) return unwrapDefault(value.default);
|
|
4923
|
+
return value;
|
|
4924
|
+
}
|
|
4925
|
+
async function normalizePlugin(value, from) {
|
|
4926
|
+
if (value === false || value === null || value === void 0) return;
|
|
4927
|
+
const tuple = Array.isArray(value);
|
|
4928
|
+
const pluginOptions = tuple ? value[1] : void 0;
|
|
4929
|
+
if (pluginOptions === false) return;
|
|
4930
|
+
let plugin = unwrapDefault(tuple ? value[0] : value);
|
|
4931
|
+
if (typeof plugin === "string") {
|
|
4932
|
+
const require$1 = (0, node_module.createRequire)((0, node_url.pathToFileURL)((0, node_path.resolve)(from)));
|
|
4933
|
+
plugin = unwrapDefault(await import((0, node_url.pathToFileURL)(require$1.resolve(plugin)).href));
|
|
4934
|
+
}
|
|
4935
|
+
if (tuple && typeof plugin === "function") plugin = unwrapDefault(await plugin(pluginOptions === true ? void 0 : pluginOptions));
|
|
4936
|
+
return plugin;
|
|
4937
|
+
}
|
|
4938
|
+
async function normalizePlugins(configured, from) {
|
|
4939
|
+
const entries = Array.isArray(configured) ? configured : Object.values(configured ?? {});
|
|
4940
|
+
const plugins = [];
|
|
4941
|
+
for (const entry of entries) {
|
|
4942
|
+
const plugin = await normalizePlugin(entry, from);
|
|
4943
|
+
if (plugin !== void 0) plugins.push(plugin);
|
|
4944
|
+
}
|
|
4945
|
+
removeTailwindPostcssPlugins(plugins);
|
|
4946
|
+
return plugins;
|
|
4947
|
+
}
|
|
4948
|
+
/** 重放框架提供的管线,不附加小程序转换或默认插件。 */
|
|
4949
|
+
async function processFrameworkCss(css, options) {
|
|
4950
|
+
const plugins = await normalizePlugins(options.plugins, options.options?.from ?? (0, node_path.resolve)("postcss.config.js"));
|
|
4951
|
+
return (0, postcss.default)(plugins).process(css, {
|
|
4952
|
+
from: void 0,
|
|
4953
|
+
...options.options
|
|
4954
|
+
});
|
|
4955
|
+
}
|
|
4956
|
+
//#endregion
|
|
3844
4957
|
//#region src/source-scan/inline-source.ts
|
|
3845
4958
|
const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
3846
4959
|
function segmentTopLevel(input, separator, options = {}) {
|
|
@@ -4320,7 +5433,7 @@ function createEmptyDirectiveAnalysis() {
|
|
|
4320
5433
|
};
|
|
4321
5434
|
}
|
|
4322
5435
|
function parseTailwindCssDirectiveRequest(params) {
|
|
4323
|
-
return
|
|
5436
|
+
return parseCssImportSpecifier(params)?.specifier;
|
|
4324
5437
|
}
|
|
4325
5438
|
function parseTailwindCssConfigRequest(params) {
|
|
4326
5439
|
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
@@ -4588,7 +5701,10 @@ function isTailwindSourceDirective(node, options = {}) {
|
|
|
4588
5701
|
const atRule = node;
|
|
4589
5702
|
if (isTailwindCssImportAtRule(atRule, options)) return true;
|
|
4590
5703
|
if (atRule.name === "import" && isTailwindCssPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
|
|
4591
|
-
if (atRule.name === "layer")
|
|
5704
|
+
if (atRule.name === "layer") {
|
|
5705
|
+
if (options.preserveCssLayers) return false;
|
|
5706
|
+
return !atRule.nodes || atRule.nodes.length === 0;
|
|
5707
|
+
}
|
|
4592
5708
|
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
|
|
4593
5709
|
}
|
|
4594
5710
|
function removeTailwindSourceDirectivesRoot(root, options = {}) {
|
|
@@ -5169,21 +6285,6 @@ function createOptionsResolver(baseOptions) {
|
|
|
5169
6285
|
return { resolve };
|
|
5170
6286
|
}
|
|
5171
6287
|
//#endregion
|
|
5172
|
-
//#region src/preflight.ts
|
|
5173
|
-
function createInjectPreflight(options) {
|
|
5174
|
-
const result = [];
|
|
5175
|
-
if (options && typeof options === "object") {
|
|
5176
|
-
const entries = Object.entries(options);
|
|
5177
|
-
for (const [prop, value] of entries) if (value !== false) result.push({
|
|
5178
|
-
prop,
|
|
5179
|
-
value: value.toString()
|
|
5180
|
-
});
|
|
5181
|
-
}
|
|
5182
|
-
return () => {
|
|
5183
|
-
return result;
|
|
5184
|
-
};
|
|
5185
|
-
}
|
|
5186
|
-
//#endregion
|
|
5187
6288
|
//#region src/autoprefixer.ts
|
|
5188
6289
|
const WEAPP_AUTOPREFIXER_BROWSERS = [
|
|
5189
6290
|
"iOS >= 8",
|
|
@@ -5333,8 +6434,20 @@ function getCalcDuplicateCleaner(options) {
|
|
|
5333
6434
|
const EMPTY_CALC_OPTIONS = {};
|
|
5334
6435
|
function getCalcPlugin(options) {
|
|
5335
6436
|
if (!options.cssCalc) return null;
|
|
5336
|
-
if (options.cssCalc === true || Array.isArray(options.cssCalc))
|
|
5337
|
-
|
|
6437
|
+
if (options.cssCalc === true || Array.isArray(options.cssCalc)) {
|
|
6438
|
+
const calcOptions = Array.isArray(options.cssCalc) ? {
|
|
6439
|
+
includeCustomProperties: options.cssCalc,
|
|
6440
|
+
...options.customPropertyValues ? { customPropertyValues: options.customPropertyValues } : {}
|
|
6441
|
+
} : options.customPropertyValues ? {
|
|
6442
|
+
customPropertyValues: options.customPropertyValues,
|
|
6443
|
+
includeCustomProperties: [...options.customPropertyValues.keys()]
|
|
6444
|
+
} : EMPTY_CALC_OPTIONS;
|
|
6445
|
+
return (0, _weapp_tailwindcss_postcss_calc.default)(calcOptions);
|
|
6446
|
+
}
|
|
6447
|
+
return (0, _weapp_tailwindcss_postcss_calc.default)({
|
|
6448
|
+
...options.cssCalc,
|
|
6449
|
+
...options.customPropertyValues ? { customPropertyValues: options.customPropertyValues } : {}
|
|
6450
|
+
});
|
|
5338
6451
|
}
|
|
5339
6452
|
//#endregion
|
|
5340
6453
|
//#region src/plugins/getCustomPropertyCleaner.ts
|
|
@@ -6616,7 +7729,7 @@ function removeLegacyFlexboxPrefix(decl) {
|
|
|
6616
7729
|
}
|
|
6617
7730
|
function removeThemeScopeTailwindcssV4Defaults(root, injectedProps) {
|
|
6618
7731
|
root.walkRules((rule) => {
|
|
6619
|
-
if (!isMiniProgramThemeScopeSelector(getRuleSelectors(rule))) return;
|
|
7732
|
+
if (!isMiniProgramThemeScopeSelector$1(getRuleSelectors(rule))) return;
|
|
6620
7733
|
rule.walkDecls((decl) => {
|
|
6621
7734
|
if (injectedProps.has(decl.prop)) decl.remove();
|
|
6622
7735
|
});
|
|
@@ -7235,10 +8348,21 @@ function createStyleHandler(options) {
|
|
|
7235
8348
|
}
|
|
7236
8349
|
const cacheKey = `${getOptionsFingerprint(resolvedOptions)}|${signal ? signalToCacheKey(signal) : ""}|${simpleHash(source)}`;
|
|
7237
8350
|
const cachedResult = resultCache.get(cacheKey);
|
|
7238
|
-
if (cachedResult)
|
|
8351
|
+
if (cachedResult) {
|
|
8352
|
+
resolvedOptions.onDiagnostic?.({
|
|
8353
|
+
phase: "postcss",
|
|
8354
|
+
durationMs: 0,
|
|
8355
|
+
cache: {
|
|
8356
|
+
hit: true,
|
|
8357
|
+
key: cacheKey
|
|
8358
|
+
}
|
|
8359
|
+
});
|
|
8360
|
+
return Promise.resolve(cloneOutput ? cloneResult(cachedResult) : cachedResult);
|
|
8361
|
+
}
|
|
7239
8362
|
const processor = processorCache.getProcessor(resolvedOptions, signal);
|
|
7240
8363
|
const processOptions = processorCache.getProcessOptions(resolvedOptions);
|
|
7241
|
-
|
|
8364
|
+
const startedAt = node_perf_hooks.performance.now();
|
|
8365
|
+
return processor.process(processInput, processOptions).async().then(async (result) => {
|
|
7242
8366
|
let finalResult = resolvePostcssFrameworkProfile(resolvedOptions).postprocess(result, resolvedOptions);
|
|
7243
8367
|
if (resolvedOptions.isMainChunk !== false && finalResult.root) {
|
|
7244
8368
|
let removed = 0;
|
|
@@ -7267,14 +8391,38 @@ function createStyleHandler(options) {
|
|
|
7267
8391
|
if (splitUnresolvedAuthorVariableFallbacks(finalResult.root, /* @__PURE__ */ new Map())) finalResult.css = finalResult.root.toString();
|
|
7268
8392
|
}
|
|
7269
8393
|
resultCache.set(cacheKey, finalResult);
|
|
8394
|
+
await resolvedOptions.onDiagnostic?.({
|
|
8395
|
+
phase: "postcss",
|
|
8396
|
+
durationMs: node_perf_hooks.performance.now() - startedAt,
|
|
8397
|
+
cache: {
|
|
8398
|
+
hit: false,
|
|
8399
|
+
key: cacheKey
|
|
8400
|
+
}
|
|
8401
|
+
});
|
|
7270
8402
|
return cloneOutput ? cloneResult(finalResult) : finalResult;
|
|
8403
|
+
}).catch(async (error) => {
|
|
8404
|
+
await resolvedOptions.onDiagnostic?.({
|
|
8405
|
+
phase: "postcss",
|
|
8406
|
+
durationMs: node_perf_hooks.performance.now() - startedAt,
|
|
8407
|
+
cache: {
|
|
8408
|
+
hit: false,
|
|
8409
|
+
key: cacheKey
|
|
8410
|
+
},
|
|
8411
|
+
error: {
|
|
8412
|
+
name: error instanceof Error ? error.name : void 0,
|
|
8413
|
+
message: error instanceof Error ? error.message : String(error)
|
|
8414
|
+
}
|
|
8415
|
+
});
|
|
8416
|
+
throw error;
|
|
7271
8417
|
});
|
|
7272
8418
|
}
|
|
7273
8419
|
const handler = ((rawSource, opt) => {
|
|
7274
8420
|
return processSource(rawSource, void 0, false, opt);
|
|
7275
8421
|
});
|
|
7276
|
-
handler.transformRoot = (root, opt) => {
|
|
7277
|
-
|
|
8422
|
+
handler.transformRoot = async (root, opt) => {
|
|
8423
|
+
const result = await processSource(root.toString(), root, true, opt);
|
|
8424
|
+
assertRootResult(result);
|
|
8425
|
+
return result;
|
|
7278
8426
|
};
|
|
7279
8427
|
handler.getPipeline = (opt) => {
|
|
7280
8428
|
const resolvedOptions = resolver.resolve(opt);
|
|
@@ -7282,56 +8430,48 @@ function createStyleHandler(options) {
|
|
|
7282
8430
|
};
|
|
7283
8431
|
return handler;
|
|
7284
8432
|
}
|
|
8433
|
+
/** 单个 Root 的变换不得返回多文档结果,避免破坏调用方的产物归属。 */
|
|
8434
|
+
function assertRootResult(result) {
|
|
8435
|
+
if (result.root.type !== "root") throw new TypeError("StyleHandler.transformRoot must return a single PostCSS Root.");
|
|
8436
|
+
}
|
|
7285
8437
|
//#endregion
|
|
7286
|
-
//#region src/
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
if (!plugin) return;
|
|
7290
|
-
if (typeof plugin === "function" && "postcss" in plugin) try {
|
|
7291
|
-
return getPostcssPluginName(plugin());
|
|
7292
|
-
} catch {
|
|
7293
|
-
return;
|
|
7294
|
-
}
|
|
7295
|
-
if (typeof plugin !== "object" || !("postcssPlugin" in plugin)) return;
|
|
7296
|
-
const { postcssPlugin } = plugin;
|
|
7297
|
-
return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
|
|
8438
|
+
//#region src/plugins/applyConfiguredCssCalc.ts
|
|
8439
|
+
function resolveCssCalcOption(options) {
|
|
8440
|
+
return options.cssOptions?.cssCalc ?? options.cssCalc;
|
|
7298
8441
|
}
|
|
7299
|
-
function
|
|
7300
|
-
const
|
|
7301
|
-
|
|
8442
|
+
function collectCustomPropertyValues(css) {
|
|
8443
|
+
const values = /* @__PURE__ */ new Map();
|
|
8444
|
+
if (!css.includes("--")) return values;
|
|
8445
|
+
try {
|
|
8446
|
+
postcss.default.parse(css).walkDecls((decl) => {
|
|
8447
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
8448
|
+
});
|
|
8449
|
+
} catch {}
|
|
8450
|
+
return values;
|
|
7302
8451
|
}
|
|
7303
|
-
function
|
|
7304
|
-
|
|
7305
|
-
for (
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
}
|
|
7309
|
-
return removed;
|
|
8452
|
+
function mergeCustomPropertyValues(css, options) {
|
|
8453
|
+
const values = collectCustomPropertyValues(options.contextCss ?? "");
|
|
8454
|
+
for (const [name, value] of collectCustomPropertyValues(css)) values.set(name, value);
|
|
8455
|
+
for (const [name, value] of options.customPropertyValues ?? []) values.set(name, value);
|
|
8456
|
+
return values;
|
|
7310
8457
|
}
|
|
7311
|
-
|
|
8458
|
+
/**
|
|
8459
|
+
* 仅按 `cssCalc` 配置预计算 `calc()` / `var()`,不跑小程序选择器替换或单位转换。
|
|
8460
|
+
*/
|
|
8461
|
+
async function applyConfiguredCssCalc(css, options = {}) {
|
|
8462
|
+
const cssCalc = resolveCssCalcOption(options);
|
|
8463
|
+
if (!cssCalc || !css.includes("calc(")) return css;
|
|
8464
|
+
const plugin = getCalcPlugin({
|
|
8465
|
+
cssCalc,
|
|
8466
|
+
customPropertyValues: mergeCustomPropertyValues(css, options)
|
|
8467
|
+
});
|
|
8468
|
+
if (!plugin) return css;
|
|
7312
8469
|
try {
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
plugins: Array.isArray(loaded.plugins) ? [...loaded.plugins] : []
|
|
7317
|
-
};
|
|
7318
|
-
} catch (error) {
|
|
7319
|
-
if ((error instanceof Error ? error.message : String(error)).includes("No PostCSS Config found")) return;
|
|
7320
|
-
throw error;
|
|
8470
|
+
return (await (0, postcss.default)([plugin]).process(css, { from: void 0 })).css;
|
|
8471
|
+
} catch {
|
|
8472
|
+
return css;
|
|
7321
8473
|
}
|
|
7322
8474
|
}
|
|
7323
|
-
async function resolveFilteredPostcssConfig(root) {
|
|
7324
|
-
const loaded = await resolvePostcssConfig(root);
|
|
7325
|
-
if (!loaded) return;
|
|
7326
|
-
const plugins = [...loaded.plugins];
|
|
7327
|
-
const removed = removeTailwindPostcssPlugins(plugins);
|
|
7328
|
-
if (removed === 0) return;
|
|
7329
|
-
return {
|
|
7330
|
-
options: loaded.options,
|
|
7331
|
-
plugins,
|
|
7332
|
-
removed
|
|
7333
|
-
};
|
|
7334
|
-
}
|
|
7335
8475
|
//#endregion
|
|
7336
8476
|
//#region src/vite-css-rules/structure.ts
|
|
7337
8477
|
const MINI_PROGRAM_PREFLIGHT_SELECTOR_KEY = "view,text,::after,::before";
|
|
@@ -7814,20 +8954,27 @@ exports.CSS_MACRO_STYLE_OPTIONS_MARKER = CSS_MACRO_STYLE_OPTIONS_MARKER;
|
|
|
7814
8954
|
exports.FULL_SOURCE_SCAN_EXTENSIONS = FULL_SOURCE_SCAN_EXTENSIONS;
|
|
7815
8955
|
exports.FULL_SOURCE_SCAN_EXTENSION_RE = FULL_SOURCE_SCAN_EXTENSION_RE;
|
|
7816
8956
|
exports.FULL_SOURCE_SCAN_PATTERN = FULL_SOURCE_SCAN_PATTERN;
|
|
8957
|
+
exports.UNI_APP_X_BORDER_PREFLIGHT_CLASS = UNI_APP_X_BORDER_PREFLIGHT_CLASS;
|
|
7817
8958
|
exports.UNI_APP_X_IMPORTANT_APPLY_MARKER = UNI_APP_X_IMPORTANT_APPLY_MARKER;
|
|
7818
8959
|
exports.analyzeTailwindCssDirectives = analyzeTailwindCssDirectives;
|
|
8960
|
+
exports.applyConfiguredCssCalc = applyConfiguredCssCalc;
|
|
7819
8961
|
exports.cleanLocalCssImportWrapperTailwindDirectives = cleanLocalCssImportWrapperTailwindDirectives;
|
|
7820
8962
|
exports.cleanLocalCssImportWrapperTailwindDirectivesRoot = cleanLocalCssImportWrapperTailwindDirectivesRoot;
|
|
7821
8963
|
exports.collectApplyOnlyCssSelectors = collectApplyOnlyCssSelectors;
|
|
7822
8964
|
exports.collectApplyOnlyCssSelectorsRoot = collectApplyOnlyCssSelectorsRoot;
|
|
8965
|
+
exports.collectCssApplyUtilities = collectCssApplyUtilities;
|
|
7823
8966
|
exports.collectCssImportRequestsRoot = collectCssImportRequestsRoot;
|
|
7824
8967
|
exports.collectCssInlineSourceCandidates = collectCssInlineSourceCandidates;
|
|
8968
|
+
exports.collectDedupedPostTransformCompatCss = collectDedupedPostTransformCompatCss;
|
|
8969
|
+
exports.collectGeneratedSelectors = collectGeneratedSelectors;
|
|
7825
8970
|
exports.compileCssMacroConditionalComments = compileCssMacroConditionalComments;
|
|
8971
|
+
exports.compileTailwindAuthorFunctions = compileTailwindAuthorFunctions;
|
|
7826
8972
|
exports.consumeCascadeLayers = consumeCascadeLayers;
|
|
7827
8973
|
exports.containsCssAfterMinify = containsCssAfterMinify;
|
|
7828
8974
|
exports.convertTailwindcssRpxDeclarationToRem = convertTailwindcssRpxDeclarationToRem;
|
|
7829
8975
|
exports.convertTailwindcssRpxDeclarationsToRem = convertTailwindcssRpxDeclarationsToRem;
|
|
7830
8976
|
exports.convertTailwindcssRpxValueToRem = convertTailwindcssRpxValueToRem;
|
|
8977
|
+
exports.createAuthorSelectorMatcher = createAuthorSelectorMatcher;
|
|
7831
8978
|
exports.createCssRuleMatcher = createCssRuleMatcher;
|
|
7832
8979
|
exports.createCssSourceOrderAppend = createCssSourceOrderAppend;
|
|
7833
8980
|
exports.createFallbackPlaceholderReplacer = createFallbackPlaceholderReplacer;
|
|
@@ -7836,10 +8983,14 @@ exports.createPostcssStyleTargetProfile = createPostcssStyleTargetProfile;
|
|
|
7836
8983
|
exports.createSourceScanPattern = createSourceScanPattern;
|
|
7837
8984
|
exports.createStyleHandler = createStyleHandler;
|
|
7838
8985
|
exports.createStylePipeline = createStylePipeline;
|
|
8986
|
+
exports.createTailwindAuthorFunctionProbe = createTailwindAuthorFunctionProbe;
|
|
7839
8987
|
exports.createTailwindSourceEntryMatcher = createTailwindSourceEntryMatcher;
|
|
8988
|
+
exports.createUniAppXBorderPreflight = createUniAppXBorderPreflight;
|
|
7840
8989
|
exports.createWeappTailwindcssPostcssPlugin = createWeappTailwindcssPostcssPlugin;
|
|
7841
8990
|
exports.cssMacroPostcssPlugin = require_postcss.creator;
|
|
8991
|
+
exports.cssToClassStyleValue = cssToClassStyleValue;
|
|
7842
8992
|
exports.dedupeCoveredCssRules = dedupeCoveredCssRules;
|
|
8993
|
+
exports.expandCssApplySourcesToStyleValue = expandCssApplySourcesToStyleValue;
|
|
7843
8994
|
exports.expandInlineSourceCandidatePattern = expandInlineSourceCandidatePattern;
|
|
7844
8995
|
exports.expandTailwindSourceEntries = expandTailwindSourceEntries;
|
|
7845
8996
|
exports.filterApplyOnlyGeneratedCss = filterApplyOnlyGeneratedCss;
|
|
@@ -7847,14 +8998,18 @@ exports.filterApplyOnlyGeneratedCssRoot = filterApplyOnlyGeneratedCssRoot;
|
|
|
7847
8998
|
exports.filterExistingCssRules = filterExistingCssRules;
|
|
7848
8999
|
exports.finalizeMiniProgramCss = finalizeMiniProgramCss;
|
|
7849
9000
|
exports.finalizeMiniProgramCssRoot = finalizeMiniProgramCssRoot;
|
|
9001
|
+
exports.finalizeMiniProgramCssStructure = finalizeMiniProgramCssStructure;
|
|
7850
9002
|
exports.getPostcssPluginName = getPostcssPluginName;
|
|
7851
9003
|
exports.hasCssMacroStyleOptions = hasCssMacroStyleOptions;
|
|
7852
9004
|
exports.hasCssMacroTailwindV4CustomVariantConditionalComments = hasCssMacroTailwindV4CustomVariantConditionalComments;
|
|
7853
9005
|
exports.hasCssMacroTailwindV4Directive = hasCssMacroTailwindV4Directive;
|
|
7854
9006
|
exports.hasCssMacroTailwindV4InternalAtRules = hasCssMacroTailwindV4InternalAtRules;
|
|
7855
9007
|
exports.hasCssMacroTailwindV4Source = hasCssMacroTailwindV4Source;
|
|
9008
|
+
exports.hasEmptyCssBlockCandidate = hasEmptyCssBlockCandidate;
|
|
7856
9009
|
exports.hasMiniProgramCssSpecificityPlaceholders = hasMiniProgramCssSpecificityPlaceholders;
|
|
7857
9010
|
exports.hoistTailwindPreflightBase = hoistTailwindPreflightBase;
|
|
9011
|
+
exports.hoistUniAppXBorderPreflight = hoistUniAppXBorderPreflight;
|
|
9012
|
+
exports.inheritLegacyUnitConvertedDeclarations = inheritLegacyUnitConvertedDeclarations;
|
|
7858
9013
|
exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
|
|
7859
9014
|
exports.isFileExcludedByTailwindSourceEntries = isFileExcludedByTailwindSourceEntries;
|
|
7860
9015
|
exports.isFileMatchedByTailwindSourceEntries = isFileMatchedByTailwindSourceEntries;
|
|
@@ -7863,13 +9018,17 @@ exports.isMiniProgramLocalCssImportRequest = isMiniProgramLocalCssImportRequest;
|
|
|
7863
9018
|
exports.isPureLocalCssImportWrapper = isPureLocalCssImportWrapper;
|
|
7864
9019
|
exports.isPureLocalCssImportWrapperRoot = isPureLocalCssImportWrapperRoot;
|
|
7865
9020
|
exports.isTailwindCssGenerationDirective = isTailwindCssGenerationDirective;
|
|
9021
|
+
exports.isTailwindCssImport = isTailwindCssImport;
|
|
7866
9022
|
exports.isTailwindCssImportAtRule = isTailwindCssImportAtRule;
|
|
7867
9023
|
exports.isTailwindCssImportRequest = isTailwindCssImportRequest;
|
|
7868
9024
|
exports.isTailwindCssPackageJsonImportRequest = isTailwindCssPackageJsonImportRequest;
|
|
9025
|
+
exports.isTailwindRuntimePropertyRule = isTailwindRuntimePropertyRule;
|
|
9026
|
+
exports.isUniAppXStyleSourceEmpty = isUniAppXStyleSourceEmpty;
|
|
7869
9027
|
exports.isWeappTailwindcssImportRequest = isWeappTailwindcssImportRequest;
|
|
7870
9028
|
exports.mergeCoveredCssRuleDeclarations = mergeCoveredCssRuleDeclarations;
|
|
7871
9029
|
exports.mergeMiniProgramPreflightRuleDeclarations = mergeMiniProgramPreflightRuleDeclarations;
|
|
7872
9030
|
exports.mergeMiniProgramThemeScopeRuleDeclarations = mergeMiniProgramThemeScopeRuleDeclarations;
|
|
9031
|
+
exports.normalizeCompatSelectors = normalizeCompatSelectors;
|
|
7873
9032
|
exports.normalizeLegacyContentEntries = normalizeLegacyContentEntries;
|
|
7874
9033
|
exports.normalizeMiniProgramGeneratedCssForPostcss = normalizeMiniProgramGeneratedCssForPostcss;
|
|
7875
9034
|
exports.normalizeMiniProgramPrefixedDeclaration = normalizeMiniProgramPrefixedDeclaration;
|
|
@@ -7884,9 +9043,14 @@ exports.normalizeTailwindcssWebRpxDeclarations = normalizeTailwindcssWebRpxDecla
|
|
|
7884
9043
|
exports.normalizeUniAppXImportantApplyForSass = normalizeUniAppXImportantApplyForSass;
|
|
7885
9044
|
exports.normalizeWebCssCompatOptions = normalizeWebCssCompatOptions;
|
|
7886
9045
|
exports.parseConfigParam = parseConfigParam;
|
|
9046
|
+
exports.parseCssImportSpecifier = parseCssImportSpecifier;
|
|
9047
|
+
exports.parseCssSource = parseCssSource;
|
|
9048
|
+
exports.parseImportSourceParam = parseImportSourceParam;
|
|
9049
|
+
exports.parseScssSource = parseScssSource;
|
|
7887
9050
|
exports.parseSourceFileParam = parseSourceFileParam;
|
|
7888
9051
|
exports.parseTailwindCssConfigRequest = parseTailwindCssConfigRequest;
|
|
7889
9052
|
exports.parseTailwindCssDirectiveRequest = parseTailwindCssDirectiveRequest;
|
|
9053
|
+
exports.parseUniAppXStyleSource = parseUniAppXStyleSource;
|
|
7890
9054
|
Object.defineProperty(exports, "postcss", {
|
|
7891
9055
|
enumerable: true,
|
|
7892
9056
|
get: function() {
|
|
@@ -7895,20 +9059,27 @@ Object.defineProperty(exports, "postcss", {
|
|
|
7895
9059
|
});
|
|
7896
9060
|
exports.postcssHtmlTransform = require_html_transform;
|
|
7897
9061
|
exports.prefixLocalCssImportsWithWebpackIgnoreRoot = prefixLocalCssImportsWithWebpackIgnoreRoot;
|
|
9062
|
+
exports.processFrameworkCss = processFrameworkCss;
|
|
7898
9063
|
exports.protectDynamicColorMixAlpha = protectDynamicColorMixAlpha;
|
|
7899
9064
|
exports.protectDynamicVarFallbacks = protectDynamicVarFallbacks;
|
|
7900
9065
|
exports.pruneMiniProgramGeneratedCss = pruneMiniProgramGeneratedCss;
|
|
9066
|
+
exports.quoteCssImportSpecifier = quoteCssImportSpecifier;
|
|
7901
9067
|
exports.removeEmptyAtRules = removeEmptyAtRules;
|
|
7902
9068
|
exports.removeEmptyRules = removeEmptyRules;
|
|
9069
|
+
exports.removeGeneratedSelectorCompatCss = removeGeneratedSelectorCompatCss;
|
|
7903
9070
|
exports.removeMatchingLocalCssImports = removeMatchingLocalCssImports;
|
|
7904
9071
|
exports.removeMatchingLocalCssImportsRoot = removeMatchingLocalCssImportsRoot;
|
|
9072
|
+
exports.removeTailwindApplyRules = removeTailwindApplyRules;
|
|
7905
9073
|
exports.removeTailwindPostcssPlugins = removeTailwindPostcssPlugins;
|
|
7906
9074
|
exports.removeTailwindSourceDirectivesRoot = removeTailwindSourceDirectivesRoot;
|
|
9075
|
+
exports.removeTailwindV4PreflightImports = removeTailwindV4PreflightImports;
|
|
7907
9076
|
exports.removeUnsupportedAtSupports = removeUnsupportedAtSupports;
|
|
7908
9077
|
exports.removeUnsupportedCascadeLayers = removeUnsupportedCascadeLayers;
|
|
7909
9078
|
exports.removeUnsupportedMiniProgramAtRules = removeUnsupportedMiniProgramAtRules;
|
|
7910
9079
|
exports.removeUnsupportedMiniProgramCssImportsRoot = removeUnsupportedMiniProgramCssImportsRoot;
|
|
7911
9080
|
exports.removeUnsupportedMiniProgramPrefixedAtRule = removeUnsupportedMiniProgramPrefixedAtRule;
|
|
9081
|
+
exports.removeUnsupportedThemeVendorKeyframes = removeUnsupportedThemeVendorKeyframes;
|
|
9082
|
+
exports.removeUnusedMiniProgramContentInit = removeUnusedMiniProgramContentInit;
|
|
7912
9083
|
exports.repairTrailingUnclosedTailwindSourceMedia = repairTrailingUnclosedTailwindSourceMedia;
|
|
7913
9084
|
exports.resolveCssSourceEntries = resolveCssSourceEntries;
|
|
7914
9085
|
exports.resolveFilteredPostcssConfig = resolveFilteredPostcssConfig;
|
|
@@ -7922,11 +9093,19 @@ exports.resolveSourceScanPath = resolveSourceScanPath;
|
|
|
7922
9093
|
exports.resolveTailwindSourceEntry = resolveTailwindSourceEntry;
|
|
7923
9094
|
exports.restoreLocalCssImports = restoreLocalCssImports;
|
|
7924
9095
|
exports.restoreUniAppXImportantApplyMarker = restoreUniAppXImportantApplyMarker;
|
|
9096
|
+
exports.retainUniAppXAuthorApplyCss = retainUniAppXAuthorApplyCss;
|
|
7925
9097
|
exports.rewriteLocalCssImportRequestsForOutput = rewriteLocalCssImportRequestsForOutput;
|
|
7926
9098
|
exports.rewriteLocalCssImportRequestsForOutputRoot = rewriteLocalCssImportRequestsForOutputRoot;
|
|
9099
|
+
Object.defineProperty(exports, "scss", {
|
|
9100
|
+
enumerable: true,
|
|
9101
|
+
get: function() {
|
|
9102
|
+
return postcss_scss.default;
|
|
9103
|
+
}
|
|
9104
|
+
});
|
|
7927
9105
|
exports.selectorContainsPseudoClass = selectorContainsPseudoClass;
|
|
7928
9106
|
exports.splitLocalCssImports = splitLocalCssImports;
|
|
7929
9107
|
exports.splitLocalCssImportsRoot = splitLocalCssImportsRoot;
|
|
9108
|
+
exports.stringifyScssSource = stringifyScssSource;
|
|
7930
9109
|
exports.stripMiniProgramCssSpecificityPlaceholders = stripMiniProgramCssSpecificityPlaceholders;
|
|
7931
9110
|
exports.toPosixPath = toPosixPath;
|
|
7932
9111
|
exports.transformCssMacroCss = transformCssMacroCss;
|