@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.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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; }require('./chunk-GGNOJ77I.js');
|
|
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;require('./chunk-GGNOJ77I.js');
|
|
2
2
|
|
|
3
3
|
// src/handler.ts
|
|
4
4
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
5
|
-
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
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
|
+
|
|
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 = _shared.defuOverrideArray.call(void 0,
|
|
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
|
+
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
132
|
+
|
|
38
133
|
// src/pipeline.ts
|
|
39
134
|
var _postcsspresetenv = require('postcss-preset-env'); var _postcsspresetenv2 = _interopRequireDefault(_postcsspresetenv);
|
|
40
135
|
|
|
@@ -154,7 +249,7 @@ function createContext() {
|
|
|
154
249
|
// src/plugins/getCalcPlugin.ts
|
|
155
250
|
var _postcsscalc = require('@weapp-tailwindcss/postcss-calc'); var _postcsscalc2 = _interopRequireDefault(_postcsscalc);
|
|
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++) {
|
|
@@ -220,9 +315,10 @@ function getCustomPropertyCleaner(options) {
|
|
|
220
315
|
|
|
221
316
|
// src/plugins/getPxTransformPlugin.ts
|
|
222
317
|
|
|
223
|
-
var
|
|
318
|
+
var _postcsspxtrans = require('postcss-pxtrans'); var _postcsspxtrans2 = _interopRequireDefault(_postcsspxtrans);
|
|
224
319
|
var defaultPxTransformOptions = {
|
|
225
320
|
platform: "weapp",
|
|
321
|
+
targetUnit: "rpx",
|
|
226
322
|
unitPrecision: 5,
|
|
227
323
|
propList: ["*"],
|
|
228
324
|
selectorBlackList: [],
|
|
@@ -242,7 +338,7 @@ function getPxTransformPlugin(options) {
|
|
|
242
338
|
return null;
|
|
243
339
|
}
|
|
244
340
|
const userOptions = typeof options.px2rpx === "object" ? options.px2rpx : {};
|
|
245
|
-
return
|
|
341
|
+
return _postcsspxtrans2.default.call(void 0,
|
|
246
342
|
_shared.defuOverrideArray.call(void 0,
|
|
247
343
|
userOptions,
|
|
248
344
|
defaultPxTransformOptions
|
|
@@ -276,8 +372,36 @@ function getRemTransformPlugin(options) {
|
|
|
276
372
|
// src/plugins/post.ts
|
|
277
373
|
|
|
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 = _optionalChain([options, 'optionalAccess', _12 => _12.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,23 +541,27 @@ 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
|
+
|
|
546
|
+
function createCssVarNodes(definitions) {
|
|
547
|
+
return definitions.map((def) => new (0, _postcss.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/;
|
|
423
556
|
var RADIUS_THRESHOLD = 1e5;
|
|
424
557
|
var CLAMP_PX = 9999;
|
|
425
558
|
function isTailwindcssV4(options) {
|
|
426
|
-
return _optionalChain([options, 'optionalAccess',
|
|
559
|
+
return _optionalChain([options, 'optionalAccess', _13 => _13.majorVersion]) === 4;
|
|
427
560
|
}
|
|
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 (0, _postcss.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/,
|
|
@@ -475,7 +603,7 @@ function normalizeTailwindcssV4Declaration(decl) {
|
|
|
475
603
|
|
|
476
604
|
// src/compat/uni-app-x.ts
|
|
477
605
|
function isUniAppXEnabled(options) {
|
|
478
|
-
return Boolean(_optionalChain([options, 'optionalAccess',
|
|
606
|
+
return Boolean(_optionalChain([options, 'optionalAccess', _14 => _14.uniAppX]));
|
|
479
607
|
}
|
|
480
608
|
function stripUnsupportedPseudoForUniAppX(node, enabled) {
|
|
481
609
|
if (!enabled) {
|
|
@@ -509,7 +637,7 @@ var beforeAfterParser = _postcssselectorparser2.default.call(void 0, (selectors)
|
|
|
509
637
|
return;
|
|
510
638
|
}
|
|
511
639
|
selectors.walkPseudos((s) => {
|
|
512
|
-
if (_optionalChain([s, 'access',
|
|
640
|
+
if (_optionalChain([s, 'access', _15 => _15.parent, 'optionalAccess', _16 => _16.length]) === 1) {
|
|
513
641
|
if (/^:?:before$/.test(s.value)) {
|
|
514
642
|
state.before = true;
|
|
515
643
|
}
|
|
@@ -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 = _nullishCoalesce(options, () => ( fallbackDefaultKey));
|
|
588
717
|
let entry = fallbackRemoveCache.get(cacheKey);
|
|
@@ -597,13 +726,13 @@ function getFallbackRemove(_rule, options) {
|
|
|
597
726
|
maybeImportantId = true;
|
|
598
727
|
}
|
|
599
728
|
if (selector.type === "universal") {
|
|
600
|
-
_optionalChain([selector, 'access',
|
|
729
|
+
_optionalChain([selector, 'access', _17 => _17.parent, 'optionalAccess', _18 => _18.remove, 'call', _19 => _19()]);
|
|
601
730
|
} else if (selector.type === "pseudo") {
|
|
602
731
|
if (selector.value === ":is") {
|
|
603
|
-
if (maybeImportantId && _optionalChain([selector, 'access',
|
|
732
|
+
if (maybeImportantId && _optionalChain([selector, 'access', _20 => _20.nodes, 'access', _21 => _21[0], 'optionalAccess', _22 => _22.type]) === "selector") {
|
|
604
733
|
selector.replaceWith(selector.nodes[0]);
|
|
605
734
|
} else {
|
|
606
|
-
_optionalChain([selector, 'access',
|
|
735
|
+
_optionalChain([selector, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.remove, 'call', _25 => _25()]);
|
|
607
736
|
}
|
|
608
737
|
} else if (selector.value === ":not") {
|
|
609
738
|
for (const x of selector.nodes) {
|
|
@@ -626,7 +755,7 @@ function getFallbackRemove(_rule, options) {
|
|
|
626
755
|
}
|
|
627
756
|
} else if (selector.type === "attribute") {
|
|
628
757
|
if (selector.attribute === "hidden") {
|
|
629
|
-
_optionalChain([activeRule, 'optionalAccess',
|
|
758
|
+
_optionalChain([activeRule, 'optionalAccess', _26 => _26.remove, 'call', _27 => _27()]);
|
|
630
759
|
}
|
|
631
760
|
}
|
|
632
761
|
});
|
|
@@ -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 = _nullishCoalesce(_optionalChain([declarations, 'access', _28 => _28[declarations.length - 1], 'optionalAccess', _29 => _29.next, 'call', _30 => _30()]), () => ( 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 = _nullishCoalesce(_optionalChain([unique, 'access', _27 => _27[unique.length - 1], 'optionalAccess', _28 => _28.next, 'call', _29 => _29()]), () => ( 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) {
|
|
@@ -797,7 +953,7 @@ function isNotLastChildPseudo(node) {
|
|
|
797
953
|
if (firstSelector.type !== "selector") {
|
|
798
954
|
return false;
|
|
799
955
|
}
|
|
800
|
-
const target = _optionalChain([firstSelector, 'access',
|
|
956
|
+
const target = _optionalChain([firstSelector, 'access', _31 => _31.nodes, 'optionalAccess', _32 => _32[0]]);
|
|
801
957
|
return Boolean(target && target.type === "pseudo" && target.value === ":last-child");
|
|
802
958
|
}
|
|
803
959
|
function transformSpacingSelector(nodes2, options) {
|
|
@@ -844,7 +1000,7 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
844
1000
|
node.value = ":is";
|
|
845
1001
|
}
|
|
846
1002
|
if (index === 0 && node.length === 1) {
|
|
847
|
-
const targetSelector = _optionalChain([node, 'access',
|
|
1003
|
+
const targetSelector = _optionalChain([node, 'access', _33 => _33.nodes, 'optionalAccess', _34 => _34[0]]);
|
|
848
1004
|
if (targetSelector && targetSelector.type === "selector" && transformSpacingSelector(targetSelector.nodes, context.options)) {
|
|
849
1005
|
context.requiresSpacingNormalization = true;
|
|
850
1006
|
}
|
|
@@ -864,7 +1020,7 @@ function handleUniversalNode(node, context) {
|
|
|
864
1020
|
if (node.type !== "universal") {
|
|
865
1021
|
return;
|
|
866
1022
|
}
|
|
867
|
-
const replacement = _optionalChain([context, 'access',
|
|
1023
|
+
const replacement = _optionalChain([context, 'access', _35 => _35.options, 'access', _36 => _36.cssSelectorReplacement, 'optionalAccess', _37 => _37.universal]);
|
|
868
1024
|
if (replacement) {
|
|
869
1025
|
node.value = composeIsPseudo(replacement);
|
|
870
1026
|
}
|
|
@@ -899,7 +1055,7 @@ function handleCombinatorNode(node, index, context) {
|
|
|
899
1055
|
if (node.type !== "combinator" || node.value !== ">") {
|
|
900
1056
|
return;
|
|
901
1057
|
}
|
|
902
|
-
const nodes2 = _optionalChain([node, 'access',
|
|
1058
|
+
const nodes2 = _optionalChain([node, 'access', _38 => _38.parent, 'optionalAccess', _39 => _39.nodes]);
|
|
903
1059
|
if (!nodes2) {
|
|
904
1060
|
return;
|
|
905
1061
|
}
|
|
@@ -915,7 +1071,7 @@ function handlePseudoNode(node, index, context, parent) {
|
|
|
915
1071
|
if (node.type !== "pseudo") {
|
|
916
1072
|
return;
|
|
917
1073
|
}
|
|
918
|
-
if (node.value === ":root" && _optionalChain([context, 'access',
|
|
1074
|
+
if (node.value === ":root" && _optionalChain([context, 'access', _40 => _40.options, 'access', _41 => _41.cssSelectorReplacement, 'optionalAccess', _42 => _42.root])) {
|
|
919
1075
|
node.value = composeIsPseudo(context.options.cssSelectorReplacement.root);
|
|
920
1076
|
return;
|
|
921
1077
|
}
|
|
@@ -937,7 +1093,7 @@ function handleSelectorNode(selector, context) {
|
|
|
937
1093
|
}
|
|
938
1094
|
function transformSelectors(selectors, context) {
|
|
939
1095
|
selectors.walk((node, index) => {
|
|
940
|
-
const parent = _optionalChain([node, 'access',
|
|
1096
|
+
const parent = _optionalChain([node, 'access', _43 => _43.parent, 'optionalAccess', _44 => _44.type]) === "selector" ? node.parent : void 0;
|
|
941
1097
|
switch (node.type) {
|
|
942
1098
|
case "class":
|
|
943
1099
|
handleClassNode(node, context);
|
|
@@ -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
|
}
|
|
@@ -1015,7 +1171,7 @@ function normalizeSelectorList(value) {
|
|
|
1015
1171
|
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1016
1172
|
}
|
|
1017
1173
|
function getSpecificityMatchingName(options) {
|
|
1018
|
-
const feature = _optionalChain([options, 'access',
|
|
1174
|
+
const feature = _optionalChain([options, 'access', _45 => _45.cssPresetEnv, 'optionalAccess', _46 => _46.features, 'optionalAccess', _47 => _47["is-pseudo-class"]]);
|
|
1019
1175
|
if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
|
|
1020
1176
|
const specificityName = feature.specificityMatchingName;
|
|
1021
1177
|
return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
|
|
@@ -1024,12 +1180,12 @@ function getSpecificityMatchingName(options) {
|
|
|
1024
1180
|
}
|
|
1025
1181
|
function createRootSpecificityCleaner(options) {
|
|
1026
1182
|
const specificityMatchingName = getSpecificityMatchingName(options);
|
|
1027
|
-
const selectors = normalizeSelectorList(_optionalChain([options, 'access',
|
|
1183
|
+
const selectors = normalizeSelectorList(_optionalChain([options, 'access', _48 => _48.cssSelectorReplacement, 'optionalAccess', _49 => _49.root]));
|
|
1028
1184
|
if (!specificityMatchingName || selectors.length === 0) {
|
|
1029
1185
|
return void 0;
|
|
1030
1186
|
}
|
|
1031
1187
|
const suffix = `:not(.${specificityMatchingName})`;
|
|
1032
|
-
const targets = selectors.map((selector) => _optionalChain([selector, 'optionalAccess',
|
|
1188
|
+
const targets = selectors.map((selector) => _optionalChain([selector, 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()])).filter((selector) => Boolean(_optionalChain([selector, 'optionalAccess', _52 => _52.length]))).map((selector) => ({
|
|
1033
1189
|
match: `${selector}${suffix}`,
|
|
1034
1190
|
spacedMatch: `${selector} ${suffix}`,
|
|
1035
1191
|
replacement: selector
|
|
@@ -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 = _nullishCoalesce(_optionalChain([declarations, 'access', _52 => _52[declarations.length - 1], 'optionalAccess', _53 => _53.next, 'call', _54 => _54()]), () => ( 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]) {
|
|
@@ -1219,9 +1353,9 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1219
1353
|
const fallbackRemove = enableMainChunkTransforms ? getFallbackRemove(void 0, opts) : void 0;
|
|
1220
1354
|
p.RuleExit = (rule) => {
|
|
1221
1355
|
if (enableMainChunkTransforms) {
|
|
1222
|
-
_optionalChain([fallbackRemove, 'optionalAccess',
|
|
1356
|
+
_optionalChain([fallbackRemove, 'optionalAccess', _53 => _53.transformSync, 'call', _54 => _54(rule)]);
|
|
1223
1357
|
}
|
|
1224
|
-
_optionalChain([cleanRootSpecificity, 'optionalCall',
|
|
1358
|
+
_optionalChain([cleanRootSpecificity, 'optionalCall', _55 => _55(rule)]);
|
|
1225
1359
|
if (enableMainChunkTransforms) {
|
|
1226
1360
|
dedupeDeclarations(rule);
|
|
1227
1361
|
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
@@ -1234,12 +1368,15 @@ 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();
|
|
1241
1378
|
}
|
|
1242
|
-
_optionalChain([atRule, 'access',
|
|
1379
|
+
_optionalChain([atRule, 'access', _56 => _56.nodes, 'optionalAccess', _57 => _57.length]) === 0 && atRule.remove();
|
|
1243
1380
|
};
|
|
1244
1381
|
}
|
|
1245
1382
|
return p;
|
|
@@ -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 _nullishCoalesce(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
|
}
|
|
@@ -1533,7 +1659,7 @@ function remakeCssVarSelector(selectors, options) {
|
|
|
1533
1659
|
function commonChunkPreflight(node, options) {
|
|
1534
1660
|
const { ctx, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
1535
1661
|
if (testIfVariablesScope(node)) {
|
|
1536
|
-
_optionalChain([ctx, 'optionalAccess',
|
|
1662
|
+
_optionalChain([ctx, 'optionalAccess', _58 => _58.markVariablesScope, 'call', _59 => _59(node)]);
|
|
1537
1663
|
node.selectors = remakeCssVarSelector(node.selectors, options);
|
|
1538
1664
|
node.before(makePseudoVarRule());
|
|
1539
1665
|
if (typeof cssInjectPreflight === "function") {
|
|
@@ -1590,9 +1716,9 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
1590
1716
|
root.walkAtRules((atRule) => {
|
|
1591
1717
|
if (atRule.name === "layer") {
|
|
1592
1718
|
if (atRule.params === "properties") {
|
|
1593
|
-
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access',
|
|
1719
|
+
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _60 => _60.nodes, 'optionalAccess', _61 => _61.length]) === 0) {
|
|
1594
1720
|
layerProperties = atRule;
|
|
1595
|
-
} else if (_optionalChain([atRule, 'access',
|
|
1721
|
+
} else if (_optionalChain([atRule, 'access', _62 => _62.first, 'optionalAccess', _63 => _63.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
|
|
1596
1722
|
if (layerProperties) {
|
|
1597
1723
|
layerProperties.replaceWith(atRule.first.nodes);
|
|
1598
1724
|
atRule.remove();
|
|
@@ -1604,7 +1730,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
1604
1730
|
atRule.replaceWith(atRule.nodes);
|
|
1605
1731
|
}
|
|
1606
1732
|
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
1607
|
-
if (_optionalChain([atRule, 'access',
|
|
1733
|
+
if (_optionalChain([atRule, 'access', _64 => _64.first, 'optionalAccess', _65 => _65.type]) === "atrule" && atRule.first.name === "layer") {
|
|
1608
1734
|
atRule.replaceWith(atRule.first.nodes);
|
|
1609
1735
|
}
|
|
1610
1736
|
}
|
|
@@ -1649,7 +1775,7 @@ function createPipelineDefinitions(options) {
|
|
|
1649
1775
|
normal: [],
|
|
1650
1776
|
post: []
|
|
1651
1777
|
};
|
|
1652
|
-
const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access',
|
|
1778
|
+
const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access', _66 => _66.postcssOptions, 'optionalAccess', _67 => _67.plugins]));
|
|
1653
1779
|
userPlugins.forEach((plugin, index) => {
|
|
1654
1780
|
stages.pre.push(createStaticDefinition(`pre:user-${index}`, "pre", plugin));
|
|
1655
1781
|
});
|
|
@@ -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
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
1919
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _68 => _68.postcssOptions, 'optionalAccess', _69 => _69.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 = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this); }
|
|
1923
|
+
__init() {this.pipelineCache = /* @__PURE__ */ new WeakMap()}
|
|
1924
|
+
__init2() {this.processOptionsCache = /* @__PURE__ */ new WeakMap()}
|
|
1925
|
+
__init3() {this.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 = _optionalChain([options, 'access', _70 => _70.postcssOptions, 'optionalAccess', _71 => _71.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 = _postcss2.default.call(void 0, pipeline.plugins);
|
|
1950
|
+
this.processorCache.set(options, processor);
|
|
1951
|
+
}
|
|
1952
|
+
return processor;
|
|
1953
|
+
}
|
|
1954
|
+
}, _class);
|
|
1955
|
+
|
|
1956
|
+
// src/handler.ts
|
|
1845
1957
|
function createStyleHandler(options) {
|
|
1846
1958
|
const cachedOptions = _shared.defuOverrideArray.call(void 0,
|
|
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 = _shared.defuOverrideArray.call(void 0, 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
|
}
|