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
package/README.md
CHANGED
|
@@ -11,14 +11,8 @@
|
|
|
11
11
|
<h1 align="center">weapp-tailwindcss</h1>
|
|
12
12
|
|
|
13
13
|
</p>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<img src="./assets/logo-text-light.png#gh-light-mode-only" alt="weapp-tailwindcss-logo" width="300">
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://weapp-tw.icebreaker.top#gh-dark-mode-only">
|
|
19
|
-
<img src="./assets/logo-text-dark.png#gh-dark-mode-only" alt="weapp-tailwindcss-logo" width="300">
|
|
20
|
-
</a>
|
|
21
|
-
<br> -->
|
|
14
|
+
|
|
15
|
+
> 简体中文(zh-cn) | [English](./README_en.md)
|
|
22
16
|
|
|
23
17
|

|
|
24
18
|

|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var options = require('./options-
|
|
3
|
+
var options = require('./options-487394fa.js');
|
|
4
4
|
require('micromatch');
|
|
5
5
|
require('@babel/types');
|
|
6
6
|
require('@babel/generator');
|
|
@@ -9,7 +9,7 @@ require('@babel/traverse');
|
|
|
9
9
|
require('./replace.js');
|
|
10
10
|
require('./shared-ae7dd073.js');
|
|
11
11
|
require('postcss');
|
|
12
|
-
require('./postcss-
|
|
12
|
+
require('./postcss-b53e9504.js');
|
|
13
13
|
require('postcss-selector-parser');
|
|
14
14
|
require('@csstools/postcss-is-pseudo-class');
|
|
15
15
|
require('node:path');
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getOptions, c as createPatch } from './options-
|
|
1
|
+
import { g as getOptions, c as createPatch } from './options-f7b71f03.mjs';
|
|
2
2
|
import 'micromatch';
|
|
3
3
|
import '@babel/types';
|
|
4
4
|
import '@babel/generator';
|
|
@@ -7,7 +7,7 @@ import '@babel/traverse';
|
|
|
7
7
|
import './replace.mjs';
|
|
8
8
|
import './shared-7c88fb94.mjs';
|
|
9
9
|
import 'postcss';
|
|
10
|
-
import './postcss-
|
|
10
|
+
import './postcss-760298ba.mjs';
|
|
11
11
|
import 'postcss-selector-parser';
|
|
12
12
|
import '@csstools/postcss-is-pseudo-class';
|
|
13
13
|
import 'node:path';
|
package/dist/gulp.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var stream = require('node:stream');
|
|
6
|
-
var options = require('./options-
|
|
6
|
+
var options = require('./options-487394fa.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('@babel/types');
|
|
9
9
|
require('@babel/generator');
|
|
@@ -12,7 +12,7 @@ require('@babel/traverse');
|
|
|
12
12
|
require('./replace.js');
|
|
13
13
|
require('./shared-ae7dd073.js');
|
|
14
14
|
require('postcss');
|
|
15
|
-
require('./postcss-
|
|
15
|
+
require('./postcss-b53e9504.js');
|
|
16
16
|
require('postcss-selector-parser');
|
|
17
17
|
require('@csstools/postcss-is-pseudo-class');
|
|
18
18
|
require('node:path');
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import stream from 'node:stream';
|
|
2
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
2
|
+
import { g as getOptions, a as createTailwindcssPatcher } from './options-f7b71f03.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import '@babel/types';
|
|
5
5
|
import '@babel/generator';
|
|
@@ -8,7 +8,7 @@ import '@babel/traverse';
|
|
|
8
8
|
import './replace.mjs';
|
|
9
9
|
import './shared-7c88fb94.mjs';
|
|
10
10
|
import 'postcss';
|
|
11
|
-
import './postcss-
|
|
11
|
+
import './postcss-760298ba.mjs';
|
|
12
12
|
import 'postcss-selector-parser';
|
|
13
13
|
import '@csstools/postcss-is-pseudo-class';
|
|
14
14
|
import 'node:path';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var vite = require('./vite.js');
|
|
|
7
7
|
var gulp = require('./gulp.js');
|
|
8
8
|
require('node:path');
|
|
9
9
|
require('node:fs');
|
|
10
|
-
require('./options-
|
|
10
|
+
require('./options-487394fa.js');
|
|
11
11
|
require('micromatch');
|
|
12
12
|
require('@babel/types');
|
|
13
13
|
require('@babel/generator');
|
|
@@ -16,7 +16,7 @@ require('@babel/traverse');
|
|
|
16
16
|
require('./replace.js');
|
|
17
17
|
require('./shared-ae7dd073.js');
|
|
18
18
|
require('postcss');
|
|
19
|
-
require('./postcss-
|
|
19
|
+
require('./postcss-b53e9504.js');
|
|
20
20
|
require('postcss-selector-parser');
|
|
21
21
|
require('@csstools/postcss-is-pseudo-class');
|
|
22
22
|
require('semver');
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
4
|
import 'node:path';
|
|
5
5
|
import 'node:fs';
|
|
6
|
-
import './options-
|
|
6
|
+
import './options-f7b71f03.mjs';
|
|
7
7
|
import 'micromatch';
|
|
8
8
|
import '@babel/types';
|
|
9
9
|
import '@babel/generator';
|
|
@@ -12,7 +12,7 @@ import '@babel/traverse';
|
|
|
12
12
|
import './replace.mjs';
|
|
13
13
|
import './shared-7c88fb94.mjs';
|
|
14
14
|
import 'postcss';
|
|
15
|
-
import './postcss-
|
|
15
|
+
import './postcss-760298ba.mjs';
|
|
16
16
|
import 'postcss-selector-parser';
|
|
17
17
|
import '@csstools/postcss-is-pseudo-class';
|
|
18
18
|
import 'semver';
|
|
@@ -8,7 +8,7 @@ var traverse = require('@babel/traverse');
|
|
|
8
8
|
var replace = require('./replace.js');
|
|
9
9
|
var shared = require('./shared-ae7dd073.js');
|
|
10
10
|
var postcss = require('postcss');
|
|
11
|
-
var postcss$1 = require('./postcss-
|
|
11
|
+
var postcss$1 = require('./postcss-b53e9504.js');
|
|
12
12
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
13
13
|
var path = require('node:path');
|
|
14
14
|
var fs = require('node:fs');
|
|
@@ -372,7 +372,8 @@ const defaultOptions = {
|
|
|
372
372
|
allowDoubleQuotes: false
|
|
373
373
|
},
|
|
374
374
|
cssChildCombinatorReplaceValue: 'view + view',
|
|
375
|
-
inlineWxs: false
|
|
375
|
+
inlineWxs: false,
|
|
376
|
+
injectAdditionalCssVarScope: false
|
|
376
377
|
};
|
|
377
378
|
|
|
378
379
|
function generateCode(match, options = {}) {
|
|
@@ -732,7 +733,7 @@ function getOptions(options = {}) {
|
|
|
732
733
|
const result = defu(options, defaultOptions, {
|
|
733
734
|
minifiedJs: isProd()
|
|
734
735
|
});
|
|
735
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs } = result;
|
|
736
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope } = result;
|
|
736
737
|
result.escapeMap = customReplaceDictionary;
|
|
737
738
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
738
739
|
const customAttributesEntities = isMap(options.customAttributes)
|
|
@@ -748,7 +749,8 @@ function getOptions(options = {}) {
|
|
|
748
749
|
replaceUniversalSelectorWith,
|
|
749
750
|
escapeMap,
|
|
750
751
|
mangleContext,
|
|
751
|
-
cssChildCombinatorReplaceValue
|
|
752
|
+
cssChildCombinatorReplaceValue,
|
|
753
|
+
injectAdditionalCssVarScope
|
|
752
754
|
});
|
|
753
755
|
result.styleHandler = styleHandler;
|
|
754
756
|
const jsHandler = createjsHandler({
|
|
@@ -6,7 +6,7 @@ import traverse from '@babel/traverse';
|
|
|
6
6
|
import { replaceJs as replaceWxml } from './replace.mjs';
|
|
7
7
|
import { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-7c88fb94.mjs';
|
|
8
8
|
import postcss from 'postcss';
|
|
9
|
-
import { p as postcssWeappTailwindcss } from './postcss-
|
|
9
|
+
import { p as postcssWeappTailwindcss } from './postcss-760298ba.mjs';
|
|
10
10
|
import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import fs from 'node:fs';
|
|
@@ -342,7 +342,8 @@ const defaultOptions = {
|
|
|
342
342
|
allowDoubleQuotes: false
|
|
343
343
|
},
|
|
344
344
|
cssChildCombinatorReplaceValue: 'view + view',
|
|
345
|
-
inlineWxs: false
|
|
345
|
+
inlineWxs: false,
|
|
346
|
+
injectAdditionalCssVarScope: false
|
|
346
347
|
};
|
|
347
348
|
|
|
348
349
|
function generateCode(match, options = {}) {
|
|
@@ -702,7 +703,7 @@ function getOptions(options = {}) {
|
|
|
702
703
|
const result = defu(options, defaultOptions, {
|
|
703
704
|
minifiedJs: isProd()
|
|
704
705
|
});
|
|
705
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs } = result;
|
|
706
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope } = result;
|
|
706
707
|
result.escapeMap = customReplaceDictionary;
|
|
707
708
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
708
709
|
const customAttributesEntities = isMap(options.customAttributes)
|
|
@@ -718,7 +719,8 @@ function getOptions(options = {}) {
|
|
|
718
719
|
replaceUniversalSelectorWith,
|
|
719
720
|
escapeMap,
|
|
720
721
|
mangleContext,
|
|
721
|
-
cssChildCombinatorReplaceValue
|
|
722
|
+
cssChildCombinatorReplaceValue,
|
|
723
|
+
injectAdditionalCssVarScope
|
|
722
724
|
});
|
|
723
725
|
result.styleHandler = styleHandler;
|
|
724
726
|
const jsHandler = createjsHandler({
|
package/dist/postcss/mp.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Rule } from 'postcss';
|
|
2
2
|
import type { IStyleHandlerOptions } from "../types";
|
|
3
3
|
export declare function testIfVariablesScope(node: Rule, count?: number): boolean;
|
|
4
|
+
export declare function testIfTwBackdrop(node: Rule, count?: number): boolean;
|
|
5
|
+
export declare function makePseudoVarRule(): Rule;
|
|
6
|
+
export declare function remakeCssVarSelector(selectors: string[], cssPreflightRange: IStyleHandlerOptions['cssPreflightRange']): string[];
|
|
7
|
+
export declare function remakeCombinatorSelector(selector: string, cssChildCombinatorReplaceValue: IStyleHandlerOptions['cssChildCombinatorReplaceValue']): string;
|
|
4
8
|
export declare function commonChunkPreflight(node: Rule, options: IStyleHandlerOptions): void;
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import selectorParser from 'postcss-selector-parser';
|
|
2
|
+
import { i as internalCssSelectorReplacer } from './shared-7c88fb94.mjs';
|
|
3
|
+
import { Declaration, Rule } 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
|
+
var cssVars = [
|
|
43
|
+
{
|
|
44
|
+
prop: '--tw-border-spacing-x',
|
|
45
|
+
value: '0'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
prop: '--tw-border-spacing-y',
|
|
49
|
+
value: '0'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
prop: '--tw-translate-x',
|
|
53
|
+
value: '0'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
prop: '--tw-translate-y',
|
|
57
|
+
value: '0'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
prop: '--tw-rotate',
|
|
61
|
+
value: '0'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
prop: '--tw-skew-x',
|
|
65
|
+
value: '0'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
prop: '--tw-skew-y',
|
|
69
|
+
value: '0'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
prop: '--tw-scale-x',
|
|
73
|
+
value: '1'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
prop: '--tw-scale-y',
|
|
77
|
+
value: '1'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
prop: '--tw-pan-x',
|
|
81
|
+
value: ' '
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
prop: '--tw-pan-y',
|
|
85
|
+
value: ' '
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
prop: '--tw-pinch-zoom',
|
|
89
|
+
value: ' '
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
prop: '--tw-scroll-snap-strictness',
|
|
93
|
+
value: 'proximity'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
prop: '--tw-gradient-from-position',
|
|
97
|
+
value: ' '
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
prop: '--tw-gradient-via-position',
|
|
101
|
+
value: ' '
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
prop: '--tw-gradient-to-position',
|
|
105
|
+
value: ' '
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
prop: '--tw-ordinal',
|
|
109
|
+
value: ' '
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
prop: '--tw-slashed-zero',
|
|
113
|
+
value: ' '
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
prop: '--tw-numeric-figure',
|
|
117
|
+
value: ' '
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
prop: '--tw-numeric-spacing',
|
|
121
|
+
value: ' '
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
prop: '--tw-numeric-fraction',
|
|
125
|
+
value: ' '
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
prop: '--tw-ring-inset',
|
|
129
|
+
value: ' '
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
prop: '--tw-ring-offset-width',
|
|
133
|
+
value: '0rpx'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
prop: '--tw-ring-offset-color',
|
|
137
|
+
value: '#fff'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
prop: '--tw-ring-color',
|
|
141
|
+
value: 'rgba(59, 130, 246, 0.5)'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
prop: '--tw-ring-offset-shadow',
|
|
145
|
+
value: '0 0 #0000'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
prop: '--tw-ring-shadow',
|
|
149
|
+
value: '0 0 #0000'
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
prop: '--tw-shadow',
|
|
153
|
+
value: '0 0 #0000'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
prop: '--tw-shadow-colored',
|
|
157
|
+
value: '0 0 #0000'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
prop: '--tw-blur',
|
|
161
|
+
value: ' '
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
prop: '--tw-brightness',
|
|
165
|
+
value: ' '
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
prop: '--tw-contrast',
|
|
169
|
+
value: ' '
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
prop: '--tw-grayscale',
|
|
173
|
+
value: ' '
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
prop: '--tw-hue-rotate',
|
|
177
|
+
value: ' '
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
prop: '--tw-invert',
|
|
181
|
+
value: ' '
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
prop: '--tw-saturate',
|
|
185
|
+
value: ' '
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
prop: '--tw-sepia',
|
|
189
|
+
value: ' '
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
prop: '--tw-drop-shadow',
|
|
193
|
+
value: ' '
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
prop: '--tw-backdrop-blur',
|
|
197
|
+
value: ' '
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
prop: '--tw-backdrop-brightness',
|
|
201
|
+
value: ' '
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
prop: '--tw-backdrop-contrast',
|
|
205
|
+
value: ' '
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
prop: '--tw-backdrop-grayscale',
|
|
209
|
+
value: ' '
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
prop: '--tw-backdrop-hue-rotate',
|
|
213
|
+
value: ' '
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
prop: '--tw-backdrop-invert',
|
|
217
|
+
value: ' '
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
prop: '--tw-backdrop-opacity',
|
|
221
|
+
value: ' '
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
prop: '--tw-backdrop-saturate',
|
|
225
|
+
value: ' '
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
prop: '--tw-backdrop-sepia',
|
|
229
|
+
value: ' '
|
|
230
|
+
}
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
const initialNodes = cssVars.map((x) => {
|
|
234
|
+
return new Declaration({
|
|
235
|
+
prop: x.prop,
|
|
236
|
+
value: x.value
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
const PATTERNS = [/:not\(template\)\s*~\s*:not\(template\)/.source, /:not\(\[hidden\]\)\s*~\s*:not\(\[hidden\]\)/.source].join('|');
|
|
240
|
+
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
241
|
+
function testIfVariablesScope(node, count = 1) {
|
|
242
|
+
if (/:?:before/.test(node.selector) && /:?:after/.test(node.selector)) {
|
|
243
|
+
for (let i = 0; i < count; i++) {
|
|
244
|
+
const tryTestDecl = node.nodes[i];
|
|
245
|
+
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
function testIfTwBackdrop(node, count = 1) {
|
|
257
|
+
if (node.type === 'rule' && node.selector === '::backdrop') {
|
|
258
|
+
for (let i = 0; i < count; i++) {
|
|
259
|
+
const tryTestDecl = node.nodes[i];
|
|
260
|
+
if (tryTestDecl && tryTestDecl.type === 'decl' && tryTestDecl.prop.startsWith('--tw-')) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
function makePseudoVarRule() {
|
|
272
|
+
const pseudoVarRule = new Rule({
|
|
273
|
+
selector: '::before,::after'
|
|
274
|
+
});
|
|
275
|
+
pseudoVarRule.append(new Declaration({
|
|
276
|
+
prop: '--tw-content',
|
|
277
|
+
value: '""'
|
|
278
|
+
}));
|
|
279
|
+
return pseudoVarRule;
|
|
280
|
+
}
|
|
281
|
+
function remakeCssVarSelector(selectors, cssPreflightRange) {
|
|
282
|
+
const idx = selectors.indexOf('*');
|
|
283
|
+
if (idx > -1) {
|
|
284
|
+
selectors.splice(idx, 1);
|
|
285
|
+
}
|
|
286
|
+
if (!selectors.includes('view')) {
|
|
287
|
+
selectors.push('view');
|
|
288
|
+
}
|
|
289
|
+
if (cssPreflightRange === 'all' &&
|
|
290
|
+
!selectors.includes(':not(not)')) {
|
|
291
|
+
selectors.push(':not(not)');
|
|
292
|
+
}
|
|
293
|
+
return selectors;
|
|
294
|
+
}
|
|
295
|
+
function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
|
|
296
|
+
let childCombinatorReplaceValue = 'view + view';
|
|
297
|
+
if (Array.isArray(cssChildCombinatorReplaceValue)) {
|
|
298
|
+
const part = cssChildCombinatorReplaceValue.join(',');
|
|
299
|
+
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
300
|
+
}
|
|
301
|
+
else if (typeof cssChildCombinatorReplaceValue === 'string') {
|
|
302
|
+
childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
|
|
303
|
+
}
|
|
304
|
+
return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
305
|
+
}
|
|
306
|
+
function commonChunkPreflight(node, options) {
|
|
307
|
+
node.selector = remakeCombinatorSelector(node.selector, options.cssChildCombinatorReplaceValue);
|
|
308
|
+
if (testIfVariablesScope(node)) {
|
|
309
|
+
node.selectors = remakeCssVarSelector(node.selectors, options.cssPreflightRange);
|
|
310
|
+
node.before(makePseudoVarRule());
|
|
311
|
+
if (typeof options.cssInjectPreflight === 'function') {
|
|
312
|
+
node.append(...options.cssInjectPreflight());
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (options.injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
|
|
316
|
+
const syntheticRule = new Rule({
|
|
317
|
+
selectors: ['::after', '::before'],
|
|
318
|
+
nodes: initialNodes
|
|
319
|
+
});
|
|
320
|
+
syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options.cssPreflightRange);
|
|
321
|
+
node.before(syntheticRule);
|
|
322
|
+
node.before(makePseudoVarRule());
|
|
323
|
+
if (typeof options.cssInjectPreflight === 'function') {
|
|
324
|
+
syntheticRule.append(...options.cssInjectPreflight());
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
330
|
+
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
331
|
+
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
332
|
+
|
|
333
|
+
const postcssWeappTailwindcss = (options = {
|
|
334
|
+
isMainChunk: true
|
|
335
|
+
}) => {
|
|
336
|
+
const { customRuleCallback, isMainChunk } = options;
|
|
337
|
+
const flag = typeof customRuleCallback === 'function';
|
|
338
|
+
return {
|
|
339
|
+
postcssPlugin,
|
|
340
|
+
Once(css) {
|
|
341
|
+
css.walkRules((rule) => {
|
|
342
|
+
transformSync(rule, options);
|
|
343
|
+
isMainChunk && commonChunkPreflight(rule, options);
|
|
344
|
+
flag && customRuleCallback(rule, options);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
postcssWeappTailwindcss.postcss = true;
|
|
350
|
+
|
|
351
|
+
export { pluginName as a, postcssWeappTailwindcss as p, vitePluginName as v };
|