@weapp-tailwindcss/postcss 2.0.8 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IStyleHandlerOptions, S as StyleHandler, a as InternalCssSelectorReplacerOptions } from './types-6NcGD9Zr.mjs';
2
- export { C as CssCalcOptions, h as CssPreflightOptions, g as IPropValue, L as LoadedPostcssOptions, P as PipelineNodeContext, b as PipelineNodeCursor, d as PipelineStage, i as RequiredStyleHandlerOptions, R as ResolvedPipelineNode, e as StyleProcessingPipeline, U as UserDefinedPostcssOptions, f as createInjectPreflight, c as createStylePipeline } from './types-6NcGD9Zr.mjs';
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
- export { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
4
+ export { PxTransformOptions as Px2rpxOptions } from 'postcss-pxtrans';
5
5
  export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
6
6
  import '@weapp-tailwindcss/postcss-calc';
7
7
  import 'postcss';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IStyleHandlerOptions, S as StyleHandler, a as InternalCssSelectorReplacerOptions } from './types-6NcGD9Zr.js';
2
- export { C as CssCalcOptions, h as CssPreflightOptions, g as IPropValue, L as LoadedPostcssOptions, P as PipelineNodeContext, b as PipelineNodeCursor, d as PipelineStage, i as RequiredStyleHandlerOptions, R as ResolvedPipelineNode, e as StyleProcessingPipeline, U as UserDefinedPostcssOptions, f as createInjectPreflight, c as createStylePipeline } from './types-6NcGD9Zr.js';
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
- export { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
4
+ export { PxTransformOptions as Px2rpxOptions } from 'postcss-pxtrans';
5
5
  export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
6
6
  import '@weapp-tailwindcss/postcss-calc';
7
7
  import 'postcss';
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.43.0/node_modules/es-toolkit/dist/object/omit.mjs
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++) {
@@ -315,9 +343,10 @@ function getCustomPropertyCleaner(options) {
315
343
 
316
344
  // src/plugins/getPxTransformPlugin.ts
317
345
 
318
- var _postcsspxtransform = require('postcss-pxtransform'); var _postcsspxtransform2 = _interopRequireDefault(_postcsspxtransform);
346
+ var _postcsspxtrans = require('postcss-pxtrans'); var _postcsspxtrans2 = _interopRequireDefault(_postcsspxtrans);
319
347
  var defaultPxTransformOptions = {
320
348
  platform: "weapp",
349
+ targetUnit: "rpx",
321
350
  unitPrecision: 5,
322
351
  propList: ["*"],
323
352
  selectorBlackList: [],
@@ -337,7 +366,7 @@ function getPxTransformPlugin(options) {
337
366
  return null;
338
367
  }
339
368
  const userOptions = typeof options.px2rpx === "object" ? options.px2rpx : {};
340
- return _postcsspxtransform2.default.call(void 0,
369
+ return _postcsspxtrans2.default.call(void 0,
341
370
  _shared.defuOverrideArray.call(void 0,
342
371
  userOptions,
343
372
  defaultPxTransformOptions
@@ -813,9 +842,11 @@ function internalCssSelectorReplacer(selectors, options = {
813
842
  escapeMap: _escape.MappingChars2String
814
843
  }) {
815
844
  const { escapeMap } = options;
816
- return _escape.escape.call(void 0, selectors, {
817
- map: escapeMap
818
- });
845
+ const escapeOptions = {};
846
+ if (escapeMap !== void 0) {
847
+ escapeOptions["map"] = escapeMap;
848
+ }
849
+ return _escape.escape.call(void 0, selectors, escapeOptions);
819
850
  }
820
851
  function composeIsPseudo(strs) {
821
852
  if (typeof strs === "string") {
@@ -868,8 +899,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
868
899
  }
869
900
  }
870
901
 
871
- // src/selectorParser/rule-transformer.ts
872
- var ruleTransformCache = /* @__PURE__ */ new WeakMap();
902
+ // src/selectorParser/spacing.ts
873
903
  var MIRROR_PROP_PAIRS = [
874
904
  ["margin-top", "margin-bottom"],
875
905
  ["margin-left", "margin-right"],
@@ -895,7 +925,6 @@ var LEGACY_WEBKIT_SPACING_PROPS = /* @__PURE__ */ new Set([
895
925
  "-webkit-margin-after"
896
926
  ]);
897
927
  var VAR_REFERENCE_PATTERN = /var\(/i;
898
- var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
899
928
  function dedupeSpacingProps(rule) {
900
929
  const grouped = /* @__PURE__ */ new Map();
901
930
  for (const node of rule.nodes) {
@@ -949,7 +978,7 @@ function isNotLastChildPseudo(node) {
949
978
  return false;
950
979
  }
951
980
  const firstSelector = selectors[0];
952
- if (firstSelector.type !== "selector") {
981
+ if (!firstSelector || firstSelector.type !== "selector") {
953
982
  return false;
954
983
  }
955
984
  const target = _optionalChain([firstSelector, 'access', _31 => _31.nodes, 'optionalAccess', _32 => _32[0]]);
@@ -961,7 +990,7 @@ function transformSpacingSelector(nodes2, options) {
961
990
  }
962
991
  for (let idx = 0; idx < nodes2.length; idx++) {
963
992
  const current = nodes2[idx];
964
- if (current.type !== "class" && current.type !== "nesting") {
993
+ if (!current || current.type !== "class" && current.type !== "nesting") {
965
994
  continue;
966
995
  }
967
996
  const combinator = nodes2[idx + 1];
@@ -994,6 +1023,10 @@ function normalizeSpacingDeclarations(rule) {
994
1023
  }
995
1024
  dedupeSpacingProps(rule);
996
1025
  }
1026
+
1027
+ // src/selectorParser/rule-transformer.ts
1028
+ var ruleTransformCache = /* @__PURE__ */ new WeakMap();
1029
+ var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
997
1030
  function flattenWherePseudo(node, context, index, parent) {
998
1031
  if (isUniAppXEnabled(context.options)) {
999
1032
  node.value = ":is";
@@ -1013,7 +1046,8 @@ function handleClassNode(node, context) {
1013
1046
  if (node.type !== "class") {
1014
1047
  return;
1015
1048
  }
1016
- node.value = internalCssSelectorReplacer(node.value, { escapeMap: context.options.escapeMap });
1049
+ const { escapeMap } = context.options;
1050
+ node.value = escapeMap === void 0 ? internalCssSelectorReplacer(node.value, {}) : internalCssSelectorReplacer(node.value, { escapeMap });
1017
1051
  }
1018
1052
  function handleUniversalNode(node, context) {
1019
1053
  if (node.type !== "universal") {
@@ -1162,55 +1196,7 @@ function ruleTransformSync(rule, options) {
1162
1196
  transformer(rule);
1163
1197
  }
1164
1198
 
1165
- // src/plugins/post.ts
1166
- function normalizeSelectorList(value) {
1167
- if (value === void 0 || value === false) {
1168
- return [];
1169
- }
1170
- return Array.isArray(value) ? value.filter(Boolean) : [value];
1171
- }
1172
- function getSpecificityMatchingName(options) {
1173
- const feature = _optionalChain([options, 'access', _45 => _45.cssPresetEnv, 'optionalAccess', _46 => _46.features, 'optionalAccess', _47 => _47["is-pseudo-class"]]);
1174
- if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
1175
- const specificityName = feature.specificityMatchingName;
1176
- return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
1177
- }
1178
- return void 0;
1179
- }
1180
- function createRootSpecificityCleaner(options) {
1181
- const specificityMatchingName = getSpecificityMatchingName(options);
1182
- const selectors = normalizeSelectorList(_optionalChain([options, 'access', _48 => _48.cssSelectorReplacement, 'optionalAccess', _49 => _49.root]));
1183
- if (!specificityMatchingName || selectors.length === 0) {
1184
- return void 0;
1185
- }
1186
- const suffix = `:not(.${specificityMatchingName})`;
1187
- 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) => ({
1188
- match: `${selector}${suffix}`,
1189
- spacedMatch: `${selector} ${suffix}`,
1190
- replacement: selector
1191
- }));
1192
- if (!targets.length) {
1193
- return void 0;
1194
- }
1195
- return (rule) => {
1196
- if (!rule.selectors || rule.selectors.length === 0) {
1197
- return;
1198
- }
1199
- const next = rule.selectors.map((selector) => {
1200
- let updated = selector;
1201
- for (const target of targets) {
1202
- if (updated.includes(target.match)) {
1203
- updated = updated.split(target.match).join(target.replacement);
1204
- }
1205
- if (updated.includes(target.spacedMatch)) {
1206
- updated = updated.split(target.spacedMatch).join(target.replacement);
1207
- }
1208
- }
1209
- return updated;
1210
- });
1211
- rule.selectors = next;
1212
- };
1213
- }
1199
+ // src/plugins/post/decl-dedupe.ts
1214
1200
  var logicalPropMap = /* @__PURE__ */ new Map([
1215
1201
  // margin 方向映射
1216
1202
  ["margin-inline-start", "margin-left"],
@@ -1339,6 +1325,58 @@ function dedupeDeclarations(rule) {
1339
1325
  }
1340
1326
  }
1341
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
1342
1380
  var postcssWeappTailwindcssPostPlugin = (options) => {
1343
1381
  const opts = _shared.defu.call(void 0, options, {
1344
1382
  isMainChunk: true
@@ -1368,7 +1406,11 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
1368
1406
  }
1369
1407
  if (enableMainChunkTransforms) {
1370
1408
  p.DeclarationExit = (decl) => {
1371
- normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
1409
+ if (opts.majorVersion === void 0) {
1410
+ normalizeTailwindcssRpxDeclaration(decl);
1411
+ } else {
1412
+ normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
1413
+ }
1372
1414
  normalizeTailwindcssV4Declaration(decl);
1373
1415
  };
1374
1416
  p.AtRuleExit = (atRule) => {
@@ -1841,6 +1883,18 @@ function createPipelineDefinitions(options) {
1841
1883
  } : void 0;
1842
1884
  }
1843
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
+ });
1844
1898
  stages.normal.push({
1845
1899
  id: "normal:custom-property-cleaner",
1846
1900
  stage: "normal",
@@ -1887,16 +1941,26 @@ function createStylePipeline(options) {
1887
1941
  index,
1888
1942
  size,
1889
1943
  stageIndex,
1890
- stageSize: _nullishCoalesce(stageSizes.get(node.stage), () => ( 0)),
1891
- previous: index > 0 ? {
1892
- id: preparedNodes[index - 1].id,
1893
- stage: preparedNodes[index - 1].stage
1894
- } : void 0,
1895
- next: index < size - 1 ? {
1896
- id: preparedNodes[index + 1].id,
1897
- stage: preparedNodes[index + 1].stage
1898
- } : void 0
1944
+ stageSize: _nullishCoalesce(stageSizes.get(node.stage), () => ( 0))
1899
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
+ }
1900
1964
  stageIndices.set(node.stage, stageIndex + 1);
1901
1965
  nodes2.push({
1902
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.43.0/node_modules/es-toolkit/dist/object/omit.mjs
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++) {
@@ -315,9 +343,10 @@ function getCustomPropertyCleaner(options) {
315
343
 
316
344
  // src/plugins/getPxTransformPlugin.ts
317
345
  import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
318
- import postcssPxtransform from "postcss-pxtransform";
346
+ import postcssPxtrans from "postcss-pxtrans";
319
347
  var defaultPxTransformOptions = {
320
348
  platform: "weapp",
349
+ targetUnit: "rpx",
321
350
  unitPrecision: 5,
322
351
  propList: ["*"],
323
352
  selectorBlackList: [],
@@ -337,7 +366,7 @@ function getPxTransformPlugin(options) {
337
366
  return null;
338
367
  }
339
368
  const userOptions = typeof options.px2rpx === "object" ? options.px2rpx : {};
340
- return postcssPxtransform(
369
+ return postcssPxtrans(
341
370
  defuOverrideArray2(
342
371
  userOptions,
343
372
  defaultPxTransformOptions
@@ -813,9 +842,11 @@ function internalCssSelectorReplacer(selectors, options = {
813
842
  escapeMap: MappingChars2String
814
843
  }) {
815
844
  const { escapeMap } = options;
816
- return escape(selectors, {
817
- map: escapeMap
818
- });
845
+ const escapeOptions = {};
846
+ if (escapeMap !== void 0) {
847
+ escapeOptions["map"] = escapeMap;
848
+ }
849
+ return escape(selectors, escapeOptions);
819
850
  }
820
851
  function composeIsPseudo(strs) {
821
852
  if (typeof strs === "string") {
@@ -868,8 +899,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
868
899
  }
869
900
  }
870
901
 
871
- // src/selectorParser/rule-transformer.ts
872
- var ruleTransformCache = /* @__PURE__ */ new WeakMap();
902
+ // src/selectorParser/spacing.ts
873
903
  var MIRROR_PROP_PAIRS = [
874
904
  ["margin-top", "margin-bottom"],
875
905
  ["margin-left", "margin-right"],
@@ -895,7 +925,6 @@ var LEGACY_WEBKIT_SPACING_PROPS = /* @__PURE__ */ new Set([
895
925
  "-webkit-margin-after"
896
926
  ]);
897
927
  var VAR_REFERENCE_PATTERN = /var\(/i;
898
- var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
899
928
  function dedupeSpacingProps(rule) {
900
929
  const grouped = /* @__PURE__ */ new Map();
901
930
  for (const node of rule.nodes) {
@@ -949,7 +978,7 @@ function isNotLastChildPseudo(node) {
949
978
  return false;
950
979
  }
951
980
  const firstSelector = selectors[0];
952
- if (firstSelector.type !== "selector") {
981
+ if (!firstSelector || firstSelector.type !== "selector") {
953
982
  return false;
954
983
  }
955
984
  const target = firstSelector.nodes?.[0];
@@ -961,7 +990,7 @@ function transformSpacingSelector(nodes2, options) {
961
990
  }
962
991
  for (let idx = 0; idx < nodes2.length; idx++) {
963
992
  const current = nodes2[idx];
964
- if (current.type !== "class" && current.type !== "nesting") {
993
+ if (!current || current.type !== "class" && current.type !== "nesting") {
965
994
  continue;
966
995
  }
967
996
  const combinator = nodes2[idx + 1];
@@ -994,6 +1023,10 @@ function normalizeSpacingDeclarations(rule) {
994
1023
  }
995
1024
  dedupeSpacingProps(rule);
996
1025
  }
1026
+
1027
+ // src/selectorParser/rule-transformer.ts
1028
+ var ruleTransformCache = /* @__PURE__ */ new WeakMap();
1029
+ var SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
997
1030
  function flattenWherePseudo(node, context, index, parent) {
998
1031
  if (isUniAppXEnabled(context.options)) {
999
1032
  node.value = ":is";
@@ -1013,7 +1046,8 @@ function handleClassNode(node, context) {
1013
1046
  if (node.type !== "class") {
1014
1047
  return;
1015
1048
  }
1016
- node.value = internalCssSelectorReplacer(node.value, { escapeMap: context.options.escapeMap });
1049
+ const { escapeMap } = context.options;
1050
+ node.value = escapeMap === void 0 ? internalCssSelectorReplacer(node.value, {}) : internalCssSelectorReplacer(node.value, { escapeMap });
1017
1051
  }
1018
1052
  function handleUniversalNode(node, context) {
1019
1053
  if (node.type !== "universal") {
@@ -1162,55 +1196,7 @@ function ruleTransformSync(rule, options) {
1162
1196
  transformer(rule);
1163
1197
  }
1164
1198
 
1165
- // src/plugins/post.ts
1166
- function normalizeSelectorList(value) {
1167
- if (value === void 0 || value === false) {
1168
- return [];
1169
- }
1170
- return Array.isArray(value) ? value.filter(Boolean) : [value];
1171
- }
1172
- function getSpecificityMatchingName(options) {
1173
- const feature = options.cssPresetEnv?.features?.["is-pseudo-class"];
1174
- if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
1175
- const specificityName = feature.specificityMatchingName;
1176
- return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
1177
- }
1178
- return void 0;
1179
- }
1180
- function createRootSpecificityCleaner(options) {
1181
- const specificityMatchingName = getSpecificityMatchingName(options);
1182
- const selectors = normalizeSelectorList(options.cssSelectorReplacement?.root);
1183
- if (!specificityMatchingName || selectors.length === 0) {
1184
- return void 0;
1185
- }
1186
- const suffix = `:not(.${specificityMatchingName})`;
1187
- const targets = selectors.map((selector) => selector?.trim()).filter((selector) => Boolean(selector?.length)).map((selector) => ({
1188
- match: `${selector}${suffix}`,
1189
- spacedMatch: `${selector} ${suffix}`,
1190
- replacement: selector
1191
- }));
1192
- if (!targets.length) {
1193
- return void 0;
1194
- }
1195
- return (rule) => {
1196
- if (!rule.selectors || rule.selectors.length === 0) {
1197
- return;
1198
- }
1199
- const next = rule.selectors.map((selector) => {
1200
- let updated = selector;
1201
- for (const target of targets) {
1202
- if (updated.includes(target.match)) {
1203
- updated = updated.split(target.match).join(target.replacement);
1204
- }
1205
- if (updated.includes(target.spacedMatch)) {
1206
- updated = updated.split(target.spacedMatch).join(target.replacement);
1207
- }
1208
- }
1209
- return updated;
1210
- });
1211
- rule.selectors = next;
1212
- };
1213
- }
1199
+ // src/plugins/post/decl-dedupe.ts
1214
1200
  var logicalPropMap = /* @__PURE__ */ new Map([
1215
1201
  // margin 方向映射
1216
1202
  ["margin-inline-start", "margin-left"],
@@ -1339,6 +1325,58 @@ function dedupeDeclarations(rule) {
1339
1325
  }
1340
1326
  }
1341
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
1342
1380
  var postcssWeappTailwindcssPostPlugin = (options) => {
1343
1381
  const opts = defu(options, {
1344
1382
  isMainChunk: true
@@ -1368,7 +1406,11 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
1368
1406
  }
1369
1407
  if (enableMainChunkTransforms) {
1370
1408
  p.DeclarationExit = (decl) => {
1371
- normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
1409
+ if (opts.majorVersion === void 0) {
1410
+ normalizeTailwindcssRpxDeclaration(decl);
1411
+ } else {
1412
+ normalizeTailwindcssRpxDeclaration(decl, { majorVersion: opts.majorVersion });
1413
+ }
1372
1414
  normalizeTailwindcssV4Declaration(decl);
1373
1415
  };
1374
1416
  p.AtRuleExit = (atRule) => {
@@ -1841,6 +1883,18 @@ function createPipelineDefinitions(options) {
1841
1883
  } : void 0;
1842
1884
  }
1843
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
+ });
1844
1898
  stages.normal.push({
1845
1899
  id: "normal:custom-property-cleaner",
1846
1900
  stage: "normal",
@@ -1887,16 +1941,26 @@ function createStylePipeline(options) {
1887
1941
  index,
1888
1942
  size,
1889
1943
  stageIndex,
1890
- stageSize: stageSizes.get(node.stage) ?? 0,
1891
- previous: index > 0 ? {
1892
- id: preparedNodes[index - 1].id,
1893
- stage: preparedNodes[index - 1].stage
1894
- } : void 0,
1895
- next: index < size - 1 ? {
1896
- id: preparedNodes[index + 1].id,
1897
- stage: preparedNodes[index + 1].stage
1898
- } : void 0
1944
+ stageSize: stageSizes.get(node.stage) ?? 0
1899
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
+ }
1900
1964
  stageIndices.set(node.stage, stageIndex + 1);
1901
1965
  nodes2.push({
1902
1966
  id: node.id,
@@ -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 { PxtransformOptions } from 'postcss-pxtransform';
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 | PxtransformOptions;
109
+ px2rpx?: boolean | PxTransformOptions;
110
110
  postcssOptions?: LoadedPostcssOptions;
111
111
  cssRemoveHoverPseudoClass?: boolean;
112
112
  cssRemoveProperty?: boolean;
@@ -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 ResolvedPipelineNode as R, type StyleHandler as S, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type PipelineNodeCursor as b, createStylePipeline as c, type PipelineStage as d, type StyleProcessingPipeline as e, createInjectPreflight as f, type IPropValue as g, type CssPreflightOptions as h, type RequiredStyleHandlerOptions as i };
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 };
@@ -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 { PxtransformOptions } from 'postcss-pxtransform';
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 | PxtransformOptions;
109
+ px2rpx?: boolean | PxTransformOptions;
110
110
  postcssOptions?: LoadedPostcssOptions;
111
111
  cssRemoveHoverPseudoClass?: boolean;
112
112
  cssRemoveProperty?: boolean;
@@ -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 ResolvedPipelineNode as R, type StyleHandler as S, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type PipelineNodeCursor as b, createStylePipeline as c, type PipelineStage as d, type StyleProcessingPipeline as e, createInjectPreflight as f, type IPropValue as g, type CssPreflightOptions as h, type RequiredStyleHandlerOptions as i };
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
@@ -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 { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
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-6NcGD9Zr.mjs';
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
@@ -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 { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
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-6NcGD9Zr.js';
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.0.8",
3
+ "version": "2.1.1",
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.5.0",
46
- "postcss-pxtransform": "^4.1.9",
47
- "postcss-rem-to-responsive-pixel": "^6.1.0",
48
+ "postcss-preset-env": "^11.1.1",
49
+ "postcss-pxtrans": "^1.0.0",
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.1"
53
+ "@weapp-tailwindcss/shared": "1.1.2"
51
54
  },
52
55
  "devDependencies": {
53
- "@csstools/postcss-is-pseudo-class": "^5.0.3",
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
  },