weapp-tailwindcss 3.3.7 → 3.4.0-alpha.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/chunk-23B34GUU.js +126 -0
- package/dist/chunk-33GCHXV2.js +953 -0
- package/dist/chunk-556KTBON.js +31 -0
- package/dist/chunk-6Z776ZWK.js +43 -0
- package/dist/chunk-75EWCRQW.mjs +13 -0
- package/dist/chunk-76AXDOI5.js +173 -0
- package/dist/chunk-77FRX3XG.js +30 -0
- package/dist/chunk-AB467PG7.mjs +43 -0
- package/dist/chunk-D7TNNBED.js +95 -0
- package/dist/chunk-E7XGHGC7.mjs +62 -0
- package/dist/chunk-F7IR3ASC.mjs +152 -0
- package/dist/chunk-GUE4UCRJ.mjs +126 -0
- package/dist/chunk-H62TECOL.js +216 -0
- package/dist/chunk-HBQASQKY.js +13 -0
- package/dist/chunk-IOYI6MSW.mjs +533 -0
- package/dist/chunk-JMMU4NZL.mjs +173 -0
- package/dist/chunk-KR2M4GD3.mjs +953 -0
- package/dist/chunk-LYLCSEZ7.js +152 -0
- package/dist/chunk-NVFWRLOI.mjs +27 -0
- package/dist/chunk-ODCGCGWM.js +533 -0
- package/dist/chunk-ORMKM6ZA.mjs +30 -0
- package/dist/chunk-S2GPPMOJ.js +27 -0
- package/dist/chunk-SRLZU2YE.mjs +95 -0
- package/dist/chunk-U2UGOG3R.js +62 -0
- package/dist/chunk-VECXHWWG.mjs +31 -0
- package/dist/chunk-Z3EH2XYL.mjs +216 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +32 -51
- package/dist/cli.mjs +34 -46
- package/dist/core.d.mts +22 -0
- package/dist/core.d.ts +16 -2
- package/dist/core.js +43 -63
- package/dist/core.mjs +46 -62
- package/dist/css-macro/index.d.mts +18 -0
- package/dist/css-macro/index.d.ts +7 -4
- package/dist/css-macro/index.js +37 -34
- package/dist/css-macro/index.mjs +35 -28
- package/dist/css-macro/postcss.d.mts +7 -0
- package/dist/css-macro/postcss.d.ts +5 -3
- package/dist/css-macro/postcss.js +54 -45
- package/dist/css-macro/postcss.mjs +54 -45
- package/dist/defaults.d.mts +16 -0
- package/dist/defaults.d.ts +16 -2
- package/dist/defaults.js +6 -9
- package/dist/defaults.mjs +9 -4
- package/dist/gulp.d.mts +26 -0
- package/dist/gulp.d.ts +26 -1
- package/dist/gulp.js +12 -37
- package/dist/gulp.mjs +15 -32
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +23 -44
- package/dist/index.mjs +23 -34
- package/dist/postcss.d.mts +23 -0
- package/dist/postcss.d.ts +23 -1
- package/dist/postcss.js +10 -24
- package/dist/postcss.mjs +17 -8
- package/dist/replace.d.mts +19 -0
- package/dist/replace.d.ts +19 -3
- package/dist/replace.js +30 -50
- package/dist/replace.mjs +30 -26
- package/dist/types-DSNuiOhH.d.mts +519 -0
- package/dist/types-DSNuiOhH.d.ts +519 -0
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -1
- package/dist/vite.js +12 -35
- package/dist/vite.mjs +15 -30
- package/dist/weapp-tw-runtime-loader.d.mts +7 -0
- package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
- package/dist/weapp-tw-runtime-loader.js +12 -12
- package/dist/weapp-tw-runtime-loader.mjs +12 -8
- package/dist/webpack.d.mts +26 -0
- package/dist/webpack.d.ts +26 -1
- package/dist/webpack.js +12 -35
- package/dist/webpack.mjs +15 -30
- package/dist/webpack4.d.mts +27 -0
- package/dist/webpack4.d.ts +27 -1
- package/dist/webpack4.js +205 -192
- package/dist/webpack4.mjs +211 -189
- package/package.json +18 -19
- package/dist/babel/index.d.ts +0 -16
- package/dist/bundlers/gulp/index.d.ts +0 -8
- package/dist/bundlers/vite/index.d.ts +0 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
- package/dist/bundlers/webpack/index.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -32
- package/dist/constants-CFM1J-h1.js +0 -42
- package/dist/constants-Dy2Dd3Fz.mjs +0 -36
- package/dist/constants.d.ts +0 -7
- package/dist/css-macro/constants.d.ts +0 -14
- package/dist/debug/index.d.ts +0 -2
- package/dist/defaults-DUZZvtdg.mjs +0 -149
- package/dist/defaults-syv_N3uk.js +0 -156
- package/dist/defu-Cdz2PomB.js +0 -60
- package/dist/defu-n46TJT6t.mjs +0 -57
- package/dist/env.d.ts +0 -2
- package/dist/escape.d.ts +0 -4
- package/dist/extractors/split.d.ts +0 -3
- package/dist/index-B8TOcVAt.js +0 -130
- package/dist/index-BEIjgKpF.mjs +0 -11
- package/dist/index-BKZH-Gxq.mjs +0 -134
- package/dist/index-BPzIdybK.mjs +0 -513
- package/dist/index-Bc61v7B0.mjs +0 -124
- package/dist/index-DXeB6ex8.js +0 -136
- package/dist/index-DwZHOkK3.js +0 -526
- package/dist/index-HC-Qkn0i.js +0 -17
- package/dist/js/handlers.d.ts +0 -13
- package/dist/js/index.d.ts +0 -7
- package/dist/mangle/index.d.ts +0 -8
- package/dist/options-BHJnjA_a.mjs +0 -981
- package/dist/options-DAp5AdGz.js +0 -1014
- package/dist/options.d.ts +0 -2
- package/dist/postcss/cssVars.d.ts +0 -5
- package/dist/postcss/index.d.ts +0 -3
- package/dist/postcss/mp.d.ts +0 -8
- package/dist/postcss/plugins/ctx.d.ts +0 -6
- package/dist/postcss/plugins/index.d.ts +0 -7
- package/dist/postcss/plugins/post.d.ts +0 -5
- package/dist/postcss/plugins/pre.d.ts +0 -5
- package/dist/postcss/preflight.d.ts +0 -3
- package/dist/postcss/selectorParser.d.ts +0 -6
- package/dist/postcss/shared.d.ts +0 -3
- package/dist/postcss/symbols.d.ts +0 -1
- package/dist/reg.d.ts +0 -1
- package/dist/shared-DbJl6i6a.mjs +0 -25
- package/dist/shared-hzYeE1wX.js +0 -28
- package/dist/tailwindcss/patcher.d.ts +0 -8
- package/dist/tailwindcss/supportCustomUnit.d.ts +0 -6
- package/dist/types.d.ts +0 -179
- package/dist/utils.d.ts +0 -18
- package/dist/v5-B9S3lBOs.mjs +0 -174
- package/dist/v5-QURRYPNk.js +0 -181
- package/dist/wxml/Tokenizer.d.ts +0 -31
- package/dist/wxml/index.d.ts +0 -2
- package/dist/wxml/shared.d.ts +0 -2
- package/dist/wxml/utils.d.ts +0 -9
package/dist/index-BKZH-Gxq.mjs
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { g as getOptions, _ as __awaiter } from './options-BHJnjA_a.mjs';
|
|
2
|
-
import { v as vitePluginName } from './index-BPzIdybK.mjs';
|
|
3
|
-
import { g as getGroupedEntries } from './defaults-DUZZvtdg.mjs';
|
|
4
|
-
import { c as createDebug } from './index-BEIjgKpF.mjs';
|
|
5
|
-
|
|
6
|
-
const debug = createDebug();
|
|
7
|
-
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
8
|
-
const opts = getOptions(options);
|
|
9
|
-
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, twPatcher, } = opts;
|
|
10
|
-
if (disabled) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
patch === null || patch === void 0 ? void 0 : patch();
|
|
14
|
-
onLoad();
|
|
15
|
-
return {
|
|
16
|
-
name: vitePluginName,
|
|
17
|
-
enforce: 'post',
|
|
18
|
-
generateBundle(opt, bundle) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
debug('start');
|
|
21
|
-
onStart();
|
|
22
|
-
const entries = Object.entries(bundle);
|
|
23
|
-
const groupedEntries = getGroupedEntries(entries, opts);
|
|
24
|
-
const runtimeSet = twPatcher.getClassSet();
|
|
25
|
-
setMangleRuntimeSet(runtimeSet);
|
|
26
|
-
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
27
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
28
|
-
let noCachedCount = 0;
|
|
29
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
30
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
31
|
-
const oldVal = originalSource.source.toString();
|
|
32
|
-
const hash = cache.computeHash(oldVal);
|
|
33
|
-
cache.calcHashValueChanged(file, hash);
|
|
34
|
-
yield cache.process(file, () => {
|
|
35
|
-
const source = cache.get(file);
|
|
36
|
-
if (source) {
|
|
37
|
-
originalSource.source = source;
|
|
38
|
-
debug('html cache hit: %s', file);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
originalSource.source = yield templateHandler(oldVal, {
|
|
45
|
-
runtimeSet,
|
|
46
|
-
});
|
|
47
|
-
onUpdate(file, oldVal, originalSource.source);
|
|
48
|
-
debug('html handle: %s', file);
|
|
49
|
-
noCachedCount++;
|
|
50
|
-
return {
|
|
51
|
-
key: file,
|
|
52
|
-
source: originalSource.source,
|
|
53
|
-
};
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
57
|
-
}
|
|
58
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
59
|
-
let noCachedCount = 0;
|
|
60
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
61
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
62
|
-
const rawSource = originalSource.code;
|
|
63
|
-
const hash = cache.computeHash(rawSource);
|
|
64
|
-
cache.calcHashValueChanged(file, hash);
|
|
65
|
-
yield cache.process(file, () => {
|
|
66
|
-
const source = cache.get(file);
|
|
67
|
-
if (source) {
|
|
68
|
-
originalSource.code = source;
|
|
69
|
-
debug('js cache hit: %s', file);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const mapFilename = `${file}.map`;
|
|
76
|
-
const hasMap = Boolean(bundle[mapFilename]);
|
|
77
|
-
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
78
|
-
generateMap: hasMap,
|
|
79
|
-
});
|
|
80
|
-
originalSource.code = code;
|
|
81
|
-
onUpdate(file, rawSource, code);
|
|
82
|
-
debug('js handle: %s', file);
|
|
83
|
-
noCachedCount++;
|
|
84
|
-
if (hasMap && map) {
|
|
85
|
-
bundle[mapFilename].source = map.toString();
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
key: file,
|
|
89
|
-
source: code,
|
|
90
|
-
};
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
94
|
-
}
|
|
95
|
-
if (Array.isArray(groupedEntries.css)) {
|
|
96
|
-
let noCachedCount = 0;
|
|
97
|
-
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
98
|
-
const [file, originalSource] = groupedEntries.css[i];
|
|
99
|
-
const rawSource = originalSource.source.toString();
|
|
100
|
-
const hash = cache.computeHash(rawSource);
|
|
101
|
-
cache.calcHashValueChanged(file, hash);
|
|
102
|
-
yield cache.process(file, () => {
|
|
103
|
-
const source = cache.get(file);
|
|
104
|
-
if (source) {
|
|
105
|
-
originalSource.source = source;
|
|
106
|
-
debug('css cache hit: %s', file);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
const css = yield styleHandler(rawSource, {
|
|
113
|
-
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType),
|
|
114
|
-
});
|
|
115
|
-
originalSource.source = css;
|
|
116
|
-
onUpdate(file, rawSource, css);
|
|
117
|
-
debug('css handle: %s', file);
|
|
118
|
-
noCachedCount++;
|
|
119
|
-
return {
|
|
120
|
-
key: file,
|
|
121
|
-
source: css,
|
|
122
|
-
};
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
126
|
-
}
|
|
127
|
-
onEnd();
|
|
128
|
-
debug('end');
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export { UnifiedViteWeappTailwindcssPlugin as U };
|
package/dist/index-BPzIdybK.mjs
DELETED
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
|
|
2
|
-
import postcssRem2rpx from 'postcss-rem-to-responsive-pixel';
|
|
3
|
-
import selectorParser from 'postcss-selector-parser';
|
|
4
|
-
import { c as composeIsPseudo, i as internalCssSelectorReplacer } from './shared-DbJl6i6a.mjs';
|
|
5
|
-
import { Declaration, Rule } from 'postcss';
|
|
6
|
-
|
|
7
|
-
function createRuleTransform(rule, options) {
|
|
8
|
-
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
|
|
9
|
-
const transform = (selectors) => {
|
|
10
|
-
selectors.walk((selector) => {
|
|
11
|
-
if (selector.type === 'universal' && cssSelectorReplacement && cssSelectorReplacement.universal) {
|
|
12
|
-
selector.value = composeIsPseudo(cssSelectorReplacement.universal);
|
|
13
|
-
}
|
|
14
|
-
if (cssRemoveHoverPseudoClass && 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 === 'pseudo'
|
|
19
|
-
&& selector.value === ':root'
|
|
20
|
-
&& cssSelectorReplacement
|
|
21
|
-
&& cssSelectorReplacement.root) {
|
|
22
|
-
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
23
|
-
}
|
|
24
|
-
if (selector.type === 'class') {
|
|
25
|
-
selector.value = 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
|
-
function getRuleTransformer(rule, options) {
|
|
38
|
-
return selectorParser(createRuleTransform(rule, options));
|
|
39
|
-
}
|
|
40
|
-
function ruleTransformSync(rule, options) {
|
|
41
|
-
const transformer = getRuleTransformer(rule, options);
|
|
42
|
-
return transformer.transformSync(rule, {
|
|
43
|
-
lossless: false,
|
|
44
|
-
updateSelector: true,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
48
|
-
let b = false;
|
|
49
|
-
let a = false;
|
|
50
|
-
selectorParser((selectors) => {
|
|
51
|
-
selectors.walkPseudos((s) => {
|
|
52
|
-
var _a;
|
|
53
|
-
if (((_a = s.parent) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
54
|
-
if (/^:?:before$/.test(s.value)) {
|
|
55
|
-
b = true;
|
|
56
|
-
}
|
|
57
|
-
if (/^:?:after$/.test(s.value)) {
|
|
58
|
-
a = true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}).astSync(node);
|
|
63
|
-
return b && a;
|
|
64
|
-
}
|
|
65
|
-
const fallbackRemove = selectorParser((selectors) => {
|
|
66
|
-
selectors.walk((selector) => {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
if (selector.type === 'universal') {
|
|
69
|
-
(_a = selector.parent) === null || _a === void 0 ? void 0 : _a.remove();
|
|
70
|
-
}
|
|
71
|
-
if (selector.type === 'pseudo' && selector.value === ':is') {
|
|
72
|
-
(_b = selector.parent) === null || _b === void 0 ? void 0 : _b.remove();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
var cssVars = [
|
|
78
|
-
{
|
|
79
|
-
prop: '--tw-border-spacing-x',
|
|
80
|
-
value: '0',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
prop: '--tw-border-spacing-y',
|
|
84
|
-
value: '0',
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
prop: '--tw-translate-x',
|
|
88
|
-
value: '0',
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
prop: '--tw-translate-y',
|
|
92
|
-
value: '0',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
prop: '--tw-rotate',
|
|
96
|
-
value: '0',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
prop: '--tw-skew-x',
|
|
100
|
-
value: '0',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
prop: '--tw-skew-y',
|
|
104
|
-
value: '0',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
prop: '--tw-scale-x',
|
|
108
|
-
value: '1',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
prop: '--tw-scale-y',
|
|
112
|
-
value: '1',
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
prop: '--tw-pan-x',
|
|
116
|
-
value: ' ',
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
prop: '--tw-pan-y',
|
|
120
|
-
value: ' ',
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
prop: '--tw-pinch-zoom',
|
|
124
|
-
value: ' ',
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
prop: '--tw-scroll-snap-strictness',
|
|
128
|
-
value: 'proximity',
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
prop: '--tw-gradient-from-position',
|
|
132
|
-
value: ' ',
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
prop: '--tw-gradient-via-position',
|
|
136
|
-
value: ' ',
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
prop: '--tw-gradient-to-position',
|
|
140
|
-
value: ' ',
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
prop: '--tw-ordinal',
|
|
144
|
-
value: ' ',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
prop: '--tw-slashed-zero',
|
|
148
|
-
value: ' ',
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
prop: '--tw-numeric-figure',
|
|
152
|
-
value: ' ',
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
prop: '--tw-numeric-spacing',
|
|
156
|
-
value: ' ',
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
prop: '--tw-numeric-fraction',
|
|
160
|
-
value: ' ',
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
prop: '--tw-ring-inset',
|
|
164
|
-
value: ' ',
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
prop: '--tw-ring-offset-width',
|
|
168
|
-
value: '0px',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
prop: '--tw-ring-offset-color',
|
|
172
|
-
value: '#fff',
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
prop: '--tw-ring-color',
|
|
176
|
-
value: 'rgb(59 130 246 / 0.5)',
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
prop: '--tw-ring-offset-shadow',
|
|
180
|
-
value: '0 0 #0000',
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
prop: '--tw-ring-shadow',
|
|
184
|
-
value: '0 0 #0000',
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
prop: '--tw-shadow',
|
|
188
|
-
value: '0 0 #0000',
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
prop: '--tw-shadow-colored',
|
|
192
|
-
value: '0 0 #0000',
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
prop: '--tw-blur',
|
|
196
|
-
value: ' ',
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
prop: '--tw-brightness',
|
|
200
|
-
value: ' ',
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
prop: '--tw-contrast',
|
|
204
|
-
value: ' ',
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
prop: '--tw-grayscale',
|
|
208
|
-
value: ' ',
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
prop: '--tw-hue-rotate',
|
|
212
|
-
value: ' ',
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
prop: '--tw-invert',
|
|
216
|
-
value: ' ',
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
prop: '--tw-saturate',
|
|
220
|
-
value: ' ',
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
prop: '--tw-sepia',
|
|
224
|
-
value: ' ',
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
prop: '--tw-drop-shadow',
|
|
228
|
-
value: ' ',
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
prop: '--tw-backdrop-blur',
|
|
232
|
-
value: ' ',
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
prop: '--tw-backdrop-brightness',
|
|
236
|
-
value: ' ',
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
prop: '--tw-backdrop-contrast',
|
|
240
|
-
value: ' ',
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
prop: '--tw-backdrop-grayscale',
|
|
244
|
-
value: ' ',
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
prop: '--tw-backdrop-hue-rotate',
|
|
248
|
-
value: ' ',
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
prop: '--tw-backdrop-invert',
|
|
252
|
-
value: ' ',
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
prop: '--tw-backdrop-opacity',
|
|
256
|
-
value: ' ',
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
prop: '--tw-backdrop-saturate',
|
|
260
|
-
value: ' ',
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
prop: '--tw-backdrop-sepia',
|
|
264
|
-
value: ' ',
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
prop: '--tw-contain-size',
|
|
268
|
-
value: ' ',
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
prop: '--tw-contain-layout',
|
|
272
|
-
value: ' ',
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
prop: '--tw-contain-paint',
|
|
276
|
-
value: ' ',
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
prop: '--tw-contain-style',
|
|
280
|
-
value: ' ',
|
|
281
|
-
},
|
|
282
|
-
];
|
|
283
|
-
|
|
284
|
-
const initialNodes = cssVars.map((x) => {
|
|
285
|
-
return new Declaration({
|
|
286
|
-
prop: x.prop,
|
|
287
|
-
value: x.value,
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
const PATTERNS = [
|
|
291
|
-
/:not\(template\)\s*[~+]\s*:not\(template\)/.source,
|
|
292
|
-
/:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source,
|
|
293
|
-
].join('|');
|
|
294
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
295
|
-
function testIfVariablesScope(node, count = 2) {
|
|
296
|
-
if (isOnlyBeforeAndAfterPseudoElement(node)) {
|
|
297
|
-
const nodes = node.nodes;
|
|
298
|
-
let c = 0;
|
|
299
|
-
for (const tryTestDecl of nodes) {
|
|
300
|
-
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
301
|
-
c++;
|
|
302
|
-
}
|
|
303
|
-
if (c >= count) {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
311
|
-
function testIfTwBackdrop(node, count = 2) {
|
|
312
|
-
if (node.type === 'rule' && node.selector === '::backdrop') {
|
|
313
|
-
const nodes = node.nodes;
|
|
314
|
-
let c = 0;
|
|
315
|
-
for (const tryTestDecl of nodes) {
|
|
316
|
-
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
317
|
-
c++;
|
|
318
|
-
}
|
|
319
|
-
if (c >= count) {
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
function makePseudoVarRule() {
|
|
328
|
-
const pseudoVarRule = new Rule({
|
|
329
|
-
selector: '::before,::after',
|
|
330
|
-
});
|
|
331
|
-
pseudoVarRule.append(new Declaration({
|
|
332
|
-
prop: '--tw-content',
|
|
333
|
-
value: '""',
|
|
334
|
-
}));
|
|
335
|
-
return pseudoVarRule;
|
|
336
|
-
}
|
|
337
|
-
function remakeCssVarSelector(selectors, options) {
|
|
338
|
-
const { cssPreflightRange, cssSelectorReplacement } = options;
|
|
339
|
-
if (cssPreflightRange === 'all'
|
|
340
|
-
&& !selectors.includes(':not(not)')) {
|
|
341
|
-
selectors.push(':not(not)');
|
|
342
|
-
}
|
|
343
|
-
if (cssSelectorReplacement) {
|
|
344
|
-
if (Array.isArray(cssSelectorReplacement.universal)) {
|
|
345
|
-
if (!cssSelectorReplacement.universal.every((x) => {
|
|
346
|
-
return selectors.includes(x);
|
|
347
|
-
})
|
|
348
|
-
&& !selectors.includes('*')) {
|
|
349
|
-
selectors.unshift('*');
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
else if (typeof cssSelectorReplacement.universal === 'string'
|
|
353
|
-
&& !selectors.includes(cssSelectorReplacement.universal)
|
|
354
|
-
&& !selectors.includes('*')) {
|
|
355
|
-
selectors.unshift('*');
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return selectors;
|
|
359
|
-
}
|
|
360
|
-
function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
|
|
361
|
-
let childCombinatorReplaceValue = 'view + view';
|
|
362
|
-
if (Array.isArray(cssChildCombinatorReplaceValue) && cssChildCombinatorReplaceValue.length > 0) {
|
|
363
|
-
const x = composeIsPseudo(cssChildCombinatorReplaceValue);
|
|
364
|
-
childCombinatorReplaceValue = `${x} + ${x}`;
|
|
365
|
-
}
|
|
366
|
-
else if (typeof cssChildCombinatorReplaceValue === 'string') {
|
|
367
|
-
childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
|
|
368
|
-
}
|
|
369
|
-
return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
370
|
-
}
|
|
371
|
-
function commonChunkPreflight(node, options) {
|
|
372
|
-
const { ctx, cssChildCombinatorReplaceValue, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
373
|
-
node.selector = remakeCombinatorSelector(node.selector, cssChildCombinatorReplaceValue);
|
|
374
|
-
if (testIfVariablesScope(node)) {
|
|
375
|
-
ctx === null || ctx === void 0 ? void 0 : ctx.markVariablesScope(node);
|
|
376
|
-
node.selectors = remakeCssVarSelector(node.selectors, options);
|
|
377
|
-
node.before(makePseudoVarRule());
|
|
378
|
-
if (typeof cssInjectPreflight === 'function') {
|
|
379
|
-
node.append(...cssInjectPreflight());
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
|
|
383
|
-
const syntheticRule = new Rule({
|
|
384
|
-
selectors: ['*', '::after', '::before'],
|
|
385
|
-
nodes: initialNodes,
|
|
386
|
-
});
|
|
387
|
-
syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
|
|
388
|
-
node.before(syntheticRule);
|
|
389
|
-
node.before(makePseudoVarRule());
|
|
390
|
-
if (typeof cssInjectPreflight === 'function') {
|
|
391
|
-
syntheticRule.append(...cssInjectPreflight());
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
397
|
-
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
398
|
-
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
399
|
-
const WEAPP_TW_REQUIRED_NODE_VERSION = '16.6.0';
|
|
400
|
-
|
|
401
|
-
function isAtMediaHover(atRule) {
|
|
402
|
-
return (/media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name)
|
|
403
|
-
|| (atRule.name === 'media' && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params)));
|
|
404
|
-
}
|
|
405
|
-
const postcssWeappTailwindcssPrePlugin = (options = {
|
|
406
|
-
isMainChunk: true,
|
|
407
|
-
}) => {
|
|
408
|
-
const { isMainChunk } = options;
|
|
409
|
-
const p = {
|
|
410
|
-
postcssPlugin,
|
|
411
|
-
Rule(rule) {
|
|
412
|
-
ruleTransformSync(rule, options);
|
|
413
|
-
},
|
|
414
|
-
AtRule(atRule) {
|
|
415
|
-
if (isAtMediaHover(atRule)) {
|
|
416
|
-
if (atRule.nodes) {
|
|
417
|
-
atRule.replaceWith(atRule.nodes);
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
atRule.remove();
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
};
|
|
425
|
-
if (isMainChunk) {
|
|
426
|
-
p.Once = (root) => {
|
|
427
|
-
root.walkRules((rule) => {
|
|
428
|
-
commonChunkPreflight(rule, options);
|
|
429
|
-
});
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
return p;
|
|
433
|
-
};
|
|
434
|
-
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
435
|
-
|
|
436
|
-
const postcssWeappTailwindcssPostPlugin = (options = {
|
|
437
|
-
isMainChunk: true,
|
|
438
|
-
}) => {
|
|
439
|
-
const { customRuleCallback, isMainChunk, ctx } = options;
|
|
440
|
-
const p = {
|
|
441
|
-
postcssPlugin,
|
|
442
|
-
};
|
|
443
|
-
if (isMainChunk) {
|
|
444
|
-
p.OnceExit = (root) => {
|
|
445
|
-
root.walkRules((rule) => {
|
|
446
|
-
if (ctx) {
|
|
447
|
-
if (ctx.isVariablesScope(rule)) {
|
|
448
|
-
fallbackRemove.transformSync(rule, {
|
|
449
|
-
updateSelector: true,
|
|
450
|
-
lossless: false,
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
else if (testIfVariablesScope(rule)) {
|
|
455
|
-
fallbackRemove.transformSync(rule, {
|
|
456
|
-
updateSelector: true,
|
|
457
|
-
lossless: false,
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
if (typeof customRuleCallback === 'function') {
|
|
464
|
-
p.Rule = (rule) => {
|
|
465
|
-
customRuleCallback(rule, options);
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
return p;
|
|
469
|
-
};
|
|
470
|
-
postcssWeappTailwindcssPostPlugin.postcss = true;
|
|
471
|
-
|
|
472
|
-
const VariablesScopeSymbol = Symbol('VariablesScope');
|
|
473
|
-
|
|
474
|
-
function createContext() {
|
|
475
|
-
const variablesScopeWeakMap = new WeakMap();
|
|
476
|
-
function isVariablesScope(rule) {
|
|
477
|
-
return variablesScopeWeakMap.get(rule) === VariablesScopeSymbol;
|
|
478
|
-
}
|
|
479
|
-
function markVariablesScope(rule) {
|
|
480
|
-
variablesScopeWeakMap.set(rule, VariablesScopeSymbol);
|
|
481
|
-
}
|
|
482
|
-
return {
|
|
483
|
-
variablesScopeWeakMap,
|
|
484
|
-
isVariablesScope,
|
|
485
|
-
markVariablesScope,
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function getPlugins(options) {
|
|
490
|
-
var _a, _b;
|
|
491
|
-
const ctx = createContext();
|
|
492
|
-
options.ctx = ctx;
|
|
493
|
-
const plugins = [
|
|
494
|
-
...((_b = (_a = options.postcssOptions) === null || _a === void 0 ? void 0 : _a.plugins) !== null && _b !== void 0 ? _b : []),
|
|
495
|
-
postcssWeappTailwindcssPrePlugin(options),
|
|
496
|
-
postcssIsPseudoClass({
|
|
497
|
-
specificityMatchingName: 'weapp-tw-ig',
|
|
498
|
-
}),
|
|
499
|
-
];
|
|
500
|
-
if (options.rem2rpx) {
|
|
501
|
-
plugins.push(postcssRem2rpx(typeof options.rem2rpx === 'object'
|
|
502
|
-
? options.rem2rpx
|
|
503
|
-
: {
|
|
504
|
-
rootValue: 32,
|
|
505
|
-
propList: ['*'],
|
|
506
|
-
transformUnit: 'rpx',
|
|
507
|
-
}));
|
|
508
|
-
}
|
|
509
|
-
plugins.push(postcssWeappTailwindcssPostPlugin(options));
|
|
510
|
-
return plugins;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export { WEAPP_TW_REQUIRED_NODE_VERSION as W, postcssWeappTailwindcssPrePlugin as a, pluginName as b, getPlugins as g, postcssWeappTailwindcssPostPlugin as p, vitePluginName as v };
|