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