@weapp-tailwindcss/postcss 2.2.1-next.3 → 2.2.1-next.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/mini-program-prefixes.d.ts +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +146 -11
- package/dist/index.mjs +145 -12
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AtRule, Declaration } from 'postcss';
|
|
2
|
+
/**
|
|
3
|
+
* 收敛小程序 CSS 中的 WebKit 前缀,只保留 WXSS 里有实际价值的兼容写法。
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeMiniProgramPrefixedDeclaration(decl: Declaration): void;
|
|
6
|
+
export declare function removeUnsupportedMiniProgramPrefixedAtRule(atRule: AtRule): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { type DynamicColorMixAlphaProtection, type DynamicColorMixAlphaProtectionOptions, type ModernColorValueNormalization, normalizeModernColorValue, protectDynamicColorMixAlpha, } from './compat/color-mix';
|
|
2
|
+
export { normalizeMiniProgramPrefixedDeclaration, removeUnsupportedMiniProgramPrefixedAtRule, } from './compat/mini-program-prefixes';
|
|
2
3
|
export * from './handler';
|
|
3
4
|
export { default as postcssHtmlTransform, type IOptions as PostcssHtmlTransformOptions } from './html-transform';
|
|
4
5
|
export { createStylePipeline, type PipelineNodeContext, type PipelineNodeCursor, type PipelineStage, type ResolvedPipelineNode, type StyleProcessingPipeline, } from './pipeline';
|
package/dist/index.js
CHANGED
|
@@ -274,6 +274,96 @@ function protectDynamicColorMixAlpha(css, options = {}) {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
//#endregion
|
|
277
|
+
//#region src/compat/mini-program-prefixes.ts
|
|
278
|
+
const PRESERVED_WEBKIT_DECLARATION_PROPS = new Set([
|
|
279
|
+
"-webkit-box-orient",
|
|
280
|
+
"-webkit-line-clamp",
|
|
281
|
+
"-webkit-overflow-scrolling",
|
|
282
|
+
"-webkit-text-fill-color",
|
|
283
|
+
"-webkit-text-stroke",
|
|
284
|
+
"-webkit-text-stroke-color",
|
|
285
|
+
"-webkit-text-stroke-width"
|
|
286
|
+
]);
|
|
287
|
+
const PRESERVED_WEBKIT_VALUE_DECLARATIONS = new Map([["display", new Set(["-webkit-box"])], ["-webkit-background-clip", new Set(["text"])]]);
|
|
288
|
+
const TRANSITION_PROPS = new Set(["transition", "transition-property"]);
|
|
289
|
+
function splitTopLevelCommaList(value) {
|
|
290
|
+
const parts = [];
|
|
291
|
+
let start = 0;
|
|
292
|
+
let depth = 0;
|
|
293
|
+
let quote;
|
|
294
|
+
let escaped = false;
|
|
295
|
+
for (let i = 0; i < value.length; i++) {
|
|
296
|
+
const char = value[i];
|
|
297
|
+
if (escaped) {
|
|
298
|
+
escaped = false;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (char === "\\") {
|
|
302
|
+
escaped = true;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (quote) {
|
|
306
|
+
if (char === quote) quote = void 0;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (char === "\"" || char === "'") {
|
|
310
|
+
quote = char;
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (char === "(") {
|
|
314
|
+
depth++;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (char === ")") {
|
|
318
|
+
depth = Math.max(0, depth - 1);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (char === "," && depth === 0) {
|
|
322
|
+
parts.push(value.slice(start, i));
|
|
323
|
+
start = i + 1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
parts.push(value.slice(start));
|
|
327
|
+
return parts;
|
|
328
|
+
}
|
|
329
|
+
function isPreservedWebkitDeclaration(decl) {
|
|
330
|
+
const prop = decl.prop.toLowerCase();
|
|
331
|
+
if (prop.startsWith("-webkit-mask")) return true;
|
|
332
|
+
if (PRESERVED_WEBKIT_DECLARATION_PROPS.has(prop)) return true;
|
|
333
|
+
return PRESERVED_WEBKIT_VALUE_DECLARATIONS.get(prop)?.has(decl.value.trim().toLowerCase()) ?? false;
|
|
334
|
+
}
|
|
335
|
+
function normalizeTransitionValue(value) {
|
|
336
|
+
return splitTopLevelCommaList(value).map((part) => part.trim()).filter((part) => part.length > 0 && !part.toLowerCase().startsWith("-webkit-")).join(", ");
|
|
337
|
+
}
|
|
338
|
+
function hasUnsupportedWebkitKeywordValue(decl) {
|
|
339
|
+
const value = decl.value.trim().toLowerCase();
|
|
340
|
+
if (!value.startsWith("-webkit-")) return false;
|
|
341
|
+
if (PRESERVED_WEBKIT_VALUE_DECLARATIONS.get(decl.prop.toLowerCase())?.has(value)) return false;
|
|
342
|
+
return /^-webkit-[\w-]+$/.test(value);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* 收敛小程序 CSS 中的 WebKit 前缀,只保留 WXSS 里有实际价值的兼容写法。
|
|
346
|
+
*/
|
|
347
|
+
function normalizeMiniProgramPrefixedDeclaration(decl) {
|
|
348
|
+
const prop = decl.prop.toLowerCase();
|
|
349
|
+
if (TRANSITION_PROPS.has(prop) && decl.value.toLowerCase().includes("-webkit-")) {
|
|
350
|
+
const value = normalizeTransitionValue(decl.value);
|
|
351
|
+
if (value.length === 0) {
|
|
352
|
+
decl.remove();
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
decl.value = value;
|
|
356
|
+
}
|
|
357
|
+
if (prop.startsWith("-webkit-") && !isPreservedWebkitDeclaration(decl)) {
|
|
358
|
+
decl.remove();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (hasUnsupportedWebkitKeywordValue(decl)) decl.remove();
|
|
362
|
+
}
|
|
363
|
+
function removeUnsupportedMiniProgramPrefixedAtRule(atRule) {
|
|
364
|
+
if (atRule.name.toLowerCase() === "-webkit-keyframes") atRule.remove();
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
277
367
|
//#region src/compat/uni-app-x.ts
|
|
278
368
|
const UNI_APP_X_BASE_CARRIER_SELECTORS = new Set([
|
|
279
369
|
"*",
|
|
@@ -691,6 +781,13 @@ const WEAPP_AUTOPREFIXER_BROWSERS = [
|
|
|
691
781
|
"Android >= 4.4",
|
|
692
782
|
"ChromeAndroid >= 37"
|
|
693
783
|
];
|
|
784
|
+
const WEAPP_AUTOPREFIXER_DEFAULT_OPTIONS = {
|
|
785
|
+
add: true,
|
|
786
|
+
flexbox: false,
|
|
787
|
+
grid: false,
|
|
788
|
+
remove: true,
|
|
789
|
+
supports: false
|
|
790
|
+
};
|
|
694
791
|
const AUTOPREFIXER_PLUGIN_NAME = "autoprefixer";
|
|
695
792
|
function isAutoprefixerPlugin(plugin) {
|
|
696
793
|
return plugin?.postcssPlugin === AUTOPREFIXER_PLUGIN_NAME;
|
|
@@ -699,6 +796,7 @@ function resolveAutoprefixerPlugin(option) {
|
|
|
699
796
|
if (option === false) return;
|
|
700
797
|
const userOptions = option === true || option === void 0 ? {} : option;
|
|
701
798
|
return (0, autoprefixer.default)({
|
|
799
|
+
...WEAPP_AUTOPREFIXER_DEFAULT_OPTIONS,
|
|
702
800
|
...userOptions,
|
|
703
801
|
overrideBrowserslist: userOptions.overrideBrowserslist ?? WEAPP_AUTOPREFIXER_BROWSERS
|
|
704
802
|
});
|
|
@@ -1966,6 +2064,21 @@ const DEFAULT_ROOT_SELECTORS$1 = [
|
|
|
1966
2064
|
".tw-root",
|
|
1967
2065
|
"wx-root-portal-content"
|
|
1968
2066
|
];
|
|
2067
|
+
const LEGACY_FLEXBOX_DECLARATION_PROPS = new Set([
|
|
2068
|
+
"-webkit-align-content",
|
|
2069
|
+
"-webkit-align-items",
|
|
2070
|
+
"-webkit-align-self",
|
|
2071
|
+
"-webkit-flex",
|
|
2072
|
+
"-webkit-flex-basis",
|
|
2073
|
+
"-webkit-flex-direction",
|
|
2074
|
+
"-webkit-flex-flow",
|
|
2075
|
+
"-webkit-flex-grow",
|
|
2076
|
+
"-webkit-flex-shrink",
|
|
2077
|
+
"-webkit-flex-wrap",
|
|
2078
|
+
"-webkit-justify-content",
|
|
2079
|
+
"-webkit-order"
|
|
2080
|
+
]);
|
|
2081
|
+
const LEGACY_FLEXBOX_DISPLAY_VALUES = new Set(["-webkit-flex", "-webkit-inline-flex"]);
|
|
1969
2082
|
function normalizeRootSelectors(value) {
|
|
1970
2083
|
if (value === void 0 || value === false) return [];
|
|
1971
2084
|
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
@@ -1979,6 +2092,13 @@ function createHostSelectorAppender(options) {
|
|
|
1979
2092
|
return DEFAULT_ROOT_SELECTORS$1.every((selector) => selectors.includes(selector));
|
|
1980
2093
|
};
|
|
1981
2094
|
}
|
|
2095
|
+
function removeLegacyFlexboxPrefix(decl) {
|
|
2096
|
+
if (decl.prop === "display" && LEGACY_FLEXBOX_DISPLAY_VALUES.has(decl.value)) {
|
|
2097
|
+
decl.remove();
|
|
2098
|
+
return;
|
|
2099
|
+
}
|
|
2100
|
+
if (LEGACY_FLEXBOX_DECLARATION_PROPS.has(decl.prop)) decl.remove();
|
|
2101
|
+
}
|
|
1982
2102
|
const postcssWeappTailwindcssPostPlugin = (options) => {
|
|
1983
2103
|
const opts = (0, _weapp_tailwindcss_shared.defu)(options, { isMainChunk: true });
|
|
1984
2104
|
const p = { postcssPlugin };
|
|
@@ -2007,17 +2127,30 @@ const postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
2007
2127
|
if (opts.majorVersion === void 0) normalizeTailwindcssRpxDeclaration(decl);
|
|
2008
2128
|
else normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
|
|
2009
2129
|
if (enableMainChunkTransforms) normalizeTailwindcssV4Declaration(decl);
|
|
2130
|
+
removeLegacyFlexboxPrefix(decl);
|
|
2131
|
+
if (enableMainChunkTransforms) normalizeMiniProgramPrefixedDeclaration(decl);
|
|
2010
2132
|
};
|
|
2011
|
-
if (enableMainChunkTransforms)
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2133
|
+
if (enableMainChunkTransforms) {
|
|
2134
|
+
p.OnceExit = (root) => {
|
|
2135
|
+
root.walkDecls((decl) => {
|
|
2136
|
+
normalizeMiniProgramPrefixedDeclaration(decl);
|
|
2137
|
+
});
|
|
2138
|
+
root.walkAtRules((atRule) => {
|
|
2139
|
+
removeUnsupportedMiniProgramPrefixedAtRule(atRule);
|
|
2140
|
+
});
|
|
2141
|
+
};
|
|
2142
|
+
p.AtRuleExit = (atRule) => {
|
|
2143
|
+
removeUnsupportedMiniProgramPrefixedAtRule(atRule);
|
|
2144
|
+
/**
|
|
2145
|
+
* @description 移除 property
|
|
2146
|
+
*/
|
|
2147
|
+
if (opts.cssRemoveProperty && atRule.name === "property") atRule.remove();
|
|
2148
|
+
/**
|
|
2149
|
+
* 清除空节点
|
|
2150
|
+
*/
|
|
2151
|
+
atRule.nodes?.length === 0 && atRule.remove();
|
|
2152
|
+
};
|
|
2153
|
+
}
|
|
2021
2154
|
return p;
|
|
2022
2155
|
};
|
|
2023
2156
|
postcssWeappTailwindcssPostPlugin.postcss = true;
|
|
@@ -2464,7 +2597,7 @@ function shouldUseDefaultAutoprefixer(options, userPlugins) {
|
|
|
2464
2597
|
if (options.autoprefixer === false) return false;
|
|
2465
2598
|
if (hasUserAutoprefixerPlugin(options.postcssOptions?.plugins, userPlugins)) return false;
|
|
2466
2599
|
if (options.autoprefixer === true || typeof options.autoprefixer === "object") return true;
|
|
2467
|
-
return options.majorVersion === 4;
|
|
2600
|
+
return options.majorVersion === 3 || options.majorVersion === 4;
|
|
2468
2601
|
}
|
|
2469
2602
|
function createPreparedNodes(options, signal) {
|
|
2470
2603
|
const preparedNodes = [];
|
|
@@ -2732,6 +2865,8 @@ exports.createInjectPreflight = createInjectPreflight;
|
|
|
2732
2865
|
exports.createStyleHandler = createStyleHandler;
|
|
2733
2866
|
exports.createStylePipeline = createStylePipeline;
|
|
2734
2867
|
exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
|
|
2868
|
+
exports.normalizeMiniProgramPrefixedDeclaration = normalizeMiniProgramPrefixedDeclaration;
|
|
2735
2869
|
exports.normalizeModernColorValue = normalizeModernColorValue;
|
|
2736
2870
|
exports.postcssHtmlTransform = require_html_transform.postcssHtmlTransform;
|
|
2737
2871
|
exports.protectDynamicColorMixAlpha = protectDynamicColorMixAlpha;
|
|
2872
|
+
exports.removeUnsupportedMiniProgramPrefixedAtRule = removeUnsupportedMiniProgramPrefixedAtRule;
|
package/dist/index.mjs
CHANGED
|
@@ -264,6 +264,96 @@ function protectDynamicColorMixAlpha(css, options = {}) {
|
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
//#endregion
|
|
267
|
+
//#region src/compat/mini-program-prefixes.ts
|
|
268
|
+
const PRESERVED_WEBKIT_DECLARATION_PROPS = new Set([
|
|
269
|
+
"-webkit-box-orient",
|
|
270
|
+
"-webkit-line-clamp",
|
|
271
|
+
"-webkit-overflow-scrolling",
|
|
272
|
+
"-webkit-text-fill-color",
|
|
273
|
+
"-webkit-text-stroke",
|
|
274
|
+
"-webkit-text-stroke-color",
|
|
275
|
+
"-webkit-text-stroke-width"
|
|
276
|
+
]);
|
|
277
|
+
const PRESERVED_WEBKIT_VALUE_DECLARATIONS = new Map([["display", new Set(["-webkit-box"])], ["-webkit-background-clip", new Set(["text"])]]);
|
|
278
|
+
const TRANSITION_PROPS = new Set(["transition", "transition-property"]);
|
|
279
|
+
function splitTopLevelCommaList(value) {
|
|
280
|
+
const parts = [];
|
|
281
|
+
let start = 0;
|
|
282
|
+
let depth = 0;
|
|
283
|
+
let quote;
|
|
284
|
+
let escaped = false;
|
|
285
|
+
for (let i = 0; i < value.length; i++) {
|
|
286
|
+
const char = value[i];
|
|
287
|
+
if (escaped) {
|
|
288
|
+
escaped = false;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (char === "\\") {
|
|
292
|
+
escaped = true;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (quote) {
|
|
296
|
+
if (char === quote) quote = void 0;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (char === "\"" || char === "'") {
|
|
300
|
+
quote = char;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (char === "(") {
|
|
304
|
+
depth++;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (char === ")") {
|
|
308
|
+
depth = Math.max(0, depth - 1);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (char === "," && depth === 0) {
|
|
312
|
+
parts.push(value.slice(start, i));
|
|
313
|
+
start = i + 1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
parts.push(value.slice(start));
|
|
317
|
+
return parts;
|
|
318
|
+
}
|
|
319
|
+
function isPreservedWebkitDeclaration(decl) {
|
|
320
|
+
const prop = decl.prop.toLowerCase();
|
|
321
|
+
if (prop.startsWith("-webkit-mask")) return true;
|
|
322
|
+
if (PRESERVED_WEBKIT_DECLARATION_PROPS.has(prop)) return true;
|
|
323
|
+
return PRESERVED_WEBKIT_VALUE_DECLARATIONS.get(prop)?.has(decl.value.trim().toLowerCase()) ?? false;
|
|
324
|
+
}
|
|
325
|
+
function normalizeTransitionValue(value) {
|
|
326
|
+
return splitTopLevelCommaList(value).map((part) => part.trim()).filter((part) => part.length > 0 && !part.toLowerCase().startsWith("-webkit-")).join(", ");
|
|
327
|
+
}
|
|
328
|
+
function hasUnsupportedWebkitKeywordValue(decl) {
|
|
329
|
+
const value = decl.value.trim().toLowerCase();
|
|
330
|
+
if (!value.startsWith("-webkit-")) return false;
|
|
331
|
+
if (PRESERVED_WEBKIT_VALUE_DECLARATIONS.get(decl.prop.toLowerCase())?.has(value)) return false;
|
|
332
|
+
return /^-webkit-[\w-]+$/.test(value);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* 收敛小程序 CSS 中的 WebKit 前缀,只保留 WXSS 里有实际价值的兼容写法。
|
|
336
|
+
*/
|
|
337
|
+
function normalizeMiniProgramPrefixedDeclaration(decl) {
|
|
338
|
+
const prop = decl.prop.toLowerCase();
|
|
339
|
+
if (TRANSITION_PROPS.has(prop) && decl.value.toLowerCase().includes("-webkit-")) {
|
|
340
|
+
const value = normalizeTransitionValue(decl.value);
|
|
341
|
+
if (value.length === 0) {
|
|
342
|
+
decl.remove();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
decl.value = value;
|
|
346
|
+
}
|
|
347
|
+
if (prop.startsWith("-webkit-") && !isPreservedWebkitDeclaration(decl)) {
|
|
348
|
+
decl.remove();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (hasUnsupportedWebkitKeywordValue(decl)) decl.remove();
|
|
352
|
+
}
|
|
353
|
+
function removeUnsupportedMiniProgramPrefixedAtRule(atRule) {
|
|
354
|
+
if (atRule.name.toLowerCase() === "-webkit-keyframes") atRule.remove();
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
267
357
|
//#region src/compat/uni-app-x.ts
|
|
268
358
|
const UNI_APP_X_BASE_CARRIER_SELECTORS = new Set([
|
|
269
359
|
"*",
|
|
@@ -681,6 +771,13 @@ const WEAPP_AUTOPREFIXER_BROWSERS = [
|
|
|
681
771
|
"Android >= 4.4",
|
|
682
772
|
"ChromeAndroid >= 37"
|
|
683
773
|
];
|
|
774
|
+
const WEAPP_AUTOPREFIXER_DEFAULT_OPTIONS = {
|
|
775
|
+
add: true,
|
|
776
|
+
flexbox: false,
|
|
777
|
+
grid: false,
|
|
778
|
+
remove: true,
|
|
779
|
+
supports: false
|
|
780
|
+
};
|
|
684
781
|
const AUTOPREFIXER_PLUGIN_NAME = "autoprefixer";
|
|
685
782
|
function isAutoprefixerPlugin(plugin) {
|
|
686
783
|
return plugin?.postcssPlugin === AUTOPREFIXER_PLUGIN_NAME;
|
|
@@ -689,6 +786,7 @@ function resolveAutoprefixerPlugin(option) {
|
|
|
689
786
|
if (option === false) return;
|
|
690
787
|
const userOptions = option === true || option === void 0 ? {} : option;
|
|
691
788
|
return autoprefixerPlugin({
|
|
789
|
+
...WEAPP_AUTOPREFIXER_DEFAULT_OPTIONS,
|
|
692
790
|
...userOptions,
|
|
693
791
|
overrideBrowserslist: userOptions.overrideBrowserslist ?? WEAPP_AUTOPREFIXER_BROWSERS
|
|
694
792
|
});
|
|
@@ -1956,6 +2054,21 @@ const DEFAULT_ROOT_SELECTORS$1 = [
|
|
|
1956
2054
|
".tw-root",
|
|
1957
2055
|
"wx-root-portal-content"
|
|
1958
2056
|
];
|
|
2057
|
+
const LEGACY_FLEXBOX_DECLARATION_PROPS = new Set([
|
|
2058
|
+
"-webkit-align-content",
|
|
2059
|
+
"-webkit-align-items",
|
|
2060
|
+
"-webkit-align-self",
|
|
2061
|
+
"-webkit-flex",
|
|
2062
|
+
"-webkit-flex-basis",
|
|
2063
|
+
"-webkit-flex-direction",
|
|
2064
|
+
"-webkit-flex-flow",
|
|
2065
|
+
"-webkit-flex-grow",
|
|
2066
|
+
"-webkit-flex-shrink",
|
|
2067
|
+
"-webkit-flex-wrap",
|
|
2068
|
+
"-webkit-justify-content",
|
|
2069
|
+
"-webkit-order"
|
|
2070
|
+
]);
|
|
2071
|
+
const LEGACY_FLEXBOX_DISPLAY_VALUES = new Set(["-webkit-flex", "-webkit-inline-flex"]);
|
|
1959
2072
|
function normalizeRootSelectors(value) {
|
|
1960
2073
|
if (value === void 0 || value === false) return [];
|
|
1961
2074
|
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
@@ -1969,6 +2082,13 @@ function createHostSelectorAppender(options) {
|
|
|
1969
2082
|
return DEFAULT_ROOT_SELECTORS$1.every((selector) => selectors.includes(selector));
|
|
1970
2083
|
};
|
|
1971
2084
|
}
|
|
2085
|
+
function removeLegacyFlexboxPrefix(decl) {
|
|
2086
|
+
if (decl.prop === "display" && LEGACY_FLEXBOX_DISPLAY_VALUES.has(decl.value)) {
|
|
2087
|
+
decl.remove();
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2090
|
+
if (LEGACY_FLEXBOX_DECLARATION_PROPS.has(decl.prop)) decl.remove();
|
|
2091
|
+
}
|
|
1972
2092
|
const postcssWeappTailwindcssPostPlugin = (options) => {
|
|
1973
2093
|
const opts = defu(options, { isMainChunk: true });
|
|
1974
2094
|
const p = { postcssPlugin };
|
|
@@ -1997,17 +2117,30 @@ const postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1997
2117
|
if (opts.majorVersion === void 0) normalizeTailwindcssRpxDeclaration(decl);
|
|
1998
2118
|
else normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
|
|
1999
2119
|
if (enableMainChunkTransforms) normalizeTailwindcssV4Declaration(decl);
|
|
2120
|
+
removeLegacyFlexboxPrefix(decl);
|
|
2121
|
+
if (enableMainChunkTransforms) normalizeMiniProgramPrefixedDeclaration(decl);
|
|
2000
2122
|
};
|
|
2001
|
-
if (enableMainChunkTransforms)
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2123
|
+
if (enableMainChunkTransforms) {
|
|
2124
|
+
p.OnceExit = (root) => {
|
|
2125
|
+
root.walkDecls((decl) => {
|
|
2126
|
+
normalizeMiniProgramPrefixedDeclaration(decl);
|
|
2127
|
+
});
|
|
2128
|
+
root.walkAtRules((atRule) => {
|
|
2129
|
+
removeUnsupportedMiniProgramPrefixedAtRule(atRule);
|
|
2130
|
+
});
|
|
2131
|
+
};
|
|
2132
|
+
p.AtRuleExit = (atRule) => {
|
|
2133
|
+
removeUnsupportedMiniProgramPrefixedAtRule(atRule);
|
|
2134
|
+
/**
|
|
2135
|
+
* @description 移除 property
|
|
2136
|
+
*/
|
|
2137
|
+
if (opts.cssRemoveProperty && atRule.name === "property") atRule.remove();
|
|
2138
|
+
/**
|
|
2139
|
+
* 清除空节点
|
|
2140
|
+
*/
|
|
2141
|
+
atRule.nodes?.length === 0 && atRule.remove();
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2011
2144
|
return p;
|
|
2012
2145
|
};
|
|
2013
2146
|
postcssWeappTailwindcssPostPlugin.postcss = true;
|
|
@@ -2454,7 +2587,7 @@ function shouldUseDefaultAutoprefixer(options, userPlugins) {
|
|
|
2454
2587
|
if (options.autoprefixer === false) return false;
|
|
2455
2588
|
if (hasUserAutoprefixerPlugin(options.postcssOptions?.plugins, userPlugins)) return false;
|
|
2456
2589
|
if (options.autoprefixer === true || typeof options.autoprefixer === "object") return true;
|
|
2457
|
-
return options.majorVersion === 4;
|
|
2590
|
+
return options.majorVersion === 3 || options.majorVersion === 4;
|
|
2458
2591
|
}
|
|
2459
2592
|
function createPreparedNodes(options, signal) {
|
|
2460
2593
|
const preparedNodes = [];
|
|
@@ -2717,4 +2850,4 @@ function createStyleHandler(options) {
|
|
|
2717
2850
|
return handler;
|
|
2718
2851
|
}
|
|
2719
2852
|
//#endregion
|
|
2720
|
-
export { createFallbackPlaceholderReplacer, createInjectPreflight, createStyleHandler, createStylePipeline, internalCssSelectorReplacer, normalizeModernColorValue, postcssHtmlTransform, protectDynamicColorMixAlpha };
|
|
2853
|
+
export { createFallbackPlaceholderReplacer, createInjectPreflight, createStyleHandler, createStylePipeline, internalCssSelectorReplacer, normalizeMiniProgramPrefixedDeclaration, normalizeModernColorValue, postcssHtmlTransform, protectDynamicColorMixAlpha, removeUnsupportedMiniProgramPrefixedAtRule };
|