@weapp-tailwindcss/postcss 2.1.5 → 2.1.6-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/html-transform.js +2 -1
- package/dist/html-transform.mjs +2 -1
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +398 -257
- package/dist/index.mjs +383 -242
- package/dist/{types-BUB5jCYX.d.mts → types-CsRGpZ_r.d.mts} +18 -4
- package/dist/{types-BUB5jCYX.d.ts → types-CsRGpZ_r.d.ts} +18 -4
- package/dist/types.d.mts +1 -2
- package/dist/types.d.ts +1 -2
- package/package.json +17 -3
package/dist/index.js
CHANGED
|
@@ -69,26 +69,151 @@ function fingerprintOptions(value, state = { map: /* @__PURE__ */ new WeakMap(),
|
|
|
69
69
|
|
|
70
70
|
// src/options-resolver.ts
|
|
71
71
|
var BASE_CACHE_KEY = "base";
|
|
72
|
+
var SIMPLE_OVERRIDE_UNSET = "__unset__";
|
|
73
|
+
function getSimpleOverrideCacheKey(options) {
|
|
74
|
+
let isMainChunk = SIMPLE_OVERRIDE_UNSET;
|
|
75
|
+
let majorVersion = SIMPLE_OVERRIDE_UNSET;
|
|
76
|
+
let cssRemoveProperty = SIMPLE_OVERRIDE_UNSET;
|
|
77
|
+
let cssRemoveHoverPseudoClass = SIMPLE_OVERRIDE_UNSET;
|
|
78
|
+
let uniAppX = SIMPLE_OVERRIDE_UNSET;
|
|
79
|
+
let cssPreflightRange = SIMPLE_OVERRIDE_UNSET;
|
|
80
|
+
let injectAdditionalCssVarScope = SIMPLE_OVERRIDE_UNSET;
|
|
81
|
+
let rem2rpx = SIMPLE_OVERRIDE_UNSET;
|
|
82
|
+
let px2rpx = SIMPLE_OVERRIDE_UNSET;
|
|
83
|
+
let unitsToPx = SIMPLE_OVERRIDE_UNSET;
|
|
84
|
+
let cssCalc = SIMPLE_OVERRIDE_UNSET;
|
|
85
|
+
let cssChildCombinatorReplaceValue = SIMPLE_OVERRIDE_UNSET;
|
|
86
|
+
let cssPreflight = SIMPLE_OVERRIDE_UNSET;
|
|
87
|
+
for (const key of Object.keys(options)) {
|
|
88
|
+
const value = options[key];
|
|
89
|
+
switch (key) {
|
|
90
|
+
case "isMainChunk":
|
|
91
|
+
if (typeof value !== "boolean") {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
isMainChunk = value ? "1" : "0";
|
|
95
|
+
break;
|
|
96
|
+
case "majorVersion":
|
|
97
|
+
if (typeof value !== "number") {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
majorVersion = String(value);
|
|
101
|
+
break;
|
|
102
|
+
case "cssRemoveProperty":
|
|
103
|
+
if (typeof value !== "boolean") {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
cssRemoveProperty = value ? "1" : "0";
|
|
107
|
+
break;
|
|
108
|
+
case "cssRemoveHoverPseudoClass":
|
|
109
|
+
if (typeof value !== "boolean") {
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
cssRemoveHoverPseudoClass = value ? "1" : "0";
|
|
113
|
+
break;
|
|
114
|
+
case "uniAppX":
|
|
115
|
+
if (typeof value !== "boolean") {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
uniAppX = value ? "1" : "0";
|
|
119
|
+
break;
|
|
120
|
+
case "cssPreflightRange":
|
|
121
|
+
if (typeof value !== "string") {
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
cssPreflightRange = value;
|
|
125
|
+
break;
|
|
126
|
+
case "injectAdditionalCssVarScope":
|
|
127
|
+
if (typeof value !== "boolean") {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
injectAdditionalCssVarScope = value ? "1" : "0";
|
|
131
|
+
break;
|
|
132
|
+
case "rem2rpx":
|
|
133
|
+
if (typeof value !== "boolean") {
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
rem2rpx = value ? "1" : "0";
|
|
137
|
+
break;
|
|
138
|
+
case "px2rpx":
|
|
139
|
+
if (typeof value !== "boolean") {
|
|
140
|
+
return void 0;
|
|
141
|
+
}
|
|
142
|
+
px2rpx = value ? "1" : "0";
|
|
143
|
+
break;
|
|
144
|
+
case "unitsToPx":
|
|
145
|
+
if (typeof value !== "boolean") {
|
|
146
|
+
return void 0;
|
|
147
|
+
}
|
|
148
|
+
unitsToPx = value ? "1" : "0";
|
|
149
|
+
break;
|
|
150
|
+
case "cssCalc":
|
|
151
|
+
if (typeof value !== "boolean") {
|
|
152
|
+
return void 0;
|
|
153
|
+
}
|
|
154
|
+
cssCalc = value ? "1" : "0";
|
|
155
|
+
break;
|
|
156
|
+
case "cssChildCombinatorReplaceValue":
|
|
157
|
+
if (typeof value !== "string") {
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
160
|
+
cssChildCombinatorReplaceValue = value;
|
|
161
|
+
break;
|
|
162
|
+
case "cssPreflight":
|
|
163
|
+
if (value !== false) {
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
cssPreflight = "0";
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return [
|
|
173
|
+
"simple",
|
|
174
|
+
isMainChunk,
|
|
175
|
+
majorVersion,
|
|
176
|
+
cssRemoveProperty,
|
|
177
|
+
cssRemoveHoverPseudoClass,
|
|
178
|
+
uniAppX,
|
|
179
|
+
cssPreflightRange,
|
|
180
|
+
injectAdditionalCssVarScope,
|
|
181
|
+
rem2rpx,
|
|
182
|
+
px2rpx,
|
|
183
|
+
unitsToPx,
|
|
184
|
+
cssCalc,
|
|
185
|
+
cssChildCombinatorReplaceValue,
|
|
186
|
+
cssPreflight
|
|
187
|
+
].join(":");
|
|
188
|
+
}
|
|
72
189
|
function hasOverrides(options) {
|
|
73
190
|
return Boolean(options && Object.keys(options).length > 0);
|
|
74
191
|
}
|
|
75
192
|
function createOptionsResolver(baseOptions) {
|
|
76
193
|
const cacheByKey = /* @__PURE__ */ new Map();
|
|
77
194
|
const cacheByRef = /* @__PURE__ */ new WeakMap();
|
|
78
|
-
const
|
|
195
|
+
const cacheKeyByRef = /* @__PURE__ */ new WeakMap();
|
|
196
|
+
const emptyOverrideRefs = /* @__PURE__ */ new WeakSet();
|
|
79
197
|
cacheByKey.set(BASE_CACHE_KEY, baseOptions);
|
|
80
198
|
const resolve = (overrides) => {
|
|
81
|
-
if (!
|
|
199
|
+
if (!overrides) {
|
|
82
200
|
return baseOptions;
|
|
83
201
|
}
|
|
84
202
|
const refCached = cacheByRef.get(overrides);
|
|
85
203
|
if (refCached) {
|
|
86
204
|
return refCached;
|
|
87
205
|
}
|
|
88
|
-
|
|
206
|
+
if (emptyOverrideRefs.has(overrides)) {
|
|
207
|
+
return baseOptions;
|
|
208
|
+
}
|
|
209
|
+
if (!hasOverrides(overrides)) {
|
|
210
|
+
emptyOverrideRefs.add(overrides);
|
|
211
|
+
return baseOptions;
|
|
212
|
+
}
|
|
213
|
+
let key = cacheKeyByRef.get(overrides);
|
|
89
214
|
if (!key) {
|
|
90
|
-
key = fingerprintOptions(overrides);
|
|
91
|
-
|
|
215
|
+
key = _nullishCoalesce(getSimpleOverrideCacheKey(overrides), () => ( fingerprintOptions(overrides)));
|
|
216
|
+
cacheKeyByRef.set(overrides, key);
|
|
92
217
|
}
|
|
93
218
|
const cached = cacheByKey.get(key);
|
|
94
219
|
if (cached) {
|
|
@@ -247,37 +372,38 @@ function createContext() {
|
|
|
247
372
|
}
|
|
248
373
|
|
|
249
374
|
// src/plugins/getCalcDuplicateCleaner.ts
|
|
375
|
+
var calcDuplicateCleanerPlugin = {
|
|
376
|
+
postcssPlugin: "postcss-calc-duplicate-cleaner",
|
|
377
|
+
Rule(rule) {
|
|
378
|
+
rule.walkDecls((decl) => {
|
|
379
|
+
const prev = decl.prev();
|
|
380
|
+
if (!prev || prev.type !== "decl") {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (prev.prop !== decl.prop) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (prev.important !== decl.important) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (prev.value !== decl.value) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
decl.remove();
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
};
|
|
250
396
|
function getCalcDuplicateCleaner(options) {
|
|
251
397
|
if (!options.cssCalc) {
|
|
252
398
|
return null;
|
|
253
399
|
}
|
|
254
|
-
return
|
|
255
|
-
postcssPlugin: "postcss-calc-duplicate-cleaner",
|
|
256
|
-
Rule(rule) {
|
|
257
|
-
rule.walkDecls((decl) => {
|
|
258
|
-
const prev = decl.prev();
|
|
259
|
-
if (!prev || prev.type !== "decl") {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
if (prev.prop !== decl.prop) {
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (prev.important !== decl.important) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
if (prev.value !== decl.value) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
decl.remove();
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
};
|
|
400
|
+
return calcDuplicateCleanerPlugin;
|
|
275
401
|
}
|
|
276
402
|
|
|
277
403
|
// src/plugins/getCalcPlugin.ts
|
|
278
404
|
var _postcsscalc = require('@weapp-tailwindcss/postcss-calc'); var _postcsscalc2 = _interopRequireDefault(_postcsscalc);
|
|
279
405
|
|
|
280
|
-
// ../../node_modules/.pnpm/es-toolkit@1.
|
|
406
|
+
// ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/omit.mjs
|
|
281
407
|
function omit(obj, keys) {
|
|
282
408
|
const result = { ...obj };
|
|
283
409
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -288,12 +414,17 @@ function omit(obj, keys) {
|
|
|
288
414
|
}
|
|
289
415
|
|
|
290
416
|
// src/plugins/getCalcPlugin.ts
|
|
417
|
+
var EMPTY_CALC_OPTIONS = {};
|
|
291
418
|
function getCalcPlugin(options) {
|
|
292
419
|
if (!options.cssCalc) {
|
|
293
420
|
return null;
|
|
294
421
|
}
|
|
295
|
-
|
|
296
|
-
|
|
422
|
+
if (options.cssCalc === true || Array.isArray(options.cssCalc)) {
|
|
423
|
+
return _postcsscalc2.default.call(void 0, EMPTY_CALC_OPTIONS);
|
|
424
|
+
}
|
|
425
|
+
return _postcsscalc2.default.call(void 0,
|
|
426
|
+
omit(options.cssCalc, ["includeCustomProperties"])
|
|
427
|
+
);
|
|
297
428
|
}
|
|
298
429
|
|
|
299
430
|
// src/plugins/getCustomPropertyCleaner.ts
|
|
@@ -305,6 +436,7 @@ function getCustomPropertyCleaner(options) {
|
|
|
305
436
|
if (!shouldMatchCustomProperties) {
|
|
306
437
|
return null;
|
|
307
438
|
}
|
|
439
|
+
const shouldInspectValue = (value) => value.includes("var(") && value.includes("--");
|
|
308
440
|
return {
|
|
309
441
|
postcssPlugin: "postcss-remove-include-custom-properties",
|
|
310
442
|
OnceExit(root) {
|
|
@@ -317,7 +449,7 @@ function getCustomPropertyCleaner(options) {
|
|
|
317
449
|
decl.remove();
|
|
318
450
|
return;
|
|
319
451
|
}
|
|
320
|
-
if (!
|
|
452
|
+
if (!shouldInspectValue(decl.value)) {
|
|
321
453
|
return;
|
|
322
454
|
}
|
|
323
455
|
const parsed = _postcssvalueparser2.default.call(void 0, decl.value);
|
|
@@ -365,10 +497,12 @@ function getPxTransformPlugin(options) {
|
|
|
365
497
|
if (!options.px2rpx) {
|
|
366
498
|
return null;
|
|
367
499
|
}
|
|
368
|
-
|
|
500
|
+
if (options.px2rpx === true) {
|
|
501
|
+
return _postcsspxtrans2.default.call(void 0, defaultPxTransformOptions);
|
|
502
|
+
}
|
|
369
503
|
return _postcsspxtrans2.default.call(void 0,
|
|
370
504
|
_shared.defuOverrideArray.call(void 0,
|
|
371
|
-
|
|
505
|
+
options.px2rpx,
|
|
372
506
|
defaultPxTransformOptions
|
|
373
507
|
)
|
|
374
508
|
);
|
|
@@ -385,13 +519,19 @@ var defaultRemOptions = {
|
|
|
385
519
|
var defaultStage = {
|
|
386
520
|
processorStage: "OnceExit"
|
|
387
521
|
};
|
|
522
|
+
var defaultRemTransformOptions = {
|
|
523
|
+
...defaultRemOptions,
|
|
524
|
+
...defaultStage
|
|
525
|
+
};
|
|
388
526
|
function getRemTransformPlugin(options) {
|
|
389
527
|
if (!options.rem2rpx) {
|
|
390
528
|
return null;
|
|
391
529
|
}
|
|
392
|
-
|
|
530
|
+
if (options.rem2rpx === true) {
|
|
531
|
+
return _postcssremtoresponsivepixel2.default.call(void 0, defaultRemTransformOptions);
|
|
532
|
+
}
|
|
393
533
|
const merged = _shared.defuOverrideArray.call(void 0,
|
|
394
|
-
|
|
534
|
+
options.rem2rpx,
|
|
395
535
|
defaultStage
|
|
396
536
|
);
|
|
397
537
|
return _postcssremtoresponsivepixel2.default.call(void 0, merged);
|
|
@@ -593,6 +733,12 @@ var OKLAB_SUFFIX = "in oklab";
|
|
|
593
733
|
var INFINITY_CALC_REGEXP = /calc\(\s*infinity\s*\*\s*(?:\d+(?:\.\d*)?|\.\d+)r?px/;
|
|
594
734
|
var RADIUS_THRESHOLD = 1e5;
|
|
595
735
|
var CLAMP_PX = 9999;
|
|
736
|
+
var MODERN_CHECK_WEBKIT_HYPHENS_RE = /-webkit-hyphens\s*:\s*none/;
|
|
737
|
+
var MODERN_CHECK_MARGIN_TRIM_RE = /margin-trim\s*:\s*inline/;
|
|
738
|
+
var MODERN_CHECK_MOZ_ORIENT_RE = /-moz-orient\s*:\s*inline/;
|
|
739
|
+
var MODERN_CHECK_COLOR_RGB_RE = /color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)/;
|
|
740
|
+
var RADIUS_VALUE_RE = /\b([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)\s*(r?px)\b/gi;
|
|
741
|
+
var SCIENTIFIC_NOTATION_RE = /e/i;
|
|
596
742
|
function isTailwindcssV4(options) {
|
|
597
743
|
return _optionalChain([options, 'optionalAccess', _13 => _13.majorVersion]) === 4;
|
|
598
744
|
}
|
|
@@ -602,10 +748,10 @@ function testIfRootHostForV4(node) {
|
|
|
602
748
|
var cssVarsV4Nodes = createCssVarNodes(cssVarsV4_default);
|
|
603
749
|
function isTailwindcssV4ModernCheck(atRule) {
|
|
604
750
|
return atRule.name === "supports" && [
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
751
|
+
MODERN_CHECK_WEBKIT_HYPHENS_RE,
|
|
752
|
+
MODERN_CHECK_MARGIN_TRIM_RE,
|
|
753
|
+
MODERN_CHECK_MOZ_ORIENT_RE,
|
|
754
|
+
MODERN_CHECK_COLOR_RGB_RE
|
|
609
755
|
].every((regex) => regex.test(atRule.params));
|
|
610
756
|
}
|
|
611
757
|
function normalizeTailwindcssV4Declaration(decl) {
|
|
@@ -618,14 +764,15 @@ function normalizeTailwindcssV4Declaration(decl) {
|
|
|
618
764
|
return true;
|
|
619
765
|
}
|
|
620
766
|
if (decl.prop.includes("radius")) {
|
|
767
|
+
RADIUS_VALUE_RE.lastIndex = 0;
|
|
621
768
|
const next = decl.value.replace(
|
|
622
|
-
|
|
769
|
+
RADIUS_VALUE_RE,
|
|
623
770
|
(m, num) => {
|
|
624
771
|
const n = Number(num);
|
|
625
772
|
if (!Number.isFinite(n)) {
|
|
626
773
|
return `${CLAMP_PX}px`;
|
|
627
774
|
}
|
|
628
|
-
if (
|
|
775
|
+
if (SCIENTIFIC_NOTATION_RE.test(String(num)) || n > RADIUS_THRESHOLD) {
|
|
629
776
|
return `${CLAMP_PX}px`;
|
|
630
777
|
}
|
|
631
778
|
return m;
|
|
@@ -669,6 +816,8 @@ var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
|
669
816
|
// src/selectorParser/before-after.ts
|
|
670
817
|
var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
|
|
671
818
|
var beforeAfterStateRef = null;
|
|
819
|
+
var BEFORE_PSEUDO_RE = /^:?:before$/;
|
|
820
|
+
var AFTER_PSEUDO_RE = /^:?:after$/;
|
|
672
821
|
var beforeAfterParser = _postcssselectorparser2.default.call(void 0, (selectors) => {
|
|
673
822
|
const state = beforeAfterStateRef;
|
|
674
823
|
if (!state) {
|
|
@@ -676,10 +825,10 @@ var beforeAfterParser = _postcssselectorparser2.default.call(void 0, (selectors)
|
|
|
676
825
|
}
|
|
677
826
|
selectors.walkPseudos((s) => {
|
|
678
827
|
if (_optionalChain([s, 'access', _15 => _15.parent, 'optionalAccess', _16 => _16.length]) === 1) {
|
|
679
|
-
if (
|
|
828
|
+
if (BEFORE_PSEUDO_RE.test(s.value)) {
|
|
680
829
|
state.before = true;
|
|
681
830
|
}
|
|
682
|
-
if (
|
|
831
|
+
if (AFTER_PSEUDO_RE.test(s.value)) {
|
|
683
832
|
state.after = true;
|
|
684
833
|
}
|
|
685
834
|
}
|
|
@@ -701,6 +850,7 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
|
701
850
|
|
|
702
851
|
// src/selectorParser/utils.ts
|
|
703
852
|
|
|
853
|
+
var combinatorSelectorAstCache = /* @__PURE__ */ new WeakMap();
|
|
704
854
|
function normalizeTransformOptions(options) {
|
|
705
855
|
return {
|
|
706
856
|
lossless: false,
|
|
@@ -738,12 +888,16 @@ function composeIsPseudoAst(strs) {
|
|
|
738
888
|
}));
|
|
739
889
|
}
|
|
740
890
|
function getCombinatorSelectorAst(options) {
|
|
741
|
-
let
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
891
|
+
let template = combinatorSelectorAstCache.get(options);
|
|
892
|
+
if (!template) {
|
|
893
|
+
template = mklist(_postcssselectorparser2.default.tag({ value: "view" }));
|
|
894
|
+
const { cssChildCombinatorReplaceValue } = options;
|
|
895
|
+
if (typeof cssChildCombinatorReplaceValue === "string" || Array.isArray(cssChildCombinatorReplaceValue) && cssChildCombinatorReplaceValue.length > 0) {
|
|
896
|
+
template = composeIsPseudoAst(cssChildCombinatorReplaceValue);
|
|
897
|
+
}
|
|
898
|
+
combinatorSelectorAstCache.set(options, template);
|
|
745
899
|
}
|
|
746
|
-
return
|
|
900
|
+
return template.map((node) => node.clone());
|
|
747
901
|
}
|
|
748
902
|
|
|
749
903
|
// src/selectorParser/fallback.ts
|
|
@@ -754,8 +908,17 @@ function getFallbackRemove(_rule, options) {
|
|
|
754
908
|
const cacheKey = _nullishCoalesce(options, () => ( fallbackDefaultKey));
|
|
755
909
|
let entry = fallbackRemoveCache.get(cacheKey);
|
|
756
910
|
if (!entry) {
|
|
911
|
+
let writeSelectorCache2 = function(selector, result) {
|
|
912
|
+
if (selectorCache.size >= selectorCacheLimit) {
|
|
913
|
+
selectorCache.clear();
|
|
914
|
+
}
|
|
915
|
+
selectorCache.set(selector, result);
|
|
916
|
+
};
|
|
917
|
+
var writeSelectorCache = writeSelectorCache2;
|
|
757
918
|
const uniAppX = isUniAppXEnabled(options);
|
|
758
919
|
let currentRule;
|
|
920
|
+
const selectorCache = /* @__PURE__ */ new Map();
|
|
921
|
+
const selectorCacheLimit = 5e4;
|
|
759
922
|
const parser = _postcssselectorparser2.default.call(void 0, (selectors) => {
|
|
760
923
|
const activeRule = currentRule;
|
|
761
924
|
let maybeImportantId = false;
|
|
@@ -812,12 +975,33 @@ function getFallbackRemove(_rule, options) {
|
|
|
812
975
|
});
|
|
813
976
|
const rawTransformSync = parser.transformSync.bind(parser);
|
|
814
977
|
const transform = (targetRule) => {
|
|
978
|
+
const sourceSelector = targetRule.selector;
|
|
979
|
+
if (!sourceSelector) {
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const cached = selectorCache.get(sourceSelector);
|
|
983
|
+
if (cached) {
|
|
984
|
+
if (cached.action === "remove") {
|
|
985
|
+
targetRule.remove();
|
|
986
|
+
} else if (cached.action === "update" && cached.selector && cached.selector !== sourceSelector) {
|
|
987
|
+
targetRule.selector = cached.selector;
|
|
988
|
+
}
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
815
991
|
currentRule = targetRule;
|
|
816
992
|
try {
|
|
817
993
|
rawTransformSync(targetRule, FALLBACK_TRANSFORM_OPTIONS);
|
|
818
994
|
} finally {
|
|
819
995
|
currentRule = void 0;
|
|
820
996
|
}
|
|
997
|
+
const wasRemoved = targetRule.parent == null;
|
|
998
|
+
if (wasRemoved) {
|
|
999
|
+
writeSelectorCache2(sourceSelector, { action: "remove" });
|
|
1000
|
+
} else if (targetRule.selector === sourceSelector) {
|
|
1001
|
+
writeSelectorCache2(sourceSelector, { action: "keep" });
|
|
1002
|
+
} else {
|
|
1003
|
+
writeSelectorCache2(sourceSelector, { action: "update", selector: targetRule.selector });
|
|
1004
|
+
}
|
|
821
1005
|
};
|
|
822
1006
|
parser.transformSync = ((input, opts) => {
|
|
823
1007
|
const transformOptions = opts ? normalizeTransformOptions(opts) : FALLBACK_TRANSFORM_OPTIONS;
|
|
@@ -848,15 +1032,21 @@ function getFallbackRemove(_rule, options) {
|
|
|
848
1032
|
|
|
849
1033
|
// src/shared.ts
|
|
850
1034
|
var _escape = require('@weapp-core/escape');
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
escapeOptions["map"] = escapeMap;
|
|
1035
|
+
var escapeOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
1036
|
+
function getEscapeOptions(escapeMap) {
|
|
1037
|
+
let cached = escapeOptionsCache.get(escapeMap);
|
|
1038
|
+
if (!cached) {
|
|
1039
|
+
cached = { map: escapeMap };
|
|
1040
|
+
escapeOptionsCache.set(escapeMap, cached);
|
|
858
1041
|
}
|
|
859
|
-
return
|
|
1042
|
+
return cached;
|
|
1043
|
+
}
|
|
1044
|
+
function internalCssSelectorReplacer(selectors, options) {
|
|
1045
|
+
const escapeMap = _optionalChain([options, 'optionalAccess', _28 => _28.escapeMap]);
|
|
1046
|
+
if (escapeMap === void 0 || escapeMap === _escape.MappingChars2String) {
|
|
1047
|
+
return _escape.escape.call(void 0, selectors);
|
|
1048
|
+
}
|
|
1049
|
+
return _escape.escape.call(void 0, selectors, getEscapeOptions(escapeMap));
|
|
860
1050
|
}
|
|
861
1051
|
function composeIsPseudo(strs) {
|
|
862
1052
|
if (typeof strs === "string") {
|
|
@@ -896,7 +1086,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
|
|
|
896
1086
|
if (alreadyOrdered) {
|
|
897
1087
|
return;
|
|
898
1088
|
}
|
|
899
|
-
const anchor = _nullishCoalesce(_optionalChain([declarations, 'access',
|
|
1089
|
+
const anchor = _nullishCoalesce(_optionalChain([declarations, 'access', _29 => _29.at, 'call', _30 => _30(-1), 'optionalAccess', _31 => _31.next, 'call', _32 => _32()]), () => ( void 0));
|
|
900
1090
|
for (const decl of declarations) {
|
|
901
1091
|
decl.remove();
|
|
902
1092
|
}
|
|
@@ -935,49 +1125,32 @@ var LEGACY_WEBKIT_SPACING_PROPS = /* @__PURE__ */ new Set([
|
|
|
935
1125
|
"-webkit-margin-after"
|
|
936
1126
|
]);
|
|
937
1127
|
var VAR_REFERENCE_PATTERN = /var\(/i;
|
|
938
|
-
function
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
if (node.type !== "decl") {
|
|
942
|
-
continue;
|
|
943
|
-
}
|
|
944
|
-
if (!SPACING_PROP_SET.has(node.prop)) {
|
|
945
|
-
continue;
|
|
946
|
-
}
|
|
947
|
-
const list = grouped.get(node.prop);
|
|
948
|
-
if (list) {
|
|
949
|
-
list.push(node);
|
|
950
|
-
} else {
|
|
951
|
-
grouped.set(node.prop, [node]);
|
|
952
|
-
}
|
|
1128
|
+
function dedupeSpacingGroup(rule, declarations) {
|
|
1129
|
+
if (declarations.length <= 1) {
|
|
1130
|
+
return;
|
|
953
1131
|
}
|
|
954
|
-
|
|
955
|
-
|
|
1132
|
+
const unique = [];
|
|
1133
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
1134
|
+
for (const decl of declarations) {
|
|
1135
|
+
if (decl.parent !== rule) {
|
|
956
1136
|
continue;
|
|
957
1137
|
}
|
|
958
|
-
const
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
if (decl.parent !== rule) {
|
|
962
|
-
continue;
|
|
963
|
-
}
|
|
964
|
-
const key = `${decl.important ? "!important@@" : ""}${decl.value}`;
|
|
965
|
-
if (seenValues.has(key)) {
|
|
966
|
-
decl.remove();
|
|
967
|
-
continue;
|
|
968
|
-
}
|
|
969
|
-
seenValues.add(key);
|
|
970
|
-
unique.push(decl);
|
|
971
|
-
}
|
|
972
|
-
if (unique.length <= 1) {
|
|
1138
|
+
const key = `${decl.important ? "!important@@" : ""}${decl.value}`;
|
|
1139
|
+
if (seenValues.has(key)) {
|
|
1140
|
+
decl.remove();
|
|
973
1141
|
continue;
|
|
974
1142
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
unique,
|
|
978
|
-
(decl) => VAR_REFERENCE_PATTERN.test(decl.value)
|
|
979
|
-
);
|
|
1143
|
+
seenValues.add(key);
|
|
1144
|
+
unique.push(decl);
|
|
980
1145
|
}
|
|
1146
|
+
if (unique.length <= 1) {
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
reorderLiteralFirst(
|
|
1150
|
+
rule,
|
|
1151
|
+
unique,
|
|
1152
|
+
(decl) => VAR_REFERENCE_PATTERN.test(decl.value)
|
|
1153
|
+
);
|
|
981
1154
|
}
|
|
982
1155
|
function isNotLastChildPseudo(node) {
|
|
983
1156
|
if (!node || node.type !== "pseudo" || node.value !== ":not") {
|
|
@@ -991,7 +1164,7 @@ function isNotLastChildPseudo(node) {
|
|
|
991
1164
|
if (!firstSelector || firstSelector.type !== "selector") {
|
|
992
1165
|
return false;
|
|
993
1166
|
}
|
|
994
|
-
const target = _optionalChain([firstSelector, 'access',
|
|
1167
|
+
const target = _optionalChain([firstSelector, 'access', _33 => _33.nodes, 'optionalAccess', _34 => _34[0]]);
|
|
995
1168
|
return Boolean(target && target.type === "pseudo" && target.value === ":last-child");
|
|
996
1169
|
}
|
|
997
1170
|
function transformSpacingSelector(nodes2, options) {
|
|
@@ -1018,6 +1191,7 @@ function transformSpacingSelector(nodes2, options) {
|
|
|
1018
1191
|
return false;
|
|
1019
1192
|
}
|
|
1020
1193
|
function normalizeSpacingDeclarations(rule) {
|
|
1194
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
1021
1195
|
for (const node of [...rule.nodes]) {
|
|
1022
1196
|
if (node.type !== "decl") {
|
|
1023
1197
|
continue;
|
|
@@ -1030,8 +1204,19 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
1030
1204
|
if (mirror) {
|
|
1031
1205
|
node.prop = mirror;
|
|
1032
1206
|
}
|
|
1207
|
+
if (!SPACING_PROP_SET.has(node.prop)) {
|
|
1208
|
+
continue;
|
|
1209
|
+
}
|
|
1210
|
+
const declarations = grouped.get(node.prop);
|
|
1211
|
+
if (declarations) {
|
|
1212
|
+
declarations.push(node);
|
|
1213
|
+
} else {
|
|
1214
|
+
grouped.set(node.prop, [node]);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
for (const declarations of grouped.values()) {
|
|
1218
|
+
dedupeSpacingGroup(rule, declarations);
|
|
1033
1219
|
}
|
|
1034
|
-
dedupeSpacingProps(rule);
|
|
1035
1220
|
}
|
|
1036
1221
|
|
|
1037
1222
|
// src/selectorParser/rule-transformer.ts
|
|
@@ -1091,7 +1276,7 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
1091
1276
|
node.value = ":is";
|
|
1092
1277
|
}
|
|
1093
1278
|
if (index === 0 && node.length === 1) {
|
|
1094
|
-
const targetSelector = _optionalChain([node, 'access',
|
|
1279
|
+
const targetSelector = _optionalChain([node, 'access', _35 => _35.nodes, 'optionalAccess', _36 => _36[0]]);
|
|
1095
1280
|
if (targetSelector && targetSelector.type === "selector" && transformSpacingSelector(targetSelector.nodes, context.options)) {
|
|
1096
1281
|
context.requiresSpacingNormalization = true;
|
|
1097
1282
|
}
|
|
@@ -1105,16 +1290,14 @@ function handleClassNode(node, context) {
|
|
|
1105
1290
|
if (node.type !== "class") {
|
|
1106
1291
|
return;
|
|
1107
1292
|
}
|
|
1108
|
-
|
|
1109
|
-
node.value = escapeMap === void 0 ? internalCssSelectorReplacer(node.value, {}) : internalCssSelectorReplacer(node.value, { escapeMap });
|
|
1293
|
+
node.value = context.selectorReplacerOptions === void 0 ? internalCssSelectorReplacer(node.value) : internalCssSelectorReplacer(node.value, context.selectorReplacerOptions);
|
|
1110
1294
|
}
|
|
1111
1295
|
function handleUniversalNode(node, context) {
|
|
1112
1296
|
if (node.type !== "universal") {
|
|
1113
1297
|
return;
|
|
1114
1298
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
node.value = composeIsPseudo(replacement);
|
|
1299
|
+
if (context.universalReplacement) {
|
|
1300
|
+
node.value = context.universalReplacement;
|
|
1118
1301
|
}
|
|
1119
1302
|
}
|
|
1120
1303
|
function shouldRemoveHoverSelector(selector, options) {
|
|
@@ -1154,7 +1337,7 @@ function handleCombinatorNode(node, index, context) {
|
|
|
1154
1337
|
if (node.type !== "combinator" || node.value !== ">") {
|
|
1155
1338
|
return;
|
|
1156
1339
|
}
|
|
1157
|
-
const nodes2 = _optionalChain([node, 'access',
|
|
1340
|
+
const nodes2 = _optionalChain([node, 'access', _37 => _37.parent, 'optionalAccess', _38 => _38.nodes]);
|
|
1158
1341
|
if (!nodes2) {
|
|
1159
1342
|
return;
|
|
1160
1343
|
}
|
|
@@ -1174,8 +1357,8 @@ function handlePseudoNode(node, index, context, parent) {
|
|
|
1174
1357
|
stripUnsupportedRtlLanguagePseudo(node);
|
|
1175
1358
|
return;
|
|
1176
1359
|
}
|
|
1177
|
-
if (node.value === ":root" &&
|
|
1178
|
-
node.value =
|
|
1360
|
+
if (node.value === ":root" && context.rootReplacement) {
|
|
1361
|
+
node.value = context.rootReplacement;
|
|
1179
1362
|
return;
|
|
1180
1363
|
}
|
|
1181
1364
|
if (node.value === ":where") {
|
|
@@ -1207,7 +1390,7 @@ function canSkipRuleTransform(rule) {
|
|
|
1207
1390
|
}
|
|
1208
1391
|
function transformSelectors(selectors, context) {
|
|
1209
1392
|
selectors.walk((node, index) => {
|
|
1210
|
-
const parent = _optionalChain([node, 'access',
|
|
1393
|
+
const parent = _optionalChain([node, 'access', _39 => _39.parent, 'optionalAccess', _40 => _40.type]) === "selector" ? node.parent : void 0;
|
|
1211
1394
|
switch (node.type) {
|
|
1212
1395
|
case "class":
|
|
1213
1396
|
handleClassNode(node, context);
|
|
@@ -1254,6 +1437,9 @@ function createRuleTransformer(options) {
|
|
|
1254
1437
|
let context;
|
|
1255
1438
|
const selectorResultCache = /* @__PURE__ */ new Map();
|
|
1256
1439
|
const selectorResultCacheLimit = 5e4;
|
|
1440
|
+
const rootReplacement = _optionalChain([options, 'access', _41 => _41.cssSelectorReplacement, 'optionalAccess', _42 => _42.root]) ? composeIsPseudo(options.cssSelectorReplacement.root) : void 0;
|
|
1441
|
+
const universalReplacement = _optionalChain([options, 'access', _43 => _43.cssSelectorReplacement, 'optionalAccess', _44 => _44.universal]) ? composeIsPseudo(options.cssSelectorReplacement.universal) : void 0;
|
|
1442
|
+
const selectorReplacerOptions = options.escapeMap ? { escapeMap: options.escapeMap } : void 0;
|
|
1257
1443
|
function writeSelectorResultCache(selector, result) {
|
|
1258
1444
|
if (selectorResultCache.size >= selectorResultCacheLimit) {
|
|
1259
1445
|
selectorResultCache.clear();
|
|
@@ -1288,7 +1474,10 @@ function createRuleTransformer(options) {
|
|
|
1288
1474
|
context = {
|
|
1289
1475
|
options,
|
|
1290
1476
|
requiresSpacingNormalization: false,
|
|
1291
|
-
rule
|
|
1477
|
+
rule,
|
|
1478
|
+
rootReplacement,
|
|
1479
|
+
universalReplacement,
|
|
1480
|
+
selectorReplacerOptions
|
|
1292
1481
|
};
|
|
1293
1482
|
let wasRemoved = false;
|
|
1294
1483
|
let requiresSpacingNormalization = false;
|
|
@@ -1360,6 +1549,8 @@ var variablePriorityProps = /* @__PURE__ */ new Set([
|
|
|
1360
1549
|
function getCanonicalProp(prop) {
|
|
1361
1550
|
return _nullishCoalesce(logicalPropMap.get(prop), () => ( prop));
|
|
1362
1551
|
}
|
|
1552
|
+
var NESTED_CALC_RE = /calc\(\s*calc\(/gi;
|
|
1553
|
+
var CALC_WRAP_RE = /calc\(\s*(1\s*-\s*var\([^()]+\))\s*\)/gi;
|
|
1363
1554
|
function normalizeCalcValue(value) {
|
|
1364
1555
|
if (!value.includes("calc")) {
|
|
1365
1556
|
return value;
|
|
@@ -1368,9 +1559,11 @@ function normalizeCalcValue(value) {
|
|
|
1368
1559
|
let prev;
|
|
1369
1560
|
do {
|
|
1370
1561
|
prev = next;
|
|
1371
|
-
|
|
1562
|
+
NESTED_CALC_RE.lastIndex = 0;
|
|
1563
|
+
next = prev.replace(NESTED_CALC_RE, "calc((");
|
|
1372
1564
|
} while (next !== prev);
|
|
1373
|
-
|
|
1565
|
+
CALC_WRAP_RE.lastIndex = 0;
|
|
1566
|
+
return next.replace(CALC_WRAP_RE, "($1)");
|
|
1374
1567
|
}
|
|
1375
1568
|
function hasVariableReference(value) {
|
|
1376
1569
|
return value.includes("var(");
|
|
@@ -1515,16 +1708,19 @@ function normalizeRootSelectors(value) {
|
|
|
1515
1708
|
}
|
|
1516
1709
|
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1517
1710
|
}
|
|
1518
|
-
function
|
|
1519
|
-
const selectors = _nullishCoalesce(rule.selectors, () => ( []));
|
|
1520
|
-
if (selectors.includes(":host")) {
|
|
1521
|
-
return false;
|
|
1522
|
-
}
|
|
1711
|
+
function createHostSelectorAppender(options) {
|
|
1523
1712
|
const rootSelectors = normalizeRootSelectors(_optionalChain([options, 'access', _54 => _54.cssSelectorReplacement, 'optionalAccess', _55 => _55.root]));
|
|
1524
|
-
|
|
1525
|
-
|
|
1713
|
+
const shouldAppendHostSelector = rootSelectors.length === DEFAULT_ROOT_SELECTORS.length && rootSelectors.every((selector, index) => selector === DEFAULT_ROOT_SELECTORS[index]);
|
|
1714
|
+
if (!shouldAppendHostSelector) {
|
|
1715
|
+
return void 0;
|
|
1526
1716
|
}
|
|
1527
|
-
return
|
|
1717
|
+
return (rule) => {
|
|
1718
|
+
const selectors = _nullishCoalesce(rule.selectors, () => ( []));
|
|
1719
|
+
if (selectors.includes(":host")) {
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1722
|
+
return DEFAULT_ROOT_SELECTORS.every((selector) => selectors.includes(selector));
|
|
1723
|
+
};
|
|
1528
1724
|
}
|
|
1529
1725
|
var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
1530
1726
|
const opts = _shared.defu.call(void 0, options, {
|
|
@@ -1534,6 +1730,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1534
1730
|
postcssPlugin
|
|
1535
1731
|
};
|
|
1536
1732
|
const cleanRootSpecificity = createRootSpecificityCleaner(opts);
|
|
1733
|
+
const shouldAppendHostSelector = createHostSelectorAppender(opts);
|
|
1537
1734
|
const enableMainChunkTransforms = opts.isMainChunk !== false;
|
|
1538
1735
|
if (enableMainChunkTransforms || cleanRootSpecificity) {
|
|
1539
1736
|
const fallbackRemove = enableMainChunkTransforms ? getFallbackRemove(void 0, opts) : void 0;
|
|
@@ -1543,7 +1740,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1543
1740
|
}
|
|
1544
1741
|
_optionalChain([cleanRootSpecificity, 'optionalCall', _58 => _58(rule)]);
|
|
1545
1742
|
if (enableMainChunkTransforms) {
|
|
1546
|
-
if (shouldAppendHostSelector(rule
|
|
1743
|
+
if (_optionalChain([shouldAppendHostSelector, 'optionalCall', _59 => _59(rule)])) {
|
|
1547
1744
|
rule.selectors = [...rule.selectors, ":host"];
|
|
1548
1745
|
}
|
|
1549
1746
|
dedupeDeclarations(rule);
|
|
@@ -1569,7 +1766,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1569
1766
|
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
1570
1767
|
atRule.remove();
|
|
1571
1768
|
}
|
|
1572
|
-
_optionalChain([atRule, 'access',
|
|
1769
|
+
_optionalChain([atRule, 'access', _60 => _60.nodes, 'optionalAccess', _61 => _61.length]) === 0 && atRule.remove();
|
|
1573
1770
|
};
|
|
1574
1771
|
}
|
|
1575
1772
|
return p;
|
|
@@ -1852,7 +2049,7 @@ function remakeCssVarSelector(selectors, options) {
|
|
|
1852
2049
|
}
|
|
1853
2050
|
function commonChunkPreflight(node, options) {
|
|
1854
2051
|
const { ctx, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
1855
|
-
const rootOption = _optionalChain([options, 'access',
|
|
2052
|
+
const rootOption = _optionalChain([options, 'access', _62 => _62.cssSelectorReplacement, 'optionalAccess', _63 => _63.root]);
|
|
1856
2053
|
const rootSelectors = rootOption === false || rootOption === void 0 ? [] : Array.isArray(rootOption) ? rootOption.filter(Boolean) : [rootOption];
|
|
1857
2054
|
const hasHostSelector = node.selectors.some((selector) => selector.includes(":host"));
|
|
1858
2055
|
const hasRootPseudoSelector = node.selectors.some((selector) => selector.includes(":root"));
|
|
@@ -1861,7 +2058,7 @@ function commonChunkPreflight(node, options) {
|
|
|
1861
2058
|
node.selectors = [...node.selectors, ":host"];
|
|
1862
2059
|
}
|
|
1863
2060
|
if (testIfVariablesScope(node)) {
|
|
1864
|
-
_optionalChain([ctx, 'optionalAccess',
|
|
2061
|
+
_optionalChain([ctx, 'optionalAccess', _64 => _64.markVariablesScope, 'call', _65 => _65(node)]);
|
|
1865
2062
|
node.selectors = remakeCssVarSelector(node.selectors, options);
|
|
1866
2063
|
node.before(makePseudoVarRule());
|
|
1867
2064
|
if (typeof cssInjectPreflight === "function") {
|
|
@@ -1884,8 +2081,11 @@ function commonChunkPreflight(node, options) {
|
|
|
1884
2081
|
}
|
|
1885
2082
|
|
|
1886
2083
|
// src/plugins/pre.ts
|
|
2084
|
+
var MEDIA_HOVER_NAME_RE = /media\(\s*hover\s*:\s*hover\s*\)/;
|
|
2085
|
+
var MEDIA_HOVER_PARAMS_RE = /\(\s*hover\s*:\s*hover\s*\)/;
|
|
2086
|
+
var COLOR_MIX_RE = /color-mix/;
|
|
1887
2087
|
function isAtMediaHover(atRule) {
|
|
1888
|
-
return
|
|
2088
|
+
return MEDIA_HOVER_NAME_RE.test(atRule.name) || atRule.name === "media" && MEDIA_HOVER_PARAMS_RE.test(atRule.params);
|
|
1889
2089
|
}
|
|
1890
2090
|
var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
1891
2091
|
const opts = _shared.defu.call(void 0, options, { isMainChunk: true });
|
|
@@ -1902,7 +2102,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
1902
2102
|
atRule.remove();
|
|
1903
2103
|
}
|
|
1904
2104
|
} else if (atRule.name === "supports") {
|
|
1905
|
-
if (
|
|
2105
|
+
if (COLOR_MIX_RE.test(atRule.params)) {
|
|
1906
2106
|
atRule.remove();
|
|
1907
2107
|
}
|
|
1908
2108
|
} else if (atRule.name === "layer") {
|
|
@@ -1918,9 +2118,9 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
1918
2118
|
root.walkAtRules((atRule) => {
|
|
1919
2119
|
if (atRule.name === "layer") {
|
|
1920
2120
|
if (atRule.params === "properties") {
|
|
1921
|
-
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access',
|
|
2121
|
+
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _66 => _66.nodes, 'optionalAccess', _67 => _67.length]) === 0) {
|
|
1922
2122
|
layerProperties = atRule;
|
|
1923
|
-
} else if (_optionalChain([atRule, 'access',
|
|
2123
|
+
} else if (_optionalChain([atRule, 'access', _68 => _68.first, 'optionalAccess', _69 => _69.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
|
|
1924
2124
|
if (layerProperties) {
|
|
1925
2125
|
layerProperties.replaceWith(atRule.first.nodes);
|
|
1926
2126
|
atRule.remove();
|
|
@@ -1932,7 +2132,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
1932
2132
|
atRule.replaceWith(atRule.nodes);
|
|
1933
2133
|
}
|
|
1934
2134
|
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
1935
|
-
if (_optionalChain([atRule, 'access',
|
|
2135
|
+
if (_optionalChain([atRule, 'access', _70 => _70.first, 'optionalAccess', _71 => _71.type]) === "atrule" && atRule.first.name === "layer") {
|
|
1936
2136
|
atRule.replaceWith(atRule.first.nodes);
|
|
1937
2137
|
}
|
|
1938
2138
|
}
|
|
@@ -1947,7 +2147,6 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
1947
2147
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
1948
2148
|
|
|
1949
2149
|
// src/pipeline.ts
|
|
1950
|
-
var STAGE_ORDER = ["pre", "normal", "post"];
|
|
1951
2150
|
function normalizeUserPlugins(plugins) {
|
|
1952
2151
|
if (!plugins) {
|
|
1953
2152
|
return [];
|
|
@@ -1960,140 +2159,53 @@ function normalizeUserPlugins(plugins) {
|
|
|
1960
2159
|
}
|
|
1961
2160
|
return [];
|
|
1962
2161
|
}
|
|
1963
|
-
function
|
|
2162
|
+
function createPreparedNode(id, stage, createPlugin) {
|
|
1964
2163
|
return {
|
|
1965
2164
|
id,
|
|
1966
2165
|
stage,
|
|
1967
|
-
|
|
1968
|
-
id,
|
|
1969
|
-
stage,
|
|
1970
|
-
createPlugin: () => plugin
|
|
1971
|
-
})
|
|
2166
|
+
createPlugin
|
|
1972
2167
|
};
|
|
1973
2168
|
}
|
|
1974
|
-
function
|
|
1975
|
-
const
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
post: []
|
|
1979
|
-
};
|
|
1980
|
-
const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access', _71 => _71.postcssOptions, 'optionalAccess', _72 => _72.plugins]));
|
|
2169
|
+
function createPreparedNodes(options) {
|
|
2170
|
+
const preparedNodes = [];
|
|
2171
|
+
const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access', _72 => _72.postcssOptions, 'optionalAccess', _73 => _73.plugins]));
|
|
2172
|
+
const presetEnvOptions = options.cssPresetEnv;
|
|
1981
2173
|
userPlugins.forEach((plugin, index) => {
|
|
1982
|
-
|
|
1983
|
-
});
|
|
1984
|
-
stages.pre.push({
|
|
1985
|
-
id: "pre:core",
|
|
1986
|
-
stage: "pre",
|
|
1987
|
-
prepare: () => ({
|
|
1988
|
-
id: "pre:core",
|
|
1989
|
-
stage: "pre",
|
|
1990
|
-
createPlugin: () => postcssWeappTailwindcssPrePlugin(options)
|
|
1991
|
-
})
|
|
1992
|
-
});
|
|
1993
|
-
stages.normal.push({
|
|
1994
|
-
id: "normal:preset-env",
|
|
1995
|
-
stage: "normal",
|
|
1996
|
-
prepare: () => ({
|
|
1997
|
-
id: "normal:preset-env",
|
|
1998
|
-
stage: "normal",
|
|
1999
|
-
createPlugin: () => _postcsspresetenv2.default.call(void 0, options.cssPresetEnv)
|
|
2000
|
-
})
|
|
2001
|
-
});
|
|
2002
|
-
stages.normal.push({
|
|
2003
|
-
id: "normal:color-functional-fallback",
|
|
2004
|
-
stage: "normal",
|
|
2005
|
-
prepare: () => ({
|
|
2006
|
-
id: "normal:color-functional-fallback",
|
|
2007
|
-
stage: "normal",
|
|
2008
|
-
createPlugin: () => createColorFunctionalFallback()
|
|
2009
|
-
})
|
|
2010
|
-
});
|
|
2011
|
-
stages.normal.push({
|
|
2012
|
-
id: "normal:units-to-px",
|
|
2013
|
-
stage: "normal",
|
|
2014
|
-
prepare: () => {
|
|
2015
|
-
const plugin = getUnitsToPxPlugin(options);
|
|
2016
|
-
return plugin ? {
|
|
2017
|
-
id: "normal:units-to-px",
|
|
2018
|
-
stage: "normal",
|
|
2019
|
-
createPlugin: () => plugin
|
|
2020
|
-
} : void 0;
|
|
2021
|
-
}
|
|
2174
|
+
preparedNodes.push(createPreparedNode(`pre:user-${index}`, "pre", () => plugin));
|
|
2022
2175
|
});
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
return plugin ? {
|
|
2053
|
-
id: "normal:calc",
|
|
2054
|
-
stage: "normal",
|
|
2055
|
-
createPlugin: () => plugin
|
|
2056
|
-
} : void 0;
|
|
2057
|
-
}
|
|
2058
|
-
});
|
|
2059
|
-
stages.normal.push({
|
|
2060
|
-
id: "normal:calc-duplicate-cleaner",
|
|
2061
|
-
stage: "normal",
|
|
2062
|
-
prepare: () => {
|
|
2063
|
-
const plugin = getCalcDuplicateCleaner(options);
|
|
2064
|
-
return plugin ? {
|
|
2065
|
-
id: "normal:calc-duplicate-cleaner",
|
|
2066
|
-
stage: "normal",
|
|
2067
|
-
createPlugin: () => plugin
|
|
2068
|
-
} : void 0;
|
|
2069
|
-
}
|
|
2070
|
-
});
|
|
2071
|
-
stages.normal.push({
|
|
2072
|
-
id: "normal:custom-property-cleaner",
|
|
2073
|
-
stage: "normal",
|
|
2074
|
-
prepare: () => {
|
|
2075
|
-
const plugin = getCustomPropertyCleaner(options);
|
|
2076
|
-
return plugin ? {
|
|
2077
|
-
id: "normal:custom-property-cleaner",
|
|
2078
|
-
stage: "normal",
|
|
2079
|
-
createPlugin: () => plugin
|
|
2080
|
-
} : void 0;
|
|
2081
|
-
}
|
|
2082
|
-
});
|
|
2083
|
-
stages.post.push({
|
|
2084
|
-
id: "post:core",
|
|
2085
|
-
stage: "post",
|
|
2086
|
-
prepare: () => ({
|
|
2087
|
-
id: "post:core",
|
|
2088
|
-
stage: "post",
|
|
2089
|
-
createPlugin: () => postcssWeappTailwindcssPostPlugin(options)
|
|
2090
|
-
})
|
|
2091
|
-
});
|
|
2092
|
-
return STAGE_ORDER.flatMap((stage) => stages[stage]);
|
|
2176
|
+
preparedNodes.push(createPreparedNode("pre:core", "pre", () => postcssWeappTailwindcssPrePlugin(options)));
|
|
2177
|
+
preparedNodes.push(createPreparedNode("normal:preset-env", "normal", () => _postcsspresetenv2.default.call(void 0, presetEnvOptions)));
|
|
2178
|
+
preparedNodes.push(createPreparedNode("normal:color-functional-fallback", "normal", () => createColorFunctionalFallback()));
|
|
2179
|
+
const unitsToPxPlugin = getUnitsToPxPlugin(options);
|
|
2180
|
+
if (unitsToPxPlugin) {
|
|
2181
|
+
preparedNodes.push(createPreparedNode("normal:units-to-px", "normal", () => unitsToPxPlugin));
|
|
2182
|
+
}
|
|
2183
|
+
const pxTransformPlugin = getPxTransformPlugin(options);
|
|
2184
|
+
if (pxTransformPlugin) {
|
|
2185
|
+
preparedNodes.push(createPreparedNode("normal:px-transform", "normal", () => pxTransformPlugin));
|
|
2186
|
+
}
|
|
2187
|
+
const remTransformPlugin = getRemTransformPlugin(options);
|
|
2188
|
+
if (remTransformPlugin) {
|
|
2189
|
+
preparedNodes.push(createPreparedNode("normal:rem-transform", "normal", () => remTransformPlugin));
|
|
2190
|
+
}
|
|
2191
|
+
const calcPlugin = getCalcPlugin(options);
|
|
2192
|
+
if (calcPlugin) {
|
|
2193
|
+
preparedNodes.push(createPreparedNode("normal:calc", "normal", () => calcPlugin));
|
|
2194
|
+
}
|
|
2195
|
+
const calcDuplicateCleaner = getCalcDuplicateCleaner(options);
|
|
2196
|
+
if (calcDuplicateCleaner) {
|
|
2197
|
+
preparedNodes.push(createPreparedNode("normal:calc-duplicate-cleaner", "normal", () => calcDuplicateCleaner));
|
|
2198
|
+
}
|
|
2199
|
+
const customPropertyCleaner = getCustomPropertyCleaner(options);
|
|
2200
|
+
if (customPropertyCleaner) {
|
|
2201
|
+
preparedNodes.push(createPreparedNode("normal:custom-property-cleaner", "normal", () => customPropertyCleaner));
|
|
2202
|
+
}
|
|
2203
|
+
preparedNodes.push(createPreparedNode("post:core", "post", () => postcssWeappTailwindcssPostPlugin(options)));
|
|
2204
|
+
return preparedNodes;
|
|
2093
2205
|
}
|
|
2094
2206
|
function createStylePipeline(options) {
|
|
2095
2207
|
options.ctx = createContext();
|
|
2096
|
-
const preparedNodes =
|
|
2208
|
+
const preparedNodes = createPreparedNodes(options);
|
|
2097
2209
|
if (preparedNodes.length === 0) {
|
|
2098
2210
|
return {
|
|
2099
2211
|
nodes: [],
|
|
@@ -2152,9 +2264,38 @@ function createStylePipeline(options) {
|
|
|
2152
2264
|
function createProcessOptions(options) {
|
|
2153
2265
|
return {
|
|
2154
2266
|
from: void 0,
|
|
2155
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
2267
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _74 => _74.postcssOptions, 'optionalAccess', _75 => _75.options]), () => ( {}))
|
|
2156
2268
|
};
|
|
2157
2269
|
}
|
|
2270
|
+
function getSimpleProcessOptionsCacheKey(options) {
|
|
2271
|
+
const parts = ["simple"];
|
|
2272
|
+
for (const key of Object.keys(options).sort()) {
|
|
2273
|
+
const value = options[key];
|
|
2274
|
+
switch (typeof value) {
|
|
2275
|
+
case "string":
|
|
2276
|
+
parts.push(`${key}:str:${value}`);
|
|
2277
|
+
break;
|
|
2278
|
+
case "number":
|
|
2279
|
+
parts.push(`${key}:num:${value}`);
|
|
2280
|
+
break;
|
|
2281
|
+
case "boolean":
|
|
2282
|
+
parts.push(`${key}:bool:${value ? "1" : "0"}`);
|
|
2283
|
+
break;
|
|
2284
|
+
case "undefined":
|
|
2285
|
+
parts.push(`${key}:undefined`);
|
|
2286
|
+
break;
|
|
2287
|
+
case "object":
|
|
2288
|
+
if (value === null) {
|
|
2289
|
+
parts.push(`${key}:null`);
|
|
2290
|
+
break;
|
|
2291
|
+
}
|
|
2292
|
+
return void 0;
|
|
2293
|
+
default:
|
|
2294
|
+
return void 0;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
return parts.join("|");
|
|
2298
|
+
}
|
|
2158
2299
|
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);_class.prototype.__init5.call(this); }
|
|
2159
2300
|
__init() {this.pipelineCache = /* @__PURE__ */ new WeakMap()}
|
|
2160
2301
|
__init2() {this.processOptionsCache = /* @__PURE__ */ new WeakMap()}
|
|
@@ -2162,7 +2303,7 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
|
|
|
2162
2303
|
__init4() {this.processorCacheByKey = /* @__PURE__ */ new Map()}
|
|
2163
2304
|
__init5() {this.processorKeyCache = /* @__PURE__ */ new WeakMap()}
|
|
2164
2305
|
createProcessorCacheKey(options) {
|
|
2165
|
-
const from = _optionalChain([options, 'access',
|
|
2306
|
+
const from = _optionalChain([options, 'access', _76 => _76.postcssOptions, 'optionalAccess', _77 => _77.options, 'optionalAccess', _78 => _78.from]);
|
|
2166
2307
|
if (from == null) {
|
|
2167
2308
|
return fingerprintOptions(options);
|
|
2168
2309
|
}
|
|
@@ -2171,7 +2312,7 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
|
|
|
2171
2312
|
postcssOptions: {
|
|
2172
2313
|
..._nullishCoalesce(options.postcssOptions, () => ( {})),
|
|
2173
2314
|
options: {
|
|
2174
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
2315
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _79 => _79.postcssOptions, 'optionalAccess', _80 => _80.options]), () => ( {})),
|
|
2175
2316
|
from: void 0
|
|
2176
2317
|
}
|
|
2177
2318
|
}
|
|
@@ -2186,12 +2327,12 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
|
|
|
2186
2327
|
return pipeline;
|
|
2187
2328
|
}
|
|
2188
2329
|
getProcessOptions(options) {
|
|
2189
|
-
const source = _optionalChain([options, 'access',
|
|
2190
|
-
const
|
|
2330
|
+
const source = _optionalChain([options, 'access', _81 => _81.postcssOptions, 'optionalAccess', _82 => _82.options]);
|
|
2331
|
+
const cacheKey = source ? _nullishCoalesce(getSimpleProcessOptionsCacheKey(source), () => ( fingerprintOptions(source))) : void 0;
|
|
2191
2332
|
const cached = this.processOptionsCache.get(options);
|
|
2192
|
-
if (!cached || cached.
|
|
2333
|
+
if (!cached || cached.cacheKey !== cacheKey) {
|
|
2193
2334
|
const created = createProcessOptions(options);
|
|
2194
|
-
this.processOptionsCache.set(options, { value: created,
|
|
2335
|
+
this.processOptionsCache.set(options, { value: created, cacheKey });
|
|
2195
2336
|
return { ...created };
|
|
2196
2337
|
}
|
|
2197
2338
|
return { ...cached.value };
|