@weapp-tailwindcss/postcss 2.2.0-alpha.1 → 2.2.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.js CHANGED
@@ -1077,6 +1077,7 @@ var MODERN_CHECK_WEBKIT_HYPHENS_RE = /-webkit-hyphens\s*:\s*none/;
1077
1077
  var MODERN_CHECK_MARGIN_TRIM_RE = /margin-trim\s*:\s*inline/;
1078
1078
  var MODERN_CHECK_MOZ_ORIENT_RE = /-moz-orient\s*:\s*inline/;
1079
1079
  var MODERN_CHECK_COLOR_RGB_RE = /color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)/;
1080
+ var LINEAR_GRADIENT_LAB_RE = /background-image\s*:\s*linear-gradient\(\s*in\s+lab\s*,\s*red\s*,\s*red\s*\)/;
1080
1081
  var RADIUS_VALUE_RE = /\b([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)\s*(r?px)\b/gi;
1081
1082
  var SCIENTIFIC_NOTATION_RE = /e/i;
1082
1083
  function isTailwindcssV4(options) {
@@ -1094,6 +1095,9 @@ function isTailwindcssV4ModernCheck(atRule) {
1094
1095
  MODERN_CHECK_COLOR_RGB_RE
1095
1096
  ].every((regex) => regex.test(atRule.params));
1096
1097
  }
1098
+ function isTailwindcssV4LinearGradientSupports(atRule) {
1099
+ return atRule.name === "supports" && LINEAR_GRADIENT_LAB_RE.test(atRule.params);
1100
+ }
1097
1101
  function normalizeTailwindcssV4Declaration(decl) {
1098
1102
  if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OKLAB_SUFFIX)) {
1099
1103
  decl.value = decl.value.slice(0, decl.value.length - OKLAB_SUFFIX.length);
@@ -1290,19 +1294,21 @@ function getFallbackRemove(_rule, options) {
1290
1294
  });
1291
1295
  });
1292
1296
  const rawTransformSync = parser.transformSync.bind(parser);
1293
- const transform = (targetRule) => {
1297
+ const transformRule = (targetRule, transformOptions = FALLBACK_TRANSFORM_OPTIONS) => {
1294
1298
  const sourceSelector = targetRule.selector;
1295
1299
  if (!sourceSelector) {
1296
1300
  return;
1297
1301
  }
1298
- const cached = selectorCache.get(sourceSelector);
1299
- if (cached) {
1300
- if (cached.action === "remove") {
1301
- targetRule.remove();
1302
- } else if (cached.action === "update" && cached.selector && cached.selector !== sourceSelector) {
1303
- targetRule.selector = cached.selector;
1302
+ if (transformOptions === FALLBACK_TRANSFORM_OPTIONS) {
1303
+ const cached = selectorCache.get(sourceSelector);
1304
+ if (cached) {
1305
+ if (cached.action === "remove") {
1306
+ targetRule.remove();
1307
+ } else if (cached.action === "update" && cached.selector && cached.selector !== sourceSelector) {
1308
+ targetRule.selector = cached.selector;
1309
+ }
1310
+ return;
1304
1311
  }
1305
- return;
1306
1312
  }
1307
1313
  currentRule = targetRule;
1308
1314
  try {
@@ -1310,13 +1316,15 @@ function getFallbackRemove(_rule, options) {
1310
1316
  } finally {
1311
1317
  currentRule = void 0;
1312
1318
  }
1313
- const wasRemoved = targetRule.parent == null;
1314
- if (wasRemoved) {
1315
- writeSelectorCache2(sourceSelector, { action: "remove" });
1316
- } else if (targetRule.selector === sourceSelector) {
1317
- writeSelectorCache2(sourceSelector, { action: "keep" });
1318
- } else {
1319
- writeSelectorCache2(sourceSelector, { action: "update", selector: targetRule.selector });
1319
+ if (transformOptions === FALLBACK_TRANSFORM_OPTIONS) {
1320
+ const wasRemoved = targetRule.parent == null;
1321
+ if (wasRemoved) {
1322
+ writeSelectorCache2(sourceSelector, { action: "remove" });
1323
+ } else if (targetRule.selector === sourceSelector) {
1324
+ writeSelectorCache2(sourceSelector, { action: "keep" });
1325
+ } else {
1326
+ writeSelectorCache2(sourceSelector, { action: "update", selector: targetRule.selector });
1327
+ }
1320
1328
  }
1321
1329
  };
1322
1330
  parser.transformSync = ((input, opts) => {
@@ -1324,19 +1332,14 @@ function getFallbackRemove(_rule, options) {
1324
1332
  if (input && typeof input === "object" && "type" in input) {
1325
1333
  const maybeRule = input;
1326
1334
  if (maybeRule.type === "rule") {
1327
- currentRule = input;
1328
- try {
1329
- return rawTransformSync(input, transformOptions);
1330
- } finally {
1331
- currentRule = void 0;
1332
- }
1335
+ transformRule(input, transformOptions);
1336
+ return void 0;
1333
1337
  }
1334
1338
  }
1335
1339
  return rawTransformSync(input, transformOptions);
1336
1340
  });
1337
1341
  entry = {
1338
- parser,
1339
- transform
1342
+ parser
1340
1343
  };
1341
1344
  fallbackRemoveCache.set(cacheKey, entry);
1342
1345
  }
@@ -2564,6 +2567,8 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
2564
2567
  } else if (atRule.name === "supports") {
2565
2568
  if (COLOR_MIX_RE.test(atRule.params)) {
2566
2569
  atRule.remove();
2570
+ } else if (isTailwindcssV4LinearGradientSupports(atRule)) {
2571
+ atRule.remove();
2567
2572
  }
2568
2573
  } else if (atRule.name === "layer") {
2569
2574
  if (atRule.nodes === void 0 || Array.isArray(atRule.nodes) && atRule.nodes.length === 0) {
package/dist/index.mjs CHANGED
@@ -1077,6 +1077,7 @@ var MODERN_CHECK_WEBKIT_HYPHENS_RE = /-webkit-hyphens\s*:\s*none/;
1077
1077
  var MODERN_CHECK_MARGIN_TRIM_RE = /margin-trim\s*:\s*inline/;
1078
1078
  var MODERN_CHECK_MOZ_ORIENT_RE = /-moz-orient\s*:\s*inline/;
1079
1079
  var MODERN_CHECK_COLOR_RGB_RE = /color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)/;
1080
+ var LINEAR_GRADIENT_LAB_RE = /background-image\s*:\s*linear-gradient\(\s*in\s+lab\s*,\s*red\s*,\s*red\s*\)/;
1080
1081
  var RADIUS_VALUE_RE = /\b([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)\s*(r?px)\b/gi;
1081
1082
  var SCIENTIFIC_NOTATION_RE = /e/i;
1082
1083
  function isTailwindcssV4(options) {
@@ -1094,6 +1095,9 @@ function isTailwindcssV4ModernCheck(atRule) {
1094
1095
  MODERN_CHECK_COLOR_RGB_RE
1095
1096
  ].every((regex) => regex.test(atRule.params));
1096
1097
  }
1098
+ function isTailwindcssV4LinearGradientSupports(atRule) {
1099
+ return atRule.name === "supports" && LINEAR_GRADIENT_LAB_RE.test(atRule.params);
1100
+ }
1097
1101
  function normalizeTailwindcssV4Declaration(decl) {
1098
1102
  if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OKLAB_SUFFIX)) {
1099
1103
  decl.value = decl.value.slice(0, decl.value.length - OKLAB_SUFFIX.length);
@@ -1290,19 +1294,21 @@ function getFallbackRemove(_rule, options) {
1290
1294
  });
1291
1295
  });
1292
1296
  const rawTransformSync = parser.transformSync.bind(parser);
1293
- const transform = (targetRule) => {
1297
+ const transformRule = (targetRule, transformOptions = FALLBACK_TRANSFORM_OPTIONS) => {
1294
1298
  const sourceSelector = targetRule.selector;
1295
1299
  if (!sourceSelector) {
1296
1300
  return;
1297
1301
  }
1298
- const cached = selectorCache.get(sourceSelector);
1299
- if (cached) {
1300
- if (cached.action === "remove") {
1301
- targetRule.remove();
1302
- } else if (cached.action === "update" && cached.selector && cached.selector !== sourceSelector) {
1303
- targetRule.selector = cached.selector;
1302
+ if (transformOptions === FALLBACK_TRANSFORM_OPTIONS) {
1303
+ const cached = selectorCache.get(sourceSelector);
1304
+ if (cached) {
1305
+ if (cached.action === "remove") {
1306
+ targetRule.remove();
1307
+ } else if (cached.action === "update" && cached.selector && cached.selector !== sourceSelector) {
1308
+ targetRule.selector = cached.selector;
1309
+ }
1310
+ return;
1304
1311
  }
1305
- return;
1306
1312
  }
1307
1313
  currentRule = targetRule;
1308
1314
  try {
@@ -1310,13 +1316,15 @@ function getFallbackRemove(_rule, options) {
1310
1316
  } finally {
1311
1317
  currentRule = void 0;
1312
1318
  }
1313
- const wasRemoved = targetRule.parent == null;
1314
- if (wasRemoved) {
1315
- writeSelectorCache2(sourceSelector, { action: "remove" });
1316
- } else if (targetRule.selector === sourceSelector) {
1317
- writeSelectorCache2(sourceSelector, { action: "keep" });
1318
- } else {
1319
- writeSelectorCache2(sourceSelector, { action: "update", selector: targetRule.selector });
1319
+ if (transformOptions === FALLBACK_TRANSFORM_OPTIONS) {
1320
+ const wasRemoved = targetRule.parent == null;
1321
+ if (wasRemoved) {
1322
+ writeSelectorCache2(sourceSelector, { action: "remove" });
1323
+ } else if (targetRule.selector === sourceSelector) {
1324
+ writeSelectorCache2(sourceSelector, { action: "keep" });
1325
+ } else {
1326
+ writeSelectorCache2(sourceSelector, { action: "update", selector: targetRule.selector });
1327
+ }
1320
1328
  }
1321
1329
  };
1322
1330
  parser.transformSync = ((input, opts) => {
@@ -1324,19 +1332,14 @@ function getFallbackRemove(_rule, options) {
1324
1332
  if (input && typeof input === "object" && "type" in input) {
1325
1333
  const maybeRule = input;
1326
1334
  if (maybeRule.type === "rule") {
1327
- currentRule = input;
1328
- try {
1329
- return rawTransformSync(input, transformOptions);
1330
- } finally {
1331
- currentRule = void 0;
1332
- }
1335
+ transformRule(input, transformOptions);
1336
+ return void 0;
1333
1337
  }
1334
1338
  }
1335
1339
  return rawTransformSync(input, transformOptions);
1336
1340
  });
1337
1341
  entry = {
1338
- parser,
1339
- transform
1342
+ parser
1340
1343
  };
1341
1344
  fallbackRemoveCache.set(cacheKey, entry);
1342
1345
  }
@@ -2564,6 +2567,8 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
2564
2567
  } else if (atRule.name === "supports") {
2565
2568
  if (COLOR_MIX_RE.test(atRule.params)) {
2566
2569
  atRule.remove();
2570
+ } else if (isTailwindcssV4LinearGradientSupports(atRule)) {
2571
+ atRule.remove();
2567
2572
  }
2568
2573
  } else if (atRule.name === "layer") {
2569
2574
  if (atRule.nodes === void 0 || Array.isArray(atRule.nodes) && atRule.nodes.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "2.2.0-alpha.1",
3
+ "version": "2.2.0",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -60,7 +60,7 @@
60
60
  "@weapp-tailwindcss/postcss-calc": "^1.0.0",
61
61
  "autoprefixer": "^10.5.0",
62
62
  "lru-cache": "10.4.3",
63
- "postcss": "^8.5.12",
63
+ "postcss": "^8.5.13",
64
64
  "postcss-preset-env": "^10.6.1",
65
65
  "postcss-pxtrans": "^1.0.4",
66
66
  "postcss-rem-to-responsive-pixel": "^7.0.4",