@weapp-tailwindcss/postcss 2.1.6 → 2.2.0-alpha.1
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/chunk-2DNJBRQ3.mjs +64 -0
- package/dist/chunk-2Y3ULRB3.js +64 -0
- package/dist/html-transform.js +4 -61
- package/dist/html-transform.mjs +3 -60
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +426 -84
- package/dist/index.mjs +382 -40
- package/dist/{types-CsRGpZ_r.d.mts → types-DiOShlJF.d.mts} +39 -4
- package/dist/{types-CsRGpZ_r.d.ts → types-DiOShlJF.d.ts} +39 -4
- package/dist/types.d.mts +3 -2
- package/dist/types.d.ts +3 -2
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
|
+
|
|
3
|
+
var _chunk2Y3ULRB3js = require('./chunk-2Y3ULRB3.js');
|
|
4
|
+
require('./chunk-GGNOJ77I.js');
|
|
2
5
|
|
|
3
6
|
// src/handler.ts
|
|
4
7
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
8
|
+
var _lrucache = require('lru-cache');
|
|
5
9
|
|
|
6
10
|
// src/compat/uni-app-x.ts
|
|
7
11
|
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
@@ -132,6 +136,145 @@ function shouldRemoveEmptyRuleForUniAppX(rule, options) {
|
|
|
132
136
|
return isUniAppXEnabled(options) && rule.nodes.length === 0;
|
|
133
137
|
}
|
|
134
138
|
|
|
139
|
+
// src/compat/uni-app-x-uvue.ts
|
|
140
|
+
var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
|
|
141
|
+
var ALLOWED_DISPLAY_VALUES = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
142
|
+
var FALLBACK_CLASS_RE = /\.((?:\\.|[\w-])+)/g;
|
|
143
|
+
var IMPORTANT_SUFFIX_RE = /\s*!important$/i;
|
|
144
|
+
function isUniAppXUvueTarget(options) {
|
|
145
|
+
return Boolean(_optionalChain([options, 'optionalAccess', _2 => _2.uniAppX])) && _optionalChain([options, 'optionalAccess', _3 => _3.uniAppXCssTarget]) === "uvue";
|
|
146
|
+
}
|
|
147
|
+
function normalizeUnsupportedMode(mode) {
|
|
148
|
+
return _nullishCoalesce(mode, () => ( "warn"));
|
|
149
|
+
}
|
|
150
|
+
function normalizeValue(value) {
|
|
151
|
+
return value.trim().toLowerCase().replace(IMPORTANT_SUFFIX_RE, "");
|
|
152
|
+
}
|
|
153
|
+
function getSourceFile(rule, result) {
|
|
154
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([rule, 'access', _4 => _4.source, 'optionalAccess', _5 => _5.input, 'access', _6 => _6.from]), () => ( result.opts.from)), () => ( "unknown source"));
|
|
155
|
+
}
|
|
156
|
+
function collectUtilityClassNames(rule) {
|
|
157
|
+
const classNames = /* @__PURE__ */ new Set();
|
|
158
|
+
for (const selector of _nullishCoalesce(rule.selectors, () => ( []))) {
|
|
159
|
+
try {
|
|
160
|
+
const ast = _postcssselectorparser2.default.call(void 0, ).astSync(selector);
|
|
161
|
+
ast.walkClasses((node) => {
|
|
162
|
+
if (node.value) {
|
|
163
|
+
classNames.add(node.value);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
} catch (e) {
|
|
167
|
+
for (const match of selector.matchAll(FALLBACK_CLASS_RE)) {
|
|
168
|
+
if (match[1]) {
|
|
169
|
+
classNames.add(match[1].replaceAll("\\", ""));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return [...classNames];
|
|
175
|
+
}
|
|
176
|
+
function hasOnlyClassSelectors(rule) {
|
|
177
|
+
const selectors = _nullishCoalesce(rule.selectors, () => ( []));
|
|
178
|
+
if (selectors.length === 0) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
return selectors.every((selector) => {
|
|
182
|
+
try {
|
|
183
|
+
const ast = _postcssselectorparser2.default.call(void 0, ).astSync(selector);
|
|
184
|
+
return ast.nodes.every((node) => node.nodes.length > 0 && node.nodes.every((child) => child.type === "class"));
|
|
185
|
+
} catch (e2) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function getUnsupportedDeclarationReason(prop, value) {
|
|
191
|
+
const normalizedProp = prop.trim().toLowerCase();
|
|
192
|
+
const normalizedValue = normalizeValue(value);
|
|
193
|
+
if (normalizedProp === "display" && !ALLOWED_DISPLAY_VALUES.has(normalizedValue)) {
|
|
194
|
+
return `${normalizedProp}: ${value}`;
|
|
195
|
+
}
|
|
196
|
+
if (normalizedProp === "min-height" && normalizedValue === "100vh") {
|
|
197
|
+
return `${normalizedProp}: ${value}`;
|
|
198
|
+
}
|
|
199
|
+
if (normalizedProp === "grid-template-columns" || normalizedProp === "grid-template-rows" || normalizedProp === "grid-auto-columns" || normalizedProp === "grid-auto-rows" || normalizedProp === "grid-auto-flow") {
|
|
200
|
+
return `${normalizedProp}: ${value}`;
|
|
201
|
+
}
|
|
202
|
+
if (normalizedProp === "gap" || normalizedProp === "row-gap" || normalizedProp === "column-gap") {
|
|
203
|
+
return `${normalizedProp}: ${value}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function reportUnsupportedRule(rule, result, mode, warningCache, reason) {
|
|
207
|
+
if (mode === "silent") {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const classNames = collectUtilityClassNames(rule);
|
|
211
|
+
const classLabel = classNames.length > 0 ? classNames.join(", ") : rule.selector;
|
|
212
|
+
const source = getSourceFile(rule, result);
|
|
213
|
+
const message = `uni-app x uvue unsupported utility: ${classLabel} (${reason}) in ${source}`;
|
|
214
|
+
if (mode === "error") {
|
|
215
|
+
throw rule.error(message);
|
|
216
|
+
}
|
|
217
|
+
if (warningCache.has(message)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
warningCache.add(message);
|
|
221
|
+
rule.warn(result, message);
|
|
222
|
+
}
|
|
223
|
+
function applyUniAppXUvueCompatibility(result, options) {
|
|
224
|
+
if (!isUniAppXUvueTarget(options)) {
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
const mode = normalizeUnsupportedMode(_optionalChain([options, 'optionalAccess', _7 => _7.uniAppXUnsupported]));
|
|
228
|
+
const warningCache = /* @__PURE__ */ new Set();
|
|
229
|
+
result.root.walkRules((rule) => {
|
|
230
|
+
if (!hasOnlyClassSelectors(rule)) {
|
|
231
|
+
reportUnsupportedRule(rule, result, mode, warningCache, "selector must be class-only");
|
|
232
|
+
rule.remove();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
rule.walkDecls((decl) => {
|
|
236
|
+
const reason = getUnsupportedDeclarationReason(decl.prop, decl.value);
|
|
237
|
+
if (!reason) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
reportUnsupportedRule(rule, result, mode, warningCache, reason);
|
|
241
|
+
decl.remove();
|
|
242
|
+
});
|
|
243
|
+
if ((_nullishCoalesce(_optionalChain([rule, 'access', _8 => _8.nodes, 'optionalAccess', _9 => _9.length]), () => ( 0))) === 0) {
|
|
244
|
+
rule.remove();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
result.root.walkAtRules((atRule) => {
|
|
248
|
+
if ((_nullishCoalesce(_optionalChain([atRule, 'access', _10 => _10.nodes, 'optionalAccess', _11 => _11.length]), () => ( 0))) === 0) {
|
|
249
|
+
atRule.remove();
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
const nextResult = result.root.toResult(result.opts);
|
|
253
|
+
nextResult.messages.push(...result.messages);
|
|
254
|
+
return nextResult;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// src/content-probe.ts
|
|
258
|
+
var EMPTY_SIGNAL = {
|
|
259
|
+
hasModernColorFunction: false,
|
|
260
|
+
hasPresetEnvFeatures: false
|
|
261
|
+
};
|
|
262
|
+
var MODERN_COLOR_RE = /rgb\w*\s*\([^),][^\s),]*\s[^),][^\s),]*\s[^),][^),/]*\/[^)]+\)/i;
|
|
263
|
+
function probeFeatures(css) {
|
|
264
|
+
if (!css) {
|
|
265
|
+
return { ...EMPTY_SIGNAL };
|
|
266
|
+
}
|
|
267
|
+
const hasModernColorFunction = MODERN_COLOR_RE.test(css);
|
|
268
|
+
const hasPresetEnvFeatures = true;
|
|
269
|
+
return {
|
|
270
|
+
hasModernColorFunction,
|
|
271
|
+
hasPresetEnvFeatures
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function signalToCacheKey(signal) {
|
|
275
|
+
return `signal:${signal.hasPresetEnvFeatures ? 1 : 0},${signal.hasModernColorFunction ? 1 : 0}`;
|
|
276
|
+
}
|
|
277
|
+
|
|
135
278
|
// src/defaults.ts
|
|
136
279
|
function getDefaultOptions(options) {
|
|
137
280
|
return {
|
|
@@ -144,9 +287,9 @@ function getDefaultOptions(options) {
|
|
|
144
287
|
},
|
|
145
288
|
"oklab-function": true,
|
|
146
289
|
"color-mix": true,
|
|
147
|
-
"color-functional-notation": _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
290
|
+
"color-functional-notation": _nullishCoalesce(_optionalChain([options, 'optionalAccess', _12 => _12.cssPresetEnv, 'optionalAccess', _13 => _13.features, 'optionalAccess', _14 => _14["color-functional-notation"]]), () => ( { preserve: false })),
|
|
148
291
|
// 在 calc 下,这个需要开启
|
|
149
|
-
"custom-properties": _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
292
|
+
"custom-properties": _nullishCoalesce(_optionalChain([options, 'optionalAccess', _15 => _15.cssPresetEnv, 'optionalAccess', _16 => _16.features, 'optionalAccess', _17 => _17["custom-properties"]]), () => ( _optionalChain([options, 'optionalAccess', _18 => _18.cssCalc]))) ? { preserve: true } : false
|
|
150
293
|
},
|
|
151
294
|
autoprefixer: {
|
|
152
295
|
add: false
|
|
@@ -154,6 +297,7 @@ function getDefaultOptions(options) {
|
|
|
154
297
|
},
|
|
155
298
|
// 支付宝小程序不支持,所以默认关闭
|
|
156
299
|
cssRemoveProperty: true,
|
|
300
|
+
uniAppXUnsupported: "warn",
|
|
157
301
|
// cssRemoveAtSupports: true,
|
|
158
302
|
// cssRemoveAtMedia: true,
|
|
159
303
|
cssSelectorReplacement: {
|
|
@@ -163,9 +307,6 @@ function getDefaultOptions(options) {
|
|
|
163
307
|
};
|
|
164
308
|
}
|
|
165
309
|
|
|
166
|
-
// src/options-resolver.ts
|
|
167
|
-
|
|
168
|
-
|
|
169
310
|
// src/fingerprint.ts
|
|
170
311
|
function fingerprintOptions(value, state = { map: /* @__PURE__ */ new WeakMap(), counter: 0 }) {
|
|
171
312
|
if (value === null || value === void 0) {
|
|
@@ -197,6 +338,7 @@ function fingerprintOptions(value, state = { map: /* @__PURE__ */ new WeakMap(),
|
|
|
197
338
|
}
|
|
198
339
|
|
|
199
340
|
// src/options-resolver.ts
|
|
341
|
+
|
|
200
342
|
var BASE_CACHE_KEY = "base";
|
|
201
343
|
var SIMPLE_OVERRIDE_UNSET = "__unset__";
|
|
202
344
|
function getSimpleOverrideCacheKey(options) {
|
|
@@ -213,6 +355,7 @@ function getSimpleOverrideCacheKey(options) {
|
|
|
213
355
|
let cssCalc = SIMPLE_OVERRIDE_UNSET;
|
|
214
356
|
let cssChildCombinatorReplaceValue = SIMPLE_OVERRIDE_UNSET;
|
|
215
357
|
let cssPreflight = SIMPLE_OVERRIDE_UNSET;
|
|
358
|
+
let autoprefixer = SIMPLE_OVERRIDE_UNSET;
|
|
216
359
|
for (const key of Object.keys(options)) {
|
|
217
360
|
const value = options[key];
|
|
218
361
|
switch (key) {
|
|
@@ -294,6 +437,12 @@ function getSimpleOverrideCacheKey(options) {
|
|
|
294
437
|
}
|
|
295
438
|
cssPreflight = "0";
|
|
296
439
|
break;
|
|
440
|
+
case "autoprefixer":
|
|
441
|
+
if (typeof value !== "boolean") {
|
|
442
|
+
return void 0;
|
|
443
|
+
}
|
|
444
|
+
autoprefixer = value ? "1" : "0";
|
|
445
|
+
break;
|
|
297
446
|
default:
|
|
298
447
|
return void 0;
|
|
299
448
|
}
|
|
@@ -312,7 +461,8 @@ function getSimpleOverrideCacheKey(options) {
|
|
|
312
461
|
unitsToPx,
|
|
313
462
|
cssCalc,
|
|
314
463
|
cssChildCombinatorReplaceValue,
|
|
315
|
-
cssPreflight
|
|
464
|
+
cssPreflight,
|
|
465
|
+
autoprefixer
|
|
316
466
|
].join(":");
|
|
317
467
|
}
|
|
318
468
|
function hasOverrides(options) {
|
|
@@ -387,6 +537,28 @@ function createInjectPreflight(options) {
|
|
|
387
537
|
// src/pipeline.ts
|
|
388
538
|
var _postcsspresetenv = require('postcss-preset-env'); var _postcsspresetenv2 = _interopRequireDefault(_postcsspresetenv);
|
|
389
539
|
|
|
540
|
+
// src/autoprefixer.ts
|
|
541
|
+
var _autoprefixer = require('autoprefixer'); var _autoprefixer2 = _interopRequireDefault(_autoprefixer);
|
|
542
|
+
var WEAPP_AUTOPREFIXER_BROWSERS = [
|
|
543
|
+
"iOS >= 8",
|
|
544
|
+
"Android >= 4.4",
|
|
545
|
+
"ChromeAndroid >= 37"
|
|
546
|
+
];
|
|
547
|
+
var AUTOPREFIXER_PLUGIN_NAME = "autoprefixer";
|
|
548
|
+
function isAutoprefixerPlugin(plugin) {
|
|
549
|
+
return _optionalChain([plugin, 'optionalAccess', _19 => _19.postcssPlugin]) === AUTOPREFIXER_PLUGIN_NAME;
|
|
550
|
+
}
|
|
551
|
+
function resolveAutoprefixerPlugin(option) {
|
|
552
|
+
if (option === false) {
|
|
553
|
+
return void 0;
|
|
554
|
+
}
|
|
555
|
+
const userOptions = option === true || option === void 0 ? {} : option;
|
|
556
|
+
return _autoprefixer2.default.call(void 0, {
|
|
557
|
+
...userOptions,
|
|
558
|
+
overrideBrowserslist: _nullishCoalesce(userOptions.overrideBrowserslist, () => ( WEAPP_AUTOPREFIXER_BROWSERS))
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
|
|
390
562
|
// src/plugins/colorFunctionalFallback.ts
|
|
391
563
|
var _postcssvalueparser = require('postcss-value-parser'); var _postcssvalueparser2 = _interopRequireDefault(_postcssvalueparser);
|
|
392
564
|
var RGB_FUNCTION_NAME = "rgb";
|
|
@@ -394,10 +566,10 @@ var isSlashDiv = (node) => node.type === "div" && node.value === "/";
|
|
|
394
566
|
function trimNodes(nodes2) {
|
|
395
567
|
let start = 0;
|
|
396
568
|
let end = nodes2.length;
|
|
397
|
-
while (start < end && _optionalChain([nodes2, 'access',
|
|
569
|
+
while (start < end && _optionalChain([nodes2, 'access', _20 => _20[start], 'optionalAccess', _21 => _21.type]) === "space") {
|
|
398
570
|
start += 1;
|
|
399
571
|
}
|
|
400
|
-
while (end > start && _optionalChain([nodes2, 'access',
|
|
572
|
+
while (end > start && _optionalChain([nodes2, 'access', _22 => _22[end - 1], 'optionalAccess', _23 => _23.type]) === "space") {
|
|
401
573
|
end -= 1;
|
|
402
574
|
}
|
|
403
575
|
return nodes2.slice(start, end);
|
|
@@ -532,7 +704,7 @@ function getCalcDuplicateCleaner(options) {
|
|
|
532
704
|
// src/plugins/getCalcPlugin.ts
|
|
533
705
|
var _postcsscalc = require('@weapp-tailwindcss/postcss-calc'); var _postcsscalc2 = _interopRequireDefault(_postcsscalc);
|
|
534
706
|
|
|
535
|
-
// ../../node_modules/.pnpm/es-toolkit@1.
|
|
707
|
+
// ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/object/omit.mjs
|
|
536
708
|
function omit(obj, keys) {
|
|
537
709
|
const result = { ...obj };
|
|
538
710
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -667,13 +839,52 @@ function getRemTransformPlugin(options) {
|
|
|
667
839
|
}
|
|
668
840
|
|
|
669
841
|
// src/plugins/getUnitsToPxPlugin.ts
|
|
670
|
-
var
|
|
842
|
+
var _postcssruleunitconverter = require('postcss-rule-unit-converter'); var _postcssruleunitconverter2 = _interopRequireDefault(_postcssruleunitconverter);
|
|
671
843
|
function getUnitsToPxPlugin(options) {
|
|
672
844
|
if (!options.unitsToPx) {
|
|
673
845
|
return null;
|
|
674
846
|
}
|
|
675
847
|
const userOptions = typeof options.unitsToPx === "object" ? options.unitsToPx : void 0;
|
|
676
|
-
|
|
848
|
+
if (_optionalChain([userOptions, 'optionalAccess', _24 => _24.disabled]) || _optionalChain([userOptions, 'optionalAccess', _25 => _25.transform]) === false) {
|
|
849
|
+
return _postcssruleunitconverter2.default.call(void 0, { disabled: true });
|
|
850
|
+
}
|
|
851
|
+
const presetOptions = {};
|
|
852
|
+
const converterOptions = {
|
|
853
|
+
rules: []
|
|
854
|
+
};
|
|
855
|
+
if (_optionalChain([userOptions, 'optionalAccess', _26 => _26.minValue]) !== void 0) {
|
|
856
|
+
presetOptions.minValue = userOptions.minValue;
|
|
857
|
+
converterOptions.minValue = userOptions.minValue;
|
|
858
|
+
}
|
|
859
|
+
if (_optionalChain([userOptions, 'optionalAccess', _27 => _27.to]) !== void 0) {
|
|
860
|
+
presetOptions.to = userOptions.to;
|
|
861
|
+
}
|
|
862
|
+
if (_optionalChain([userOptions, 'optionalAccess', _28 => _28.transform]) !== void 0) {
|
|
863
|
+
presetOptions.transform = userOptions.transform;
|
|
864
|
+
}
|
|
865
|
+
if (_optionalChain([userOptions, 'optionalAccess', _29 => _29.unitMap]) !== void 0) {
|
|
866
|
+
presetOptions.unitMap = userOptions.unitMap;
|
|
867
|
+
}
|
|
868
|
+
if (_optionalChain([userOptions, 'optionalAccess', _30 => _30.exclude]) !== void 0) {
|
|
869
|
+
converterOptions.exclude = userOptions.exclude;
|
|
870
|
+
}
|
|
871
|
+
if (_optionalChain([userOptions, 'optionalAccess', _31 => _31.mediaQuery]) !== void 0) {
|
|
872
|
+
converterOptions.mediaQuery = userOptions.mediaQuery;
|
|
873
|
+
}
|
|
874
|
+
if (_optionalChain([userOptions, 'optionalAccess', _32 => _32.propList]) !== void 0) {
|
|
875
|
+
converterOptions.propList = userOptions.propList;
|
|
876
|
+
}
|
|
877
|
+
if (_optionalChain([userOptions, 'optionalAccess', _33 => _33.replace]) !== void 0) {
|
|
878
|
+
converterOptions.replace = userOptions.replace;
|
|
879
|
+
}
|
|
880
|
+
if (_optionalChain([userOptions, 'optionalAccess', _34 => _34.selectorBlackList]) !== void 0) {
|
|
881
|
+
converterOptions.selectorBlackList = userOptions.selectorBlackList;
|
|
882
|
+
}
|
|
883
|
+
if (_optionalChain([userOptions, 'optionalAccess', _35 => _35.unitPrecision]) !== void 0) {
|
|
884
|
+
converterOptions.unitPrecision = userOptions.unitPrecision;
|
|
885
|
+
}
|
|
886
|
+
converterOptions.rules = _postcssruleunitconverter.presets.unitsToPx(presetOptions);
|
|
887
|
+
return _postcssruleunitconverter2.default.call(void 0, converterOptions);
|
|
677
888
|
}
|
|
678
889
|
|
|
679
890
|
// src/plugins/post.ts
|
|
@@ -682,7 +893,7 @@ function getUnitsToPxPlugin(options) {
|
|
|
682
893
|
// src/compat/tailwindcss-rpx.ts
|
|
683
894
|
var LENGTH_VALUE_REGEXP = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?rpx$/i;
|
|
684
895
|
function normalizeTailwindcssRpxDeclaration(decl, options) {
|
|
685
|
-
const majorVersion = _optionalChain([options, 'optionalAccess',
|
|
896
|
+
const majorVersion = _optionalChain([options, 'optionalAccess', _36 => _36.majorVersion]);
|
|
686
897
|
const normalizedValue = decl.value.trim();
|
|
687
898
|
if (LENGTH_VALUE_REGEXP.test(normalizedValue) && (majorVersion === void 0 || majorVersion === 2 || majorVersion === 3 || majorVersion === 4)) {
|
|
688
899
|
const lowerProp = decl.prop.toLowerCase();
|
|
@@ -869,7 +1080,7 @@ var MODERN_CHECK_COLOR_RGB_RE = /color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)
|
|
|
869
1080
|
var RADIUS_VALUE_RE = /\b([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)\s*(r?px)\b/gi;
|
|
870
1081
|
var SCIENTIFIC_NOTATION_RE = /e/i;
|
|
871
1082
|
function isTailwindcssV4(options) {
|
|
872
|
-
return _optionalChain([options, 'optionalAccess',
|
|
1083
|
+
return _optionalChain([options, 'optionalAccess', _37 => _37.majorVersion]) === 4;
|
|
873
1084
|
}
|
|
874
1085
|
function testIfRootHostForV4(node) {
|
|
875
1086
|
return node.type === "rule" && node.selector.includes(":root") && node.selector.includes(":host");
|
|
@@ -919,7 +1130,7 @@ function normalizeTailwindcssV4Declaration(decl) {
|
|
|
919
1130
|
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
920
1131
|
|
|
921
1132
|
// src/selectorParser/before-after.ts
|
|
922
|
-
|
|
1133
|
+
|
|
923
1134
|
var beforeAfterStateRef = null;
|
|
924
1135
|
var BEFORE_PSEUDO_RE = /^:?:before$/;
|
|
925
1136
|
var AFTER_PSEUDO_RE = /^:?:after$/;
|
|
@@ -929,7 +1140,7 @@ var beforeAfterParser = _postcssselectorparser2.default.call(void 0, (selectors)
|
|
|
929
1140
|
return;
|
|
930
1141
|
}
|
|
931
1142
|
selectors.walkPseudos((s) => {
|
|
932
|
-
if (_optionalChain([s, 'access',
|
|
1143
|
+
if (_optionalChain([s, 'access', _38 => _38.parent, 'optionalAccess', _39 => _39.length]) === 1) {
|
|
933
1144
|
if (BEFORE_PSEUDO_RE.test(s.value)) {
|
|
934
1145
|
state.before = true;
|
|
935
1146
|
}
|
|
@@ -1032,13 +1243,13 @@ function getFallbackRemove(_rule, options) {
|
|
|
1032
1243
|
maybeImportantId = true;
|
|
1033
1244
|
}
|
|
1034
1245
|
if (selector.type === "universal") {
|
|
1035
|
-
_optionalChain([selector, 'access',
|
|
1246
|
+
_optionalChain([selector, 'access', _40 => _40.parent, 'optionalAccess', _41 => _41.remove, 'call', _42 => _42()]);
|
|
1036
1247
|
} else if (selector.type === "pseudo") {
|
|
1037
1248
|
if (selector.value === ":is") {
|
|
1038
|
-
if (maybeImportantId && _optionalChain([selector, 'access',
|
|
1249
|
+
if (maybeImportantId && _optionalChain([selector, 'access', _43 => _43.nodes, 'access', _44 => _44[0], 'optionalAccess', _45 => _45.type]) === "selector") {
|
|
1039
1250
|
selector.replaceWith(selector.nodes[0]);
|
|
1040
1251
|
} else {
|
|
1041
|
-
_optionalChain([selector, 'access',
|
|
1252
|
+
_optionalChain([selector, 'access', _46 => _46.parent, 'optionalAccess', _47 => _47.remove, 'call', _48 => _48()]);
|
|
1042
1253
|
}
|
|
1043
1254
|
} else if (selector.value === ":not") {
|
|
1044
1255
|
for (const x of selector.nodes) {
|
|
@@ -1061,7 +1272,7 @@ function getFallbackRemove(_rule, options) {
|
|
|
1061
1272
|
}
|
|
1062
1273
|
} else if (selector.type === "attribute") {
|
|
1063
1274
|
if (selector.attribute === "hidden") {
|
|
1064
|
-
_optionalChain([activeRule, 'optionalAccess',
|
|
1275
|
+
_optionalChain([activeRule, 'optionalAccess', _49 => _49.remove, 'call', _50 => _50()]);
|
|
1065
1276
|
}
|
|
1066
1277
|
}
|
|
1067
1278
|
});
|
|
@@ -1147,7 +1358,7 @@ function getEscapeOptions(escapeMap) {
|
|
|
1147
1358
|
return cached;
|
|
1148
1359
|
}
|
|
1149
1360
|
function internalCssSelectorReplacer(selectors, options) {
|
|
1150
|
-
const escapeMap = _optionalChain([options, 'optionalAccess',
|
|
1361
|
+
const escapeMap = _optionalChain([options, 'optionalAccess', _51 => _51.escapeMap]);
|
|
1151
1362
|
if (escapeMap === void 0 || escapeMap === _escape.MappingChars2String) {
|
|
1152
1363
|
return _escape.escape.call(void 0, selectors);
|
|
1153
1364
|
}
|
|
@@ -1191,7 +1402,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
|
|
|
1191
1402
|
if (alreadyOrdered) {
|
|
1192
1403
|
return;
|
|
1193
1404
|
}
|
|
1194
|
-
const anchor = _nullishCoalesce(_optionalChain([declarations, 'access',
|
|
1405
|
+
const anchor = _nullishCoalesce(_optionalChain([declarations, 'access', _52 => _52.at, 'call', _53 => _53(-1), 'optionalAccess', _54 => _54.next, 'call', _55 => _55()]), () => ( void 0));
|
|
1195
1406
|
for (const decl of declarations) {
|
|
1196
1407
|
decl.remove();
|
|
1197
1408
|
}
|
|
@@ -1269,7 +1480,7 @@ function isNotLastChildPseudo(node) {
|
|
|
1269
1480
|
if (!firstSelector || firstSelector.type !== "selector") {
|
|
1270
1481
|
return false;
|
|
1271
1482
|
}
|
|
1272
|
-
const target = _optionalChain([firstSelector, 'access',
|
|
1483
|
+
const target = _optionalChain([firstSelector, 'access', _56 => _56.nodes, 'optionalAccess', _57 => _57[0]]);
|
|
1273
1484
|
return Boolean(target && target.type === "pseudo" && target.value === ":last-child");
|
|
1274
1485
|
}
|
|
1275
1486
|
function transformSpacingSelector(nodes2, options) {
|
|
@@ -1381,7 +1592,7 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
1381
1592
|
node.value = ":is";
|
|
1382
1593
|
}
|
|
1383
1594
|
if (index === 0 && node.length === 1) {
|
|
1384
|
-
const targetSelector = _optionalChain([node, 'access',
|
|
1595
|
+
const targetSelector = _optionalChain([node, 'access', _58 => _58.nodes, 'optionalAccess', _59 => _59[0]]);
|
|
1385
1596
|
if (targetSelector && targetSelector.type === "selector" && transformSpacingSelector(targetSelector.nodes, context.options)) {
|
|
1386
1597
|
context.requiresSpacingNormalization = true;
|
|
1387
1598
|
}
|
|
@@ -1449,7 +1660,7 @@ function handleCombinatorNode(node, index, context) {
|
|
|
1449
1660
|
if (node.type !== "combinator" || node.value !== ">") {
|
|
1450
1661
|
return;
|
|
1451
1662
|
}
|
|
1452
|
-
const nodes2 = _optionalChain([node, 'access',
|
|
1663
|
+
const nodes2 = _optionalChain([node, 'access', _60 => _60.parent, 'optionalAccess', _61 => _61.nodes]);
|
|
1453
1664
|
if (!nodes2) {
|
|
1454
1665
|
return;
|
|
1455
1666
|
}
|
|
@@ -1502,7 +1713,7 @@ function canSkipRuleTransform(rule) {
|
|
|
1502
1713
|
}
|
|
1503
1714
|
function transformSelectors(selectors, context) {
|
|
1504
1715
|
selectors.walk((node, index) => {
|
|
1505
|
-
const parent = _optionalChain([node, 'access',
|
|
1716
|
+
const parent = _optionalChain([node, 'access', _62 => _62.parent, 'optionalAccess', _63 => _63.type]) === "selector" ? node.parent : void 0;
|
|
1506
1717
|
switch (node.type) {
|
|
1507
1718
|
case "class":
|
|
1508
1719
|
handleClassNode(node, context);
|
|
@@ -1549,8 +1760,8 @@ function createRuleTransformer(options) {
|
|
|
1549
1760
|
let context;
|
|
1550
1761
|
const selectorResultCache = /* @__PURE__ */ new Map();
|
|
1551
1762
|
const selectorResultCacheLimit = 5e4;
|
|
1552
|
-
const rootReplacement = _optionalChain([options, 'access',
|
|
1553
|
-
const universalReplacement = _optionalChain([options, 'access',
|
|
1763
|
+
const rootReplacement = _optionalChain([options, 'access', _64 => _64.cssSelectorReplacement, 'optionalAccess', _65 => _65.root]) ? composeIsPseudo(options.cssSelectorReplacement.root) : void 0;
|
|
1764
|
+
const universalReplacement = _optionalChain([options, 'access', _66 => _66.cssSelectorReplacement, 'optionalAccess', _67 => _67.universal]) ? composeIsPseudo(options.cssSelectorReplacement.universal) : void 0;
|
|
1554
1765
|
const selectorReplacerOptions = options.escapeMap ? { escapeMap: options.escapeMap } : void 0;
|
|
1555
1766
|
function writeSelectorResultCache(selector, result) {
|
|
1556
1767
|
if (selectorResultCache.size >= selectorResultCacheLimit) {
|
|
@@ -1598,7 +1809,7 @@ function createRuleTransformer(options) {
|
|
|
1598
1809
|
} finally {
|
|
1599
1810
|
const currentContext = context;
|
|
1600
1811
|
wasRemoved = rule.parent == null;
|
|
1601
|
-
requiresSpacingNormalization = _optionalChain([currentContext, 'optionalAccess',
|
|
1812
|
+
requiresSpacingNormalization = _optionalChain([currentContext, 'optionalAccess', _68 => _68.requiresSpacingNormalization]) === true;
|
|
1602
1813
|
context = void 0;
|
|
1603
1814
|
}
|
|
1604
1815
|
if (wasRemoved) {
|
|
@@ -1822,6 +2033,7 @@ function dedupeDeclarations(rule) {
|
|
|
1822
2033
|
}
|
|
1823
2034
|
|
|
1824
2035
|
// src/plugins/post/specificity-cleaner.ts
|
|
2036
|
+
var FALLBACK_PLACEHOLDER_SUFFIXES = [":not(#n)", ":not(#\\#)"];
|
|
1825
2037
|
function normalizeSelectorList(value) {
|
|
1826
2038
|
if (value === void 0 || value === false) {
|
|
1827
2039
|
return [];
|
|
@@ -1829,21 +2041,60 @@ function normalizeSelectorList(value) {
|
|
|
1829
2041
|
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1830
2042
|
}
|
|
1831
2043
|
function getSpecificityMatchingName(options) {
|
|
1832
|
-
const feature = _optionalChain([options, 'access',
|
|
2044
|
+
const feature = _optionalChain([options, 'access', _69 => _69.cssPresetEnv, 'optionalAccess', _70 => _70.features, 'optionalAccess', _71 => _71["is-pseudo-class"]]);
|
|
1833
2045
|
if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
|
|
1834
2046
|
const specificityName = feature.specificityMatchingName;
|
|
1835
2047
|
return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
|
|
1836
2048
|
}
|
|
1837
2049
|
return void 0;
|
|
1838
2050
|
}
|
|
2051
|
+
function replaceFallbackPlaceholder(selector) {
|
|
2052
|
+
let output = selector;
|
|
2053
|
+
for (const suffix of FALLBACK_PLACEHOLDER_SUFFIXES) {
|
|
2054
|
+
if (output.includes(suffix)) {
|
|
2055
|
+
output = output.split(suffix).join("");
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
return output;
|
|
2059
|
+
}
|
|
2060
|
+
function createFallbackPlaceholderReplacer() {
|
|
2061
|
+
return (code) => {
|
|
2062
|
+
let output = code;
|
|
2063
|
+
for (const suffix of FALLBACK_PLACEHOLDER_SUFFIXES) {
|
|
2064
|
+
if (output.includes(suffix)) {
|
|
2065
|
+
output = output.split(suffix).join("");
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
return output;
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
function createFallbackPlaceholderCleaner() {
|
|
2072
|
+
return (rule) => {
|
|
2073
|
+
if (!rule.selectors || rule.selectors.length === 0) {
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
let changed = false;
|
|
2077
|
+
const next = rule.selectors.map((selector) => {
|
|
2078
|
+
const updated = replaceFallbackPlaceholder(selector);
|
|
2079
|
+
if (updated !== selector) {
|
|
2080
|
+
changed = true;
|
|
2081
|
+
}
|
|
2082
|
+
return updated;
|
|
2083
|
+
});
|
|
2084
|
+
changed && assignRuleSelectors(rule, next, {
|
|
2085
|
+
phase: "post",
|
|
2086
|
+
reason: "clean-fallback-placeholder"
|
|
2087
|
+
});
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
1839
2090
|
function createRootSpecificityCleaner(options) {
|
|
1840
2091
|
const specificityMatchingName = getSpecificityMatchingName(options);
|
|
1841
|
-
const selectors = normalizeSelectorList(_optionalChain([options, 'access',
|
|
2092
|
+
const selectors = normalizeSelectorList(_optionalChain([options, 'access', _72 => _72.cssSelectorReplacement, 'optionalAccess', _73 => _73.root]));
|
|
1842
2093
|
if (!specificityMatchingName || selectors.length === 0) {
|
|
1843
2094
|
return void 0;
|
|
1844
2095
|
}
|
|
1845
2096
|
const suffix = `:not(.${specificityMatchingName})`;
|
|
1846
|
-
const targets = selectors.map((selector) => _optionalChain([selector, 'optionalAccess',
|
|
2097
|
+
const targets = selectors.map((selector) => _optionalChain([selector, 'optionalAccess', _74 => _74.trim, 'call', _75 => _75()])).filter((selector) => Boolean(_optionalChain([selector, 'optionalAccess', _76 => _76.length]))).map((selector) => ({
|
|
1847
2098
|
match: `${selector}${suffix}`,
|
|
1848
2099
|
spacedMatch: `${selector} ${suffix}`,
|
|
1849
2100
|
replacement: selector
|
|
@@ -1887,7 +2138,7 @@ function normalizeRootSelectors(value) {
|
|
|
1887
2138
|
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1888
2139
|
}
|
|
1889
2140
|
function createHostSelectorAppender(options) {
|
|
1890
|
-
const rootSelectors = normalizeRootSelectors(_optionalChain([options, 'access',
|
|
2141
|
+
const rootSelectors = normalizeRootSelectors(_optionalChain([options, 'access', _77 => _77.cssSelectorReplacement, 'optionalAccess', _78 => _78.root]));
|
|
1891
2142
|
const shouldAppendHostSelector = rootSelectors.length === DEFAULT_ROOT_SELECTORS.length && rootSelectors.every((selector, index) => selector === DEFAULT_ROOT_SELECTORS[index]);
|
|
1892
2143
|
if (!shouldAppendHostSelector) {
|
|
1893
2144
|
return void 0;
|
|
@@ -1908,17 +2159,19 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1908
2159
|
postcssPlugin
|
|
1909
2160
|
};
|
|
1910
2161
|
const cleanRootSpecificity = createRootSpecificityCleaner(opts);
|
|
2162
|
+
const cleanFallbackPlaceholder = createFallbackPlaceholderCleaner();
|
|
1911
2163
|
const shouldAppendHostSelector = createHostSelectorAppender(opts);
|
|
1912
2164
|
const enableMainChunkTransforms = opts.isMainChunk !== false;
|
|
1913
2165
|
if (enableMainChunkTransforms || cleanRootSpecificity) {
|
|
1914
2166
|
const fallbackRemove = enableMainChunkTransforms ? getFallbackRemove(void 0, opts) : void 0;
|
|
1915
2167
|
p.RuleExit = (rule) => {
|
|
1916
2168
|
if (enableMainChunkTransforms) {
|
|
1917
|
-
_optionalChain([fallbackRemove, 'optionalAccess',
|
|
2169
|
+
_optionalChain([fallbackRemove, 'optionalAccess', _79 => _79.transformSync, 'call', _80 => _80(rule)]);
|
|
1918
2170
|
}
|
|
1919
|
-
|
|
2171
|
+
cleanFallbackPlaceholder(rule);
|
|
2172
|
+
_optionalChain([cleanRootSpecificity, 'optionalCall', _81 => _81(rule)]);
|
|
1920
2173
|
if (enableMainChunkTransforms) {
|
|
1921
|
-
if (_optionalChain([shouldAppendHostSelector, 'optionalCall',
|
|
2174
|
+
if (_optionalChain([shouldAppendHostSelector, 'optionalCall', _82 => _82(rule)])) {
|
|
1922
2175
|
appendRuleSelector(rule, ":host", {
|
|
1923
2176
|
phase: "post",
|
|
1924
2177
|
reason: "append-host-selector"
|
|
@@ -1947,7 +2200,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1947
2200
|
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
1948
2201
|
atRule.remove();
|
|
1949
2202
|
}
|
|
1950
|
-
_optionalChain([atRule, 'access',
|
|
2203
|
+
_optionalChain([atRule, 'access', _83 => _83.nodes, 'optionalAccess', _84 => _84.length]) === 0 && atRule.remove();
|
|
1951
2204
|
};
|
|
1952
2205
|
}
|
|
1953
2206
|
return p;
|
|
@@ -2229,7 +2482,7 @@ function remakeCssVarSelector(selectors, options) {
|
|
|
2229
2482
|
return selectors;
|
|
2230
2483
|
}
|
|
2231
2484
|
function resolveUniAppXVariableScopeSelectors(options) {
|
|
2232
|
-
const universal = _optionalChain([options, 'access',
|
|
2485
|
+
const universal = _optionalChain([options, 'access', _85 => _85.cssSelectorReplacement, 'optionalAccess', _86 => _86.universal]);
|
|
2233
2486
|
if (Array.isArray(universal) && universal.length > 0) {
|
|
2234
2487
|
return [...universal];
|
|
2235
2488
|
}
|
|
@@ -2241,7 +2494,7 @@ function resolveUniAppXVariableScopeSelectors(options) {
|
|
|
2241
2494
|
function commonChunkPreflight(node, options) {
|
|
2242
2495
|
const { ctx, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
2243
2496
|
const uniAppXEnabled = isUniAppXEnabled(options);
|
|
2244
|
-
const rootOption = _optionalChain([options, 'access',
|
|
2497
|
+
const rootOption = _optionalChain([options, 'access', _87 => _87.cssSelectorReplacement, 'optionalAccess', _88 => _88.root]);
|
|
2245
2498
|
const rootSelectors = rootOption === false || rootOption === void 0 ? [] : Array.isArray(rootOption) ? rootOption.filter(Boolean) : [rootOption];
|
|
2246
2499
|
const hasHostSelector = node.selectors.some((selector) => selector.includes(":host"));
|
|
2247
2500
|
const hasRootPseudoSelector = node.selectors.some((selector) => selector.includes(":root"));
|
|
@@ -2253,7 +2506,7 @@ function commonChunkPreflight(node, options) {
|
|
|
2253
2506
|
});
|
|
2254
2507
|
}
|
|
2255
2508
|
if (testIfVariablesScope(node) || uniAppXEnabled && node.selectors.includes("*") && hasTwVars(node, 2)) {
|
|
2256
|
-
_optionalChain([ctx, 'optionalAccess',
|
|
2509
|
+
_optionalChain([ctx, 'optionalAccess', _89 => _89.markVariablesScope, 'call', _90 => _90(node)]);
|
|
2257
2510
|
assignRuleSelectors(node, uniAppXEnabled ? resolveUniAppXVariableScopeSelectors(options) : remakeCssVarSelector(node.selectors, options), {
|
|
2258
2511
|
phase: "pre",
|
|
2259
2512
|
reason: "rewrite-variable-scope"
|
|
@@ -2325,9 +2578,9 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
2325
2578
|
root.walkAtRules((atRule) => {
|
|
2326
2579
|
if (atRule.name === "layer") {
|
|
2327
2580
|
if (atRule.params === "properties") {
|
|
2328
|
-
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access',
|
|
2581
|
+
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _91 => _91.nodes, 'optionalAccess', _92 => _92.length]) === 0) {
|
|
2329
2582
|
layerProperties = atRule;
|
|
2330
|
-
} else if (_optionalChain([atRule, 'access',
|
|
2583
|
+
} else if (_optionalChain([atRule, 'access', _93 => _93.first, 'optionalAccess', _94 => _94.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
|
|
2331
2584
|
if (layerProperties) {
|
|
2332
2585
|
layerProperties.replaceWith(atRule.first.nodes);
|
|
2333
2586
|
atRule.remove();
|
|
@@ -2339,7 +2592,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
2339
2592
|
atRule.replaceWith(atRule.nodes);
|
|
2340
2593
|
}
|
|
2341
2594
|
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
2342
|
-
if (_optionalChain([atRule, 'access',
|
|
2595
|
+
if (_optionalChain([atRule, 'access', _95 => _95.first, 'optionalAccess', _96 => _96.type]) === "atrule" && atRule.first.name === "layer") {
|
|
2343
2596
|
atRule.replaceWith(atRule.first.nodes);
|
|
2344
2597
|
}
|
|
2345
2598
|
}
|
|
@@ -2373,16 +2626,42 @@ function createPreparedNode(id, stage, createPlugin) {
|
|
|
2373
2626
|
createPlugin
|
|
2374
2627
|
};
|
|
2375
2628
|
}
|
|
2376
|
-
function
|
|
2629
|
+
function hasUserAutoprefixerPlugin(rawPlugins, plugins) {
|
|
2630
|
+
if (plugins.some((plugin) => isAutoprefixerPlugin(plugin))) {
|
|
2631
|
+
return true;
|
|
2632
|
+
}
|
|
2633
|
+
if (rawPlugins && !Array.isArray(rawPlugins) && typeof rawPlugins === "object") {
|
|
2634
|
+
const autoprefixerEntry = rawPlugins["autoprefixer"];
|
|
2635
|
+
return Boolean(autoprefixerEntry);
|
|
2636
|
+
}
|
|
2637
|
+
return false;
|
|
2638
|
+
}
|
|
2639
|
+
function shouldUseDefaultAutoprefixer(options, userPlugins) {
|
|
2640
|
+
if (options.autoprefixer === false) {
|
|
2641
|
+
return false;
|
|
2642
|
+
}
|
|
2643
|
+
if (hasUserAutoprefixerPlugin(_optionalChain([options, 'access', _97 => _97.postcssOptions, 'optionalAccess', _98 => _98.plugins]), userPlugins)) {
|
|
2644
|
+
return false;
|
|
2645
|
+
}
|
|
2646
|
+
if (options.autoprefixer === true || typeof options.autoprefixer === "object") {
|
|
2647
|
+
return true;
|
|
2648
|
+
}
|
|
2649
|
+
return options.majorVersion === 4;
|
|
2650
|
+
}
|
|
2651
|
+
function createPreparedNodes(options, signal) {
|
|
2377
2652
|
const preparedNodes = [];
|
|
2378
|
-
const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access',
|
|
2653
|
+
const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access', _99 => _99.postcssOptions, 'optionalAccess', _100 => _100.plugins]));
|
|
2379
2654
|
const presetEnvOptions = options.cssPresetEnv;
|
|
2380
2655
|
userPlugins.forEach((plugin, index) => {
|
|
2381
2656
|
preparedNodes.push(createPreparedNode(`pre:user-${index}`, "pre", () => plugin));
|
|
2382
2657
|
});
|
|
2383
2658
|
preparedNodes.push(createPreparedNode("pre:core", "pre", () => postcssWeappTailwindcssPrePlugin(options)));
|
|
2384
|
-
|
|
2385
|
-
|
|
2659
|
+
if (!signal || signal.hasPresetEnvFeatures) {
|
|
2660
|
+
preparedNodes.push(createPreparedNode("normal:preset-env", "normal", () => _postcsspresetenv2.default.call(void 0, presetEnvOptions)));
|
|
2661
|
+
}
|
|
2662
|
+
if (!signal || signal.hasModernColorFunction) {
|
|
2663
|
+
preparedNodes.push(createPreparedNode("normal:color-functional-fallback", "normal", () => createColorFunctionalFallback()));
|
|
2664
|
+
}
|
|
2386
2665
|
const unitsToPxPlugin = getUnitsToPxPlugin(options);
|
|
2387
2666
|
if (unitsToPxPlugin) {
|
|
2388
2667
|
preparedNodes.push(createPreparedNode("normal:units-to-px", "normal", () => unitsToPxPlugin));
|
|
@@ -2407,12 +2686,18 @@ function createPreparedNodes(options) {
|
|
|
2407
2686
|
if (customPropertyCleaner) {
|
|
2408
2687
|
preparedNodes.push(createPreparedNode("normal:custom-property-cleaner", "normal", () => customPropertyCleaner));
|
|
2409
2688
|
}
|
|
2689
|
+
if (shouldUseDefaultAutoprefixer(options, userPlugins)) {
|
|
2690
|
+
const plugin = resolveAutoprefixerPlugin(options.autoprefixer);
|
|
2691
|
+
if (plugin) {
|
|
2692
|
+
preparedNodes.push(createPreparedNode("normal:autoprefixer", "normal", () => plugin));
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2410
2695
|
preparedNodes.push(createPreparedNode("post:core", "post", () => postcssWeappTailwindcssPostPlugin(options)));
|
|
2411
2696
|
return preparedNodes;
|
|
2412
2697
|
}
|
|
2413
|
-
function createStylePipeline(options) {
|
|
2698
|
+
function createStylePipeline(options, signal) {
|
|
2414
2699
|
options.ctx = createContext();
|
|
2415
|
-
const preparedNodes = createPreparedNodes(options);
|
|
2700
|
+
const preparedNodes = createPreparedNodes(options, signal);
|
|
2416
2701
|
if (preparedNodes.length === 0) {
|
|
2417
2702
|
return {
|
|
2418
2703
|
nodes: [],
|
|
@@ -2471,7 +2756,7 @@ function createStylePipeline(options) {
|
|
|
2471
2756
|
function createProcessOptions(options) {
|
|
2472
2757
|
return {
|
|
2473
2758
|
from: void 0,
|
|
2474
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
2759
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _101 => _101.postcssOptions, 'optionalAccess', _102 => _102.options]), () => ( {}))
|
|
2475
2760
|
};
|
|
2476
2761
|
}
|
|
2477
2762
|
function getSimpleProcessOptionsCacheKey(options) {
|
|
@@ -2503,14 +2788,13 @@ function getSimpleProcessOptionsCacheKey(options) {
|
|
|
2503
2788
|
}
|
|
2504
2789
|
return parts.join("|");
|
|
2505
2790
|
}
|
|
2506
|
-
var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
2507
|
-
__init() {this.
|
|
2791
|
+
var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this); }
|
|
2792
|
+
__init() {this.pipelineCacheByKey = /* @__PURE__ */ new Map()}
|
|
2508
2793
|
__init2() {this.processOptionsCache = /* @__PURE__ */ new WeakMap()}
|
|
2509
|
-
__init3() {this.
|
|
2510
|
-
__init4() {this.
|
|
2511
|
-
__init5() {this.processorKeyCache = /* @__PURE__ */ new WeakMap()}
|
|
2794
|
+
__init3() {this.processorCacheByKey = /* @__PURE__ */ new Map()}
|
|
2795
|
+
__init4() {this.processorKeyCache = /* @__PURE__ */ new WeakMap()}
|
|
2512
2796
|
createProcessorCacheKey(options) {
|
|
2513
|
-
const from = _optionalChain([options, 'access',
|
|
2797
|
+
const from = _optionalChain([options, 'access', _103 => _103.postcssOptions, 'optionalAccess', _104 => _104.options, 'optionalAccess', _105 => _105.from]);
|
|
2514
2798
|
if (from == null) {
|
|
2515
2799
|
return fingerprintOptions(options);
|
|
2516
2800
|
}
|
|
@@ -2519,22 +2803,37 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
|
|
|
2519
2803
|
postcssOptions: {
|
|
2520
2804
|
..._nullishCoalesce(options.postcssOptions, () => ( {})),
|
|
2521
2805
|
options: {
|
|
2522
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
2806
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _106 => _106.postcssOptions, 'optionalAccess', _107 => _107.options]), () => ( {})),
|
|
2523
2807
|
from: void 0
|
|
2524
2808
|
}
|
|
2525
2809
|
}
|
|
2526
2810
|
});
|
|
2527
2811
|
}
|
|
2528
|
-
|
|
2529
|
-
|
|
2812
|
+
/**
|
|
2813
|
+
* 构建包含信号的复合缓存键
|
|
2814
|
+
*/
|
|
2815
|
+
createCompositeCacheKey(optionsFingerprint, signal) {
|
|
2816
|
+
if (!signal) {
|
|
2817
|
+
return optionsFingerprint;
|
|
2818
|
+
}
|
|
2819
|
+
return `${optionsFingerprint}|${signalToCacheKey(signal)}`;
|
|
2820
|
+
}
|
|
2821
|
+
getPipeline(options, signal) {
|
|
2822
|
+
let optionsKey = this.processorKeyCache.get(options);
|
|
2823
|
+
if (!optionsKey) {
|
|
2824
|
+
optionsKey = this.createProcessorCacheKey(options);
|
|
2825
|
+
this.processorKeyCache.set(options, optionsKey);
|
|
2826
|
+
}
|
|
2827
|
+
const compositeKey = this.createCompositeCacheKey(optionsKey, signal);
|
|
2828
|
+
let pipeline = this.pipelineCacheByKey.get(compositeKey);
|
|
2530
2829
|
if (!pipeline) {
|
|
2531
|
-
pipeline = createStylePipeline(options);
|
|
2532
|
-
this.
|
|
2830
|
+
pipeline = createStylePipeline(options, signal);
|
|
2831
|
+
this.pipelineCacheByKey.set(compositeKey, pipeline);
|
|
2533
2832
|
}
|
|
2534
2833
|
return pipeline;
|
|
2535
2834
|
}
|
|
2536
2835
|
getProcessOptions(options) {
|
|
2537
|
-
const source = _optionalChain([options, 'access',
|
|
2836
|
+
const source = _optionalChain([options, 'access', _108 => _108.postcssOptions, 'optionalAccess', _109 => _109.options]);
|
|
2538
2837
|
const cacheKey = source ? _nullishCoalesce(getSimpleProcessOptionsCacheKey(source), () => ( fingerprintOptions(source))) : void 0;
|
|
2539
2838
|
const cached = this.processOptionsCache.get(options);
|
|
2540
2839
|
if (!cached || cached.cacheKey !== cacheKey) {
|
|
@@ -2544,27 +2843,33 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
|
|
|
2544
2843
|
}
|
|
2545
2844
|
return { ...cached.value };
|
|
2546
2845
|
}
|
|
2547
|
-
getProcessor(options) {
|
|
2548
|
-
let
|
|
2846
|
+
getProcessor(options, signal) {
|
|
2847
|
+
let optionsKey = this.processorKeyCache.get(options);
|
|
2848
|
+
if (!optionsKey) {
|
|
2849
|
+
optionsKey = this.createProcessorCacheKey(options);
|
|
2850
|
+
this.processorKeyCache.set(options, optionsKey);
|
|
2851
|
+
}
|
|
2852
|
+
const compositeKey = this.createCompositeCacheKey(optionsKey, signal);
|
|
2853
|
+
let processor = this.processorCacheByKey.get(compositeKey);
|
|
2549
2854
|
if (!processor) {
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
this.processorKeyCache.set(options, cacheKey);
|
|
2554
|
-
}
|
|
2555
|
-
processor = this.processorCacheByKey.get(cacheKey);
|
|
2556
|
-
if (!processor) {
|
|
2557
|
-
const pipeline = this.getPipeline(options);
|
|
2558
|
-
processor = _postcss2.default.call(void 0, pipeline.plugins);
|
|
2559
|
-
this.processorCacheByKey.set(cacheKey, processor);
|
|
2560
|
-
}
|
|
2561
|
-
this.processorCache.set(options, processor);
|
|
2855
|
+
const pipeline = this.getPipeline(options, signal);
|
|
2856
|
+
processor = _postcss2.default.call(void 0, pipeline.plugins);
|
|
2857
|
+
this.processorCacheByKey.set(compositeKey, processor);
|
|
2562
2858
|
}
|
|
2563
2859
|
return processor;
|
|
2564
2860
|
}
|
|
2565
2861
|
}, _class);
|
|
2566
2862
|
|
|
2567
2863
|
// src/handler.ts
|
|
2864
|
+
var CSS_RESULT_CACHE_MAX = 256;
|
|
2865
|
+
function simpleHash(str) {
|
|
2866
|
+
let hash = 2166136261 | 0;
|
|
2867
|
+
for (let i = 0; i < str.length; i++) {
|
|
2868
|
+
hash ^= str.charCodeAt(i);
|
|
2869
|
+
hash = hash * 16777619 | 0;
|
|
2870
|
+
}
|
|
2871
|
+
return (hash >>> 0).toString(36);
|
|
2872
|
+
}
|
|
2568
2873
|
function createStyleHandler(options) {
|
|
2569
2874
|
const cachedOptions = _shared.defuOverrideArray.call(void 0,
|
|
2570
2875
|
options,
|
|
@@ -2572,22 +2877,57 @@ function createStyleHandler(options) {
|
|
|
2572
2877
|
);
|
|
2573
2878
|
cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
|
|
2574
2879
|
const resolver = createOptionsResolver(cachedOptions);
|
|
2575
|
-
const
|
|
2880
|
+
const processorCache = new StyleProcessorCache();
|
|
2576
2881
|
const base = resolver.resolve();
|
|
2577
|
-
|
|
2578
|
-
|
|
2882
|
+
processorCache.getProcessor(base);
|
|
2883
|
+
processorCache.getProcessOptions(base);
|
|
2884
|
+
const optionsFingerprintCache = /* @__PURE__ */ new WeakMap();
|
|
2885
|
+
function getOptionsFingerprint(opts) {
|
|
2886
|
+
const cached = optionsFingerprintCache.get(opts);
|
|
2887
|
+
if (cached) {
|
|
2888
|
+
return cached;
|
|
2889
|
+
}
|
|
2890
|
+
const fp = fingerprintOptions(opts);
|
|
2891
|
+
optionsFingerprintCache.set(opts, fp);
|
|
2892
|
+
return fp;
|
|
2893
|
+
}
|
|
2894
|
+
const resultCache = new (0, _lrucache.LRUCache)({ max: CSS_RESULT_CACHE_MAX });
|
|
2895
|
+
const hasUserPlugins = Boolean(
|
|
2896
|
+
_optionalChain([cachedOptions, 'access', _110 => _110.postcssOptions, 'optionalAccess', _111 => _111.plugins]) && (Array.isArray(cachedOptions.postcssOptions.plugins) ? cachedOptions.postcssOptions.plugins.length > 0 : typeof cachedOptions.postcssOptions.plugins === "object" && Object.keys(cachedOptions.postcssOptions.plugins).length > 0)
|
|
2897
|
+
);
|
|
2579
2898
|
const handler = ((rawSource, opt) => {
|
|
2580
2899
|
const resolvedOptions = resolver.resolve(opt);
|
|
2581
|
-
|
|
2582
|
-
|
|
2900
|
+
let signal;
|
|
2901
|
+
if (!hasUserPlugins) {
|
|
2902
|
+
try {
|
|
2903
|
+
signal = probeFeatures(rawSource);
|
|
2904
|
+
} catch (e3) {
|
|
2905
|
+
signal = void 0;
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
const optsFp = getOptionsFingerprint(resolvedOptions);
|
|
2909
|
+
const signalKey = signal ? signalToCacheKey(signal) : "";
|
|
2910
|
+
const contentHash = simpleHash(rawSource);
|
|
2911
|
+
const cacheKey = `${optsFp}|${signalKey}|${contentHash}`;
|
|
2912
|
+
const cachedResult = resultCache.get(cacheKey);
|
|
2913
|
+
if (cachedResult) {
|
|
2914
|
+
return Promise.resolve(cachedResult);
|
|
2915
|
+
}
|
|
2916
|
+
const processor = processorCache.getProcessor(resolvedOptions, signal);
|
|
2917
|
+
const processOptions = processorCache.getProcessOptions(resolvedOptions);
|
|
2583
2918
|
return processor.process(
|
|
2584
2919
|
rawSource,
|
|
2585
2920
|
processOptions
|
|
2586
|
-
).async().then((result) =>
|
|
2921
|
+
).async().then((result) => {
|
|
2922
|
+
const baseCompatible = applyUniAppXBaseCompatibility(result, resolvedOptions);
|
|
2923
|
+
const finalResult = applyUniAppXUvueCompatibility(baseCompatible, resolvedOptions);
|
|
2924
|
+
resultCache.set(cacheKey, finalResult);
|
|
2925
|
+
return finalResult;
|
|
2926
|
+
});
|
|
2587
2927
|
});
|
|
2588
2928
|
handler.getPipeline = (opt) => {
|
|
2589
2929
|
const resolvedOptions = resolver.resolve(opt);
|
|
2590
|
-
return
|
|
2930
|
+
return processorCache.getPipeline(resolvedOptions);
|
|
2591
2931
|
};
|
|
2592
2932
|
return handler;
|
|
2593
2933
|
}
|
|
@@ -2596,4 +2936,6 @@ function createStyleHandler(options) {
|
|
|
2596
2936
|
|
|
2597
2937
|
|
|
2598
2938
|
|
|
2599
|
-
|
|
2939
|
+
|
|
2940
|
+
|
|
2941
|
+
exports.createFallbackPlaceholderReplacer = createFallbackPlaceholderReplacer; exports.createInjectPreflight = createInjectPreflight; exports.createStyleHandler = createStyleHandler; exports.createStylePipeline = createStylePipeline; exports.internalCssSelectorReplacer = internalCssSelectorReplacer; exports.postcssHtmlTransform = _chunk2Y3ULRB3js.html_transform_default;
|