tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421
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 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +12 -15
- package/lib/cli/build/plugin.js +107 -167
- package/lib/cli/build/utils.js +13 -13
- package/lib/cli/build/watching.js +10 -10
- package/lib/cli/help/index.js +11 -11
- package/lib/cli/index.js +60 -61
- package/lib/cli/init/index.js +16 -16
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +2018 -1905
- package/lib/css/preflight.css +18 -12
- package/lib/featureFlags.js +17 -23
- package/lib/index.js +1 -1
- package/lib/lib/cacheInvalidation.js +3 -3
- package/lib/lib/collapseAdjacentRules.js +6 -6
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/content.js +39 -32
- package/lib/lib/defaultExtractor.js +40 -17
- package/lib/lib/evaluateTailwindFunctions.js +23 -23
- package/lib/lib/expandApplyAtRules.js +37 -18
- package/lib/lib/expandTailwindAtRules.js +49 -85
- package/lib/lib/findAtConfigPath.js +5 -5
- package/lib/lib/generateRules.js +82 -55
- package/lib/lib/getModuleDependencies.js +23 -23
- package/lib/lib/load-config.js +21 -6
- package/lib/lib/normalizeTailwindDirectives.js +36 -21
- package/lib/lib/offsets.js +97 -48
- package/lib/lib/partitionApplyAtRules.js +2 -2
- package/lib/lib/regex.js +5 -5
- package/lib/lib/resolveDefaultsAtRules.js +27 -25
- package/lib/lib/setupContextUtils.js +195 -167
- package/lib/lib/setupTrackingContext.js +4 -5
- package/lib/lib/sharedState.js +10 -10
- package/lib/lib/substituteScreenAtRules.js +4 -4
- package/lib/plugin.js +8 -124
- package/lib/postcss-plugins/nesting/index.js +2 -2
- package/lib/postcss-plugins/nesting/plugin.js +11 -11
- package/lib/processTailwindFeatures.js +3 -5
- package/lib/public/colors.js +264 -264
- package/lib/util/applyImportantSelector.js +2 -2
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +19 -19
- package/lib/util/createUtilityPlugin.js +3 -3
- package/lib/util/dataTypes.js +170 -113
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +24 -19
- package/lib/util/getAllConfigs.js +4 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +2 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
- package/lib/util/log.js +6 -23
- package/lib/util/nameClass.js +4 -4
- package/lib/util/negateValue.js +8 -8
- package/lib/util/normalizeConfig.js +63 -94
- package/lib/util/normalizeScreens.js +18 -18
- package/lib/util/parseAnimationValue.js +38 -38
- package/lib/util/parseBoxShadowValue.js +18 -18
- package/lib/util/parseDependency.js +4 -4
- package/lib/util/parseGlob.js +4 -4
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +36 -21
- package/lib/util/prefixSelector.js +4 -4
- package/lib/util/pseudoElements.js +72 -69
- package/lib/util/removeAlphaVariables.js +1 -1
- package/lib/util/resolveConfig.js +11 -15
- package/lib/util/resolveConfigPath.js +6 -6
- package/lib/util/responsive.js +1 -1
- package/lib/util/splitAtTopLevelOnly.js +3 -3
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +24 -24
- package/lib/util/validateConfig.js +9 -20
- package/lib/util/validateFormalSyntax.js +5 -5
- package/lib/util/withAlphaVariable.js +5 -5
- package/lib/value-parser/index.js +5 -5
- package/lib/value-parser/parse.js +43 -43
- package/lib/value-parser/stringify.js +11 -11
- package/lib/value-parser/unit.js +5 -5
- package/lib/value-parser/walk.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +41 -36
- package/peers/index.js +96503 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +118 -31
- package/src/css/preflight.css +18 -12
- package/src/featureFlags.js +3 -5
- package/src/lib/content.js +39 -30
- package/src/lib/defaultExtractor.js +29 -6
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +39 -8
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/dataTypes.js +72 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +20 -0
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +68 -8
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +28 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
package/lib/lib/offsets.js
CHANGED
|
@@ -17,6 +17,44 @@ function _interop_require_default(obj) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
class Offsets {
|
|
20
|
+
constructor(){
|
|
21
|
+
/**
|
|
22
|
+
* Offsets for the next rule in a given layer
|
|
23
|
+
*
|
|
24
|
+
* @type {Record<Layer, bigint>}
|
|
25
|
+
*/ this.offsets = {
|
|
26
|
+
defaults: 0n,
|
|
27
|
+
base: 0n,
|
|
28
|
+
components: 0n,
|
|
29
|
+
utilities: 0n,
|
|
30
|
+
variants: 0n,
|
|
31
|
+
user: 0n
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Positions for a given layer
|
|
35
|
+
*
|
|
36
|
+
* @type {Record<Layer, bigint>}
|
|
37
|
+
*/ this.layerPositions = {
|
|
38
|
+
defaults: 0n,
|
|
39
|
+
base: 1n,
|
|
40
|
+
components: 2n,
|
|
41
|
+
utilities: 3n,
|
|
42
|
+
// There isn't technically a "user" layer, but we need to give it a position
|
|
43
|
+
// Because it's used for ordering user-css from @apply
|
|
44
|
+
user: 4n,
|
|
45
|
+
variants: 5n
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The total number of functions currently registered across all variants (including arbitrary variants)
|
|
49
|
+
*
|
|
50
|
+
* @type {bigint}
|
|
51
|
+
*/ this.reservedVariantBits = 0n;
|
|
52
|
+
/**
|
|
53
|
+
* Positions for a given variant
|
|
54
|
+
*
|
|
55
|
+
* @type {Map<string, bigint>}
|
|
56
|
+
*/ this.variantOffsets = new Map();
|
|
57
|
+
}
|
|
20
58
|
/**
|
|
21
59
|
* @param {Layer} layer
|
|
22
60
|
* @returns {RuleOffset}
|
|
@@ -28,15 +66,19 @@ class Offsets {
|
|
|
28
66
|
variants: 0n,
|
|
29
67
|
parallelIndex: 0n,
|
|
30
68
|
index: this.offsets[layer]++,
|
|
69
|
+
propertyOffset: 0n,
|
|
70
|
+
property: "",
|
|
31
71
|
options: []
|
|
32
72
|
};
|
|
33
73
|
}
|
|
34
74
|
/**
|
|
75
|
+
* @param {string} name
|
|
35
76
|
* @returns {RuleOffset}
|
|
36
|
-
*/ arbitraryProperty() {
|
|
77
|
+
*/ arbitraryProperty(name) {
|
|
37
78
|
return {
|
|
38
|
-
...this.create(
|
|
39
|
-
arbitrary: 1n
|
|
79
|
+
...this.create("utilities"),
|
|
80
|
+
arbitrary: 1n,
|
|
81
|
+
property: name
|
|
40
82
|
};
|
|
41
83
|
}
|
|
42
84
|
/**
|
|
@@ -51,7 +93,7 @@ class Offsets {
|
|
|
51
93
|
throw new Error(`Cannot find offset for unknown variant ${variant}`);
|
|
52
94
|
}
|
|
53
95
|
return {
|
|
54
|
-
...this.create(
|
|
96
|
+
...this.create("variants"),
|
|
55
97
|
variants: offset << BigInt(index)
|
|
56
98
|
};
|
|
57
99
|
}
|
|
@@ -64,8 +106,8 @@ class Offsets {
|
|
|
64
106
|
options.variant = variant.variants;
|
|
65
107
|
return {
|
|
66
108
|
...rule,
|
|
67
|
-
layer:
|
|
68
|
-
parentLayer: rule.layer ===
|
|
109
|
+
layer: "variants",
|
|
110
|
+
parentLayer: rule.layer === "variants" ? rule.parentLayer : rule.layer,
|
|
69
111
|
variants: rule.variants | variant.variants,
|
|
70
112
|
options: options.sort ? [].concat(options, rule.options) : rule.options,
|
|
71
113
|
// TODO: Technically this is wrong. We should be handling parallel index on a per variant basis.
|
|
@@ -118,7 +160,7 @@ class Offsets {
|
|
|
118
160
|
// @see `RuleOffset.parallelIndex`
|
|
119
161
|
this.reservedVariantBits += BigInt(fnCount);
|
|
120
162
|
return {
|
|
121
|
-
...this.create(
|
|
163
|
+
...this.create("variants"),
|
|
122
164
|
variants: this.variantOffsets.get(variant)
|
|
123
165
|
};
|
|
124
166
|
}
|
|
@@ -176,6 +218,10 @@ class Offsets {
|
|
|
176
218
|
if (a.arbitrary !== b.arbitrary) {
|
|
177
219
|
return a.arbitrary - b.arbitrary;
|
|
178
220
|
}
|
|
221
|
+
// Always sort arbitrary properties alphabetically
|
|
222
|
+
if (a.propertyOffset !== b.propertyOffset) {
|
|
223
|
+
return a.propertyOffset - b.propertyOffset;
|
|
224
|
+
}
|
|
179
225
|
// Sort utilities, components, etc… in the order they were registered
|
|
180
226
|
return a.index - b.index;
|
|
181
227
|
}
|
|
@@ -187,7 +233,7 @@ class Offsets {
|
|
|
187
233
|
* be in alphabetical order starting from the offset of the first arbitrary variant.
|
|
188
234
|
*/ recalculateVariantOffsets() {
|
|
189
235
|
// Sort the variants by their name
|
|
190
|
-
let variants = Array.from(this.variantOffsets.entries()).filter(([v])=>v.startsWith(
|
|
236
|
+
let variants = Array.from(this.variantOffsets.entries()).filter(([v])=>v.startsWith("[")).sort(([a], [z])=>fastCompare(a, z));
|
|
191
237
|
// Sort the list of offsets
|
|
192
238
|
// This is not necessarily a discrete range of numbers which is why
|
|
193
239
|
// we're using sort instead of creating a range from min/max
|
|
@@ -208,7 +254,7 @@ class Offsets {
|
|
|
208
254
|
*/ remapArbitraryVariantOffsets(list) {
|
|
209
255
|
let mapping = this.recalculateVariantOffsets();
|
|
210
256
|
// No arbitrary variants? Nothing to do.
|
|
211
|
-
//
|
|
257
|
+
// Everyhing already in order? Nothing to do.
|
|
212
258
|
if (mapping.length === 0) {
|
|
213
259
|
return list;
|
|
214
260
|
}
|
|
@@ -229,48 +275,51 @@ class Offsets {
|
|
|
229
275
|
* @template T
|
|
230
276
|
* @param {[RuleOffset, T][]} list
|
|
231
277
|
* @returns {[RuleOffset, T][]}
|
|
278
|
+
*/ sortArbitraryProperties(list) {
|
|
279
|
+
// Collect all known arbitrary properties
|
|
280
|
+
let known = new Set();
|
|
281
|
+
for (let [offset] of list){
|
|
282
|
+
if (offset.arbitrary === 1n) {
|
|
283
|
+
known.add(offset.property);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// No arbitrary properties? Nothing to do.
|
|
287
|
+
if (known.size === 0) {
|
|
288
|
+
return list;
|
|
289
|
+
}
|
|
290
|
+
// Sort the properties alphabetically
|
|
291
|
+
let properties = Array.from(known).sort();
|
|
292
|
+
// Create a map from the property name to its offset
|
|
293
|
+
let offsets = new Map();
|
|
294
|
+
let offset = 1n;
|
|
295
|
+
for (let property of properties){
|
|
296
|
+
offsets.set(property, offset++);
|
|
297
|
+
}
|
|
298
|
+
// Apply the sorted offsets to the list
|
|
299
|
+
return list.map((item)=>{
|
|
300
|
+
let [offset, rule] = item;
|
|
301
|
+
var _offsets_get;
|
|
302
|
+
offset = {
|
|
303
|
+
...offset,
|
|
304
|
+
propertyOffset: (_offsets_get = offsets.get(offset.property)) !== null && _offsets_get !== void 0 ? _offsets_get : 0n
|
|
305
|
+
};
|
|
306
|
+
return [
|
|
307
|
+
offset,
|
|
308
|
+
rule
|
|
309
|
+
];
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* @template T
|
|
314
|
+
* @param {[RuleOffset, T][]} list
|
|
315
|
+
* @returns {[RuleOffset, T][]}
|
|
232
316
|
*/ sort(list) {
|
|
317
|
+
// Sort arbitrary variants so they're in alphabetical order
|
|
233
318
|
list = this.remapArbitraryVariantOffsets(list);
|
|
319
|
+
// Sort arbitrary properties so they're in alphabetical order
|
|
320
|
+
list = this.sortArbitraryProperties(list);
|
|
234
321
|
return list.sort(([a], [b])=>(0, _bigSign.default)(this.compare(a, b)));
|
|
235
322
|
}
|
|
236
|
-
constructor(){
|
|
237
|
-
/**
|
|
238
|
-
* Offsets for the next rule in a given layer
|
|
239
|
-
*
|
|
240
|
-
* @type {Record<Layer, bigint>}
|
|
241
|
-
*/ this.offsets = {
|
|
242
|
-
defaults: 0n,
|
|
243
|
-
base: 0n,
|
|
244
|
-
components: 0n,
|
|
245
|
-
utilities: 0n,
|
|
246
|
-
variants: 0n,
|
|
247
|
-
user: 0n
|
|
248
|
-
};
|
|
249
|
-
/**
|
|
250
|
-
* Positions for a given layer
|
|
251
|
-
*
|
|
252
|
-
* @type {Record<Layer, bigint>}
|
|
253
|
-
*/ this.layerPositions = {
|
|
254
|
-
defaults: 0n,
|
|
255
|
-
base: 1n,
|
|
256
|
-
components: 2n,
|
|
257
|
-
utilities: 3n,
|
|
258
|
-
// There isn't technically a "user" layer, but we need to give it a position
|
|
259
|
-
// Because it's used for ordering user-css from @apply
|
|
260
|
-
user: 4n,
|
|
261
|
-
variants: 5n
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* The total number of functions currently registered across all variants (including arbitrary variants)
|
|
265
|
-
*
|
|
266
|
-
* @type {bigint}
|
|
267
|
-
*/ this.reservedVariantBits = 0n;
|
|
268
|
-
/**
|
|
269
|
-
* Positions for a given variant
|
|
270
|
-
*
|
|
271
|
-
* @type {Map<string, bigint>}
|
|
272
|
-
*/ this.variantOffsets = new Map();
|
|
273
|
-
}
|
|
274
323
|
}
|
|
275
324
|
/**
|
|
276
325
|
*
|
|
@@ -290,7 +339,7 @@ class Offsets {
|
|
|
290
339
|
* Using `.sort()` without a custom compare function is faster
|
|
291
340
|
* But you can only use that if you're sorting an array of
|
|
292
341
|
* only strings. If you're sorting strings inside objects
|
|
293
|
-
* or arrays, you need
|
|
342
|
+
* or arrays, you need must use a custom compare function.
|
|
294
343
|
*
|
|
295
344
|
* @param {string} a
|
|
296
345
|
* @param {string} b
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
function partitionRules(root) {
|
|
12
12
|
if (!root.walkAtRules) return;
|
|
13
13
|
let applyParents = new Set();
|
|
14
|
-
root.walkAtRules(
|
|
14
|
+
root.walkAtRules("apply", (rule)=>{
|
|
15
15
|
applyParents.add(rule.parent);
|
|
16
16
|
});
|
|
17
17
|
if (applyParents.size === 0) {
|
|
@@ -21,7 +21,7 @@ function partitionRules(root) {
|
|
|
21
21
|
let nodeGroups = [];
|
|
22
22
|
let lastGroup = [];
|
|
23
23
|
for (let node of rule.nodes){
|
|
24
|
-
if (node.type ===
|
|
24
|
+
if (node.type === "atrule" && node.name === "apply") {
|
|
25
25
|
if (lastGroup.length > 0) {
|
|
26
26
|
nodeGroups.push(lastGroup);
|
|
27
27
|
lastGroup = [];
|
package/lib/lib/regex.js
CHANGED
|
@@ -40,16 +40,16 @@ const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
|
|
|
40
40
|
source
|
|
41
41
|
];
|
|
42
42
|
source = source.map((item)=>item instanceof RegExp ? item.source : item);
|
|
43
|
-
return source.join(
|
|
43
|
+
return source.join("");
|
|
44
44
|
}
|
|
45
45
|
function pattern(source) {
|
|
46
|
-
return new RegExp(toSource(source),
|
|
46
|
+
return new RegExp(toSource(source), "g");
|
|
47
47
|
}
|
|
48
48
|
function withoutCapturing(source) {
|
|
49
|
-
return new RegExp(`(?:${toSource(source)})`,
|
|
49
|
+
return new RegExp(`(?:${toSource(source)})`, "g");
|
|
50
50
|
}
|
|
51
51
|
function any(sources) {
|
|
52
|
-
return `(?:${sources.map(toSource).join(
|
|
52
|
+
return `(?:${sources.map(toSource).join("|")})`;
|
|
53
53
|
}
|
|
54
54
|
function optional(source) {
|
|
55
55
|
return `(?:${toSource(source)})?`;
|
|
@@ -70,5 +70,5 @@ function nestedBrackets(open, close, depth = 1) {
|
|
|
70
70
|
]);
|
|
71
71
|
}
|
|
72
72
|
function escape(string) {
|
|
73
|
-
return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL,
|
|
73
|
+
return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
|
|
74
74
|
}
|
|
@@ -27,8 +27,8 @@ function _interop_require_default(obj) {
|
|
|
27
27
|
let getNode = {
|
|
28
28
|
id (node) {
|
|
29
29
|
return _postcssselectorparser.default.attribute({
|
|
30
|
-
attribute:
|
|
31
|
-
operator:
|
|
30
|
+
attribute: "id",
|
|
31
|
+
operator: "=",
|
|
32
32
|
value: node.value,
|
|
33
33
|
quoteMark: '"'
|
|
34
34
|
});
|
|
@@ -37,31 +37,31 @@ let getNode = {
|
|
|
37
37
|
function minimumImpactSelector(nodes) {
|
|
38
38
|
let rest = nodes.filter((node)=>{
|
|
39
39
|
// Keep non-pseudo nodes
|
|
40
|
-
if (node.type !==
|
|
40
|
+
if (node.type !== "pseudo") return true;
|
|
41
41
|
// Keep pseudo nodes that have subnodes
|
|
42
42
|
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
43
43
|
if (node.nodes.length > 0) return true;
|
|
44
44
|
// Keep pseudo `elements`
|
|
45
45
|
// This implicitly means that we ignore pseudo `classes`
|
|
46
|
-
return node.value.startsWith(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
return node.value.startsWith("::") || [
|
|
47
|
+
":before",
|
|
48
|
+
":after",
|
|
49
|
+
":first-line",
|
|
50
|
+
":first-letter"
|
|
51
51
|
].includes(node.value);
|
|
52
52
|
}).reverse();
|
|
53
53
|
let searchFor = new Set([
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
"tag",
|
|
55
|
+
"class",
|
|
56
|
+
"id",
|
|
57
|
+
"attribute"
|
|
58
58
|
]);
|
|
59
59
|
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
|
|
60
|
-
if (splitPointIdx === -1) return rest.reverse().join(
|
|
60
|
+
if (splitPointIdx === -1) return rest.reverse().join("").trim();
|
|
61
61
|
let node = rest[splitPointIdx];
|
|
62
62
|
let bestNode = getNode[node.type] ? getNode[node.type](node) : node;
|
|
63
63
|
rest = rest.slice(0, splitPointIdx);
|
|
64
|
-
let combinatorIdx = rest.findIndex((n)=>n.type ===
|
|
64
|
+
let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
|
|
65
65
|
if (combinatorIdx !== -1) {
|
|
66
66
|
rest.splice(0, combinatorIdx);
|
|
67
67
|
rest.unshift(_postcssselectorparser.default.universal());
|
|
@@ -69,11 +69,11 @@ function minimumImpactSelector(nodes) {
|
|
|
69
69
|
return [
|
|
70
70
|
bestNode,
|
|
71
71
|
...rest.reverse()
|
|
72
|
-
].join(
|
|
72
|
+
].join("").trim();
|
|
73
73
|
}
|
|
74
74
|
let elementSelectorParser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
75
75
|
return selectors.map((s)=>{
|
|
76
|
-
let nodes = s.split((n)=>n.type ===
|
|
76
|
+
let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
|
|
77
77
|
return minimumImpactSelector(nodes);
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -84,11 +84,11 @@ function extractElementSelector(selector) {
|
|
|
84
84
|
}
|
|
85
85
|
return cache.get(selector);
|
|
86
86
|
}
|
|
87
|
-
function resolveDefaultsAtRules({ tailwindConfig
|
|
87
|
+
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
88
88
|
return (root)=>{
|
|
89
89
|
let variableNodeMap = new Map();
|
|
90
90
|
/** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
|
|
91
|
-
root.walkAtRules(
|
|
91
|
+
root.walkAtRules("defaults", (rule)=>{
|
|
92
92
|
if (rule.nodes && rule.nodes.length > 0) {
|
|
93
93
|
universals.add(rule);
|
|
94
94
|
return;
|
|
@@ -100,7 +100,7 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
100
100
|
variableNodeMap.get(variable).add(rule.parent);
|
|
101
101
|
rule.remove();
|
|
102
102
|
});
|
|
103
|
-
if ((0, _featureFlags.flagEnabled)(tailwindConfig,
|
|
103
|
+
if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
104
104
|
for (let universal of universals){
|
|
105
105
|
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
106
106
|
var _variableNodeMap_get;
|
|
@@ -111,14 +111,16 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
111
111
|
// we consider them separately because merging the declarations into
|
|
112
112
|
// a single rule will cause browsers that do not understand the
|
|
113
113
|
// vendor prefix to throw out the whole rule
|
|
114
|
-
|
|
114
|
+
// Additionally if a selector contains `:has` we also consider
|
|
115
|
+
// it separately because FF only recently gained support for it
|
|
116
|
+
let selectorGroupName = selector.includes(":-") || selector.includes("::-") || selector.includes(":has") ? selector : "__DEFAULT__";
|
|
115
117
|
var _selectorGroups_get;
|
|
116
118
|
let selectors = (_selectorGroups_get = selectorGroups.get(selectorGroupName)) !== null && _selectorGroups_get !== void 0 ? _selectorGroups_get : new Set();
|
|
117
119
|
selectorGroups.set(selectorGroupName, selectors);
|
|
118
120
|
selectors.add(selector);
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
|
-
if ((0, _featureFlags.flagEnabled)(tailwindConfig,
|
|
123
|
+
if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
122
124
|
if (selectorGroups.size === 0) {
|
|
123
125
|
universal.remove();
|
|
124
126
|
continue;
|
|
@@ -139,9 +141,9 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
139
141
|
} else if (universals.size) {
|
|
140
142
|
let universalRule = _postcss.default.rule({
|
|
141
143
|
selectors: [
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
"*",
|
|
145
|
+
"::before",
|
|
146
|
+
"::after"
|
|
145
147
|
]
|
|
146
148
|
});
|
|
147
149
|
for (let universal of universals){
|
|
@@ -156,7 +158,7 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
156
158
|
}
|
|
157
159
|
let backdropRule = universalRule.clone({
|
|
158
160
|
selectors: [
|
|
159
|
-
|
|
161
|
+
"::backdrop"
|
|
160
162
|
]
|
|
161
163
|
});
|
|
162
164
|
universalRule.after(backdropRule);
|