@weapp-tailwindcss/postcss 1.0.15 → 1.0.17-alpha.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
@@ -123,103 +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
- }
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();
188
188
  }
189
189
  }
190
190
  }
191
191
  }
192
- } else if (selector.type === "combinator") {
193
- if (selector.value === ">") {
194
- const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
195
- if (nodes2) {
196
- const first = nodes2[index + 1];
197
- 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")) {
198
- const second = nodes2[index + 2];
199
- if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
200
- const third = nodes2[index + 3];
201
- 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")) {
202
- const ast = getCombinatorSelectorAst(options);
203
- _optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
204
- index + 1,
205
- 3,
206
- ...ast
207
- )]);
208
- }
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
+ )]);
209
209
  }
210
210
  }
211
211
  }
212
212
  }
213
213
  }
214
- } else {
215
- if (selector.type === "class") {
216
- selector.value = internalCssSelectorReplacer(selector.value, {
217
- escapeMap,
218
- mangleContext
219
- });
220
- } else {
221
- selector.remove();
222
- }
223
214
  }
224
215
  });
225
216
  if (selectors.length === 0) {
@@ -329,9 +320,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
329
320
  rule.remove();
330
321
  }
331
322
  rule.walkDecls((decl) => {
332
- if (opts.uniAppX && decl.prop.startsWith("--")) {
333
- decl.remove();
334
- } else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
323
+ if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
335
324
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
336
325
  } else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
337
326
  decl.value = "9999px";
package/dist/index.mjs CHANGED
@@ -123,103 +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
- }
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();
188
188
  }
189
189
  }
190
190
  }
191
191
  }
192
- } else if (selector.type === "combinator") {
193
- if (selector.value === ">") {
194
- const nodes2 = selector.parent?.nodes;
195
- if (nodes2) {
196
- const first = nodes2[index + 1];
197
- 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")) {
198
- const second = nodes2[index + 2];
199
- if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
200
- const third = nodes2[index + 3];
201
- 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")) {
202
- const ast = getCombinatorSelectorAst(options);
203
- selector.parent?.nodes.splice(
204
- index + 1,
205
- 3,
206
- ...ast
207
- );
208
- }
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
+ );
209
209
  }
210
210
  }
211
211
  }
212
212
  }
213
213
  }
214
- } else {
215
- if (selector.type === "class") {
216
- selector.value = internalCssSelectorReplacer(selector.value, {
217
- escapeMap,
218
- mangleContext
219
- });
220
- } else {
221
- selector.remove();
222
- }
223
214
  }
224
215
  });
225
216
  if (selectors.length === 0) {
@@ -329,9 +320,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
329
320
  rule.remove();
330
321
  }
331
322
  rule.walkDecls((decl) => {
332
- if (opts.uniAppX && decl.prop.startsWith("--")) {
333
- decl.remove();
334
- } else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
323
+ if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
335
324
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
336
325
  } else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
337
326
  decl.value = "9999px";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.0.15",
3
+ "version": "1.0.17-alpha.0",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -41,14 +41,14 @@
41
41
  "dependencies": {
42
42
  "@weapp-core/escape": "~4.0.1",
43
43
  "postcss": "~8.5.6",
44
- "postcss-preset-env": "^10.2.3",
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-alpha.0"
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-alpha.0"
52
52
  },
53
53
  "scripts": {
54
54
  "dev": "tsup --watch --sourcemap",