@weapp-tailwindcss/postcss 2.0.7 → 2.1.0
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/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +294 -180
- package/dist/index.mjs +274 -160
- package/dist/{types-6NcGD9Zr.d.mts → types-DiZP4O-E.d.mts} +2 -2
- package/dist/{types-6NcGD9Zr.d.ts → types-DiZP4O-E.d.ts} +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import "./chunk-WAXGOBY2.mjs";
|
|
2
2
|
|
|
3
3
|
// src/handler.ts
|
|
4
|
-
import { defuOverrideArray as
|
|
5
|
-
import postcss from "postcss";
|
|
4
|
+
import { defuOverrideArray as defuOverrideArray4 } from "@weapp-tailwindcss/shared";
|
|
6
5
|
|
|
7
6
|
// src/defaults.ts
|
|
8
7
|
function getDefaultOptions(options) {
|
|
@@ -35,6 +34,102 @@ function getDefaultOptions(options) {
|
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
|
|
37
|
+
// src/options-resolver.ts
|
|
38
|
+
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
39
|
+
|
|
40
|
+
// src/fingerprint.ts
|
|
41
|
+
function fingerprintOptions(value, state = { map: /* @__PURE__ */ new WeakMap(), counter: 0 }) {
|
|
42
|
+
if (value === null || value === void 0) {
|
|
43
|
+
return String(value);
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "function") {
|
|
46
|
+
return `fn:${value.name || "anonymous"}`;
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === "symbol") {
|
|
49
|
+
return `sym:${String(value)}`;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value !== "object") {
|
|
52
|
+
return `${typeof value}:${String(value)}`;
|
|
53
|
+
}
|
|
54
|
+
const objectValue = value;
|
|
55
|
+
const cached = state.map.get(objectValue);
|
|
56
|
+
if (cached) {
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
59
|
+
const marker = `ref:${state.counter++}`;
|
|
60
|
+
state.map.set(objectValue, marker);
|
|
61
|
+
if (Array.isArray(objectValue)) {
|
|
62
|
+
const parts2 = objectValue.map((entry) => fingerprintOptions(entry, state));
|
|
63
|
+
return `[${parts2.join(",")}]`;
|
|
64
|
+
}
|
|
65
|
+
const keys = Object.keys(objectValue).sort();
|
|
66
|
+
const parts = keys.map((key) => `${key}:${fingerprintOptions(objectValue[key], state)}`);
|
|
67
|
+
return `{${parts.join(",")}}@${marker}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/options-resolver.ts
|
|
71
|
+
var BASE_CACHE_KEY = "base";
|
|
72
|
+
function hasOverrides(options) {
|
|
73
|
+
return Boolean(options && Object.keys(options).length > 0);
|
|
74
|
+
}
|
|
75
|
+
function createOptionsResolver(baseOptions) {
|
|
76
|
+
const cacheByKey = /* @__PURE__ */ new Map();
|
|
77
|
+
const cacheByRef = /* @__PURE__ */ new WeakMap();
|
|
78
|
+
const fingerprintByRef = /* @__PURE__ */ new WeakMap();
|
|
79
|
+
cacheByKey.set(BASE_CACHE_KEY, baseOptions);
|
|
80
|
+
const resolve = (overrides) => {
|
|
81
|
+
if (!hasOverrides(overrides)) {
|
|
82
|
+
return baseOptions;
|
|
83
|
+
}
|
|
84
|
+
const refCached = cacheByRef.get(overrides);
|
|
85
|
+
if (refCached) {
|
|
86
|
+
return refCached;
|
|
87
|
+
}
|
|
88
|
+
let key = fingerprintByRef.get(overrides);
|
|
89
|
+
if (!key) {
|
|
90
|
+
key = fingerprintOptions(overrides);
|
|
91
|
+
fingerprintByRef.set(overrides, key);
|
|
92
|
+
}
|
|
93
|
+
const cached = cacheByKey.get(key);
|
|
94
|
+
if (cached) {
|
|
95
|
+
cacheByRef.set(overrides, cached);
|
|
96
|
+
return cached;
|
|
97
|
+
}
|
|
98
|
+
const merged = defuOverrideArray(
|
|
99
|
+
{ ...overrides },
|
|
100
|
+
baseOptions
|
|
101
|
+
);
|
|
102
|
+
cacheByKey.set(key, merged);
|
|
103
|
+
cacheByRef.set(overrides, merged);
|
|
104
|
+
return merged;
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
resolve
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/preflight.ts
|
|
112
|
+
function createInjectPreflight(options) {
|
|
113
|
+
const result = [];
|
|
114
|
+
if (options && typeof options === "object") {
|
|
115
|
+
const entries = Object.entries(options);
|
|
116
|
+
for (const [prop, value] of entries) {
|
|
117
|
+
if (value !== false) {
|
|
118
|
+
result.push({
|
|
119
|
+
prop,
|
|
120
|
+
value: value.toString()
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return () => {
|
|
126
|
+
return result;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/processor-cache.ts
|
|
131
|
+
import postcss from "postcss";
|
|
132
|
+
|
|
38
133
|
// src/pipeline.ts
|
|
39
134
|
import postcssPresetEnv from "postcss-preset-env";
|
|
40
135
|
|
|
@@ -154,7 +249,7 @@ function createContext() {
|
|
|
154
249
|
// src/plugins/getCalcPlugin.ts
|
|
155
250
|
import postcssCalc from "@weapp-tailwindcss/postcss-calc";
|
|
156
251
|
|
|
157
|
-
// ../../node_modules/.pnpm/es-toolkit@1.
|
|
252
|
+
// ../../node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/object/omit.mjs
|
|
158
253
|
function omit(obj, keys) {
|
|
159
254
|
const result = { ...obj };
|
|
160
255
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -219,10 +314,11 @@ function getCustomPropertyCleaner(options) {
|
|
|
219
314
|
}
|
|
220
315
|
|
|
221
316
|
// src/plugins/getPxTransformPlugin.ts
|
|
222
|
-
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
223
|
-
import
|
|
317
|
+
import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
318
|
+
import postcssPxtrans from "postcss-pxtrans";
|
|
224
319
|
var defaultPxTransformOptions = {
|
|
225
320
|
platform: "weapp",
|
|
321
|
+
targetUnit: "rpx",
|
|
226
322
|
unitPrecision: 5,
|
|
227
323
|
propList: ["*"],
|
|
228
324
|
selectorBlackList: [],
|
|
@@ -242,8 +338,8 @@ function getPxTransformPlugin(options) {
|
|
|
242
338
|
return null;
|
|
243
339
|
}
|
|
244
340
|
const userOptions = typeof options.px2rpx === "object" ? options.px2rpx : {};
|
|
245
|
-
return
|
|
246
|
-
|
|
341
|
+
return postcssPxtrans(
|
|
342
|
+
defuOverrideArray2(
|
|
247
343
|
userOptions,
|
|
248
344
|
defaultPxTransformOptions
|
|
249
345
|
)
|
|
@@ -251,7 +347,7 @@ function getPxTransformPlugin(options) {
|
|
|
251
347
|
}
|
|
252
348
|
|
|
253
349
|
// src/plugins/getRemTransformPlugin.ts
|
|
254
|
-
import { defuOverrideArray as
|
|
350
|
+
import { defuOverrideArray as defuOverrideArray3 } from "@weapp-tailwindcss/shared";
|
|
255
351
|
import postcssRem2rpx from "postcss-rem-to-responsive-pixel";
|
|
256
352
|
var defaultRemOptions = {
|
|
257
353
|
rootValue: 32,
|
|
@@ -266,7 +362,7 @@ function getRemTransformPlugin(options) {
|
|
|
266
362
|
return null;
|
|
267
363
|
}
|
|
268
364
|
const userOptions = typeof options.rem2rpx === "object" ? options.rem2rpx : defaultRemOptions;
|
|
269
|
-
const merged =
|
|
365
|
+
const merged = defuOverrideArray3(
|
|
270
366
|
userOptions,
|
|
271
367
|
defaultStage
|
|
272
368
|
);
|
|
@@ -276,8 +372,36 @@ function getRemTransformPlugin(options) {
|
|
|
276
372
|
// src/plugins/post.ts
|
|
277
373
|
import { defu } from "@weapp-tailwindcss/shared";
|
|
278
374
|
|
|
279
|
-
// src/compat/tailwindcss-
|
|
280
|
-
|
|
375
|
+
// src/compat/tailwindcss-rpx.ts
|
|
376
|
+
var LENGTH_VALUE_REGEXP = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?rpx$/i;
|
|
377
|
+
function normalizeTailwindcssRpxDeclaration(decl, options) {
|
|
378
|
+
const majorVersion = options?.majorVersion;
|
|
379
|
+
const normalizedValue = decl.value.trim();
|
|
380
|
+
if (LENGTH_VALUE_REGEXP.test(normalizedValue) && (majorVersion === void 0 || majorVersion === 2 || majorVersion === 3 || majorVersion === 4)) {
|
|
381
|
+
const lowerProp = decl.prop.toLowerCase();
|
|
382
|
+
if (lowerProp === "color") {
|
|
383
|
+
decl.prop = "font-size";
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
if (lowerProp === "background-color") {
|
|
387
|
+
decl.prop = "background-size";
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
if (lowerProp === "outline-color") {
|
|
391
|
+
decl.prop = "outline-width";
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
if (lowerProp.startsWith("border") && lowerProp.endsWith("color")) {
|
|
395
|
+
decl.prop = `${decl.prop.slice(0, -"color".length)}width`;
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
if (lowerProp === "--tw-ring-color") {
|
|
399
|
+
decl.prop = "--tw-ring-offset-width";
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
281
405
|
|
|
282
406
|
// src/cssVarsV4.ts
|
|
283
407
|
function property(ident, initialValue, _syntax) {
|
|
@@ -417,6 +541,15 @@ for (const edge of ["top", "right", "bottom", "left"]) {
|
|
|
417
541
|
}
|
|
418
542
|
var cssVarsV4_default = nodes;
|
|
419
543
|
|
|
544
|
+
// src/utils/css-vars.ts
|
|
545
|
+
import { Declaration } from "postcss";
|
|
546
|
+
function createCssVarNodes(definitions) {
|
|
547
|
+
return definitions.map((def) => new Declaration({
|
|
548
|
+
prop: def.prop,
|
|
549
|
+
value: def.value
|
|
550
|
+
}));
|
|
551
|
+
}
|
|
552
|
+
|
|
420
553
|
// src/compat/tailwindcss-v4.ts
|
|
421
554
|
var OKLAB_SUFFIX = "in oklab";
|
|
422
555
|
var INFINITY_CALC_REGEXP = /calc\(\s*infinity\s*\*\s*(?:\d+(?:\.\d*)?|\.\d+)r?px/;
|
|
@@ -428,12 +561,7 @@ function isTailwindcssV4(options) {
|
|
|
428
561
|
function testIfRootHostForV4(node) {
|
|
429
562
|
return node.type === "rule" && node.selector.includes(":root") && node.selector.includes(":host");
|
|
430
563
|
}
|
|
431
|
-
var cssVarsV4Nodes = cssVarsV4_default
|
|
432
|
-
return new Declaration({
|
|
433
|
-
prop: x.prop,
|
|
434
|
-
value: x.value
|
|
435
|
-
});
|
|
436
|
-
});
|
|
564
|
+
var cssVarsV4Nodes = createCssVarNodes(cssVarsV4_default);
|
|
437
565
|
function isTailwindcssV4ModernCheck(atRule) {
|
|
438
566
|
return atRule.name === "supports" && [
|
|
439
567
|
/-webkit-hyphens\s*:\s*none/,
|
|
@@ -583,6 +711,7 @@ function getCombinatorSelectorAst(options) {
|
|
|
583
711
|
// src/selectorParser/fallback.ts
|
|
584
712
|
var fallbackRemoveCache = /* @__PURE__ */ new WeakMap();
|
|
585
713
|
var fallbackDefaultKey = {};
|
|
714
|
+
var FALLBACK_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
586
715
|
function getFallbackRemove(_rule, options) {
|
|
587
716
|
const cacheKey = options ?? fallbackDefaultKey;
|
|
588
717
|
let entry = fallbackRemoveCache.get(cacheKey);
|
|
@@ -647,24 +776,25 @@ function getFallbackRemove(_rule, options) {
|
|
|
647
776
|
const transform = (targetRule) => {
|
|
648
777
|
currentRule = targetRule;
|
|
649
778
|
try {
|
|
650
|
-
rawTransformSync(targetRule,
|
|
779
|
+
rawTransformSync(targetRule, FALLBACK_TRANSFORM_OPTIONS);
|
|
651
780
|
} finally {
|
|
652
781
|
currentRule = void 0;
|
|
653
782
|
}
|
|
654
783
|
};
|
|
655
784
|
parser.transformSync = ((input, opts) => {
|
|
785
|
+
const transformOptions = opts ? normalizeTransformOptions(opts) : FALLBACK_TRANSFORM_OPTIONS;
|
|
656
786
|
if (input && typeof input === "object" && "type" in input) {
|
|
657
787
|
const maybeRule = input;
|
|
658
788
|
if (maybeRule.type === "rule") {
|
|
659
789
|
currentRule = input;
|
|
660
790
|
try {
|
|
661
|
-
return rawTransformSync(input,
|
|
791
|
+
return rawTransformSync(input, transformOptions);
|
|
662
792
|
} finally {
|
|
663
793
|
currentRule = void 0;
|
|
664
794
|
}
|
|
665
795
|
}
|
|
666
796
|
}
|
|
667
|
-
return rawTransformSync(input,
|
|
797
|
+
return rawTransformSync(input, transformOptions);
|
|
668
798
|
});
|
|
669
799
|
entry = {
|
|
670
800
|
parser,
|
|
@@ -698,6 +828,47 @@ function composeIsPseudo(strs) {
|
|
|
698
828
|
return strs.join("");
|
|
699
829
|
}
|
|
700
830
|
|
|
831
|
+
// src/utils/decl-order.ts
|
|
832
|
+
function reorderLiteralFirst(rule, declarations, isVariable) {
|
|
833
|
+
if (declarations.length <= 1) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
const literals = [];
|
|
837
|
+
const variables = [];
|
|
838
|
+
for (const decl of declarations) {
|
|
839
|
+
if (isVariable(decl)) {
|
|
840
|
+
variables.push(decl);
|
|
841
|
+
} else {
|
|
842
|
+
literals.push(decl);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (literals.length === 0 || variables.length === 0) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
const desired = [...literals, ...variables];
|
|
849
|
+
let alreadyOrdered = true;
|
|
850
|
+
for (let index = 0; index < desired.length; index++) {
|
|
851
|
+
if (desired[index] !== declarations[index]) {
|
|
852
|
+
alreadyOrdered = false;
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (alreadyOrdered) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const anchor = declarations[declarations.length - 1]?.next() ?? void 0;
|
|
860
|
+
for (const decl of declarations) {
|
|
861
|
+
decl.remove();
|
|
862
|
+
}
|
|
863
|
+
for (const decl of desired) {
|
|
864
|
+
if (anchor) {
|
|
865
|
+
rule.insertBefore(anchor, decl);
|
|
866
|
+
} else {
|
|
867
|
+
rule.append(decl);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
701
872
|
// src/selectorParser/rule-transformer.ts
|
|
702
873
|
var ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
703
874
|
var MIRROR_PROP_PAIRS = [
|
|
@@ -725,6 +896,7 @@ var LEGACY_WEBKIT_SPACING_PROPS = /* @__PURE__ */ new Set([
|
|
|
725
896
|
"-webkit-margin-after"
|
|
726
897
|
]);
|
|
727
898
|
var VAR_REFERENCE_PATTERN = /var\(/i;
|
|
899
|
+
var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
728
900
|
function dedupeSpacingProps(rule) {
|
|
729
901
|
const grouped = /* @__PURE__ */ new Map();
|
|
730
902
|
for (const node of rule.nodes) {
|
|
@@ -762,27 +934,11 @@ function dedupeSpacingProps(rule) {
|
|
|
762
934
|
if (unique.length <= 1) {
|
|
763
935
|
continue;
|
|
764
936
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
const ordered = [...literals, ...variables];
|
|
771
|
-
const alreadyOrdered = ordered.every((decl, index) => decl === unique[index]);
|
|
772
|
-
if (alreadyOrdered) {
|
|
773
|
-
continue;
|
|
774
|
-
}
|
|
775
|
-
const anchor = unique[unique.length - 1]?.next() ?? void 0;
|
|
776
|
-
for (const decl of unique) {
|
|
777
|
-
decl.remove();
|
|
778
|
-
}
|
|
779
|
-
for (const decl of ordered) {
|
|
780
|
-
if (anchor) {
|
|
781
|
-
rule.insertBefore(anchor, decl);
|
|
782
|
-
} else {
|
|
783
|
-
rule.append(decl);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
937
|
+
reorderLiteralFirst(
|
|
938
|
+
rule,
|
|
939
|
+
unique,
|
|
940
|
+
(decl) => VAR_REFERENCE_PATTERN.test(decl.value)
|
|
941
|
+
);
|
|
786
942
|
}
|
|
787
943
|
}
|
|
788
944
|
function isNotLastChildPseudo(node) {
|
|
@@ -992,7 +1148,7 @@ function createRuleTransformer(options) {
|
|
|
992
1148
|
rule
|
|
993
1149
|
};
|
|
994
1150
|
try {
|
|
995
|
-
parser.transformSync(rule,
|
|
1151
|
+
parser.transformSync(rule, SELECTOR_TRANSFORM_OPTIONS);
|
|
996
1152
|
} finally {
|
|
997
1153
|
context = void 0;
|
|
998
1154
|
}
|
|
@@ -1158,33 +1314,11 @@ function dedupeDeclarations(rule) {
|
|
|
1158
1314
|
if (declarations.length <= 1) {
|
|
1159
1315
|
continue;
|
|
1160
1316
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
const ordered = [...literals, ...variables];
|
|
1167
|
-
let needReorder = false;
|
|
1168
|
-
for (let index = 0; index < ordered.length; index++) {
|
|
1169
|
-
if (ordered[index] !== declarations[index]) {
|
|
1170
|
-
needReorder = true;
|
|
1171
|
-
break;
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
if (!needReorder) {
|
|
1175
|
-
continue;
|
|
1176
|
-
}
|
|
1177
|
-
const anchor = declarations[declarations.length - 1]?.next() ?? void 0;
|
|
1178
|
-
for (const decl of declarations) {
|
|
1179
|
-
decl.remove();
|
|
1180
|
-
}
|
|
1181
|
-
for (const decl of ordered) {
|
|
1182
|
-
if (anchor) {
|
|
1183
|
-
rule.insertBefore(anchor, decl);
|
|
1184
|
-
} else {
|
|
1185
|
-
rule.append(decl);
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1317
|
+
reorderLiteralFirst(
|
|
1318
|
+
rule,
|
|
1319
|
+
declarations,
|
|
1320
|
+
(decl) => hasVariableReference(decl.value)
|
|
1321
|
+
);
|
|
1188
1322
|
}
|
|
1189
1323
|
const literalSeen = /* @__PURE__ */ new Map();
|
|
1190
1324
|
for (const node of [...rule.nodes]) {
|
|
@@ -1234,7 +1368,10 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1234
1368
|
};
|
|
1235
1369
|
}
|
|
1236
1370
|
if (enableMainChunkTransforms) {
|
|
1237
|
-
p.DeclarationExit = (decl) =>
|
|
1371
|
+
p.DeclarationExit = (decl) => {
|
|
1372
|
+
normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
|
|
1373
|
+
normalizeTailwindcssV4Declaration(decl);
|
|
1374
|
+
};
|
|
1238
1375
|
p.AtRuleExit = (atRule) => {
|
|
1239
1376
|
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
1240
1377
|
atRule.remove();
|
|
@@ -1460,42 +1597,31 @@ var cssVarsV3_default = [
|
|
|
1460
1597
|
}
|
|
1461
1598
|
];
|
|
1462
1599
|
|
|
1463
|
-
// src/
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
function testIfVariablesScope(node, count = 2) {
|
|
1471
|
-
if (isOnlyBeforeAndAfterPseudoElement(node)) {
|
|
1472
|
-
const nodes2 = node.nodes;
|
|
1473
|
-
let c = 0;
|
|
1474
|
-
for (const tryTestDecl of nodes2) {
|
|
1475
|
-
if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
|
|
1476
|
-
c++;
|
|
1477
|
-
}
|
|
1478
|
-
if (c >= count) {
|
|
1600
|
+
// src/utils/tw-vars.ts
|
|
1601
|
+
function hasTwVars(rule, count = 2) {
|
|
1602
|
+
let matched = 0;
|
|
1603
|
+
for (const node of rule.nodes ?? []) {
|
|
1604
|
+
if (node.type === "decl" && node.prop.startsWith("--tw-")) {
|
|
1605
|
+
matched++;
|
|
1606
|
+
if (matched >= count) {
|
|
1479
1607
|
return true;
|
|
1480
1608
|
}
|
|
1481
1609
|
}
|
|
1482
|
-
|
|
1610
|
+
}
|
|
1611
|
+
return false;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
// src/mp.ts
|
|
1615
|
+
var cssVarsV3Nodes = createCssVarNodes(cssVarsV3_default);
|
|
1616
|
+
function testIfVariablesScope(node, count = 2) {
|
|
1617
|
+
if (isOnlyBeforeAndAfterPseudoElement(node)) {
|
|
1618
|
+
return hasTwVars(node, count);
|
|
1483
1619
|
}
|
|
1484
1620
|
return false;
|
|
1485
1621
|
}
|
|
1486
1622
|
function testIfTwBackdrop(node, count = 2) {
|
|
1487
1623
|
if (node.type === "rule" && node.selector === "::backdrop") {
|
|
1488
|
-
|
|
1489
|
-
let c = 0;
|
|
1490
|
-
for (const tryTestDecl of nodes2) {
|
|
1491
|
-
if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
|
|
1492
|
-
c++;
|
|
1493
|
-
}
|
|
1494
|
-
if (c >= count) {
|
|
1495
|
-
return true;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
return false;
|
|
1624
|
+
return hasTwVars(node, count);
|
|
1499
1625
|
}
|
|
1500
1626
|
return false;
|
|
1501
1627
|
}
|
|
@@ -1786,83 +1912,71 @@ function createStylePipeline(options) {
|
|
|
1786
1912
|
};
|
|
1787
1913
|
}
|
|
1788
1914
|
|
|
1789
|
-
// src/
|
|
1790
|
-
function createInjectPreflight(options) {
|
|
1791
|
-
const result = [];
|
|
1792
|
-
if (options && typeof options === "object") {
|
|
1793
|
-
const entries = Object.entries(options);
|
|
1794
|
-
for (const [prop, value] of entries) {
|
|
1795
|
-
if (value !== false) {
|
|
1796
|
-
result.push({
|
|
1797
|
-
prop,
|
|
1798
|
-
value: value.toString()
|
|
1799
|
-
});
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
return () => {
|
|
1804
|
-
return result;
|
|
1805
|
-
};
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
// src/handler.ts
|
|
1915
|
+
// src/processor-cache.ts
|
|
1809
1916
|
function createProcessOptions(options) {
|
|
1810
1917
|
return {
|
|
1811
1918
|
from: void 0,
|
|
1812
1919
|
...options.postcssOptions?.options ?? {}
|
|
1813
1920
|
};
|
|
1814
1921
|
}
|
|
1815
|
-
var
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
cached
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1922
|
+
var StyleProcessorCache = class {
|
|
1923
|
+
pipelineCache = /* @__PURE__ */ new WeakMap();
|
|
1924
|
+
processOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
1925
|
+
processorCache = /* @__PURE__ */ new WeakMap();
|
|
1926
|
+
getPipeline(options) {
|
|
1927
|
+
let pipeline = this.pipelineCache.get(options);
|
|
1928
|
+
if (!pipeline) {
|
|
1929
|
+
pipeline = createStylePipeline(options);
|
|
1930
|
+
this.pipelineCache.set(options, pipeline);
|
|
1931
|
+
}
|
|
1932
|
+
return pipeline;
|
|
1933
|
+
}
|
|
1934
|
+
getProcessOptions(options) {
|
|
1935
|
+
const source = options.postcssOptions?.options;
|
|
1936
|
+
const fingerprint = source ? fingerprintOptions(source) : void 0;
|
|
1937
|
+
const cached = this.processOptionsCache.get(options);
|
|
1938
|
+
if (!cached || cached.fingerprint !== fingerprint) {
|
|
1939
|
+
const created = createProcessOptions(options);
|
|
1940
|
+
this.processOptionsCache.set(options, { value: created, fingerprint });
|
|
1941
|
+
return { ...created };
|
|
1942
|
+
}
|
|
1943
|
+
return { ...cached.value };
|
|
1944
|
+
}
|
|
1945
|
+
getProcessor(options) {
|
|
1946
|
+
let processor = this.processorCache.get(options);
|
|
1947
|
+
if (!processor) {
|
|
1948
|
+
const pipeline = this.getPipeline(options);
|
|
1949
|
+
processor = postcss(pipeline.plugins);
|
|
1950
|
+
this.processorCache.set(options, processor);
|
|
1951
|
+
}
|
|
1952
|
+
return processor;
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
// src/handler.ts
|
|
1845
1957
|
function createStyleHandler(options) {
|
|
1846
|
-
const cachedOptions =
|
|
1958
|
+
const cachedOptions = defuOverrideArray4(
|
|
1847
1959
|
options,
|
|
1848
1960
|
getDefaultOptions(options)
|
|
1849
1961
|
);
|
|
1850
1962
|
cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
|
|
1851
|
-
|
|
1852
|
-
|
|
1963
|
+
const resolver = createOptionsResolver(cachedOptions);
|
|
1964
|
+
const cache = new StyleProcessorCache();
|
|
1965
|
+
const base = resolver.resolve();
|
|
1966
|
+
cache.getProcessor(base);
|
|
1967
|
+
cache.getProcessOptions(base);
|
|
1853
1968
|
const handler = ((rawSource, opt) => {
|
|
1854
|
-
const resolvedOptions =
|
|
1855
|
-
|
|
1969
|
+
const resolvedOptions = resolver.resolve(opt);
|
|
1970
|
+
const processor = cache.getProcessor(resolvedOptions);
|
|
1971
|
+
const processOptions = cache.getProcessOptions(resolvedOptions);
|
|
1972
|
+
return processor.process(
|
|
1856
1973
|
rawSource,
|
|
1857
|
-
|
|
1858
|
-
);
|
|
1974
|
+
processOptions
|
|
1975
|
+
).async();
|
|
1859
1976
|
});
|
|
1860
1977
|
handler.getPipeline = (opt) => {
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
}
|
|
1864
|
-
const resolvedOptions = defuOverrideArray3(opt, cachedOptions);
|
|
1865
|
-
return getCachedPipeline(resolvedOptions);
|
|
1978
|
+
const resolvedOptions = resolver.resolve(opt);
|
|
1979
|
+
return cache.getPipeline(resolvedOptions);
|
|
1866
1980
|
};
|
|
1867
1981
|
return handler;
|
|
1868
1982
|
}
|
|
@@ -2,7 +2,7 @@ import { PostCssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
|
|
|
2
2
|
import { AcceptedPlugin, Result as Result$1 } from 'postcss';
|
|
3
3
|
import { Result } from 'postcss-load-config';
|
|
4
4
|
import { pluginOptions } from 'postcss-preset-env';
|
|
5
|
-
import {
|
|
5
|
+
import { PxTransformOptions } from 'postcss-pxtrans';
|
|
6
6
|
import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
|
|
7
7
|
|
|
8
8
|
type PipelineStage = 'pre' | 'normal' | 'post';
|
|
@@ -106,7 +106,7 @@ interface UserDefinedPostcssOptions {
|
|
|
106
106
|
universal?: string | string[] | false;
|
|
107
107
|
};
|
|
108
108
|
rem2rpx?: boolean | UserDefinedOptions;
|
|
109
|
-
px2rpx?: boolean |
|
|
109
|
+
px2rpx?: boolean | PxTransformOptions;
|
|
110
110
|
postcssOptions?: LoadedPostcssOptions;
|
|
111
111
|
cssRemoveHoverPseudoClass?: boolean;
|
|
112
112
|
cssRemoveProperty?: boolean;
|
|
@@ -2,7 +2,7 @@ import { PostCssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
|
|
|
2
2
|
import { AcceptedPlugin, Result as Result$1 } from 'postcss';
|
|
3
3
|
import { Result } from 'postcss-load-config';
|
|
4
4
|
import { pluginOptions } from 'postcss-preset-env';
|
|
5
|
-
import {
|
|
5
|
+
import { PxTransformOptions } from 'postcss-pxtrans';
|
|
6
6
|
import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
|
|
7
7
|
|
|
8
8
|
type PipelineStage = 'pre' | 'normal' | 'post';
|
|
@@ -106,7 +106,7 @@ interface UserDefinedPostcssOptions {
|
|
|
106
106
|
universal?: string | string[] | false;
|
|
107
107
|
};
|
|
108
108
|
rem2rpx?: boolean | UserDefinedOptions;
|
|
109
|
-
px2rpx?: boolean |
|
|
109
|
+
px2rpx?: boolean | PxTransformOptions;
|
|
110
110
|
postcssOptions?: LoadedPostcssOptions;
|
|
111
111
|
cssRemoveHoverPseudoClass?: boolean;
|
|
112
112
|
cssRemoveProperty?: boolean;
|
package/dist/types.d.mts
CHANGED
|
@@ -2,6 +2,6 @@ import '@weapp-tailwindcss/postcss-calc';
|
|
|
2
2
|
import 'postcss';
|
|
3
3
|
import 'postcss-load-config';
|
|
4
4
|
export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
|
|
5
|
-
export {
|
|
5
|
+
export { PxTransformOptions as Px2rpxOptions } from 'postcss-pxtrans';
|
|
6
6
|
export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
|
|
7
|
-
export { C as CssCalcOptions, h as CssPreflightOptions, g as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, i as RequiredStyleHandlerOptions, S as StyleHandler, U as UserDefinedPostcssOptions } from './types-
|
|
7
|
+
export { C as CssCalcOptions, h as CssPreflightOptions, g as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, i as RequiredStyleHandlerOptions, S as StyleHandler, U as UserDefinedPostcssOptions } from './types-DiZP4O-E.mjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import '@weapp-tailwindcss/postcss-calc';
|
|
|
2
2
|
import 'postcss';
|
|
3
3
|
import 'postcss-load-config';
|
|
4
4
|
export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
|
|
5
|
-
export {
|
|
5
|
+
export { PxTransformOptions as Px2rpxOptions } from 'postcss-pxtrans';
|
|
6
6
|
export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
|
|
7
|
-
export { C as CssCalcOptions, h as CssPreflightOptions, g as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, i as RequiredStyleHandlerOptions, S as StyleHandler, U as UserDefinedPostcssOptions } from './types-
|
|
7
|
+
export { C as CssCalcOptions, h as CssPreflightOptions, g as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, i as RequiredStyleHandlerOptions, S as StyleHandler, U as UserDefinedPostcssOptions } from './types-DiZP4O-E.js';
|