weapp-tailwindcss 2.5.2 → 2.6.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/README.md +2 -8
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/gulp.js +2 -2
- package/dist/gulp.mjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{options-ad127e0c.js → options-487394fa.js} +6 -4
- package/dist/{options-1e3a224a.mjs → options-f7b71f03.mjs} +6 -4
- package/dist/postcss/cssVars.d.ts +5 -0
- package/dist/postcss/mp.d.ts +4 -0
- package/dist/postcss-760298ba.mjs +351 -0
- package/dist/postcss-b53e9504.js +359 -0
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/vite.js +2 -2
- package/dist/vite.mjs +2 -2
- package/dist/webpack.js +2 -2
- package/dist/webpack.mjs +2 -2
- package/package.json +30 -29
- package/dist/postcss-9a63df9d.mjs +0 -115
- package/dist/postcss-fbdc673b.js +0 -123
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import selectorParser from 'postcss-selector-parser';
|
|
2
|
-
import { i as internalCssSelectorReplacer } from './shared-7c88fb94.mjs';
|
|
3
|
-
import { Rule, Declaration } from 'postcss';
|
|
4
|
-
import '@csstools/postcss-is-pseudo-class';
|
|
5
|
-
|
|
6
|
-
const createTransform = (rule, options) => {
|
|
7
|
-
const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
|
|
8
|
-
const replaceFlag = replaceUniversalSelectorWith !== false;
|
|
9
|
-
const transform = (selectors) => {
|
|
10
|
-
selectors.walk((selector) => {
|
|
11
|
-
if (selector.type === 'universal' && replaceFlag) {
|
|
12
|
-
selector.value = replaceUniversalSelectorWith;
|
|
13
|
-
}
|
|
14
|
-
if (selector.type === 'selector') {
|
|
15
|
-
const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
|
|
16
|
-
node && selector.remove();
|
|
17
|
-
}
|
|
18
|
-
if (selector.type === 'class') {
|
|
19
|
-
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
20
|
-
escapeMap,
|
|
21
|
-
mangleContext
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
if (selectors.length === 0) {
|
|
26
|
-
rule.remove();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
return transform;
|
|
30
|
-
};
|
|
31
|
-
const getTransformer = (rule, options) => {
|
|
32
|
-
return selectorParser(createTransform(rule, options));
|
|
33
|
-
};
|
|
34
|
-
const transformSync = (rule, options) => {
|
|
35
|
-
const transformer = getTransformer(rule, options);
|
|
36
|
-
return transformer.transformSync(rule, {
|
|
37
|
-
lossless: false,
|
|
38
|
-
updateSelector: true
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const PATTERNS = [/:not\(template\)\s*~\s*:not\(template\)/.source, /:not\(\[hidden\]\)\s*~\s*:not\(\[hidden\]\)/.source].join('|');
|
|
43
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
44
|
-
function testIfVariablesScope(node, count = 1) {
|
|
45
|
-
if (/:?:before/.test(node.selector) && /:?:after/.test(node.selector)) {
|
|
46
|
-
for (let i = 0; i < count; i++) {
|
|
47
|
-
const tryTestDecl = node.nodes[i];
|
|
48
|
-
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
function commonChunkPreflight(node, options) {
|
|
60
|
-
let childCombinatorReplaceValue = 'view + view';
|
|
61
|
-
if (Array.isArray(options.cssChildCombinatorReplaceValue)) {
|
|
62
|
-
const part = options.cssChildCombinatorReplaceValue.join(',');
|
|
63
|
-
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
64
|
-
}
|
|
65
|
-
else if (typeof options.cssChildCombinatorReplaceValue === 'string') {
|
|
66
|
-
childCombinatorReplaceValue = options.cssChildCombinatorReplaceValue;
|
|
67
|
-
}
|
|
68
|
-
node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
69
|
-
if (testIfVariablesScope(node)) {
|
|
70
|
-
const selectorParts = node.selector.split(',');
|
|
71
|
-
if (!selectorParts.includes('view')) {
|
|
72
|
-
selectorParts.push('view');
|
|
73
|
-
}
|
|
74
|
-
if (options.cssPreflightRange === 'all' &&
|
|
75
|
-
!selectorParts.includes(':not(not)')) {
|
|
76
|
-
selectorParts.push(':not(not)');
|
|
77
|
-
}
|
|
78
|
-
node.selector = selectorParts.join(',');
|
|
79
|
-
if (typeof options.cssInjectPreflight === 'function') {
|
|
80
|
-
node.append(...options.cssInjectPreflight());
|
|
81
|
-
}
|
|
82
|
-
const pseudoVarRule = new Rule({
|
|
83
|
-
selector: '::before,::after'
|
|
84
|
-
});
|
|
85
|
-
pseudoVarRule.append(new Declaration({
|
|
86
|
-
prop: '--tw-content',
|
|
87
|
-
value: '""'
|
|
88
|
-
}));
|
|
89
|
-
node.before(pseudoVarRule);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
94
|
-
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
95
|
-
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
96
|
-
|
|
97
|
-
const postcssWeappTailwindcss = (options = {
|
|
98
|
-
isMainChunk: true
|
|
99
|
-
}) => {
|
|
100
|
-
const { customRuleCallback, isMainChunk } = options;
|
|
101
|
-
const flag = typeof customRuleCallback === 'function';
|
|
102
|
-
return {
|
|
103
|
-
postcssPlugin,
|
|
104
|
-
Once(css) {
|
|
105
|
-
css.walkRules((rule) => {
|
|
106
|
-
transformSync(rule, options);
|
|
107
|
-
isMainChunk && commonChunkPreflight(rule, options);
|
|
108
|
-
flag && customRuleCallback(rule, options);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
postcssWeappTailwindcss.postcss = true;
|
|
114
|
-
|
|
115
|
-
export { pluginName as a, postcssWeappTailwindcss as p, vitePluginName as v };
|
package/dist/postcss-fbdc673b.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var selectorParser = require('postcss-selector-parser');
|
|
4
|
-
var shared = require('./shared-ae7dd073.js');
|
|
5
|
-
var postcss = require('postcss');
|
|
6
|
-
require('@csstools/postcss-is-pseudo-class');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var selectorParser__default = /*#__PURE__*/_interopDefaultCompat(selectorParser);
|
|
11
|
-
|
|
12
|
-
const createTransform = (rule, options) => {
|
|
13
|
-
const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
|
|
14
|
-
const replaceFlag = replaceUniversalSelectorWith !== false;
|
|
15
|
-
const transform = (selectors) => {
|
|
16
|
-
selectors.walk((selector) => {
|
|
17
|
-
if (selector.type === 'universal' && replaceFlag) {
|
|
18
|
-
selector.value = replaceUniversalSelectorWith;
|
|
19
|
-
}
|
|
20
|
-
if (selector.type === 'selector') {
|
|
21
|
-
const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
|
|
22
|
-
node && selector.remove();
|
|
23
|
-
}
|
|
24
|
-
if (selector.type === 'class') {
|
|
25
|
-
selector.value = shared.internalCssSelectorReplacer(selector.value, {
|
|
26
|
-
escapeMap,
|
|
27
|
-
mangleContext
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
if (selectors.length === 0) {
|
|
32
|
-
rule.remove();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
return transform;
|
|
36
|
-
};
|
|
37
|
-
const getTransformer = (rule, options) => {
|
|
38
|
-
return selectorParser__default["default"](createTransform(rule, options));
|
|
39
|
-
};
|
|
40
|
-
const transformSync = (rule, options) => {
|
|
41
|
-
const transformer = getTransformer(rule, options);
|
|
42
|
-
return transformer.transformSync(rule, {
|
|
43
|
-
lossless: false,
|
|
44
|
-
updateSelector: true
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const PATTERNS = [/:not\(template\)\s*~\s*:not\(template\)/.source, /:not\(\[hidden\]\)\s*~\s*:not\(\[hidden\]\)/.source].join('|');
|
|
49
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
50
|
-
function testIfVariablesScope(node, count = 1) {
|
|
51
|
-
if (/:?:before/.test(node.selector) && /:?:after/.test(node.selector)) {
|
|
52
|
-
for (let i = 0; i < count; i++) {
|
|
53
|
-
const tryTestDecl = node.nodes[i];
|
|
54
|
-
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
function commonChunkPreflight(node, options) {
|
|
66
|
-
let childCombinatorReplaceValue = 'view + view';
|
|
67
|
-
if (Array.isArray(options.cssChildCombinatorReplaceValue)) {
|
|
68
|
-
const part = options.cssChildCombinatorReplaceValue.join(',');
|
|
69
|
-
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
70
|
-
}
|
|
71
|
-
else if (typeof options.cssChildCombinatorReplaceValue === 'string') {
|
|
72
|
-
childCombinatorReplaceValue = options.cssChildCombinatorReplaceValue;
|
|
73
|
-
}
|
|
74
|
-
node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
75
|
-
if (testIfVariablesScope(node)) {
|
|
76
|
-
const selectorParts = node.selector.split(',');
|
|
77
|
-
if (!selectorParts.includes('view')) {
|
|
78
|
-
selectorParts.push('view');
|
|
79
|
-
}
|
|
80
|
-
if (options.cssPreflightRange === 'all' &&
|
|
81
|
-
!selectorParts.includes(':not(not)')) {
|
|
82
|
-
selectorParts.push(':not(not)');
|
|
83
|
-
}
|
|
84
|
-
node.selector = selectorParts.join(',');
|
|
85
|
-
if (typeof options.cssInjectPreflight === 'function') {
|
|
86
|
-
node.append(...options.cssInjectPreflight());
|
|
87
|
-
}
|
|
88
|
-
const pseudoVarRule = new postcss.Rule({
|
|
89
|
-
selector: '::before,::after'
|
|
90
|
-
});
|
|
91
|
-
pseudoVarRule.append(new postcss.Declaration({
|
|
92
|
-
prop: '--tw-content',
|
|
93
|
-
value: '""'
|
|
94
|
-
}));
|
|
95
|
-
node.before(pseudoVarRule);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
100
|
-
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
101
|
-
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
102
|
-
|
|
103
|
-
const postcssWeappTailwindcss = (options = {
|
|
104
|
-
isMainChunk: true
|
|
105
|
-
}) => {
|
|
106
|
-
const { customRuleCallback, isMainChunk } = options;
|
|
107
|
-
const flag = typeof customRuleCallback === 'function';
|
|
108
|
-
return {
|
|
109
|
-
postcssPlugin,
|
|
110
|
-
Once(css) {
|
|
111
|
-
css.walkRules((rule) => {
|
|
112
|
-
transformSync(rule, options);
|
|
113
|
-
isMainChunk && commonChunkPreflight(rule, options);
|
|
114
|
-
flag && customRuleCallback(rule, options);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
postcssWeappTailwindcss.postcss = true;
|
|
120
|
-
|
|
121
|
-
exports.pluginName = pluginName;
|
|
122
|
-
exports.postcssWeappTailwindcss = postcssWeappTailwindcss;
|
|
123
|
-
exports.vitePluginName = vitePluginName;
|