@weapp-tailwindcss/postcss 1.0.16 → 1.0.17

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
@@ -123,105 +123,94 @@ function getCombinatorSelectorAst(options) {
123
123
  return childCombinatorReplaceValue;
124
124
  }
125
125
  function createRuleTransform(rule, options) {
126
- const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass, uniAppX } = options;
126
+ const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
127
127
  const transform = (selectors) => {
128
128
  selectors.walk((selector, index) => {
129
- if (!uniAppX) {
130
- if (selector.type === "class") {
131
- selector.value = internalCssSelectorReplacer(selector.value, {
132
- escapeMap,
133
- mangleContext
134
- });
135
- } else if (selector.type === "universal") {
136
- if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
137
- selector.value = composeIsPseudo(cssSelectorReplacement.universal);
138
- }
139
- } else if (selector.type === "selector") {
140
- if (cssRemoveHoverPseudoClass) {
141
- const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
142
- if (node) {
143
- selector.remove();
144
- }
129
+ if (selector.type === "class") {
130
+ selector.value = internalCssSelectorReplacer(selector.value, {
131
+ escapeMap,
132
+ mangleContext
133
+ });
134
+ } else if (selector.type === "universal") {
135
+ if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
136
+ selector.value = composeIsPseudo(cssSelectorReplacement.universal);
137
+ }
138
+ } else if (selector.type === "selector") {
139
+ if (cssRemoveHoverPseudoClass) {
140
+ const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
141
+ if (node) {
142
+ selector.remove();
145
143
  }
146
- } else if (selector.type === "pseudo") {
147
- if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
148
- selector.value = composeIsPseudo(cssSelectorReplacement.root);
149
- } else if (selector.value === ":where") {
150
- if (index === 0 && selector.length === 1) {
151
- selector.walk((node, idx) => {
152
- if (idx === 0 && node.type === "class") {
153
- const nodes2 = _optionalChain([node, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.nodes]);
154
- if (nodes2) {
155
- const first = nodes2[idx + 1];
156
- if (first && first.type === "combinator" && first.value === ">") {
157
- const second = nodes2[idx + 2];
158
- if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
159
- const ast = getCombinatorSelectorAst(options);
160
- second.replaceWith(
161
- ...ast
162
- );
163
- }
144
+ }
145
+ } else if (selector.type === "pseudo") {
146
+ if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
147
+ selector.value = composeIsPseudo(cssSelectorReplacement.root);
148
+ } else if (selector.value === ":where") {
149
+ if (index === 0 && selector.length === 1) {
150
+ selector.walk((node, idx) => {
151
+ if (idx === 0 && node.type === "class") {
152
+ const nodes2 = _optionalChain([node, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.nodes]);
153
+ if (nodes2) {
154
+ const first = nodes2[idx + 1];
155
+ if (first && first.type === "combinator" && first.value === ">") {
156
+ const second = nodes2[idx + 2];
157
+ if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
158
+ const ast = getCombinatorSelectorAst(options);
159
+ second.replaceWith(
160
+ ...ast
161
+ );
164
162
  }
165
163
  }
166
164
  }
167
- });
168
- selector.replaceWith(...selector.nodes);
169
- for (const node of rule.nodes) {
170
- if (node.type === "decl") {
171
- if (node.prop === "margin-block-start") {
172
- node.prop = "margin-block-end";
173
- } else if (node.prop === "margin-block-end") {
174
- node.prop = "margin-block-start";
175
- } else if (node.prop === "margin-inline-start") {
176
- node.prop = "margin-inline-end";
177
- } else if (node.prop === "margin-inline-end") {
178
- node.prop = "margin-inline-start";
179
- } else if (node.prop === "margin-top") {
180
- node.prop = "margin-bottom";
181
- } else if (node.prop === "margin-bottom") {
182
- node.prop = "margin-top";
183
- } else if (node.prop === "margin-left") {
184
- node.prop = "margin-right";
185
- } else if (node.prop === "margin-right") {
186
- node.prop = "margin-left";
187
- } else if (node.prop === "-webkit-margin-start" || node.prop === "-webkit-margin-end" || node.prop === "-webkit-margin-before" || node.prop === "-webkit-margin-after") {
188
- node.remove();
189
- }
165
+ }
166
+ });
167
+ selector.replaceWith(...selector.nodes);
168
+ for (const node of rule.nodes) {
169
+ if (node.type === "decl") {
170
+ if (node.prop === "margin-block-start") {
171
+ node.prop = "margin-block-end";
172
+ } else if (node.prop === "margin-block-end") {
173
+ node.prop = "margin-block-start";
174
+ } else if (node.prop === "margin-inline-start") {
175
+ node.prop = "margin-inline-end";
176
+ } else if (node.prop === "margin-inline-end") {
177
+ node.prop = "margin-inline-start";
178
+ } else if (node.prop === "margin-top") {
179
+ node.prop = "margin-bottom";
180
+ } else if (node.prop === "margin-bottom") {
181
+ node.prop = "margin-top";
182
+ } else if (node.prop === "margin-left") {
183
+ node.prop = "margin-right";
184
+ } else if (node.prop === "margin-right") {
185
+ node.prop = "margin-left";
186
+ } else if (node.prop === "-webkit-margin-start" || node.prop === "-webkit-margin-end" || node.prop === "-webkit-margin-before" || node.prop === "-webkit-margin-after") {
187
+ node.remove();
190
188
  }
191
189
  }
192
190
  }
193
191
  }
194
- } else if (selector.type === "combinator") {
195
- if (selector.value === ">") {
196
- const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
197
- if (nodes2) {
198
- const first = nodes2[index + 1];
199
- if (first && first.type === "pseudo" && first.value === ":not" && (first.first.first.type === "attribute" && first.first.first.attribute === "hidden" || first.first.first.type === "tag" && first.first.first.value === "template")) {
200
- const second = nodes2[index + 2];
201
- if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
202
- const third = nodes2[index + 3];
203
- if (third && third.type === "pseudo" && third.value === ":not" && (third.first.first.type === "attribute" && third.first.first.attribute === "hidden" || third.first.first.type === "tag" && third.first.first.value === "template")) {
204
- const ast = getCombinatorSelectorAst(options);
205
- _optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
206
- index + 1,
207
- 3,
208
- ...ast
209
- )]);
210
- }
192
+ }
193
+ } else if (selector.type === "combinator") {
194
+ if (selector.value === ">") {
195
+ const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
196
+ if (nodes2) {
197
+ const first = nodes2[index + 1];
198
+ if (first && first.type === "pseudo" && first.value === ":not" && (first.first.first.type === "attribute" && first.first.first.attribute === "hidden" || first.first.first.type === "tag" && first.first.first.value === "template")) {
199
+ const second = nodes2[index + 2];
200
+ if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
201
+ const third = nodes2[index + 3];
202
+ if (third && third.type === "pseudo" && third.value === ":not" && (third.first.first.type === "attribute" && third.first.first.attribute === "hidden" || third.first.first.type === "tag" && third.first.first.value === "template")) {
203
+ const ast = getCombinatorSelectorAst(options);
204
+ _optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
205
+ index + 1,
206
+ 3,
207
+ ...ast
208
+ )]);
211
209
  }
212
210
  }
213
211
  }
214
212
  }
215
213
  }
216
- } else {
217
- if (selector.type === "class") {
218
- selector.value = internalCssSelectorReplacer(selector.value, {
219
- escapeMap,
220
- mangleContext
221
- });
222
- } else {
223
- selector.remove();
224
- }
225
214
  }
226
215
  });
227
216
  if (selectors.length === 0) {
@@ -331,9 +320,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
331
320
  rule.remove();
332
321
  }
333
322
  rule.walkDecls((decl) => {
334
- if (opts.uniAppX && decl.prop.startsWith("--")) {
335
- decl.remove();
336
- } else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
323
+ if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
337
324
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
338
325
  } else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
339
326
  decl.value = "9999px";
package/dist/index.mjs CHANGED
@@ -123,105 +123,94 @@ function getCombinatorSelectorAst(options) {
123
123
  return childCombinatorReplaceValue;
124
124
  }
125
125
  function createRuleTransform(rule, options) {
126
- const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass, uniAppX } = options;
126
+ const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
127
127
  const transform = (selectors) => {
128
128
  selectors.walk((selector, index) => {
129
- if (!uniAppX) {
130
- if (selector.type === "class") {
131
- selector.value = internalCssSelectorReplacer(selector.value, {
132
- escapeMap,
133
- mangleContext
134
- });
135
- } else if (selector.type === "universal") {
136
- if (cssSelectorReplacement?.universal) {
137
- selector.value = composeIsPseudo(cssSelectorReplacement.universal);
138
- }
139
- } else if (selector.type === "selector") {
140
- if (cssRemoveHoverPseudoClass) {
141
- const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
142
- if (node) {
143
- selector.remove();
144
- }
129
+ if (selector.type === "class") {
130
+ selector.value = internalCssSelectorReplacer(selector.value, {
131
+ escapeMap,
132
+ mangleContext
133
+ });
134
+ } else if (selector.type === "universal") {
135
+ if (cssSelectorReplacement?.universal) {
136
+ selector.value = composeIsPseudo(cssSelectorReplacement.universal);
137
+ }
138
+ } else if (selector.type === "selector") {
139
+ if (cssRemoveHoverPseudoClass) {
140
+ const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
141
+ if (node) {
142
+ selector.remove();
145
143
  }
146
- } else if (selector.type === "pseudo") {
147
- if (selector.value === ":root" && cssSelectorReplacement?.root) {
148
- selector.value = composeIsPseudo(cssSelectorReplacement.root);
149
- } else if (selector.value === ":where") {
150
- if (index === 0 && selector.length === 1) {
151
- selector.walk((node, idx) => {
152
- if (idx === 0 && node.type === "class") {
153
- const nodes2 = node.parent?.nodes;
154
- if (nodes2) {
155
- const first = nodes2[idx + 1];
156
- if (first && first.type === "combinator" && first.value === ">") {
157
- const second = nodes2[idx + 2];
158
- if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
159
- const ast = getCombinatorSelectorAst(options);
160
- second.replaceWith(
161
- ...ast
162
- );
163
- }
144
+ }
145
+ } else if (selector.type === "pseudo") {
146
+ if (selector.value === ":root" && cssSelectorReplacement?.root) {
147
+ selector.value = composeIsPseudo(cssSelectorReplacement.root);
148
+ } else if (selector.value === ":where") {
149
+ if (index === 0 && selector.length === 1) {
150
+ selector.walk((node, idx) => {
151
+ if (idx === 0 && node.type === "class") {
152
+ const nodes2 = node.parent?.nodes;
153
+ if (nodes2) {
154
+ const first = nodes2[idx + 1];
155
+ if (first && first.type === "combinator" && first.value === ">") {
156
+ const second = nodes2[idx + 2];
157
+ if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
158
+ const ast = getCombinatorSelectorAst(options);
159
+ second.replaceWith(
160
+ ...ast
161
+ );
164
162
  }
165
163
  }
166
164
  }
167
- });
168
- selector.replaceWith(...selector.nodes);
169
- for (const node of rule.nodes) {
170
- if (node.type === "decl") {
171
- if (node.prop === "margin-block-start") {
172
- node.prop = "margin-block-end";
173
- } else if (node.prop === "margin-block-end") {
174
- node.prop = "margin-block-start";
175
- } else if (node.prop === "margin-inline-start") {
176
- node.prop = "margin-inline-end";
177
- } else if (node.prop === "margin-inline-end") {
178
- node.prop = "margin-inline-start";
179
- } else if (node.prop === "margin-top") {
180
- node.prop = "margin-bottom";
181
- } else if (node.prop === "margin-bottom") {
182
- node.prop = "margin-top";
183
- } else if (node.prop === "margin-left") {
184
- node.prop = "margin-right";
185
- } else if (node.prop === "margin-right") {
186
- node.prop = "margin-left";
187
- } else if (node.prop === "-webkit-margin-start" || node.prop === "-webkit-margin-end" || node.prop === "-webkit-margin-before" || node.prop === "-webkit-margin-after") {
188
- node.remove();
189
- }
165
+ }
166
+ });
167
+ selector.replaceWith(...selector.nodes);
168
+ for (const node of rule.nodes) {
169
+ if (node.type === "decl") {
170
+ if (node.prop === "margin-block-start") {
171
+ node.prop = "margin-block-end";
172
+ } else if (node.prop === "margin-block-end") {
173
+ node.prop = "margin-block-start";
174
+ } else if (node.prop === "margin-inline-start") {
175
+ node.prop = "margin-inline-end";
176
+ } else if (node.prop === "margin-inline-end") {
177
+ node.prop = "margin-inline-start";
178
+ } else if (node.prop === "margin-top") {
179
+ node.prop = "margin-bottom";
180
+ } else if (node.prop === "margin-bottom") {
181
+ node.prop = "margin-top";
182
+ } else if (node.prop === "margin-left") {
183
+ node.prop = "margin-right";
184
+ } else if (node.prop === "margin-right") {
185
+ node.prop = "margin-left";
186
+ } else if (node.prop === "-webkit-margin-start" || node.prop === "-webkit-margin-end" || node.prop === "-webkit-margin-before" || node.prop === "-webkit-margin-after") {
187
+ node.remove();
190
188
  }
191
189
  }
192
190
  }
193
191
  }
194
- } else if (selector.type === "combinator") {
195
- if (selector.value === ">") {
196
- const nodes2 = selector.parent?.nodes;
197
- if (nodes2) {
198
- const first = nodes2[index + 1];
199
- if (first && first.type === "pseudo" && first.value === ":not" && (first.first.first.type === "attribute" && first.first.first.attribute === "hidden" || first.first.first.type === "tag" && first.first.first.value === "template")) {
200
- const second = nodes2[index + 2];
201
- if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
202
- const third = nodes2[index + 3];
203
- if (third && third.type === "pseudo" && third.value === ":not" && (third.first.first.type === "attribute" && third.first.first.attribute === "hidden" || third.first.first.type === "tag" && third.first.first.value === "template")) {
204
- const ast = getCombinatorSelectorAst(options);
205
- selector.parent?.nodes.splice(
206
- index + 1,
207
- 3,
208
- ...ast
209
- );
210
- }
192
+ }
193
+ } else if (selector.type === "combinator") {
194
+ if (selector.value === ">") {
195
+ const nodes2 = selector.parent?.nodes;
196
+ if (nodes2) {
197
+ const first = nodes2[index + 1];
198
+ if (first && first.type === "pseudo" && first.value === ":not" && (first.first.first.type === "attribute" && first.first.first.attribute === "hidden" || first.first.first.type === "tag" && first.first.first.value === "template")) {
199
+ const second = nodes2[index + 2];
200
+ if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
201
+ const third = nodes2[index + 3];
202
+ if (third && third.type === "pseudo" && third.value === ":not" && (third.first.first.type === "attribute" && third.first.first.attribute === "hidden" || third.first.first.type === "tag" && third.first.first.value === "template")) {
203
+ const ast = getCombinatorSelectorAst(options);
204
+ selector.parent?.nodes.splice(
205
+ index + 1,
206
+ 3,
207
+ ...ast
208
+ );
211
209
  }
212
210
  }
213
211
  }
214
212
  }
215
213
  }
216
- } else {
217
- if (selector.type === "class") {
218
- selector.value = internalCssSelectorReplacer(selector.value, {
219
- escapeMap,
220
- mangleContext
221
- });
222
- } else {
223
- selector.remove();
224
- }
225
214
  }
226
215
  });
227
216
  if (selectors.length === 0) {
@@ -331,9 +320,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
331
320
  rule.remove();
332
321
  }
333
322
  rule.walkDecls((decl) => {
334
- if (opts.uniAppX && decl.prop.startsWith("--")) {
335
- decl.remove();
336
- } else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
323
+ if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
337
324
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
338
325
  } else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
339
326
  decl.value = "9999px";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -44,11 +44,11 @@
44
44
  "postcss-preset-env": "^10.2.4",
45
45
  "postcss-rem-to-responsive-pixel": "~6.0.2",
46
46
  "postcss-selector-parser": "~7.1.0",
47
- "@weapp-tailwindcss/shared": "1.0.2"
47
+ "@weapp-tailwindcss/shared": "1.0.3"
48
48
  },
49
49
  "devDependencies": {
50
50
  "postcss-value-parser": "^4.2.0",
51
- "@weapp-tailwindcss/mangle": "1.0.4"
51
+ "@weapp-tailwindcss/mangle": "1.0.5"
52
52
  },
53
53
  "scripts": {
54
54
  "dev": "tsup --watch --sourcemap",