tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.956419c
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/CHANGELOG.md +384 -3
- package/LICENSE +1 -2
- package/README.md +12 -8
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +239 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +13 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +4 -740
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +2064 -1811
- package/lib/css/preflight.css +5 -5
- package/lib/featureFlags.js +31 -22
- package/lib/index.js +4 -28
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +225 -31
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +118 -55
- package/lib/lib/expandApplyAtRules.js +439 -190
- package/lib/lib/expandTailwindAtRules.js +151 -134
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +454 -187
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +36 -32
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -67
- package/lib/lib/setupContextUtils.js +667 -376
- package/lib/lib/setupTrackingContext.js +38 -67
- package/lib/lib/sharedState.js +27 -14
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/oxide/cli.d.js +1 -0
- package/lib/oxide/cli.js +2 -0
- package/lib/oxide/postcss-plugin.d.js +1 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +48 -0
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +35 -25
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +11 -6
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -110
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +184 -85
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
- package/lib/util/log.js +20 -14
- package/lib/util/nameClass.js +20 -9
- package/lib/util/negateValue.js +23 -8
- package/lib/util/normalizeConfig.js +116 -72
- package/lib/util/normalizeScreens.js +120 -11
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +147 -50
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -85
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +50 -45
- package/peers/index.js +11381 -7950
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +439 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +234 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +4 -810
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +532 -217
- package/src/css/preflight.css +5 -5
- package/src/featureFlags.js +15 -9
- package/src/index.js +4 -27
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/content.js +212 -0
- package/src/lib/defaultExtractor.js +196 -33
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +482 -183
- package/src/lib/expandTailwindAtRules.js +106 -85
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +418 -129
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +51 -30
- package/src/lib/setupContextUtils.js +556 -208
- package/src/lib/setupTrackingContext.js +11 -48
- package/src/lib/sharedState.js +5 -0
- package/src/oxide/cli.d.ts +0 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.d.ts +0 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +47 -0
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +8 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +29 -21
- package/src/util/formatVariantSelector.js +184 -61
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +8 -8
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +44 -6
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -32
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +167 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +362 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/nesting/plugin.js +0 -41
package/lib/lib/generateRules.js
CHANGED
|
@@ -2,26 +2,78 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getClassNameFromSelector: ()=>getClassNameFromSelector,
|
|
13
|
+
resolveMatches: ()=>resolveMatches,
|
|
14
|
+
generateRules: ()=>generateRules
|
|
15
|
+
});
|
|
16
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
17
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
18
|
+
const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
|
|
19
|
+
const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isPlainObject"));
|
|
20
|
+
const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
|
|
21
|
+
const _pluginUtils = require("../util/pluginUtils");
|
|
22
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
23
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
24
|
+
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
25
|
+
const _nameClass = require("../util/nameClass");
|
|
26
|
+
const _dataTypes = require("../util/dataTypes");
|
|
27
|
+
const _setupContextUtils = require("./setupContextUtils");
|
|
28
|
+
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
|
|
29
|
+
const _splitAtTopLevelOnlyJs = require("../util/splitAtTopLevelOnly.js");
|
|
30
|
+
const _featureFlags = require("../featureFlags");
|
|
17
31
|
function _interopRequireDefault(obj) {
|
|
18
32
|
return obj && obj.__esModule ? obj : {
|
|
19
33
|
default: obj
|
|
20
34
|
};
|
|
21
35
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
37
|
+
if (typeof WeakMap !== "function") return null;
|
|
38
|
+
var cacheBabelInterop = new WeakMap();
|
|
39
|
+
var cacheNodeInterop = new WeakMap();
|
|
40
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
41
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
42
|
+
})(nodeInterop);
|
|
43
|
+
}
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
45
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
49
|
+
return {
|
|
50
|
+
default: obj
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
54
|
+
if (cache && cache.has(obj)) {
|
|
55
|
+
return cache.get(obj);
|
|
56
|
+
}
|
|
57
|
+
var newObj = {};
|
|
58
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
59
|
+
for(var key in obj){
|
|
60
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
61
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
62
|
+
if (desc && (desc.get || desc.set)) {
|
|
63
|
+
Object.defineProperty(newObj, key, desc);
|
|
64
|
+
} else {
|
|
65
|
+
newObj[key] = obj[key];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
newObj.default = obj;
|
|
70
|
+
if (cache) {
|
|
71
|
+
cache.set(obj, newObj);
|
|
72
|
+
}
|
|
73
|
+
return newObj;
|
|
74
|
+
}
|
|
75
|
+
let classNameParser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
76
|
+
return selectors.first.filter(({ type })=>type === "class").pop().value;
|
|
25
77
|
});
|
|
26
78
|
function getClassNameFromSelector(selector) {
|
|
27
79
|
return classNameParser.transformSync(selector);
|
|
@@ -33,35 +85,47 @@ function getClassNameFromSelector(selector) {
|
|
|
33
85
|
// Example with dynamic classes:
|
|
34
86
|
// ['grid-cols', '[[linename],1fr,auto]']
|
|
35
87
|
// ['grid', 'cols-[[linename],1fr,auto]']
|
|
36
|
-
function* candidatePermutations(candidate
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
function* candidatePermutations(candidate) {
|
|
89
|
+
let lastIndex = Infinity;
|
|
90
|
+
while(lastIndex >= 0){
|
|
91
|
+
let dashIdx;
|
|
92
|
+
let wasSlash = false;
|
|
93
|
+
if (lastIndex === Infinity && candidate.endsWith("]")) {
|
|
94
|
+
let bracketIdx = candidate.indexOf("[");
|
|
95
|
+
// If character before `[` isn't a dash or a slash, this isn't a dynamic class
|
|
96
|
+
// eg. string[]
|
|
97
|
+
if (candidate[bracketIdx - 1] === "-") {
|
|
98
|
+
dashIdx = bracketIdx - 1;
|
|
99
|
+
} else if (candidate[bracketIdx - 1] === "/") {
|
|
100
|
+
dashIdx = bracketIdx - 1;
|
|
101
|
+
wasSlash = true;
|
|
102
|
+
} else {
|
|
103
|
+
dashIdx = -1;
|
|
104
|
+
}
|
|
105
|
+
} else if (lastIndex === Infinity && candidate.includes("/")) {
|
|
106
|
+
dashIdx = candidate.lastIndexOf("/");
|
|
107
|
+
wasSlash = true;
|
|
108
|
+
} else {
|
|
109
|
+
dashIdx = candidate.lastIndexOf("-", lastIndex);
|
|
110
|
+
}
|
|
111
|
+
if (dashIdx < 0) {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
let prefix = candidate.slice(0, dashIdx);
|
|
115
|
+
let modifier = candidate.slice(wasSlash ? dashIdx : dashIdx + 1);
|
|
116
|
+
lastIndex = dashIdx - 1;
|
|
117
|
+
// TODO: This feels a bit hacky
|
|
118
|
+
if (prefix === "" || modifier === "/") {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
yield [
|
|
122
|
+
prefix,
|
|
123
|
+
modifier
|
|
124
|
+
];
|
|
125
|
+
}
|
|
62
126
|
}
|
|
63
127
|
function applyPrefix(matches, context) {
|
|
64
|
-
if (matches.length === 0 || context.tailwindConfig.prefix ===
|
|
128
|
+
if (matches.length === 0 || context.tailwindConfig.prefix === "") {
|
|
65
129
|
return matches;
|
|
66
130
|
}
|
|
67
131
|
for (let match of matches){
|
|
@@ -72,15 +136,21 @@ function applyPrefix(matches, context) {
|
|
|
72
136
|
match[1].clone()
|
|
73
137
|
]
|
|
74
138
|
});
|
|
139
|
+
let classCandidate = match[1].raws.tailwind.classCandidate;
|
|
75
140
|
container.walkRules((r)=>{
|
|
76
|
-
|
|
141
|
+
// If this is a negative utility with a dash *before* the prefix we
|
|
142
|
+
// have to ensure that the generated selector matches the candidate
|
|
143
|
+
// Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
|
|
144
|
+
// The disconnect between candidate <-> class can cause @apply to hard crash.
|
|
145
|
+
let shouldPrependNegative = classCandidate.startsWith("-");
|
|
146
|
+
r.selector = (0, _prefixSelector.default)(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
|
|
77
147
|
});
|
|
78
148
|
match[1] = container.nodes[0];
|
|
79
149
|
}
|
|
80
150
|
}
|
|
81
151
|
return matches;
|
|
82
152
|
}
|
|
83
|
-
function applyImportant(matches) {
|
|
153
|
+
function applyImportant(matches, classCandidate) {
|
|
84
154
|
if (matches.length === 0) {
|
|
85
155
|
return matches;
|
|
86
156
|
}
|
|
@@ -92,11 +162,13 @@ function applyImportant(matches) {
|
|
|
92
162
|
]
|
|
93
163
|
});
|
|
94
164
|
container.walkRules((r)=>{
|
|
95
|
-
r.selector = (0, _pluginUtils
|
|
96
|
-
|
|
165
|
+
r.selector = (0, _pluginUtils.updateAllClasses)((0, _pluginUtils.filterSelectorsForClass)(r.selector, classCandidate), (className)=>{
|
|
166
|
+
if (className === classCandidate) {
|
|
167
|
+
return `!${className}`;
|
|
168
|
+
}
|
|
169
|
+
return className;
|
|
97
170
|
});
|
|
98
|
-
r.walkDecls((d)=>d.important = true
|
|
99
|
-
);
|
|
171
|
+
r.walkDecls((d)=>d.important = true);
|
|
100
172
|
});
|
|
101
173
|
result.push([
|
|
102
174
|
{
|
|
@@ -120,32 +192,84 @@ function applyVariant(variant, matches, context) {
|
|
|
120
192
|
if (matches.length === 0) {
|
|
121
193
|
return matches;
|
|
122
194
|
}
|
|
195
|
+
/** @type {{modifier: string | null, value: string | null}} */ let args = {
|
|
196
|
+
modifier: null,
|
|
197
|
+
value: _sharedState.NONE
|
|
198
|
+
};
|
|
199
|
+
// Retrieve "modifier"
|
|
200
|
+
{
|
|
201
|
+
let match = /(.*)\/(.*)$/g.exec(variant);
|
|
202
|
+
if (match) {
|
|
203
|
+
variant = match[1];
|
|
204
|
+
args.modifier = match[2];
|
|
205
|
+
if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Retrieve "arbitrary value"
|
|
211
|
+
if (variant.endsWith("]") && !variant.startsWith("[")) {
|
|
212
|
+
// We either have:
|
|
213
|
+
// @[200px]
|
|
214
|
+
// group-[:hover]
|
|
215
|
+
//
|
|
216
|
+
// But we don't want:
|
|
217
|
+
// @-[200px] (`-` is incorrect)
|
|
218
|
+
// group[:hover] (`-` is missing)
|
|
219
|
+
let match1 = /(.)(-?)\[(.*)\]/g.exec(variant);
|
|
220
|
+
if (match1) {
|
|
221
|
+
let [, char, seperator, value] = match1;
|
|
222
|
+
// @-[200px] case
|
|
223
|
+
if (char === "@" && seperator === "-") return [];
|
|
224
|
+
// group[:hover] case
|
|
225
|
+
if (char !== "@" && seperator === "") return [];
|
|
226
|
+
variant = variant.replace(`${seperator}[${value}]`, "");
|
|
227
|
+
args.value = value;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Register arbitrary variants
|
|
231
|
+
if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
|
|
232
|
+
let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
|
|
233
|
+
if (!(0, _setupContextUtils.isValidVariantFormatString)(selector)) {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
let fn = (0, _setupContextUtils.parseVariant)(selector);
|
|
237
|
+
let sort = context.offsets.recordVariant(variant);
|
|
238
|
+
context.variantMap.set(variant, [
|
|
239
|
+
[
|
|
240
|
+
sort,
|
|
241
|
+
fn
|
|
242
|
+
]
|
|
243
|
+
]);
|
|
244
|
+
}
|
|
123
245
|
if (context.variantMap.has(variant)) {
|
|
124
|
-
let variantFunctionTuples = context.variantMap.get(variant);
|
|
246
|
+
let variantFunctionTuples = context.variantMap.get(variant).slice();
|
|
125
247
|
let result = [];
|
|
126
|
-
for (let [meta,
|
|
248
|
+
for (let [meta, rule] of matches){
|
|
127
249
|
// Don't generate variants for user css
|
|
128
|
-
if (meta.layer ===
|
|
250
|
+
if (meta.layer === "user") {
|
|
129
251
|
continue;
|
|
130
252
|
}
|
|
131
253
|
let container = _postcss.default.root({
|
|
132
254
|
nodes: [
|
|
133
|
-
|
|
255
|
+
rule.clone()
|
|
134
256
|
]
|
|
135
257
|
});
|
|
136
|
-
for (let [variantSort, variantFunction] of variantFunctionTuples){
|
|
137
|
-
let clone = container.clone();
|
|
258
|
+
for (let [variantSort, variantFunction, containerFromArray] of variantFunctionTuples){
|
|
259
|
+
let clone = (containerFromArray !== null && containerFromArray !== void 0 ? containerFromArray : container).clone();
|
|
138
260
|
let collectedFormats = [];
|
|
139
|
-
let originals = new Map();
|
|
140
261
|
function prepareBackup() {
|
|
141
|
-
|
|
142
|
-
clone.
|
|
143
|
-
|
|
262
|
+
// Already prepared, chicken out
|
|
263
|
+
if (clone.raws.neededBackup) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
clone.raws.neededBackup = true;
|
|
267
|
+
clone.walkRules((rule)=>rule.raws.originalSelector = rule.selector);
|
|
144
268
|
}
|
|
145
269
|
function modifySelectors(modifierFunction) {
|
|
146
270
|
prepareBackup();
|
|
147
271
|
clone.each((rule)=>{
|
|
148
|
-
if (rule.type !==
|
|
272
|
+
if (rule.type !== "rule") {
|
|
149
273
|
return;
|
|
150
274
|
}
|
|
151
275
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
@@ -176,28 +300,49 @@ function applyVariant(variant, matches, context) {
|
|
|
176
300
|
},
|
|
177
301
|
format (selectorFormat) {
|
|
178
302
|
collectedFormats.push(selectorFormat);
|
|
179
|
-
}
|
|
303
|
+
},
|
|
304
|
+
args
|
|
180
305
|
});
|
|
181
|
-
|
|
306
|
+
// It can happen that a list of format strings is returned from within the function. In that
|
|
307
|
+
// case, we have to process them as well. We can use the existing `variantSort`.
|
|
308
|
+
if (Array.isArray(ruleWithVariant)) {
|
|
309
|
+
for (let [idx, variantFunction1] of ruleWithVariant.entries()){
|
|
310
|
+
// This is a little bit scary since we are pushing to an array of items that we are
|
|
311
|
+
// currently looping over. However, you can also think of it like a processing queue
|
|
312
|
+
// where you keep handling jobs until everything is done and each job can queue more
|
|
313
|
+
// jobs if needed.
|
|
314
|
+
variantFunctionTuples.push([
|
|
315
|
+
context.offsets.applyParallelOffset(variantSort, idx),
|
|
316
|
+
variantFunction1,
|
|
317
|
+
// If the clone has been modified we have to pass that back
|
|
318
|
+
// though so each rule can use the modified container
|
|
319
|
+
clone.clone()
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (typeof ruleWithVariant === "string") {
|
|
182
325
|
collectedFormats.push(ruleWithVariant);
|
|
183
326
|
}
|
|
184
327
|
if (ruleWithVariant === null) {
|
|
185
328
|
continue;
|
|
186
329
|
}
|
|
187
|
-
// We
|
|
330
|
+
// We had to backup selectors, therefore we assume that somebody touched
|
|
188
331
|
// `container` or `modifySelectors`. Let's see if they did, so that we
|
|
189
332
|
// can restore the selectors, and collect the format strings.
|
|
190
|
-
if (
|
|
333
|
+
if (clone.raws.neededBackup) {
|
|
334
|
+
delete clone.raws.neededBackup;
|
|
191
335
|
clone.walkRules((rule)=>{
|
|
192
|
-
|
|
193
|
-
|
|
336
|
+
let before = rule.raws.originalSelector;
|
|
337
|
+
if (!before) return;
|
|
338
|
+
delete rule.raws.originalSelector;
|
|
194
339
|
if (before === rule.selector) return; // No mutation happened
|
|
195
340
|
let modified = rule.selector;
|
|
196
341
|
// Rebuild the base selector, this is what plugin authors would do
|
|
197
342
|
// as well. E.g.: `${variant}${separator}${className}`.
|
|
198
343
|
// However, plugin authors probably also prepend or append certain
|
|
199
344
|
// classes, pseudos, ids, ...
|
|
200
|
-
let rebuiltBase = (0, _postcssSelectorParser
|
|
345
|
+
let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
201
346
|
selectors.walkClasses((classNode)=>{
|
|
202
347
|
classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
|
|
203
348
|
});
|
|
@@ -213,18 +358,27 @@ function applyVariant(variant, matches, context) {
|
|
|
213
358
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
214
359
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
215
360
|
// format: .foo &
|
|
216
|
-
collectedFormats.push(modified.replace(rebuiltBase,
|
|
361
|
+
collectedFormats.push(modified.replace(rebuiltBase, "&"));
|
|
217
362
|
rule.selector = before;
|
|
218
363
|
});
|
|
219
364
|
}
|
|
365
|
+
// This tracks the originating layer for the variant
|
|
366
|
+
// For example:
|
|
367
|
+
// .sm:underline {} is a variant of something in the utilities layer
|
|
368
|
+
// .sm:container {} is a variant of the container component
|
|
369
|
+
clone.nodes[0].raws.tailwind = {
|
|
370
|
+
...clone.nodes[0].raws.tailwind,
|
|
371
|
+
parentLayer: meta.layer
|
|
372
|
+
};
|
|
220
373
|
var _collectedFormats;
|
|
221
374
|
let withOffset = [
|
|
222
375
|
{
|
|
223
376
|
...meta,
|
|
224
|
-
sort: variantSort
|
|
225
|
-
collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats)
|
|
377
|
+
sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
|
|
378
|
+
collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats),
|
|
379
|
+
isArbitraryVariant: isArbitraryValue(variant)
|
|
226
380
|
},
|
|
227
|
-
clone.nodes[0]
|
|
381
|
+
clone.nodes[0]
|
|
228
382
|
];
|
|
229
383
|
result.push(withOffset);
|
|
230
384
|
}
|
|
@@ -233,10 +387,9 @@ function applyVariant(variant, matches, context) {
|
|
|
233
387
|
}
|
|
234
388
|
return [];
|
|
235
389
|
}
|
|
236
|
-
function parseRules(rule, cache, options = {
|
|
237
|
-
}) {
|
|
390
|
+
function parseRules(rule, cache, options = {}) {
|
|
238
391
|
// PostCSS node
|
|
239
|
-
if (!(0, _isPlainObject
|
|
392
|
+
if (!(0, _isPlainObject.default)(rule) && !Array.isArray(rule)) {
|
|
240
393
|
return [
|
|
241
394
|
[
|
|
242
395
|
rule
|
|
@@ -250,7 +403,7 @@ function parseRules(rule, cache, options = {
|
|
|
250
403
|
}
|
|
251
404
|
// Simple object
|
|
252
405
|
if (!cache.has(rule)) {
|
|
253
|
-
cache.set(rule, (0, _parseObjectStyles
|
|
406
|
+
cache.set(rule, (0, _parseObjectStyles.default)(rule));
|
|
254
407
|
}
|
|
255
408
|
return [
|
|
256
409
|
cache.get(rule),
|
|
@@ -261,7 +414,40 @@ const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
|
|
|
261
414
|
function isValidPropName(name) {
|
|
262
415
|
return IS_VALID_PROPERTY_NAME.test(name);
|
|
263
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* @param {string} declaration
|
|
419
|
+
* @returns {boolean}
|
|
420
|
+
*/ function looksLikeUri(declaration) {
|
|
421
|
+
// Quick bailout for obvious non-urls
|
|
422
|
+
// This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
|
|
423
|
+
if (!declaration.includes("://")) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
try {
|
|
427
|
+
const url = new URL(declaration);
|
|
428
|
+
return url.scheme !== "" && url.host !== "";
|
|
429
|
+
} catch (err) {
|
|
430
|
+
// Definitely not a valid url
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function isParsableNode(node) {
|
|
435
|
+
let isParsable = true;
|
|
436
|
+
node.walkDecls((decl)=>{
|
|
437
|
+
if (!isParsableCssValue(decl.name, decl.value)) {
|
|
438
|
+
isParsable = false;
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
return isParsable;
|
|
443
|
+
}
|
|
264
444
|
function isParsableCssValue(property, value) {
|
|
445
|
+
// We don't want to to treat [https://example.com] as a custom property
|
|
446
|
+
// Even though, according to the CSS grammar, it's a totally valid CSS declaration
|
|
447
|
+
// So we short-circuit here by checking if the custom property looks like a url
|
|
448
|
+
if (looksLikeUri(`${property}:${value}`)) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
265
451
|
try {
|
|
266
452
|
_postcss.default.parse(`a{${property}:${value}}`).toResult();
|
|
267
453
|
return true;
|
|
@@ -278,55 +464,56 @@ function extractArbitraryProperty(classCandidate, context) {
|
|
|
278
464
|
if (!isValidPropName(property)) {
|
|
279
465
|
return null;
|
|
280
466
|
}
|
|
281
|
-
if (!(0,
|
|
467
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
282
468
|
return null;
|
|
283
469
|
}
|
|
284
|
-
let normalized = (0, _dataTypes
|
|
470
|
+
let normalized = (0, _dataTypes.normalize)(value);
|
|
285
471
|
if (!isParsableCssValue(property, normalized)) {
|
|
286
472
|
return null;
|
|
287
473
|
}
|
|
474
|
+
let sort = context.offsets.arbitraryProperty();
|
|
288
475
|
return [
|
|
289
476
|
[
|
|
290
477
|
{
|
|
291
|
-
sort
|
|
292
|
-
layer:
|
|
478
|
+
sort,
|
|
479
|
+
layer: "utilities"
|
|
293
480
|
},
|
|
294
481
|
()=>({
|
|
295
|
-
[(0, _nameClass
|
|
482
|
+
[(0, _nameClass.asClass)(classCandidate)]: {
|
|
296
483
|
[property]: normalized
|
|
297
484
|
}
|
|
298
485
|
})
|
|
299
|
-
|
|
300
|
-
],
|
|
486
|
+
]
|
|
301
487
|
];
|
|
302
488
|
}
|
|
303
489
|
function* resolveMatchedPlugins(classCandidate, context) {
|
|
304
490
|
if (context.candidateRuleMap.has(classCandidate)) {
|
|
305
491
|
yield [
|
|
306
492
|
context.candidateRuleMap.get(classCandidate),
|
|
307
|
-
|
|
493
|
+
"DEFAULT"
|
|
308
494
|
];
|
|
309
495
|
}
|
|
310
|
-
yield*
|
|
496
|
+
yield* function*(arbitraryPropertyRule) {
|
|
311
497
|
if (arbitraryPropertyRule !== null) {
|
|
312
498
|
yield [
|
|
313
499
|
arbitraryPropertyRule,
|
|
314
|
-
|
|
500
|
+
"DEFAULT"
|
|
315
501
|
];
|
|
316
502
|
}
|
|
317
|
-
}
|
|
503
|
+
}(extractArbitraryProperty(classCandidate, context));
|
|
318
504
|
let candidatePrefix = classCandidate;
|
|
319
505
|
let negative = false;
|
|
320
506
|
const twConfigPrefix = context.tailwindConfig.prefix;
|
|
321
507
|
const twConfigPrefixLen = twConfigPrefix.length;
|
|
322
|
-
|
|
508
|
+
const hasMatchingPrefix = candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`);
|
|
509
|
+
if (candidatePrefix[twConfigPrefixLen] === "-" && hasMatchingPrefix) {
|
|
323
510
|
negative = true;
|
|
324
511
|
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
|
|
325
512
|
}
|
|
326
513
|
if (negative && context.candidateRuleMap.has(candidatePrefix)) {
|
|
327
514
|
yield [
|
|
328
515
|
context.candidateRuleMap.get(candidatePrefix),
|
|
329
|
-
|
|
516
|
+
"-DEFAULT"
|
|
330
517
|
];
|
|
331
518
|
}
|
|
332
519
|
for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
|
|
@@ -339,16 +526,41 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
339
526
|
}
|
|
340
527
|
}
|
|
341
528
|
function splitWithSeparator(input, separator) {
|
|
342
|
-
|
|
529
|
+
if (input === _sharedState.NOT_ON_DEMAND) {
|
|
530
|
+
return [
|
|
531
|
+
_sharedState.NOT_ON_DEMAND
|
|
532
|
+
];
|
|
533
|
+
}
|
|
534
|
+
return (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(input, separator);
|
|
535
|
+
}
|
|
536
|
+
function* recordCandidates(matches, classCandidate) {
|
|
537
|
+
for (const match of matches){
|
|
538
|
+
var ref;
|
|
539
|
+
var ref1;
|
|
540
|
+
match[1].raws.tailwind = {
|
|
541
|
+
...match[1].raws.tailwind,
|
|
542
|
+
classCandidate,
|
|
543
|
+
preserveSource: (ref1 = (ref = match[0].options) === null || ref === void 0 ? void 0 : ref.preserveSource) !== null && ref1 !== void 0 ? ref1 : false
|
|
544
|
+
};
|
|
545
|
+
yield match;
|
|
546
|
+
}
|
|
343
547
|
}
|
|
344
|
-
function* resolveMatches(candidate, context) {
|
|
548
|
+
function* resolveMatches(candidate, context, original = candidate) {
|
|
345
549
|
let separator = context.tailwindConfig.separator;
|
|
346
550
|
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
|
|
347
551
|
let important = false;
|
|
348
|
-
if (classCandidate.startsWith(
|
|
552
|
+
if (classCandidate.startsWith("!")) {
|
|
349
553
|
important = true;
|
|
350
554
|
classCandidate = classCandidate.slice(1);
|
|
351
555
|
}
|
|
556
|
+
if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
|
|
557
|
+
if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
|
|
558
|
+
let base = variants.slice().reverse().join(separator);
|
|
559
|
+
for (let part of (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
|
|
560
|
+
yield* resolveMatches(base + separator + part, context, original);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
352
564
|
// TODO: Reintroduce this in ways that doesn't break on false positives
|
|
353
565
|
// function sortAgainst(toSort, against) {
|
|
354
566
|
// return toSort.slice().sort((a, z) => {
|
|
@@ -367,7 +579,7 @@ function* resolveMatches(candidate, context) {
|
|
|
367
579
|
let isOnlyPlugin = plugins.length === 1;
|
|
368
580
|
for (let [sort, plugin] of plugins){
|
|
369
581
|
let matchesPerPlugin = [];
|
|
370
|
-
if (typeof plugin ===
|
|
582
|
+
if (typeof plugin === "function") {
|
|
371
583
|
for (let ruleSet of [].concat(plugin(modifier, {
|
|
372
584
|
isOnlyPlugin
|
|
373
585
|
}))){
|
|
@@ -385,112 +597,188 @@ function* resolveMatches(candidate, context) {
|
|
|
385
597
|
]);
|
|
386
598
|
}
|
|
387
599
|
}
|
|
388
|
-
} else if (modifier ===
|
|
389
|
-
let
|
|
390
|
-
let [
|
|
391
|
-
for (let
|
|
600
|
+
} else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
|
|
601
|
+
let ruleSet1 = plugin;
|
|
602
|
+
let [rules1, options1] = parseRules(ruleSet1, context.postCssNodeCache);
|
|
603
|
+
for (let rule1 of rules1){
|
|
392
604
|
matchesPerPlugin.push([
|
|
393
605
|
{
|
|
394
606
|
...sort,
|
|
395
607
|
options: {
|
|
396
608
|
...sort.options,
|
|
397
|
-
...
|
|
609
|
+
...options1
|
|
398
610
|
}
|
|
399
611
|
},
|
|
400
|
-
|
|
612
|
+
rule1
|
|
401
613
|
]);
|
|
402
614
|
}
|
|
403
615
|
}
|
|
404
616
|
if (matchesPerPlugin.length > 0) {
|
|
405
617
|
var ref;
|
|
406
|
-
|
|
618
|
+
var ref1, _options;
|
|
619
|
+
let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((ref1 = (ref = sort.options) === null || ref === void 0 ? void 0 : ref.types) !== null && ref1 !== void 0 ? ref1 : [], modifier, (_options = sort.options) !== null && _options !== void 0 ? _options : {}, context.tailwindConfig)).map(([_, type])=>type);
|
|
620
|
+
if (matchingTypes.length > 0) {
|
|
621
|
+
typesByMatches.set(matchesPerPlugin, matchingTypes);
|
|
622
|
+
}
|
|
407
623
|
matches.push(matchesPerPlugin);
|
|
408
624
|
}
|
|
409
625
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
626
|
+
if (isArbitraryValue(modifier)) {
|
|
627
|
+
if (matches.length > 1) {
|
|
628
|
+
// Partition plugins in 2 categories so that we can start searching in the plugins that
|
|
629
|
+
// don't have `any` as a type first.
|
|
630
|
+
let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
|
|
631
|
+
let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === "any"));
|
|
632
|
+
if (hasAnyType) {
|
|
633
|
+
group[0].push(plugin);
|
|
634
|
+
} else {
|
|
635
|
+
group[1].push(plugin);
|
|
636
|
+
}
|
|
637
|
+
return group;
|
|
638
|
+
}, [
|
|
639
|
+
[],
|
|
640
|
+
[]
|
|
641
|
+
]);
|
|
642
|
+
function findFallback(matches) {
|
|
643
|
+
// If only a single plugin matches, let's take that one
|
|
644
|
+
if (matches.length === 1) {
|
|
645
|
+
return matches[0];
|
|
428
646
|
}
|
|
429
|
-
|
|
647
|
+
// Otherwise, find the plugin that creates a valid rule given the arbitrary value, and
|
|
648
|
+
// also has the correct type which preferOnConflicts the plugin in case of clashes.
|
|
649
|
+
return matches.find((rules)=>{
|
|
650
|
+
let matchingTypes = typesByMatches.get(rules);
|
|
651
|
+
return rules.some(([{ options }, rule])=>{
|
|
652
|
+
if (!isParsableNode(rule)) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
return options.types.some(({ type , preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
|
|
656
|
+
});
|
|
657
|
+
});
|
|
430
658
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
659
|
+
var ref2;
|
|
660
|
+
// Try to find a fallback plugin, because we already know that multiple plugins matched for
|
|
661
|
+
// the given arbitrary value.
|
|
662
|
+
let fallback = (ref2 = findFallback(withoutAny)) !== null && ref2 !== void 0 ? ref2 : findFallback(withAny);
|
|
663
|
+
if (fallback) {
|
|
664
|
+
matches = [
|
|
665
|
+
fallback
|
|
666
|
+
];
|
|
667
|
+
} else {
|
|
668
|
+
var ref3;
|
|
669
|
+
let typesPerPlugin = matches.map((match)=>new Set([
|
|
670
|
+
...(ref3 = typesByMatches.get(match)) !== null && ref3 !== void 0 ? ref3 : []
|
|
671
|
+
]));
|
|
672
|
+
// Remove duplicates, so that we can detect proper unique types for each plugin.
|
|
673
|
+
for (let pluginTypes of typesPerPlugin){
|
|
674
|
+
for (let type of pluginTypes){
|
|
675
|
+
let removeFromOwnGroup = false;
|
|
676
|
+
for (let otherGroup of typesPerPlugin){
|
|
677
|
+
if (pluginTypes === otherGroup) continue;
|
|
678
|
+
if (otherGroup.has(type)) {
|
|
679
|
+
otherGroup.delete(type);
|
|
680
|
+
removeFromOwnGroup = true;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (removeFromOwnGroup) pluginTypes.delete(type);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
let messages = [];
|
|
687
|
+
for (let [idx, group] of typesPerPlugin.entries()){
|
|
688
|
+
for (let type1 of group){
|
|
689
|
+
let rules2 = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
|
|
690
|
+
.map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
|
|
691
|
+
.join("\n")).join("\n\n");
|
|
692
|
+
messages.push(` Use \`${candidate.replace("[", `[${type1}:`)}\` for \`${rules2.trim()}\``);
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
_log.default.warn([
|
|
697
|
+
`The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
|
|
698
|
+
...messages,
|
|
699
|
+
`If this is content and not a class, replace it with \`${candidate.replace("[", "[").replace("]", "]")}\` to silence this warning.`
|
|
700
|
+
]);
|
|
701
|
+
continue;
|
|
444
702
|
}
|
|
445
703
|
}
|
|
446
|
-
|
|
447
|
-
`The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
|
|
448
|
-
...messages,
|
|
449
|
-
`If this is content and not a class, replace it with \`${candidate.replace('[', '[').replace(']', ']')}\` to silence this warning.`,
|
|
450
|
-
]);
|
|
451
|
-
continue;
|
|
704
|
+
matches = matches.map((list)=>list.filter((match)=>isParsableNode(match[1])));
|
|
452
705
|
}
|
|
453
|
-
matches =
|
|
706
|
+
matches = matches.flat();
|
|
707
|
+
matches = Array.from(recordCandidates(matches, classCandidate));
|
|
708
|
+
matches = applyPrefix(matches, context);
|
|
454
709
|
if (important) {
|
|
455
|
-
matches = applyImportant(matches,
|
|
710
|
+
matches = applyImportant(matches, classCandidate);
|
|
456
711
|
}
|
|
457
712
|
for (let variant of variants){
|
|
458
713
|
matches = applyVariant(variant, matches, context);
|
|
459
714
|
}
|
|
460
|
-
for (let
|
|
715
|
+
for (let match of matches){
|
|
716
|
+
match[1].raws.tailwind = {
|
|
717
|
+
...match[1].raws.tailwind,
|
|
718
|
+
candidate
|
|
719
|
+
};
|
|
461
720
|
// Apply final format selector
|
|
462
|
-
if (
|
|
463
|
-
let finalFormat = (0, _formatVariantSelector
|
|
721
|
+
if (match[0].collectedFormats) {
|
|
722
|
+
let finalFormat = (0, _formatVariantSelector.formatVariantSelector)("&", ...match[0].collectedFormats);
|
|
464
723
|
let container = _postcss.default.root({
|
|
465
724
|
nodes: [
|
|
466
|
-
|
|
725
|
+
match[1].clone()
|
|
467
726
|
]
|
|
468
727
|
});
|
|
469
728
|
container.walkRules((rule)=>{
|
|
729
|
+
var ref;
|
|
470
730
|
if (inKeyframes(rule)) return;
|
|
471
|
-
|
|
731
|
+
var ref1;
|
|
732
|
+
rule.selector = (0, _formatVariantSelector.finalizeSelector)(finalFormat, {
|
|
472
733
|
selector: rule.selector,
|
|
473
|
-
candidate,
|
|
734
|
+
candidate: original,
|
|
735
|
+
base: candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop(),
|
|
736
|
+
isArbitraryVariant: match[0].isArbitraryVariant,
|
|
474
737
|
context
|
|
475
738
|
});
|
|
476
739
|
});
|
|
477
|
-
|
|
740
|
+
match[1] = container.nodes[0];
|
|
478
741
|
}
|
|
479
|
-
yield
|
|
742
|
+
yield match;
|
|
480
743
|
}
|
|
481
744
|
}
|
|
482
745
|
}
|
|
483
746
|
function inKeyframes(rule) {
|
|
484
|
-
return rule.parent && rule.parent.type ===
|
|
747
|
+
return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
|
|
748
|
+
}
|
|
749
|
+
function getImportantStrategy(important) {
|
|
750
|
+
if (important === true) {
|
|
751
|
+
return (rule)=>{
|
|
752
|
+
if (inKeyframes(rule)) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
rule.walkDecls((d)=>{
|
|
756
|
+
if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
|
|
757
|
+
d.important = true;
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
if (typeof important === "string") {
|
|
763
|
+
return (rule)=>{
|
|
764
|
+
if (inKeyframes(rule)) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
rule.selectors = rule.selectors.map((selector)=>{
|
|
768
|
+
return `${important} ${selector}`;
|
|
769
|
+
});
|
|
770
|
+
};
|
|
771
|
+
}
|
|
485
772
|
}
|
|
486
773
|
function generateRules(candidates, context) {
|
|
487
774
|
let allRules = [];
|
|
775
|
+
let strategy = getImportantStrategy(context.tailwindConfig.important);
|
|
488
776
|
for (let candidate of candidates){
|
|
489
777
|
if (context.notClassCache.has(candidate)) {
|
|
490
778
|
continue;
|
|
491
779
|
}
|
|
492
|
-
if (context.
|
|
493
|
-
allRules.
|
|
780
|
+
if (context.candidateRuleCache.has(candidate)) {
|
|
781
|
+
allRules = allRules.concat(Array.from(context.candidateRuleCache.get(candidate)));
|
|
494
782
|
continue;
|
|
495
783
|
}
|
|
496
784
|
let matches = Array.from(resolveMatches(candidate, context));
|
|
@@ -499,52 +787,31 @@ function generateRules(candidates, context) {
|
|
|
499
787
|
continue;
|
|
500
788
|
}
|
|
501
789
|
context.classCache.set(candidate, matches);
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
rule.walkDecls((d)=>{
|
|
509
|
-
if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
|
|
510
|
-
d.important = true;
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
if (typeof important === 'string') {
|
|
516
|
-
return (rule)=>{
|
|
517
|
-
rule.selectors = rule.selectors.map((selector)=>{
|
|
518
|
-
return `${important} ${selector}`;
|
|
519
|
-
});
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
})(context.tailwindConfig.important);
|
|
523
|
-
return allRules.flat(1).map(([{ sort , layer , options }, rule])=>{
|
|
524
|
-
if (options.respectImportant) {
|
|
525
|
-
if (strategy) {
|
|
790
|
+
var ref;
|
|
791
|
+
let rules = (ref = context.candidateRuleCache.get(candidate)) !== null && ref !== void 0 ? ref : new Set();
|
|
792
|
+
context.candidateRuleCache.set(candidate, rules);
|
|
793
|
+
for (const match of matches){
|
|
794
|
+
let [{ sort , options }, rule] = match;
|
|
795
|
+
if (options.respectImportant && strategy) {
|
|
526
796
|
let container = _postcss.default.root({
|
|
527
797
|
nodes: [
|
|
528
798
|
rule.clone()
|
|
529
799
|
]
|
|
530
800
|
});
|
|
531
|
-
container.walkRules(
|
|
532
|
-
if (inKeyframes(r)) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
strategy(r);
|
|
536
|
-
});
|
|
801
|
+
container.walkRules(strategy);
|
|
537
802
|
rule = container.nodes[0];
|
|
538
803
|
}
|
|
804
|
+
let newEntry = [
|
|
805
|
+
sort,
|
|
806
|
+
rule
|
|
807
|
+
];
|
|
808
|
+
rules.add(newEntry);
|
|
809
|
+
context.ruleCache.add(newEntry);
|
|
810
|
+
allRules.push(newEntry);
|
|
539
811
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
rule
|
|
543
|
-
];
|
|
544
|
-
});
|
|
812
|
+
}
|
|
813
|
+
return allRules;
|
|
545
814
|
}
|
|
546
815
|
function isArbitraryValue(input) {
|
|
547
|
-
return input.startsWith(
|
|
816
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
548
817
|
}
|
|
549
|
-
exports.resolveMatches = resolveMatches;
|
|
550
|
-
exports.generateRules = generateRules;
|