tailwindcss 0.0.0-insiders.d33b650 → 0.0.0-insiders.d3f2221
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 +1 -1
- package/index.css +5 -0
- package/lib/cli/build/index.js +32 -19
- package/lib/cli/build/plugin.js +228 -148
- package/lib/cli/build/utils.js +31 -21
- package/lib/cli/build/watching.js +99 -30
- package/lib/cli/help/index.js +17 -15
- package/lib/cli/index.js +223 -10
- package/lib/cli/init/index.js +31 -14
- package/lib/cli.js +1 -227
- package/lib/corePluginList.js +8 -1
- package/lib/corePlugins.js +2128 -1823
- package/lib/css/preflight.css +17 -4
- package/lib/featureFlags.js +39 -25
- package/lib/index.js +1 -47
- package/lib/lib/cacheInvalidation.js +10 -8
- package/lib/lib/collapseAdjacentRules.js +10 -8
- package/lib/lib/collapseDuplicateDeclarations.js +13 -11
- package/lib/lib/content.js +65 -28
- package/lib/lib/defaultExtractor.js +24 -32
- package/lib/lib/detectNesting.js +18 -10
- package/lib/lib/evaluateTailwindFunctions.js +45 -41
- package/lib/lib/expandApplyAtRules.js +60 -52
- package/lib/lib/expandTailwindAtRules.js +115 -47
- package/lib/lib/findAtConfigPath.js +14 -12
- package/lib/lib/generateRules.js +206 -146
- package/lib/lib/getModuleDependencies.js +85 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +26 -39
- package/lib/lib/offsets.js +136 -47
- package/lib/lib/partitionApplyAtRules.js +5 -3
- package/lib/lib/regex.js +26 -12
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +53 -49
- package/lib/lib/setupContextUtils.js +337 -250
- package/lib/lib/setupTrackingContext.js +54 -29
- package/lib/lib/sharedState.js +36 -17
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/plugin.js +164 -0
- package/lib/postcss-plugins/nesting/index.js +5 -3
- package/lib/postcss-plugins/nesting/plugin.js +19 -17
- package/lib/processTailwindFeatures.js +19 -17
- package/lib/public/colors.js +269 -245
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +5 -3
- package/lib/util/cloneDeep.js +4 -2
- package/lib/util/cloneNodes.js +6 -4
- package/lib/util/color.js +46 -28
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +9 -7
- package/lib/util/dataTypes.js +215 -96
- package/lib/util/defaults.js +9 -7
- package/lib/util/escapeClassName.js +10 -8
- package/lib/util/escapeCommas.js +4 -2
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +149 -169
- package/lib/util/getAllConfigs.js +12 -9
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +4 -2
- package/lib/util/isPlainObject.js +4 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +14 -12
- package/lib/util/log.js +31 -10
- package/lib/util/nameClass.js +16 -10
- package/lib/util/negateValue.js +12 -10
- package/lib/util/normalizeConfig.js +123 -77
- package/lib/util/normalizeScreens.js +30 -22
- package/lib/util/parseAnimationValue.js +41 -39
- package/lib/util/parseBoxShadowValue.js +24 -20
- package/lib/util/parseDependency.js +7 -5
- package/lib/util/parseGlob.js +10 -8
- package/lib/util/parseObjectStyles.js +10 -8
- package/lib/util/pluginUtils.js +92 -96
- package/lib/util/prefixSelector.js +27 -11
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +4 -2
- package/lib/util/resolveConfig.js +28 -24
- package/lib/util/resolveConfigPath.js +28 -12
- package/lib/util/responsive.js +7 -5
- package/lib/util/splitAtTopLevelOnly.js +12 -4
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +4 -2
- package/lib/util/toPath.js +5 -3
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +31 -7
- package/lib/util/validateFormalSyntax.js +8 -6
- package/lib/util/withAlphaVariable.js +11 -7
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +49 -50
- package/resolveConfig.d.ts +11 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/index.js +17 -9
- package/src/cli/build/plugin.js +129 -77
- package/src/cli/build/watching.js +108 -13
- package/src/cli/index.js +217 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +1 -221
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +259 -46
- package/src/css/preflight.css +17 -4
- package/src/featureFlags.js +7 -7
- package/src/index.js +1 -47
- package/src/lib/content.js +44 -10
- package/src/lib/defaultExtractor.js +10 -14
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +10 -3
- package/src/lib/expandTailwindAtRules.js +78 -13
- package/src/lib/generateRules.js +140 -65
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/handleImportAtRules.js +34 -0
- package/src/lib/load-config.ts +31 -0
- package/src/lib/normalizeTailwindDirectives.js +0 -27
- package/src/lib/offsets.js +105 -2
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +145 -80
- package/src/lib/setupTrackingContext.js +37 -14
- package/src/lib/sharedState.js +11 -4
- package/src/plugin.js +133 -0
- package/src/processTailwindFeatures.js +3 -2
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/color.js +19 -4
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +97 -9
- package/src/util/formatVariantSelector.js +163 -165
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +24 -0
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +57 -11
- package/src/util/pluginUtils.js +38 -54
- package/src/util/prefixSelector.js +29 -10
- package/src/util/pseudoElements.js +167 -0
- package/src/util/resolveConfig.js +0 -2
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +23 -0
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +203 -172
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
- package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
- package/stubs/postcss.config.js +5 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +20 -13
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +116 -80
- package/CHANGELOG.md +0 -2300
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli/shared.js +0 -12
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/constants.js +0 -44
- package/peers/index.js +0 -79459
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/build/deps.js +0 -56
- package/src/cli/shared.js +0 -5
- package/src/cli-peer-dependencies.js +0 -15
- package/src/constants.js +0 -17
package/lib/lib/generateRules.js
CHANGED
|
@@ -9,26 +9,32 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
getClassNameFromSelector: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
getClassNameFromSelector: function() {
|
|
13
|
+
return getClassNameFromSelector;
|
|
14
|
+
},
|
|
15
|
+
resolveMatches: function() {
|
|
16
|
+
return resolveMatches;
|
|
17
|
+
},
|
|
18
|
+
generateRules: function() {
|
|
19
|
+
return generateRules;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
|
-
const _postcss = /*#__PURE__*/
|
|
17
|
-
const
|
|
18
|
-
const _parseObjectStyles = /*#__PURE__*/
|
|
19
|
-
const _isPlainObject = /*#__PURE__*/
|
|
20
|
-
const _prefixSelector = /*#__PURE__*/
|
|
22
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
23
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
24
|
+
const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
|
|
25
|
+
const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
|
|
26
|
+
const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
|
|
21
27
|
const _pluginUtils = require("../util/pluginUtils");
|
|
22
|
-
const _log = /*#__PURE__*/
|
|
23
|
-
const _sharedState = /*#__PURE__*/
|
|
28
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
29
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
24
30
|
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
25
31
|
const _nameClass = require("../util/nameClass");
|
|
26
32
|
const _dataTypes = require("../util/dataTypes");
|
|
27
33
|
const _setupContextUtils = require("./setupContextUtils");
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
function
|
|
34
|
+
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
|
|
35
|
+
const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
|
|
36
|
+
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
37
|
+
function _interop_require_default(obj) {
|
|
32
38
|
return obj && obj.__esModule ? obj : {
|
|
33
39
|
default: obj
|
|
34
40
|
};
|
|
@@ -41,7 +47,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
41
47
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
42
48
|
})(nodeInterop);
|
|
43
49
|
}
|
|
44
|
-
function
|
|
50
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
45
51
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
46
52
|
return obj;
|
|
47
53
|
}
|
|
@@ -72,8 +78,8 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
72
78
|
}
|
|
73
79
|
return newObj;
|
|
74
80
|
}
|
|
75
|
-
let classNameParser = (0,
|
|
76
|
-
return selectors.first.filter(({ type
|
|
81
|
+
let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
82
|
+
return selectors.first.filter(({ type })=>type === 'class').pop().value;
|
|
77
83
|
});
|
|
78
84
|
function getClassNameFromSelector(selector) {
|
|
79
85
|
return classNameParser.transformSync(selector);
|
|
@@ -90,23 +96,23 @@ function* candidatePermutations(candidate) {
|
|
|
90
96
|
while(lastIndex >= 0){
|
|
91
97
|
let dashIdx;
|
|
92
98
|
let wasSlash = false;
|
|
93
|
-
if (lastIndex === Infinity && candidate.endsWith(
|
|
94
|
-
let bracketIdx = candidate.indexOf(
|
|
99
|
+
if (lastIndex === Infinity && candidate.endsWith(']')) {
|
|
100
|
+
let bracketIdx = candidate.indexOf('[');
|
|
95
101
|
// If character before `[` isn't a dash or a slash, this isn't a dynamic class
|
|
96
|
-
//
|
|
97
|
-
if (candidate[bracketIdx - 1] ===
|
|
102
|
+
// e.g. string[]
|
|
103
|
+
if (candidate[bracketIdx - 1] === '-') {
|
|
98
104
|
dashIdx = bracketIdx - 1;
|
|
99
|
-
} else if (candidate[bracketIdx - 1] ===
|
|
105
|
+
} else if (candidate[bracketIdx - 1] === '/') {
|
|
100
106
|
dashIdx = bracketIdx - 1;
|
|
101
107
|
wasSlash = true;
|
|
102
108
|
} else {
|
|
103
109
|
dashIdx = -1;
|
|
104
110
|
}
|
|
105
|
-
} else if (lastIndex === Infinity && candidate.includes(
|
|
106
|
-
dashIdx = candidate.lastIndexOf(
|
|
111
|
+
} else if (lastIndex === Infinity && candidate.includes('/')) {
|
|
112
|
+
dashIdx = candidate.lastIndexOf('/');
|
|
107
113
|
wasSlash = true;
|
|
108
114
|
} else {
|
|
109
|
-
dashIdx = candidate.lastIndexOf(
|
|
115
|
+
dashIdx = candidate.lastIndexOf('-', lastIndex);
|
|
110
116
|
}
|
|
111
117
|
if (dashIdx < 0) {
|
|
112
118
|
break;
|
|
@@ -115,7 +121,7 @@ function* candidatePermutations(candidate) {
|
|
|
115
121
|
let modifier = candidate.slice(wasSlash ? dashIdx : dashIdx + 1);
|
|
116
122
|
lastIndex = dashIdx - 1;
|
|
117
123
|
// TODO: This feels a bit hacky
|
|
118
|
-
if (prefix ===
|
|
124
|
+
if (prefix === '' || modifier === '/') {
|
|
119
125
|
continue;
|
|
120
126
|
}
|
|
121
127
|
yield [
|
|
@@ -125,7 +131,7 @@ function* candidatePermutations(candidate) {
|
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
function applyPrefix(matches, context) {
|
|
128
|
-
if (matches.length === 0 || context.tailwindConfig.prefix ===
|
|
134
|
+
if (matches.length === 0 || context.tailwindConfig.prefix === '') {
|
|
129
135
|
return matches;
|
|
130
136
|
}
|
|
131
137
|
for (let match of matches){
|
|
@@ -142,7 +148,7 @@ function applyPrefix(matches, context) {
|
|
|
142
148
|
// have to ensure that the generated selector matches the candidate
|
|
143
149
|
// Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
|
|
144
150
|
// The disconnect between candidate <-> class can cause @apply to hard crash.
|
|
145
|
-
let shouldPrependNegative = classCandidate.startsWith(
|
|
151
|
+
let shouldPrependNegative = classCandidate.startsWith('-');
|
|
146
152
|
r.selector = (0, _prefixSelector.default)(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
|
|
147
153
|
});
|
|
148
154
|
match[1] = container.nodes[0];
|
|
@@ -162,12 +168,12 @@ function applyImportant(matches, classCandidate) {
|
|
|
162
168
|
]
|
|
163
169
|
});
|
|
164
170
|
container.walkRules((r)=>{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
|
|
172
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
173
|
+
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
174
|
+
// Update all instances of the base candidate to include the important marker
|
|
175
|
+
(0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
|
|
176
|
+
r.selector = ast.toString();
|
|
171
177
|
r.walkDecls((d)=>d.important = true);
|
|
172
178
|
});
|
|
173
179
|
result.push([
|
|
@@ -198,17 +204,20 @@ function applyVariant(variant, matches, context) {
|
|
|
198
204
|
};
|
|
199
205
|
// Retrieve "modifier"
|
|
200
206
|
{
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, '/');
|
|
208
|
+
// This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
|
|
209
|
+
// In this case 1/10 is a value but /20 is a modifier
|
|
210
|
+
if (modifiers.length > 1) {
|
|
211
|
+
baseVariant = baseVariant + '/' + modifiers.slice(0, -1).join('/');
|
|
212
|
+
modifiers = modifiers.slice(-1);
|
|
213
|
+
}
|
|
214
|
+
if (modifiers.length && !context.variantMap.has(variant)) {
|
|
215
|
+
variant = baseVariant;
|
|
216
|
+
args.modifier = modifiers[0];
|
|
208
217
|
}
|
|
209
218
|
}
|
|
210
219
|
// Retrieve "arbitrary value"
|
|
211
|
-
if (variant.endsWith(
|
|
220
|
+
if (variant.endsWith(']') && !variant.startsWith('[')) {
|
|
212
221
|
// We either have:
|
|
213
222
|
// @[200px]
|
|
214
223
|
// group-[:hover]
|
|
@@ -216,38 +225,50 @@ function applyVariant(variant, matches, context) {
|
|
|
216
225
|
// But we don't want:
|
|
217
226
|
// @-[200px] (`-` is incorrect)
|
|
218
227
|
// group[:hover] (`-` is missing)
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
221
|
-
let [, char,
|
|
228
|
+
let match = /(.)(-?)\[(.*)\]/g.exec(variant);
|
|
229
|
+
if (match) {
|
|
230
|
+
let [, char, separator, value] = match;
|
|
222
231
|
// @-[200px] case
|
|
223
|
-
if (char ===
|
|
232
|
+
if (char === '@' && separator === '-') return [];
|
|
224
233
|
// group[:hover] case
|
|
225
|
-
if (char !==
|
|
226
|
-
variant = variant.replace(`${
|
|
234
|
+
if (char !== '@' && separator === '') return [];
|
|
235
|
+
variant = variant.replace(`${separator}[${value}]`, '');
|
|
227
236
|
args.value = value;
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
// Register arbitrary variants
|
|
231
240
|
if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
|
|
241
|
+
let sort = context.offsets.recordVariant(variant);
|
|
232
242
|
let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
|
|
233
|
-
|
|
243
|
+
let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ',');
|
|
244
|
+
// We do not support multiple selectors for arbitrary variants
|
|
245
|
+
if (selectors.length > 1) {
|
|
234
246
|
return [];
|
|
235
247
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
sort,
|
|
241
|
-
|
|
242
|
-
]
|
|
243
|
-
|
|
248
|
+
if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
let records = selectors.map((sel, idx)=>[
|
|
252
|
+
context.offsets.applyParallelOffset(sort, idx),
|
|
253
|
+
(0, _setupContextUtils.parseVariant)(sel.trim())
|
|
254
|
+
]);
|
|
255
|
+
context.variantMap.set(variant, records);
|
|
244
256
|
}
|
|
245
257
|
if (context.variantMap.has(variant)) {
|
|
258
|
+
var _context_variantOptions_get;
|
|
259
|
+
let isArbitraryVariant = isArbitraryValue(variant);
|
|
260
|
+
var _context_variantOptions_get_INTERNAL_FEATURES;
|
|
261
|
+
let internalFeatures = (_context_variantOptions_get_INTERNAL_FEATURES = (_context_variantOptions_get = context.variantOptions.get(variant)) === null || _context_variantOptions_get === void 0 ? void 0 : _context_variantOptions_get[_setupContextUtils.INTERNAL_FEATURES]) !== null && _context_variantOptions_get_INTERNAL_FEATURES !== void 0 ? _context_variantOptions_get_INTERNAL_FEATURES : {};
|
|
246
262
|
let variantFunctionTuples = context.variantMap.get(variant).slice();
|
|
247
263
|
let result = [];
|
|
264
|
+
let respectPrefix = (()=>{
|
|
265
|
+
if (isArbitraryVariant) return false;
|
|
266
|
+
if (internalFeatures.respectPrefix === false) return false;
|
|
267
|
+
return true;
|
|
268
|
+
})();
|
|
248
269
|
for (let [meta, rule] of matches){
|
|
249
270
|
// Don't generate variants for user css
|
|
250
|
-
if (meta.layer ===
|
|
271
|
+
if (meta.layer === 'user') {
|
|
251
272
|
continue;
|
|
252
273
|
}
|
|
253
274
|
let container = _postcss.default.root({
|
|
@@ -269,7 +290,7 @@ function applyVariant(variant, matches, context) {
|
|
|
269
290
|
function modifySelectors(modifierFunction) {
|
|
270
291
|
prepareBackup();
|
|
271
292
|
clone.each((rule)=>{
|
|
272
|
-
if (rule.type !==
|
|
293
|
+
if (rule.type !== 'rule') {
|
|
273
294
|
return;
|
|
274
295
|
}
|
|
275
296
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
@@ -299,21 +320,24 @@ function applyVariant(variant, matches, context) {
|
|
|
299
320
|
clone.append(wrapper);
|
|
300
321
|
},
|
|
301
322
|
format (selectorFormat) {
|
|
302
|
-
collectedFormats.push(
|
|
323
|
+
collectedFormats.push({
|
|
324
|
+
format: selectorFormat,
|
|
325
|
+
respectPrefix
|
|
326
|
+
});
|
|
303
327
|
},
|
|
304
328
|
args
|
|
305
329
|
});
|
|
306
330
|
// It can happen that a list of format strings is returned from within the function. In that
|
|
307
331
|
// case, we have to process them as well. We can use the existing `variantSort`.
|
|
308
332
|
if (Array.isArray(ruleWithVariant)) {
|
|
309
|
-
for (let [idx,
|
|
333
|
+
for (let [idx, variantFunction] of ruleWithVariant.entries()){
|
|
310
334
|
// This is a little bit scary since we are pushing to an array of items that we are
|
|
311
335
|
// currently looping over. However, you can also think of it like a processing queue
|
|
312
336
|
// where you keep handling jobs until everything is done and each job can queue more
|
|
313
337
|
// jobs if needed.
|
|
314
338
|
variantFunctionTuples.push([
|
|
315
339
|
context.offsets.applyParallelOffset(variantSort, idx),
|
|
316
|
-
|
|
340
|
+
variantFunction,
|
|
317
341
|
// If the clone has been modified we have to pass that back
|
|
318
342
|
// though so each rule can use the modified container
|
|
319
343
|
clone.clone()
|
|
@@ -321,8 +345,11 @@ function applyVariant(variant, matches, context) {
|
|
|
321
345
|
}
|
|
322
346
|
continue;
|
|
323
347
|
}
|
|
324
|
-
if (typeof ruleWithVariant ===
|
|
325
|
-
collectedFormats.push(
|
|
348
|
+
if (typeof ruleWithVariant === 'string') {
|
|
349
|
+
collectedFormats.push({
|
|
350
|
+
format: ruleWithVariant,
|
|
351
|
+
respectPrefix
|
|
352
|
+
});
|
|
326
353
|
}
|
|
327
354
|
if (ruleWithVariant === null) {
|
|
328
355
|
continue;
|
|
@@ -342,7 +369,7 @@ function applyVariant(variant, matches, context) {
|
|
|
342
369
|
// as well. E.g.: `${variant}${separator}${className}`.
|
|
343
370
|
// However, plugin authors probably also prepend or append certain
|
|
344
371
|
// classes, pseudos, ids, ...
|
|
345
|
-
let rebuiltBase = (0,
|
|
372
|
+
let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
|
|
346
373
|
selectors.walkClasses((classNode)=>{
|
|
347
374
|
classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
|
|
348
375
|
});
|
|
@@ -358,7 +385,10 @@ function applyVariant(variant, matches, context) {
|
|
|
358
385
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
359
386
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
360
387
|
// format: .foo &
|
|
361
|
-
collectedFormats.push(
|
|
388
|
+
collectedFormats.push({
|
|
389
|
+
format: modified.replace(rebuiltBase, '&'),
|
|
390
|
+
respectPrefix
|
|
391
|
+
});
|
|
362
392
|
rule.selector = before;
|
|
363
393
|
});
|
|
364
394
|
}
|
|
@@ -370,13 +400,12 @@ function applyVariant(variant, matches, context) {
|
|
|
370
400
|
...clone.nodes[0].raws.tailwind,
|
|
371
401
|
parentLayer: meta.layer
|
|
372
402
|
};
|
|
373
|
-
var
|
|
403
|
+
var _meta_collectedFormats;
|
|
374
404
|
let withOffset = [
|
|
375
405
|
{
|
|
376
406
|
...meta,
|
|
377
407
|
sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
|
|
378
|
-
collectedFormats: ((
|
|
379
|
-
isArbitraryVariant: isArbitraryValue(variant)
|
|
408
|
+
collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
|
|
380
409
|
},
|
|
381
410
|
clone.nodes[0]
|
|
382
411
|
];
|
|
@@ -420,12 +449,12 @@ function isValidPropName(name) {
|
|
|
420
449
|
*/ function looksLikeUri(declaration) {
|
|
421
450
|
// Quick bailout for obvious non-urls
|
|
422
451
|
// This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
|
|
423
|
-
if (!declaration.includes(
|
|
452
|
+
if (!declaration.includes('://')) {
|
|
424
453
|
return false;
|
|
425
454
|
}
|
|
426
455
|
try {
|
|
427
456
|
const url = new URL(declaration);
|
|
428
|
-
return url.scheme !==
|
|
457
|
+
return url.scheme !== '' && url.host !== '';
|
|
429
458
|
} catch (err) {
|
|
430
459
|
// Definitely not a valid url
|
|
431
460
|
return false;
|
|
@@ -434,7 +463,7 @@ function isValidPropName(name) {
|
|
|
434
463
|
function isParsableNode(node) {
|
|
435
464
|
let isParsable = true;
|
|
436
465
|
node.walkDecls((decl)=>{
|
|
437
|
-
if (!isParsableCssValue(decl.
|
|
466
|
+
if (!isParsableCssValue(decl.prop, decl.value)) {
|
|
438
467
|
isParsable = false;
|
|
439
468
|
return false;
|
|
440
469
|
}
|
|
@@ -442,9 +471,9 @@ function isParsableNode(node) {
|
|
|
442
471
|
return isParsable;
|
|
443
472
|
}
|
|
444
473
|
function isParsableCssValue(property, value) {
|
|
445
|
-
// We don't want to
|
|
474
|
+
// We don't want to treat [https://example.com] as a custom property
|
|
446
475
|
// 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
|
|
476
|
+
// So we short-circuit here by checking if the custom property looks like a URL
|
|
448
477
|
if (looksLikeUri(`${property}:${value}`)) {
|
|
449
478
|
return false;
|
|
450
479
|
}
|
|
@@ -456,15 +485,15 @@ function isParsableCssValue(property, value) {
|
|
|
456
485
|
}
|
|
457
486
|
}
|
|
458
487
|
function extractArbitraryProperty(classCandidate, context) {
|
|
459
|
-
var
|
|
460
|
-
let [, property, value] = (
|
|
488
|
+
var _classCandidate_match;
|
|
489
|
+
let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
|
|
461
490
|
if (value === undefined) {
|
|
462
491
|
return null;
|
|
463
492
|
}
|
|
464
493
|
if (!isValidPropName(property)) {
|
|
465
494
|
return null;
|
|
466
495
|
}
|
|
467
|
-
if (!(0,
|
|
496
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
468
497
|
return null;
|
|
469
498
|
}
|
|
470
499
|
let normalized = (0, _dataTypes.normalize)(value);
|
|
@@ -476,7 +505,7 @@ function extractArbitraryProperty(classCandidate, context) {
|
|
|
476
505
|
[
|
|
477
506
|
{
|
|
478
507
|
sort,
|
|
479
|
-
layer:
|
|
508
|
+
layer: 'utilities'
|
|
480
509
|
},
|
|
481
510
|
()=>({
|
|
482
511
|
[(0, _nameClass.asClass)(classCandidate)]: {
|
|
@@ -490,14 +519,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
490
519
|
if (context.candidateRuleMap.has(classCandidate)) {
|
|
491
520
|
yield [
|
|
492
521
|
context.candidateRuleMap.get(classCandidate),
|
|
493
|
-
|
|
522
|
+
'DEFAULT'
|
|
494
523
|
];
|
|
495
524
|
}
|
|
496
525
|
yield* function*(arbitraryPropertyRule) {
|
|
497
526
|
if (arbitraryPropertyRule !== null) {
|
|
498
527
|
yield [
|
|
499
528
|
arbitraryPropertyRule,
|
|
500
|
-
|
|
529
|
+
'DEFAULT'
|
|
501
530
|
];
|
|
502
531
|
}
|
|
503
532
|
}(extractArbitraryProperty(classCandidate, context));
|
|
@@ -506,14 +535,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
506
535
|
const twConfigPrefix = context.tailwindConfig.prefix;
|
|
507
536
|
const twConfigPrefixLen = twConfigPrefix.length;
|
|
508
537
|
const hasMatchingPrefix = candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`);
|
|
509
|
-
if (candidatePrefix[twConfigPrefixLen] ===
|
|
538
|
+
if (candidatePrefix[twConfigPrefixLen] === '-' && hasMatchingPrefix) {
|
|
510
539
|
negative = true;
|
|
511
540
|
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
|
|
512
541
|
}
|
|
513
542
|
if (negative && context.candidateRuleMap.has(candidatePrefix)) {
|
|
514
543
|
yield [
|
|
515
544
|
context.candidateRuleMap.get(candidatePrefix),
|
|
516
|
-
|
|
545
|
+
'-DEFAULT'
|
|
517
546
|
];
|
|
518
547
|
}
|
|
519
548
|
for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
|
|
@@ -531,36 +560,28 @@ function splitWithSeparator(input, separator) {
|
|
|
531
560
|
_sharedState.NOT_ON_DEMAND
|
|
532
561
|
];
|
|
533
562
|
}
|
|
534
|
-
return (0,
|
|
563
|
+
return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
|
|
535
564
|
}
|
|
536
565
|
function* recordCandidates(matches, classCandidate) {
|
|
537
566
|
for (const match of matches){
|
|
538
|
-
var
|
|
539
|
-
var
|
|
567
|
+
var _match__options;
|
|
568
|
+
var _match__options_preserveSource;
|
|
540
569
|
match[1].raws.tailwind = {
|
|
541
570
|
...match[1].raws.tailwind,
|
|
542
571
|
classCandidate,
|
|
543
|
-
preserveSource: (
|
|
572
|
+
preserveSource: (_match__options_preserveSource = (_match__options = match[0].options) === null || _match__options === void 0 ? void 0 : _match__options.preserveSource) !== null && _match__options_preserveSource !== void 0 ? _match__options_preserveSource : false
|
|
544
573
|
};
|
|
545
574
|
yield match;
|
|
546
575
|
}
|
|
547
576
|
}
|
|
548
|
-
function* resolveMatches(candidate, context
|
|
577
|
+
function* resolveMatches(candidate, context) {
|
|
549
578
|
let separator = context.tailwindConfig.separator;
|
|
550
579
|
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
|
|
551
580
|
let important = false;
|
|
552
|
-
if (classCandidate.startsWith(
|
|
581
|
+
if (classCandidate.startsWith('!')) {
|
|
553
582
|
important = true;
|
|
554
583
|
classCandidate = classCandidate.slice(1);
|
|
555
584
|
}
|
|
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
|
-
}
|
|
564
585
|
// TODO: Reintroduce this in ways that doesn't break on false positives
|
|
565
586
|
// function sortAgainst(toSort, against) {
|
|
566
587
|
// return toSort.slice().sort((a, z) => {
|
|
@@ -579,7 +600,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
579
600
|
let isOnlyPlugin = plugins.length === 1;
|
|
580
601
|
for (let [sort, plugin] of plugins){
|
|
581
602
|
let matchesPerPlugin = [];
|
|
582
|
-
if (typeof plugin ===
|
|
603
|
+
if (typeof plugin === 'function') {
|
|
583
604
|
for (let ruleSet of [].concat(plugin(modifier, {
|
|
584
605
|
isOnlyPlugin
|
|
585
606
|
}))){
|
|
@@ -597,26 +618,26 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
597
618
|
]);
|
|
598
619
|
}
|
|
599
620
|
}
|
|
600
|
-
} else if (modifier ===
|
|
601
|
-
let
|
|
602
|
-
let [
|
|
603
|
-
for (let
|
|
621
|
+
} else if (modifier === 'DEFAULT' || modifier === '-DEFAULT') {
|
|
622
|
+
let ruleSet = plugin;
|
|
623
|
+
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
|
|
624
|
+
for (let rule of rules){
|
|
604
625
|
matchesPerPlugin.push([
|
|
605
626
|
{
|
|
606
627
|
...sort,
|
|
607
628
|
options: {
|
|
608
629
|
...sort.options,
|
|
609
|
-
...
|
|
630
|
+
...options
|
|
610
631
|
}
|
|
611
632
|
},
|
|
612
|
-
|
|
633
|
+
rule
|
|
613
634
|
]);
|
|
614
635
|
}
|
|
615
636
|
}
|
|
616
637
|
if (matchesPerPlugin.length > 0) {
|
|
617
|
-
var
|
|
618
|
-
var
|
|
619
|
-
let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((
|
|
638
|
+
var _sort_options;
|
|
639
|
+
var _sort_options_types, _sort_options1;
|
|
640
|
+
let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((_sort_options_types = (_sort_options = sort.options) === null || _sort_options === void 0 ? void 0 : _sort_options.types) !== null && _sort_options_types !== void 0 ? _sort_options_types : [], modifier, (_sort_options1 = sort.options) !== null && _sort_options1 !== void 0 ? _sort_options1 : {}, context.tailwindConfig)).map(([_, type])=>type);
|
|
620
641
|
if (matchingTypes.length > 0) {
|
|
621
642
|
typesByMatches.set(matchesPerPlugin, matchingTypes);
|
|
622
643
|
}
|
|
@@ -628,7 +649,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
628
649
|
// Partition plugins in 2 categories so that we can start searching in the plugins that
|
|
629
650
|
// don't have `any` as a type first.
|
|
630
651
|
let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
|
|
631
|
-
let hasAnyType = plugin.some(([{ options
|
|
652
|
+
let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === 'any'));
|
|
632
653
|
if (hasAnyType) {
|
|
633
654
|
group[0].push(plugin);
|
|
634
655
|
} else {
|
|
@@ -648,26 +669,26 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
648
669
|
// also has the correct type which preferOnConflicts the plugin in case of clashes.
|
|
649
670
|
return matches.find((rules)=>{
|
|
650
671
|
let matchingTypes = typesByMatches.get(rules);
|
|
651
|
-
return rules.some(([{ options
|
|
672
|
+
return rules.some(([{ options }, rule])=>{
|
|
652
673
|
if (!isParsableNode(rule)) {
|
|
653
674
|
return false;
|
|
654
675
|
}
|
|
655
|
-
return options.types.some(({ type
|
|
676
|
+
return options.types.some(({ type, preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
|
|
656
677
|
});
|
|
657
678
|
});
|
|
658
679
|
}
|
|
659
|
-
var
|
|
680
|
+
var _findFallback;
|
|
660
681
|
// Try to find a fallback plugin, because we already know that multiple plugins matched for
|
|
661
682
|
// the given arbitrary value.
|
|
662
|
-
let fallback = (
|
|
683
|
+
let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
|
|
663
684
|
if (fallback) {
|
|
664
685
|
matches = [
|
|
665
686
|
fallback
|
|
666
687
|
];
|
|
667
688
|
} else {
|
|
668
|
-
var
|
|
689
|
+
var _typesByMatches_get;
|
|
669
690
|
let typesPerPlugin = matches.map((match)=>new Set([
|
|
670
|
-
...(
|
|
691
|
+
...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
|
|
671
692
|
]));
|
|
672
693
|
// Remove duplicates, so that we can detect proper unique types for each plugin.
|
|
673
694
|
for (let pluginTypes of typesPerPlugin){
|
|
@@ -685,18 +706,18 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
685
706
|
}
|
|
686
707
|
let messages = [];
|
|
687
708
|
for (let [idx, group] of typesPerPlugin.entries()){
|
|
688
|
-
for (let
|
|
689
|
-
let
|
|
709
|
+
for (let type of group){
|
|
710
|
+
let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split('\n').slice(1, -1) // Remove selector and closing '}'
|
|
690
711
|
.map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
|
|
691
|
-
.join(
|
|
692
|
-
messages.push(` Use \`${candidate.replace(
|
|
712
|
+
.join('\n')).join('\n\n');
|
|
713
|
+
messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``);
|
|
693
714
|
break;
|
|
694
715
|
}
|
|
695
716
|
}
|
|
696
717
|
_log.default.warn([
|
|
697
718
|
`The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
|
|
698
719
|
...messages,
|
|
699
|
-
`If this is content and not a class, replace it with \`${candidate.replace(
|
|
720
|
+
`If this is content and not a class, replace it with \`${candidate.replace('[', '[').replace(']', ']')}\` to silence this warning.`
|
|
700
721
|
]);
|
|
701
722
|
continue;
|
|
702
723
|
}
|
|
@@ -718,33 +739,72 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
718
739
|
candidate
|
|
719
740
|
};
|
|
720
741
|
// Apply final format selector
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
if (inKeyframes(rule)) return;
|
|
731
|
-
var ref1;
|
|
732
|
-
rule.selector = (0, _formatVariantSelector.finalizeSelector)(finalFormat, {
|
|
733
|
-
selector: rule.selector,
|
|
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,
|
|
737
|
-
context
|
|
738
|
-
});
|
|
739
|
-
});
|
|
740
|
-
match[1] = container.nodes[0];
|
|
742
|
+
match = applyFinalFormat(match, {
|
|
743
|
+
context,
|
|
744
|
+
candidate
|
|
745
|
+
});
|
|
746
|
+
// Skip rules with invalid selectors
|
|
747
|
+
// This will cause the candidate to be added to the "not class"
|
|
748
|
+
// cache skipping it entirely for future builds
|
|
749
|
+
if (match === null) {
|
|
750
|
+
continue;
|
|
741
751
|
}
|
|
742
752
|
yield match;
|
|
743
753
|
}
|
|
744
754
|
}
|
|
745
755
|
}
|
|
756
|
+
function applyFinalFormat(match, { context, candidate }) {
|
|
757
|
+
if (!match[0].collectedFormats) {
|
|
758
|
+
return match;
|
|
759
|
+
}
|
|
760
|
+
let isValid = true;
|
|
761
|
+
let finalFormat;
|
|
762
|
+
try {
|
|
763
|
+
finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
|
|
764
|
+
context,
|
|
765
|
+
candidate
|
|
766
|
+
});
|
|
767
|
+
} catch (e) {
|
|
768
|
+
// The format selector we produced is invalid
|
|
769
|
+
// This could be because:
|
|
770
|
+
// - A bug exists
|
|
771
|
+
// - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
|
|
772
|
+
// - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
|
|
773
|
+
// Either way the build will fail because of this
|
|
774
|
+
// We would rather that the build pass "silently" given that this could
|
|
775
|
+
// happen because of picking up invalid things when scanning content
|
|
776
|
+
// So we'll throw out the candidate instead
|
|
777
|
+
return null;
|
|
778
|
+
}
|
|
779
|
+
let container = _postcss.default.root({
|
|
780
|
+
nodes: [
|
|
781
|
+
match[1].clone()
|
|
782
|
+
]
|
|
783
|
+
});
|
|
784
|
+
container.walkRules((rule)=>{
|
|
785
|
+
if (inKeyframes(rule)) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
try {
|
|
789
|
+
rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
|
|
790
|
+
candidate,
|
|
791
|
+
context
|
|
792
|
+
});
|
|
793
|
+
} catch (e) {
|
|
794
|
+
// If this selector is invalid we also want to skip it
|
|
795
|
+
// But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
|
|
796
|
+
isValid = false;
|
|
797
|
+
return false;
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
if (!isValid) {
|
|
801
|
+
return null;
|
|
802
|
+
}
|
|
803
|
+
match[1] = container.nodes[0];
|
|
804
|
+
return match;
|
|
805
|
+
}
|
|
746
806
|
function inKeyframes(rule) {
|
|
747
|
-
return rule.parent && rule.parent.type ===
|
|
807
|
+
return rule.parent && rule.parent.type === 'atrule' && rule.parent.name === 'keyframes';
|
|
748
808
|
}
|
|
749
809
|
function getImportantStrategy(important) {
|
|
750
810
|
if (important === true) {
|
|
@@ -753,19 +813,19 @@ function getImportantStrategy(important) {
|
|
|
753
813
|
return;
|
|
754
814
|
}
|
|
755
815
|
rule.walkDecls((d)=>{
|
|
756
|
-
if (d.parent.type ===
|
|
816
|
+
if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
|
|
757
817
|
d.important = true;
|
|
758
818
|
}
|
|
759
819
|
});
|
|
760
820
|
};
|
|
761
821
|
}
|
|
762
|
-
if (typeof important ===
|
|
822
|
+
if (typeof important === 'string') {
|
|
763
823
|
return (rule)=>{
|
|
764
824
|
if (inKeyframes(rule)) {
|
|
765
825
|
return;
|
|
766
826
|
}
|
|
767
827
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
768
|
-
return
|
|
828
|
+
return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
|
|
769
829
|
});
|
|
770
830
|
};
|
|
771
831
|
}
|
|
@@ -787,11 +847,11 @@ function generateRules(candidates, context) {
|
|
|
787
847
|
continue;
|
|
788
848
|
}
|
|
789
849
|
context.classCache.set(candidate, matches);
|
|
790
|
-
var
|
|
791
|
-
let rules = (
|
|
850
|
+
var _context_candidateRuleCache_get;
|
|
851
|
+
let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
|
|
792
852
|
context.candidateRuleCache.set(candidate, rules);
|
|
793
853
|
for (const match of matches){
|
|
794
|
-
let [{ sort
|
|
854
|
+
let [{ sort, options }, rule] = match;
|
|
795
855
|
if (options.respectImportant && strategy) {
|
|
796
856
|
let container = _postcss.default.root({
|
|
797
857
|
nodes: [
|
|
@@ -813,5 +873,5 @@ function generateRules(candidates, context) {
|
|
|
813
873
|
return allRules;
|
|
814
874
|
}
|
|
815
875
|
function isArbitraryValue(input) {
|
|
816
|
-
return input.startsWith(
|
|
876
|
+
return input.startsWith('[') && input.endsWith(']');
|
|
817
877
|
}
|