@weapp-tailwindcss/postcss 2.1.0 → 2.1.2
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +132 -69
- package/dist/index.mjs +132 -69
- package/dist/{types-DiZP4O-E.d.mts → types-BvKQTc7Z.d.mts} +1 -1
- package/dist/{types-DiZP4O-E.d.ts → types-BvKQTc7Z.d.ts} +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +7 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IStyleHandlerOptions, S as StyleHandler, a as InternalCssSelectorReplacerOptions } from './types-
|
|
2
|
-
export { C as CssCalcOptions,
|
|
1
|
+
import { I as IStyleHandlerOptions, S as StyleHandler, a as InternalCssSelectorReplacerOptions } from './types-BvKQTc7Z.mjs';
|
|
2
|
+
export { C as CssCalcOptions, b as CssPreflightOptions, c as IPropValue, L as LoadedPostcssOptions, P as PipelineNodeContext, d as PipelineNodeCursor, e as PipelineStage, R as RequiredStyleHandlerOptions, f as ResolvedPipelineNode, g as StyleProcessingPipeline, U as UserDefinedPostcssOptions, h as createInjectPreflight, i as createStylePipeline } from './types-BvKQTc7Z.mjs';
|
|
3
3
|
export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
|
|
4
4
|
export { PxTransformOptions as Px2rpxOptions } from 'postcss-pxtrans';
|
|
5
5
|
export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IStyleHandlerOptions, S as StyleHandler, a as InternalCssSelectorReplacerOptions } from './types-
|
|
2
|
-
export { C as CssCalcOptions,
|
|
1
|
+
import { I as IStyleHandlerOptions, S as StyleHandler, a as InternalCssSelectorReplacerOptions } from './types-BvKQTc7Z.js';
|
|
2
|
+
export { C as CssCalcOptions, b as CssPreflightOptions, c as IPropValue, L as LoadedPostcssOptions, P as PipelineNodeContext, d as PipelineNodeCursor, e as PipelineStage, R as RequiredStyleHandlerOptions, f as ResolvedPipelineNode, g as StyleProcessingPipeline, U as UserDefinedPostcssOptions, h as createInjectPreflight, i as createStylePipeline } from './types-BvKQTc7Z.js';
|
|
3
3
|
export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
|
|
4
4
|
export { PxTransformOptions as Px2rpxOptions } from 'postcss-pxtrans';
|
|
5
5
|
export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
|
package/dist/index.js
CHANGED
|
@@ -246,10 +246,38 @@ function createContext() {
|
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
// src/plugins/getCalcDuplicateCleaner.ts
|
|
250
|
+
function getCalcDuplicateCleaner(options) {
|
|
251
|
+
if (!options.cssCalc) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
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
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
249
277
|
// src/plugins/getCalcPlugin.ts
|
|
250
278
|
var _postcsscalc = require('@weapp-tailwindcss/postcss-calc'); var _postcsscalc2 = _interopRequireDefault(_postcsscalc);
|
|
251
279
|
|
|
252
|
-
// ../../node_modules/.pnpm/es-toolkit@1.
|
|
280
|
+
// ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/object/omit.mjs
|
|
253
281
|
function omit(obj, keys) {
|
|
254
282
|
const result = { ...obj };
|
|
255
283
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -814,9 +842,11 @@ function internalCssSelectorReplacer(selectors, options = {
|
|
|
814
842
|
escapeMap: _escape.MappingChars2String
|
|
815
843
|
}) {
|
|
816
844
|
const { escapeMap } = options;
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
845
|
+
const escapeOptions = {};
|
|
846
|
+
if (escapeMap !== void 0) {
|
|
847
|
+
escapeOptions["map"] = escapeMap;
|
|
848
|
+
}
|
|
849
|
+
return _escape.escape.call(void 0, selectors, escapeOptions);
|
|
820
850
|
}
|
|
821
851
|
function composeIsPseudo(strs) {
|
|
822
852
|
if (typeof strs === "string") {
|
|
@@ -869,8 +899,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
|
|
|
869
899
|
}
|
|
870
900
|
}
|
|
871
901
|
|
|
872
|
-
// src/selectorParser/
|
|
873
|
-
var ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
902
|
+
// src/selectorParser/spacing.ts
|
|
874
903
|
var MIRROR_PROP_PAIRS = [
|
|
875
904
|
["margin-top", "margin-bottom"],
|
|
876
905
|
["margin-left", "margin-right"],
|
|
@@ -896,7 +925,6 @@ var LEGACY_WEBKIT_SPACING_PROPS = /* @__PURE__ */ new Set([
|
|
|
896
925
|
"-webkit-margin-after"
|
|
897
926
|
]);
|
|
898
927
|
var VAR_REFERENCE_PATTERN = /var\(/i;
|
|
899
|
-
var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
900
928
|
function dedupeSpacingProps(rule) {
|
|
901
929
|
const grouped = /* @__PURE__ */ new Map();
|
|
902
930
|
for (const node of rule.nodes) {
|
|
@@ -950,7 +978,7 @@ function isNotLastChildPseudo(node) {
|
|
|
950
978
|
return false;
|
|
951
979
|
}
|
|
952
980
|
const firstSelector = selectors[0];
|
|
953
|
-
if (firstSelector.type !== "selector") {
|
|
981
|
+
if (!firstSelector || firstSelector.type !== "selector") {
|
|
954
982
|
return false;
|
|
955
983
|
}
|
|
956
984
|
const target = _optionalChain([firstSelector, 'access', _31 => _31.nodes, 'optionalAccess', _32 => _32[0]]);
|
|
@@ -962,7 +990,7 @@ function transformSpacingSelector(nodes2, options) {
|
|
|
962
990
|
}
|
|
963
991
|
for (let idx = 0; idx < nodes2.length; idx++) {
|
|
964
992
|
const current = nodes2[idx];
|
|
965
|
-
if (current.type !== "class" && current.type !== "nesting") {
|
|
993
|
+
if (!current || current.type !== "class" && current.type !== "nesting") {
|
|
966
994
|
continue;
|
|
967
995
|
}
|
|
968
996
|
const combinator = nodes2[idx + 1];
|
|
@@ -995,6 +1023,10 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
995
1023
|
}
|
|
996
1024
|
dedupeSpacingProps(rule);
|
|
997
1025
|
}
|
|
1026
|
+
|
|
1027
|
+
// src/selectorParser/rule-transformer.ts
|
|
1028
|
+
var ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
1029
|
+
var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
998
1030
|
function flattenWherePseudo(node, context, index, parent) {
|
|
999
1031
|
if (isUniAppXEnabled(context.options)) {
|
|
1000
1032
|
node.value = ":is";
|
|
@@ -1014,7 +1046,8 @@ function handleClassNode(node, context) {
|
|
|
1014
1046
|
if (node.type !== "class") {
|
|
1015
1047
|
return;
|
|
1016
1048
|
}
|
|
1017
|
-
|
|
1049
|
+
const { escapeMap } = context.options;
|
|
1050
|
+
node.value = escapeMap === void 0 ? internalCssSelectorReplacer(node.value, {}) : internalCssSelectorReplacer(node.value, { escapeMap });
|
|
1018
1051
|
}
|
|
1019
1052
|
function handleUniversalNode(node, context) {
|
|
1020
1053
|
if (node.type !== "universal") {
|
|
@@ -1163,55 +1196,7 @@ function ruleTransformSync(rule, options) {
|
|
|
1163
1196
|
transformer(rule);
|
|
1164
1197
|
}
|
|
1165
1198
|
|
|
1166
|
-
// src/plugins/post.ts
|
|
1167
|
-
function normalizeSelectorList(value) {
|
|
1168
|
-
if (value === void 0 || value === false) {
|
|
1169
|
-
return [];
|
|
1170
|
-
}
|
|
1171
|
-
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1172
|
-
}
|
|
1173
|
-
function getSpecificityMatchingName(options) {
|
|
1174
|
-
const feature = _optionalChain([options, 'access', _45 => _45.cssPresetEnv, 'optionalAccess', _46 => _46.features, 'optionalAccess', _47 => _47["is-pseudo-class"]]);
|
|
1175
|
-
if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
|
|
1176
|
-
const specificityName = feature.specificityMatchingName;
|
|
1177
|
-
return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
|
|
1178
|
-
}
|
|
1179
|
-
return void 0;
|
|
1180
|
-
}
|
|
1181
|
-
function createRootSpecificityCleaner(options) {
|
|
1182
|
-
const specificityMatchingName = getSpecificityMatchingName(options);
|
|
1183
|
-
const selectors = normalizeSelectorList(_optionalChain([options, 'access', _48 => _48.cssSelectorReplacement, 'optionalAccess', _49 => _49.root]));
|
|
1184
|
-
if (!specificityMatchingName || selectors.length === 0) {
|
|
1185
|
-
return void 0;
|
|
1186
|
-
}
|
|
1187
|
-
const suffix = `:not(.${specificityMatchingName})`;
|
|
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) => ({
|
|
1189
|
-
match: `${selector}${suffix}`,
|
|
1190
|
-
spacedMatch: `${selector} ${suffix}`,
|
|
1191
|
-
replacement: selector
|
|
1192
|
-
}));
|
|
1193
|
-
if (!targets.length) {
|
|
1194
|
-
return void 0;
|
|
1195
|
-
}
|
|
1196
|
-
return (rule) => {
|
|
1197
|
-
if (!rule.selectors || rule.selectors.length === 0) {
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
const next = rule.selectors.map((selector) => {
|
|
1201
|
-
let updated = selector;
|
|
1202
|
-
for (const target of targets) {
|
|
1203
|
-
if (updated.includes(target.match)) {
|
|
1204
|
-
updated = updated.split(target.match).join(target.replacement);
|
|
1205
|
-
}
|
|
1206
|
-
if (updated.includes(target.spacedMatch)) {
|
|
1207
|
-
updated = updated.split(target.spacedMatch).join(target.replacement);
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
return updated;
|
|
1211
|
-
});
|
|
1212
|
-
rule.selectors = next;
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1199
|
+
// src/plugins/post/decl-dedupe.ts
|
|
1215
1200
|
var logicalPropMap = /* @__PURE__ */ new Map([
|
|
1216
1201
|
// margin 方向映射
|
|
1217
1202
|
["margin-inline-start", "margin-left"],
|
|
@@ -1340,6 +1325,58 @@ function dedupeDeclarations(rule) {
|
|
|
1340
1325
|
}
|
|
1341
1326
|
}
|
|
1342
1327
|
}
|
|
1328
|
+
|
|
1329
|
+
// src/plugins/post/specificity-cleaner.ts
|
|
1330
|
+
function normalizeSelectorList(value) {
|
|
1331
|
+
if (value === void 0 || value === false) {
|
|
1332
|
+
return [];
|
|
1333
|
+
}
|
|
1334
|
+
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1335
|
+
}
|
|
1336
|
+
function getSpecificityMatchingName(options) {
|
|
1337
|
+
const feature = _optionalChain([options, 'access', _45 => _45.cssPresetEnv, 'optionalAccess', _46 => _46.features, 'optionalAccess', _47 => _47["is-pseudo-class"]]);
|
|
1338
|
+
if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
|
|
1339
|
+
const specificityName = feature.specificityMatchingName;
|
|
1340
|
+
return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
|
|
1341
|
+
}
|
|
1342
|
+
return void 0;
|
|
1343
|
+
}
|
|
1344
|
+
function createRootSpecificityCleaner(options) {
|
|
1345
|
+
const specificityMatchingName = getSpecificityMatchingName(options);
|
|
1346
|
+
const selectors = normalizeSelectorList(_optionalChain([options, 'access', _48 => _48.cssSelectorReplacement, 'optionalAccess', _49 => _49.root]));
|
|
1347
|
+
if (!specificityMatchingName || selectors.length === 0) {
|
|
1348
|
+
return void 0;
|
|
1349
|
+
}
|
|
1350
|
+
const suffix = `:not(.${specificityMatchingName})`;
|
|
1351
|
+
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) => ({
|
|
1352
|
+
match: `${selector}${suffix}`,
|
|
1353
|
+
spacedMatch: `${selector} ${suffix}`,
|
|
1354
|
+
replacement: selector
|
|
1355
|
+
}));
|
|
1356
|
+
if (!targets.length) {
|
|
1357
|
+
return void 0;
|
|
1358
|
+
}
|
|
1359
|
+
return (rule) => {
|
|
1360
|
+
if (!rule.selectors || rule.selectors.length === 0) {
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
const next = rule.selectors.map((selector) => {
|
|
1364
|
+
let updated = selector;
|
|
1365
|
+
for (const target of targets) {
|
|
1366
|
+
if (updated.includes(target.match)) {
|
|
1367
|
+
updated = updated.split(target.match).join(target.replacement);
|
|
1368
|
+
}
|
|
1369
|
+
if (updated.includes(target.spacedMatch)) {
|
|
1370
|
+
updated = updated.split(target.spacedMatch).join(target.replacement);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return updated;
|
|
1374
|
+
});
|
|
1375
|
+
rule.selectors = next;
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// src/plugins/post.ts
|
|
1343
1380
|
var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
1344
1381
|
const opts = _shared.defu.call(void 0, options, {
|
|
1345
1382
|
isMainChunk: true
|
|
@@ -1369,7 +1406,11 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1369
1406
|
}
|
|
1370
1407
|
if (enableMainChunkTransforms) {
|
|
1371
1408
|
p.DeclarationExit = (decl) => {
|
|
1372
|
-
|
|
1409
|
+
if (opts.majorVersion === void 0) {
|
|
1410
|
+
normalizeTailwindcssRpxDeclaration(decl);
|
|
1411
|
+
} else {
|
|
1412
|
+
normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
|
|
1413
|
+
}
|
|
1373
1414
|
normalizeTailwindcssV4Declaration(decl);
|
|
1374
1415
|
};
|
|
1375
1416
|
p.AtRuleExit = (atRule) => {
|
|
@@ -1842,6 +1883,18 @@ function createPipelineDefinitions(options) {
|
|
|
1842
1883
|
} : void 0;
|
|
1843
1884
|
}
|
|
1844
1885
|
});
|
|
1886
|
+
stages.normal.push({
|
|
1887
|
+
id: "normal:calc-duplicate-cleaner",
|
|
1888
|
+
stage: "normal",
|
|
1889
|
+
prepare: () => {
|
|
1890
|
+
const plugin = getCalcDuplicateCleaner(options);
|
|
1891
|
+
return plugin ? {
|
|
1892
|
+
id: "normal:calc-duplicate-cleaner",
|
|
1893
|
+
stage: "normal",
|
|
1894
|
+
createPlugin: () => plugin
|
|
1895
|
+
} : void 0;
|
|
1896
|
+
}
|
|
1897
|
+
});
|
|
1845
1898
|
stages.normal.push({
|
|
1846
1899
|
id: "normal:custom-property-cleaner",
|
|
1847
1900
|
stage: "normal",
|
|
@@ -1888,16 +1941,26 @@ function createStylePipeline(options) {
|
|
|
1888
1941
|
index,
|
|
1889
1942
|
size,
|
|
1890
1943
|
stageIndex,
|
|
1891
|
-
stageSize: _nullishCoalesce(stageSizes.get(node.stage), () => ( 0))
|
|
1892
|
-
previous: index > 0 ? {
|
|
1893
|
-
id: preparedNodes[index - 1].id,
|
|
1894
|
-
stage: preparedNodes[index - 1].stage
|
|
1895
|
-
} : void 0,
|
|
1896
|
-
next: index < size - 1 ? {
|
|
1897
|
-
id: preparedNodes[index + 1].id,
|
|
1898
|
-
stage: preparedNodes[index + 1].stage
|
|
1899
|
-
} : void 0
|
|
1944
|
+
stageSize: _nullishCoalesce(stageSizes.get(node.stage), () => ( 0))
|
|
1900
1945
|
};
|
|
1946
|
+
if (index > 0) {
|
|
1947
|
+
const prevNode = preparedNodes[index - 1];
|
|
1948
|
+
if (prevNode) {
|
|
1949
|
+
context.previous = {
|
|
1950
|
+
id: prevNode.id,
|
|
1951
|
+
stage: prevNode.stage
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
if (index < size - 1) {
|
|
1956
|
+
const nextNode = preparedNodes[index + 1];
|
|
1957
|
+
if (nextNode) {
|
|
1958
|
+
context.next = {
|
|
1959
|
+
id: nextNode.id,
|
|
1960
|
+
stage: nextNode.stage
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1901
1964
|
stageIndices.set(node.stage, stageIndex + 1);
|
|
1902
1965
|
nodes2.push({
|
|
1903
1966
|
id: node.id,
|
package/dist/index.mjs
CHANGED
|
@@ -246,10 +246,38 @@ function createContext() {
|
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
// src/plugins/getCalcDuplicateCleaner.ts
|
|
250
|
+
function getCalcDuplicateCleaner(options) {
|
|
251
|
+
if (!options.cssCalc) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
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
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
249
277
|
// src/plugins/getCalcPlugin.ts
|
|
250
278
|
import postcssCalc from "@weapp-tailwindcss/postcss-calc";
|
|
251
279
|
|
|
252
|
-
// ../../node_modules/.pnpm/es-toolkit@1.
|
|
280
|
+
// ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/object/omit.mjs
|
|
253
281
|
function omit(obj, keys) {
|
|
254
282
|
const result = { ...obj };
|
|
255
283
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -814,9 +842,11 @@ function internalCssSelectorReplacer(selectors, options = {
|
|
|
814
842
|
escapeMap: MappingChars2String
|
|
815
843
|
}) {
|
|
816
844
|
const { escapeMap } = options;
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
845
|
+
const escapeOptions = {};
|
|
846
|
+
if (escapeMap !== void 0) {
|
|
847
|
+
escapeOptions["map"] = escapeMap;
|
|
848
|
+
}
|
|
849
|
+
return escape(selectors, escapeOptions);
|
|
820
850
|
}
|
|
821
851
|
function composeIsPseudo(strs) {
|
|
822
852
|
if (typeof strs === "string") {
|
|
@@ -869,8 +899,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
|
|
|
869
899
|
}
|
|
870
900
|
}
|
|
871
901
|
|
|
872
|
-
// src/selectorParser/
|
|
873
|
-
var ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
902
|
+
// src/selectorParser/spacing.ts
|
|
874
903
|
var MIRROR_PROP_PAIRS = [
|
|
875
904
|
["margin-top", "margin-bottom"],
|
|
876
905
|
["margin-left", "margin-right"],
|
|
@@ -896,7 +925,6 @@ var LEGACY_WEBKIT_SPACING_PROPS = /* @__PURE__ */ new Set([
|
|
|
896
925
|
"-webkit-margin-after"
|
|
897
926
|
]);
|
|
898
927
|
var VAR_REFERENCE_PATTERN = /var\(/i;
|
|
899
|
-
var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
900
928
|
function dedupeSpacingProps(rule) {
|
|
901
929
|
const grouped = /* @__PURE__ */ new Map();
|
|
902
930
|
for (const node of rule.nodes) {
|
|
@@ -950,7 +978,7 @@ function isNotLastChildPseudo(node) {
|
|
|
950
978
|
return false;
|
|
951
979
|
}
|
|
952
980
|
const firstSelector = selectors[0];
|
|
953
|
-
if (firstSelector.type !== "selector") {
|
|
981
|
+
if (!firstSelector || firstSelector.type !== "selector") {
|
|
954
982
|
return false;
|
|
955
983
|
}
|
|
956
984
|
const target = firstSelector.nodes?.[0];
|
|
@@ -962,7 +990,7 @@ function transformSpacingSelector(nodes2, options) {
|
|
|
962
990
|
}
|
|
963
991
|
for (let idx = 0; idx < nodes2.length; idx++) {
|
|
964
992
|
const current = nodes2[idx];
|
|
965
|
-
if (current.type !== "class" && current.type !== "nesting") {
|
|
993
|
+
if (!current || current.type !== "class" && current.type !== "nesting") {
|
|
966
994
|
continue;
|
|
967
995
|
}
|
|
968
996
|
const combinator = nodes2[idx + 1];
|
|
@@ -995,6 +1023,10 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
995
1023
|
}
|
|
996
1024
|
dedupeSpacingProps(rule);
|
|
997
1025
|
}
|
|
1026
|
+
|
|
1027
|
+
// src/selectorParser/rule-transformer.ts
|
|
1028
|
+
var ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
1029
|
+
var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
998
1030
|
function flattenWherePseudo(node, context, index, parent) {
|
|
999
1031
|
if (isUniAppXEnabled(context.options)) {
|
|
1000
1032
|
node.value = ":is";
|
|
@@ -1014,7 +1046,8 @@ function handleClassNode(node, context) {
|
|
|
1014
1046
|
if (node.type !== "class") {
|
|
1015
1047
|
return;
|
|
1016
1048
|
}
|
|
1017
|
-
|
|
1049
|
+
const { escapeMap } = context.options;
|
|
1050
|
+
node.value = escapeMap === void 0 ? internalCssSelectorReplacer(node.value, {}) : internalCssSelectorReplacer(node.value, { escapeMap });
|
|
1018
1051
|
}
|
|
1019
1052
|
function handleUniversalNode(node, context) {
|
|
1020
1053
|
if (node.type !== "universal") {
|
|
@@ -1163,55 +1196,7 @@ function ruleTransformSync(rule, options) {
|
|
|
1163
1196
|
transformer(rule);
|
|
1164
1197
|
}
|
|
1165
1198
|
|
|
1166
|
-
// src/plugins/post.ts
|
|
1167
|
-
function normalizeSelectorList(value) {
|
|
1168
|
-
if (value === void 0 || value === false) {
|
|
1169
|
-
return [];
|
|
1170
|
-
}
|
|
1171
|
-
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1172
|
-
}
|
|
1173
|
-
function getSpecificityMatchingName(options) {
|
|
1174
|
-
const feature = options.cssPresetEnv?.features?.["is-pseudo-class"];
|
|
1175
|
-
if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
|
|
1176
|
-
const specificityName = feature.specificityMatchingName;
|
|
1177
|
-
return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
|
|
1178
|
-
}
|
|
1179
|
-
return void 0;
|
|
1180
|
-
}
|
|
1181
|
-
function createRootSpecificityCleaner(options) {
|
|
1182
|
-
const specificityMatchingName = getSpecificityMatchingName(options);
|
|
1183
|
-
const selectors = normalizeSelectorList(options.cssSelectorReplacement?.root);
|
|
1184
|
-
if (!specificityMatchingName || selectors.length === 0) {
|
|
1185
|
-
return void 0;
|
|
1186
|
-
}
|
|
1187
|
-
const suffix = `:not(.${specificityMatchingName})`;
|
|
1188
|
-
const targets = selectors.map((selector) => selector?.trim()).filter((selector) => Boolean(selector?.length)).map((selector) => ({
|
|
1189
|
-
match: `${selector}${suffix}`,
|
|
1190
|
-
spacedMatch: `${selector} ${suffix}`,
|
|
1191
|
-
replacement: selector
|
|
1192
|
-
}));
|
|
1193
|
-
if (!targets.length) {
|
|
1194
|
-
return void 0;
|
|
1195
|
-
}
|
|
1196
|
-
return (rule) => {
|
|
1197
|
-
if (!rule.selectors || rule.selectors.length === 0) {
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
const next = rule.selectors.map((selector) => {
|
|
1201
|
-
let updated = selector;
|
|
1202
|
-
for (const target of targets) {
|
|
1203
|
-
if (updated.includes(target.match)) {
|
|
1204
|
-
updated = updated.split(target.match).join(target.replacement);
|
|
1205
|
-
}
|
|
1206
|
-
if (updated.includes(target.spacedMatch)) {
|
|
1207
|
-
updated = updated.split(target.spacedMatch).join(target.replacement);
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
return updated;
|
|
1211
|
-
});
|
|
1212
|
-
rule.selectors = next;
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1199
|
+
// src/plugins/post/decl-dedupe.ts
|
|
1215
1200
|
var logicalPropMap = /* @__PURE__ */ new Map([
|
|
1216
1201
|
// margin 方向映射
|
|
1217
1202
|
["margin-inline-start", "margin-left"],
|
|
@@ -1340,6 +1325,58 @@ function dedupeDeclarations(rule) {
|
|
|
1340
1325
|
}
|
|
1341
1326
|
}
|
|
1342
1327
|
}
|
|
1328
|
+
|
|
1329
|
+
// src/plugins/post/specificity-cleaner.ts
|
|
1330
|
+
function normalizeSelectorList(value) {
|
|
1331
|
+
if (value === void 0 || value === false) {
|
|
1332
|
+
return [];
|
|
1333
|
+
}
|
|
1334
|
+
return Array.isArray(value) ? value.filter(Boolean) : [value];
|
|
1335
|
+
}
|
|
1336
|
+
function getSpecificityMatchingName(options) {
|
|
1337
|
+
const feature = options.cssPresetEnv?.features?.["is-pseudo-class"];
|
|
1338
|
+
if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
|
|
1339
|
+
const specificityName = feature.specificityMatchingName;
|
|
1340
|
+
return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
|
|
1341
|
+
}
|
|
1342
|
+
return void 0;
|
|
1343
|
+
}
|
|
1344
|
+
function createRootSpecificityCleaner(options) {
|
|
1345
|
+
const specificityMatchingName = getSpecificityMatchingName(options);
|
|
1346
|
+
const selectors = normalizeSelectorList(options.cssSelectorReplacement?.root);
|
|
1347
|
+
if (!specificityMatchingName || selectors.length === 0) {
|
|
1348
|
+
return void 0;
|
|
1349
|
+
}
|
|
1350
|
+
const suffix = `:not(.${specificityMatchingName})`;
|
|
1351
|
+
const targets = selectors.map((selector) => selector?.trim()).filter((selector) => Boolean(selector?.length)).map((selector) => ({
|
|
1352
|
+
match: `${selector}${suffix}`,
|
|
1353
|
+
spacedMatch: `${selector} ${suffix}`,
|
|
1354
|
+
replacement: selector
|
|
1355
|
+
}));
|
|
1356
|
+
if (!targets.length) {
|
|
1357
|
+
return void 0;
|
|
1358
|
+
}
|
|
1359
|
+
return (rule) => {
|
|
1360
|
+
if (!rule.selectors || rule.selectors.length === 0) {
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
const next = rule.selectors.map((selector) => {
|
|
1364
|
+
let updated = selector;
|
|
1365
|
+
for (const target of targets) {
|
|
1366
|
+
if (updated.includes(target.match)) {
|
|
1367
|
+
updated = updated.split(target.match).join(target.replacement);
|
|
1368
|
+
}
|
|
1369
|
+
if (updated.includes(target.spacedMatch)) {
|
|
1370
|
+
updated = updated.split(target.spacedMatch).join(target.replacement);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return updated;
|
|
1374
|
+
});
|
|
1375
|
+
rule.selectors = next;
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// src/plugins/post.ts
|
|
1343
1380
|
var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
1344
1381
|
const opts = defu(options, {
|
|
1345
1382
|
isMainChunk: true
|
|
@@ -1369,7 +1406,11 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
1369
1406
|
}
|
|
1370
1407
|
if (enableMainChunkTransforms) {
|
|
1371
1408
|
p.DeclarationExit = (decl) => {
|
|
1372
|
-
|
|
1409
|
+
if (opts.majorVersion === void 0) {
|
|
1410
|
+
normalizeTailwindcssRpxDeclaration(decl);
|
|
1411
|
+
} else {
|
|
1412
|
+
normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
|
|
1413
|
+
}
|
|
1373
1414
|
normalizeTailwindcssV4Declaration(decl);
|
|
1374
1415
|
};
|
|
1375
1416
|
p.AtRuleExit = (atRule) => {
|
|
@@ -1842,6 +1883,18 @@ function createPipelineDefinitions(options) {
|
|
|
1842
1883
|
} : void 0;
|
|
1843
1884
|
}
|
|
1844
1885
|
});
|
|
1886
|
+
stages.normal.push({
|
|
1887
|
+
id: "normal:calc-duplicate-cleaner",
|
|
1888
|
+
stage: "normal",
|
|
1889
|
+
prepare: () => {
|
|
1890
|
+
const plugin = getCalcDuplicateCleaner(options);
|
|
1891
|
+
return plugin ? {
|
|
1892
|
+
id: "normal:calc-duplicate-cleaner",
|
|
1893
|
+
stage: "normal",
|
|
1894
|
+
createPlugin: () => plugin
|
|
1895
|
+
} : void 0;
|
|
1896
|
+
}
|
|
1897
|
+
});
|
|
1845
1898
|
stages.normal.push({
|
|
1846
1899
|
id: "normal:custom-property-cleaner",
|
|
1847
1900
|
stage: "normal",
|
|
@@ -1888,16 +1941,26 @@ function createStylePipeline(options) {
|
|
|
1888
1941
|
index,
|
|
1889
1942
|
size,
|
|
1890
1943
|
stageIndex,
|
|
1891
|
-
stageSize: stageSizes.get(node.stage) ?? 0
|
|
1892
|
-
previous: index > 0 ? {
|
|
1893
|
-
id: preparedNodes[index - 1].id,
|
|
1894
|
-
stage: preparedNodes[index - 1].stage
|
|
1895
|
-
} : void 0,
|
|
1896
|
-
next: index < size - 1 ? {
|
|
1897
|
-
id: preparedNodes[index + 1].id,
|
|
1898
|
-
stage: preparedNodes[index + 1].stage
|
|
1899
|
-
} : void 0
|
|
1944
|
+
stageSize: stageSizes.get(node.stage) ?? 0
|
|
1900
1945
|
};
|
|
1946
|
+
if (index > 0) {
|
|
1947
|
+
const prevNode = preparedNodes[index - 1];
|
|
1948
|
+
if (prevNode) {
|
|
1949
|
+
context.previous = {
|
|
1950
|
+
id: prevNode.id,
|
|
1951
|
+
stage: prevNode.stage
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
if (index < size - 1) {
|
|
1956
|
+
const nextNode = preparedNodes[index + 1];
|
|
1957
|
+
if (nextNode) {
|
|
1958
|
+
context.next = {
|
|
1959
|
+
id: nextNode.id,
|
|
1960
|
+
stage: nextNode.stage
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1901
1964
|
stageIndices.set(node.stage, stageIndex + 1);
|
|
1902
1965
|
nodes2.push({
|
|
1903
1966
|
id: node.id,
|
|
@@ -118,4 +118,4 @@ interface StyleHandler {
|
|
|
118
118
|
getPipeline: (opt?: Partial<IStyleHandlerOptions>) => StyleProcessingPipeline;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
export { type CssCalcOptions as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type PipelineNodeContext as P, type
|
|
121
|
+
export { type CssCalcOptions as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type PipelineNodeContext as P, type RequiredStyleHandlerOptions as R, type StyleHandler as S, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type CssPreflightOptions as b, type IPropValue as c, type PipelineNodeCursor as d, type PipelineStage as e, type ResolvedPipelineNode as f, type StyleProcessingPipeline as g, createInjectPreflight as h, createStylePipeline as i };
|
|
@@ -118,4 +118,4 @@ interface StyleHandler {
|
|
|
118
118
|
getPipeline: (opt?: Partial<IStyleHandlerOptions>) => StyleProcessingPipeline;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
export { type CssCalcOptions as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type PipelineNodeContext as P, type
|
|
121
|
+
export { type CssCalcOptions as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type PipelineNodeContext as P, type RequiredStyleHandlerOptions as R, type StyleHandler as S, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type CssPreflightOptions as b, type IPropValue as c, type PipelineNodeCursor as d, type PipelineStage as e, type ResolvedPipelineNode as f, type StyleProcessingPipeline as g, createInjectPreflight as h, createStylePipeline as i };
|
package/dist/types.d.mts
CHANGED
|
@@ -4,4 +4,4 @@ import 'postcss-load-config';
|
|
|
4
4
|
export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
|
|
5
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,
|
|
7
|
+
export { C as CssCalcOptions, b as CssPreflightOptions, c as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, S as StyleHandler, U as UserDefinedPostcssOptions } from './types-BvKQTc7Z.mjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import 'postcss-load-config';
|
|
|
4
4
|
export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
|
|
5
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,
|
|
7
|
+
export { C as CssCalcOptions, b as CssPreflightOptions, c as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, S as StyleHandler, U as UserDefinedPostcssOptions } from './types-BvKQTc7Z.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,19 +38,22 @@
|
|
|
38
38
|
"files": [
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
43
|
+
},
|
|
41
44
|
"dependencies": {
|
|
42
45
|
"@weapp-core/escape": "~6.0.1",
|
|
43
46
|
"@weapp-tailwindcss/postcss-calc": "^1.0.0",
|
|
44
47
|
"postcss": "~8.5.6",
|
|
45
|
-
"postcss-preset-env": "^10.
|
|
48
|
+
"postcss-preset-env": "^10.6.1",
|
|
46
49
|
"postcss-pxtrans": "^1.0.0",
|
|
47
50
|
"postcss-rem-to-responsive-pixel": "^7.0.0",
|
|
48
51
|
"postcss-selector-parser": "~7.1.1",
|
|
49
52
|
"postcss-value-parser": "^4.2.0",
|
|
50
|
-
"@weapp-tailwindcss/shared": "1.1.
|
|
53
|
+
"@weapp-tailwindcss/shared": "1.1.2"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
|
-
"@csstools/postcss-is-pseudo-class": "^
|
|
56
|
+
"@csstools/postcss-is-pseudo-class": "^6.0.0",
|
|
54
57
|
"postcss-calc": "^10.1.1",
|
|
55
58
|
"postcss-custom-properties": "^14.0.6"
|
|
56
59
|
},
|