tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-insiders.b2e3cf2
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/lib/cli/build/deps.js +10 -18
- package/lib/cli/build/index.js +10 -41
- package/lib/cli/build/plugin.js +87 -268
- package/lib/cli/build/utils.js +18 -40
- package/lib/cli/build/watching.js +35 -151
- package/lib/cli/help/index.js +15 -58
- package/lib/cli/index.js +61 -120
- package/lib/cli/init/index.js +21 -43
- package/lib/cli-peer-dependencies.js +13 -15
- package/lib/cli.js +1 -5
- package/lib/corePluginList.js +3 -4
- package/lib/corePlugins.js +394 -857
- package/lib/featureFlags.js +14 -34
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +29 -75
- package/lib/lib/collapseAdjacentRules.js +22 -43
- package/lib/lib/collapseDuplicateDeclarations.js +27 -68
- package/lib/lib/content.js +37 -126
- package/lib/lib/defaultExtractor.js +96 -199
- package/lib/lib/detectNesting.js +12 -36
- package/lib/lib/evaluateTailwindFunctions.js +101 -188
- package/lib/lib/expandApplyAtRules.js +177 -482
- package/lib/lib/expandTailwindAtRules.js +69 -237
- package/lib/lib/findAtConfigPath.js +13 -30
- package/lib/lib/generateRules.js +349 -765
- package/lib/lib/getModuleDependencies.js +27 -63
- package/lib/lib/load-config.js +16 -24
- package/lib/lib/normalizeTailwindDirectives.js +26 -70
- package/lib/lib/offsets.js +61 -224
- package/lib/lib/partitionApplyAtRules.js +29 -51
- package/lib/lib/regex.js +22 -30
- package/lib/lib/remap-bitfield.js +9 -84
- package/lib/lib/resolveDefaultsAtRules.js +50 -116
- package/lib/lib/setupContextUtils.js +576 -1099
- package/lib/lib/setupTrackingContext.js +54 -143
- package/lib/lib/sharedState.js +15 -59
- package/lib/lib/substituteScreenAtRules.js +8 -16
- package/lib/oxide/cli/build/deps.js +17 -32
- package/lib/oxide/cli/build/index.js +10 -40
- package/lib/oxide/cli/build/plugin.js +87 -267
- package/lib/oxide/cli/build/utils.js +18 -39
- package/lib/oxide/cli/build/watching.js +34 -149
- package/lib/oxide/cli/help/index.js +15 -57
- package/lib/oxide/cli/index.js +66 -127
- package/lib/oxide/cli/init/index.js +17 -36
- package/lib/oxide/cli.js +2 -3
- package/lib/plugin.js +30 -57
- package/lib/postcss-plugins/nesting/index.js +6 -10
- package/lib/postcss-plugins/nesting/plugin.js +17 -60
- package/lib/processTailwindFeatures.js +8 -37
- package/lib/public/colors.js +15 -22
- package/lib/public/create-plugin.js +5 -8
- package/lib/public/default-config.js +5 -9
- package/lib/public/default-theme.js +5 -9
- package/lib/public/load-config.js +4 -6
- package/lib/public/resolve-config.js +4 -6
- package/lib/util/applyImportantSelector.js +15 -24
- package/lib/util/bigSign.js +6 -7
- package/lib/util/buildMediaQuery.js +10 -17
- package/lib/util/cloneDeep.js +9 -17
- package/lib/util/cloneNodes.js +14 -27
- package/lib/util/color.js +45 -81
- package/lib/util/configurePlugins.js +9 -16
- package/lib/util/createPlugin.js +8 -15
- package/lib/util/createUtilityPlugin.js +15 -27
- package/lib/util/dataTypes.js +23 -144
- package/lib/util/defaults.js +9 -19
- package/lib/util/escapeClassName.js +6 -10
- package/lib/util/escapeCommas.js +6 -7
- package/lib/util/flattenColorPalette.js +6 -8
- package/lib/util/formatVariantSelector.js +49 -190
- package/lib/util/getAllConfigs.js +35 -42
- package/lib/util/hashConfig.js +6 -8
- package/lib/util/isKeyframeRule.js +6 -7
- package/lib/util/isPlainObject.js +8 -11
- package/lib/util/isSyntacticallyValidPropertyValue.js +13 -42
- package/lib/util/log.js +7 -14
- package/lib/util/nameClass.js +6 -21
- package/lib/util/negateValue.js +10 -26
- package/lib/util/normalizeConfig.js +63 -240
- package/lib/util/normalizeScreens.js +70 -137
- package/lib/util/parseAnimationValue.js +13 -61
- package/lib/util/parseBoxShadowValue.js +12 -57
- package/lib/util/parseDependency.js +13 -37
- package/lib/util/parseGlob.js +7 -22
- package/lib/util/parseObjectStyles.js +17 -26
- package/lib/util/pluginUtils.js +69 -176
- package/lib/util/prefixSelector.js +11 -28
- package/lib/util/pseudoElements.js +29 -105
- package/lib/util/removeAlphaVariables.js +8 -21
- package/lib/util/resolveConfig.js +103 -220
- package/lib/util/resolveConfigPath.js +12 -38
- package/lib/util/responsive.js +4 -6
- package/lib/util/splitAtTopLevelOnly.js +10 -44
- package/lib/util/tap.js +6 -8
- package/lib/util/toColorValue.js +6 -7
- package/lib/util/toPath.js +8 -26
- package/lib/util/transformThemeValue.js +12 -45
- package/lib/util/validateConfig.js +14 -22
- package/lib/util/validateFormalSyntax.js +5 -11
- package/lib/util/withAlphaVariable.js +28 -48
- package/package.json +3 -3
- package/peers/index.js +14 -16
- package/src/cli/build/plugin.js +1 -1
- package/src/cli.js +1 -1
- package/src/corePlugins.js +16 -17
- package/src/featureFlags.js +2 -3
- package/src/index.js +1 -5
- package/src/lib/expandTailwindAtRules.js +2 -2
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +1 -1
|
@@ -1,56 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>expandApplyAtRules
|
|
8
|
-
});
|
|
9
|
-
function partitionRules(root) {
|
|
10
|
-
if (!root.walkAtRules) return;
|
|
11
|
-
let applyParents = new Set();
|
|
12
|
-
root.walkAtRules("apply", (rule)=>{
|
|
13
|
-
applyParents.add(rule.parent);
|
|
14
|
-
});
|
|
15
|
-
if (applyParents.size === 0) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
for (let rule of applyParents){
|
|
19
|
-
let nodeGroups = [];
|
|
20
|
-
let lastGroup = [];
|
|
21
|
-
for (let node of rule.nodes){
|
|
22
|
-
if (node.type === "atrule" && node.name === "apply") {
|
|
23
|
-
if (lastGroup.length > 0) {
|
|
24
|
-
nodeGroups.push(lastGroup);
|
|
25
|
-
lastGroup = [];
|
|
26
|
-
}
|
|
27
|
-
nodeGroups.push([
|
|
28
|
-
node
|
|
29
|
-
]);
|
|
30
|
-
} else {
|
|
31
|
-
lastGroup.push(node);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (lastGroup.length > 0) {
|
|
35
|
-
nodeGroups.push(lastGroup);
|
|
36
|
-
}
|
|
37
|
-
if (nodeGroups.length === 1) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
for (let group of [
|
|
41
|
-
...nodeGroups
|
|
42
|
-
].reverse()){
|
|
43
|
-
let clone = rule.clone({
|
|
44
|
-
nodes: []
|
|
45
|
-
});
|
|
46
|
-
clone.append(group);
|
|
47
|
-
rule.after(clone);
|
|
48
|
-
}
|
|
49
|
-
rule.remove();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
2
|
function expandApplyAtRules() {
|
|
53
3
|
return (root)=>{
|
|
54
|
-
|
|
4
|
+
!function(root) {
|
|
5
|
+
if (!root.walkAtRules) return;
|
|
6
|
+
let applyParents = new Set();
|
|
7
|
+
if (root.walkAtRules("apply", (rule)=>{
|
|
8
|
+
applyParents.add(rule.parent);
|
|
9
|
+
}), 0 !== applyParents.size) for (let rule of applyParents){
|
|
10
|
+
let nodeGroups = [], lastGroup = [];
|
|
11
|
+
for (let node of rule.nodes)"atrule" === node.type && "apply" === node.name ? (lastGroup.length > 0 && (nodeGroups.push(lastGroup), lastGroup = []), nodeGroups.push([
|
|
12
|
+
node
|
|
13
|
+
])) : lastGroup.push(node);
|
|
14
|
+
if (lastGroup.length > 0 && nodeGroups.push(lastGroup), 1 !== nodeGroups.length) {
|
|
15
|
+
for (let group of [
|
|
16
|
+
...nodeGroups
|
|
17
|
+
].reverse()){
|
|
18
|
+
let clone = rule.clone({
|
|
19
|
+
nodes: []
|
|
20
|
+
});
|
|
21
|
+
clone.append(group), rule.after(clone);
|
|
22
|
+
}
|
|
23
|
+
rule.remove();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}(root);
|
|
55
27
|
};
|
|
56
28
|
}
|
|
29
|
+
Object.defineProperty(exports, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), Object.defineProperty(exports, "default", {
|
|
32
|
+
enumerable: !0,
|
|
33
|
+
get: ()=>expandApplyAtRules
|
|
34
|
+
});
|
package/lib/lib/regex.js
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
function _export(target, all) {
|
|
3
|
+
value: !0
|
|
4
|
+
}), function(target, all) {
|
|
6
5
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable:
|
|
6
|
+
enumerable: !0,
|
|
8
7
|
get: all[name]
|
|
9
8
|
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
9
|
+
}(exports, {
|
|
12
10
|
pattern: ()=>pattern,
|
|
13
11
|
withoutCapturing: ()=>withoutCapturing,
|
|
14
12
|
any: ()=>any,
|
|
15
13
|
optional: ()=>optional,
|
|
16
14
|
zeroOrMore: ()=>zeroOrMore,
|
|
17
|
-
nestedBrackets: ()=>nestedBrackets,
|
|
15
|
+
nestedBrackets: ()=>function nestedBrackets(open, close, depth = 1) {
|
|
16
|
+
return withoutCapturing([
|
|
17
|
+
escape(open),
|
|
18
|
+
/[^\s]*/,
|
|
19
|
+
1 === depth ? `[^${escape(open)}${escape(close)}\s]*` : any([
|
|
20
|
+
`[^${escape(open)}${escape(close)}\s]*`,
|
|
21
|
+
nestedBrackets(open, close, depth - 1)
|
|
22
|
+
]),
|
|
23
|
+
/[^\s]*/,
|
|
24
|
+
escape(close)
|
|
25
|
+
]);
|
|
26
|
+
},
|
|
18
27
|
escape: ()=>escape
|
|
19
28
|
});
|
|
20
|
-
const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @param {string|RegExp|Array<string|RegExp>} source
|
|
24
|
-
*/ function toSource(source) {
|
|
25
|
-
source = Array.isArray(source) ? source : [
|
|
29
|
+
const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g, REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
|
|
30
|
+
function toSource(source) {
|
|
31
|
+
return (source = (source = Array.isArray(source) ? source : [
|
|
26
32
|
source
|
|
27
|
-
];
|
|
28
|
-
source = source.map((item)=>item instanceof RegExp ? item.source : item);
|
|
29
|
-
return source.join("");
|
|
33
|
+
]).map((item)=>item instanceof RegExp ? item.source : item)).join("");
|
|
30
34
|
}
|
|
31
35
|
function pattern(source) {
|
|
32
|
-
return
|
|
36
|
+
return RegExp(toSource(source), "g");
|
|
33
37
|
}
|
|
34
38
|
function withoutCapturing(source) {
|
|
35
|
-
return
|
|
39
|
+
return RegExp(`(?:${toSource(source)})`, "g");
|
|
36
40
|
}
|
|
37
41
|
function any(sources) {
|
|
38
42
|
return `(?:${sources.map(toSource).join("|")})`;
|
|
@@ -43,18 +47,6 @@ function optional(source) {
|
|
|
43
47
|
function zeroOrMore(source) {
|
|
44
48
|
return `(?:${toSource(source)})*`;
|
|
45
49
|
}
|
|
46
|
-
function nestedBrackets(open, close, depth = 1) {
|
|
47
|
-
return withoutCapturing([
|
|
48
|
-
escape(open),
|
|
49
|
-
/[^\s]*/,
|
|
50
|
-
depth === 1 ? `[^${escape(open)}${escape(close)}\s]*` : any([
|
|
51
|
-
`[^${escape(open)}${escape(close)}\s]*`,
|
|
52
|
-
nestedBrackets(open, close, depth - 1)
|
|
53
|
-
]),
|
|
54
|
-
/[^\s]*/,
|
|
55
|
-
escape(close)
|
|
56
|
-
]);
|
|
57
|
-
}
|
|
58
50
|
function escape(string) {
|
|
59
51
|
return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
|
|
60
52
|
}
|
|
@@ -1,87 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* We must remap all the old bits to new bits for each set variant
|
|
4
|
-
* Only arbitrary variants are considered as those are the only
|
|
5
|
-
* ones that need to be re-sorted at this time
|
|
6
|
-
*
|
|
7
|
-
* An iterated process that removes and sets individual bits simultaneously
|
|
8
|
-
* will not work because we may have a new bit that is also a later old bit
|
|
9
|
-
* This means that we would be removing a previously set bit which we don't
|
|
10
|
-
* want to do
|
|
11
|
-
*
|
|
12
|
-
* For example (assume `bN` = `1<<N`)
|
|
13
|
-
* Given the "total" mapping `[[b1, b3], [b2, b4], [b3, b1], [b4, b2]]`
|
|
14
|
-
* The mapping is "total" because:
|
|
15
|
-
* 1. Every input and output is accounted for
|
|
16
|
-
* 2. All combinations are unique
|
|
17
|
-
* 3. No one input maps to multiple outputs and vice versa
|
|
18
|
-
* And, given an offset with all bits set:
|
|
19
|
-
* V = b1 | b2 | b3 | b4
|
|
20
|
-
*
|
|
21
|
-
* Let's explore the issue with removing and setting bits simultaneously:
|
|
22
|
-
* V & ~b1 | b3 = b2 | b3 | b4
|
|
23
|
-
* V & ~b2 | b4 = b3 | b4
|
|
24
|
-
* V & ~b3 | b1 = b1 | b4
|
|
25
|
-
* V & ~b4 | b2 = b1 | b2
|
|
26
|
-
*
|
|
27
|
-
* As you can see, we end up with the wrong result.
|
|
28
|
-
* This is because we're removing a bit that was previously set.
|
|
29
|
-
* And, thus the final result is missing b3 and b4.
|
|
30
|
-
*
|
|
31
|
-
* Now, let's explore the issue with removing the bits first:
|
|
32
|
-
* V & ~b1 = b2 | b3 | b4
|
|
33
|
-
* V & ~b2 = b3 | b4
|
|
34
|
-
* V & ~b3 = b4
|
|
35
|
-
* V & ~b4 = 0
|
|
36
|
-
*
|
|
37
|
-
* And then setting the bits:
|
|
38
|
-
* V | b3 = b3
|
|
39
|
-
* V | b4 = b3 | b4
|
|
40
|
-
* V | b1 = b1 | b3 | b4
|
|
41
|
-
* V | b2 = b1 | b2 | b3 | b4
|
|
42
|
-
*
|
|
43
|
-
* We get the correct result because we're not removing any bits that were
|
|
44
|
-
* previously set thus properly remapping the bits to the new order
|
|
45
|
-
*
|
|
46
|
-
* To collect this into a single operation that can be done simultaneously
|
|
47
|
-
* we must first create a mask for the old bits that are set and a mask for
|
|
48
|
-
* the new bits that are set. Then we can remove the old bits and set the new
|
|
49
|
-
* bits simultaneously in a "single" operation like so:
|
|
50
|
-
* OldMask = b1 | b2 | b3 | b4
|
|
51
|
-
* NewMask = b3 | b4 | b1 | b2
|
|
52
|
-
*
|
|
53
|
-
* So this:
|
|
54
|
-
* V & ~oldMask | newMask
|
|
55
|
-
*
|
|
56
|
-
* Expands to this:
|
|
57
|
-
* V & ~b1 & ~b2 & ~b3 & ~b4 | b3 | b4 | b1 | b2
|
|
58
|
-
*
|
|
59
|
-
* Which becomes this:
|
|
60
|
-
* b1 | b2 | b3 | b4
|
|
61
|
-
*
|
|
62
|
-
* Which is the correct result!
|
|
63
|
-
*
|
|
64
|
-
* @param {bigint} num
|
|
65
|
-
* @param {[bigint, bigint][]} mapping
|
|
66
|
-
*/ "use strict";
|
|
67
|
-
Object.defineProperty(exports, "__esModule", {
|
|
68
|
-
value: true
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(exports, "remapBitfield", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
get: ()=>remapBitfield
|
|
73
|
-
});
|
|
1
|
+
"use strict";
|
|
74
2
|
function remapBitfield(num, mapping) {
|
|
75
|
-
|
|
76
|
-
let oldMask
|
|
77
|
-
let newMask = 0n;
|
|
78
|
-
for (let [oldBit, newBit] of mapping){
|
|
79
|
-
if (num & oldBit) {
|
|
80
|
-
oldMask = oldMask | oldBit;
|
|
81
|
-
newMask = newMask | newBit;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Remove all old bits
|
|
85
|
-
// Set all new bits
|
|
3
|
+
let oldMask = 0n, newMask = 0n;
|
|
4
|
+
for (let [oldBit, newBit] of mapping)num & oldBit && (oldMask |= oldBit, newMask |= newBit);
|
|
86
5
|
return num & ~oldMask | newMask;
|
|
87
6
|
}
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: !0
|
|
9
|
+
}), Object.defineProperty(exports, "remapBitfield", {
|
|
10
|
+
enumerable: !0,
|
|
11
|
+
get: ()=>remapBitfield
|
|
12
|
+
});
|
|
@@ -1,138 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
function _export(target, all) {
|
|
3
|
+
value: !0
|
|
4
|
+
}), function(target, all) {
|
|
6
5
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable:
|
|
6
|
+
enumerable: !0,
|
|
8
7
|
get: all[name]
|
|
9
8
|
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
9
|
+
}(exports, {
|
|
12
10
|
elementSelectorParser: ()=>elementSelectorParser,
|
|
13
11
|
default: ()=>resolveDefaultsAtRules
|
|
14
12
|
});
|
|
15
|
-
const _postcss =
|
|
16
|
-
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
17
|
-
const _featureFlags = require("../featureFlags");
|
|
13
|
+
const _postcss = _interopRequireDefault(require("postcss")), _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser")), _featureFlags = require("../featureFlags");
|
|
18
14
|
function _interopRequireDefault(obj) {
|
|
19
15
|
return obj && obj.__esModule ? obj : {
|
|
20
16
|
default: obj
|
|
21
17
|
};
|
|
22
18
|
}
|
|
23
19
|
let getNode = {
|
|
24
|
-
id (node)
|
|
25
|
-
return _postcssSelectorParser.default.attribute({
|
|
20
|
+
id: (node)=>_postcssSelectorParser.default.attribute({
|
|
26
21
|
attribute: "id",
|
|
27
22
|
operator: "=",
|
|
28
23
|
value: node.value,
|
|
29
24
|
quoteMark: '"'
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"tag",
|
|
51
|
-
"class",
|
|
52
|
-
"id",
|
|
53
|
-
"attribute"
|
|
54
|
-
]);
|
|
55
|
-
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
|
|
56
|
-
if (splitPointIdx === -1) return rest.reverse().join("").trim();
|
|
57
|
-
let node = rest[splitPointIdx];
|
|
58
|
-
let bestNode = getNode[node.type] ? getNode[node.type](node) : node;
|
|
59
|
-
rest = rest.slice(0, splitPointIdx);
|
|
60
|
-
let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
|
|
61
|
-
if (combinatorIdx !== -1) {
|
|
62
|
-
rest.splice(0, combinatorIdx);
|
|
63
|
-
rest.unshift(_postcssSelectorParser.default.universal());
|
|
64
|
-
}
|
|
65
|
-
return [
|
|
66
|
-
bestNode,
|
|
67
|
-
...rest.reverse()
|
|
68
|
-
].join("").trim();
|
|
69
|
-
}
|
|
70
|
-
let elementSelectorParser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
71
|
-
return selectors.map((s)=>{
|
|
72
|
-
let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
|
|
73
|
-
return minimumImpactSelector(nodes);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
let cache = new Map();
|
|
77
|
-
function extractElementSelector(selector) {
|
|
78
|
-
if (!cache.has(selector)) {
|
|
79
|
-
cache.set(selector, elementSelectorParser.transformSync(selector));
|
|
80
|
-
}
|
|
81
|
-
return cache.get(selector);
|
|
82
|
-
}
|
|
25
|
+
})
|
|
26
|
+
}, elementSelectorParser = (0, _postcssSelectorParser.default)((selectors)=>selectors.map((s)=>(function(nodes) {
|
|
27
|
+
let rest = nodes.filter((node)=>"pseudo" !== node.type || node.nodes.length > 0 || node.value.startsWith("::") || [
|
|
28
|
+
":before",
|
|
29
|
+
":after",
|
|
30
|
+
":first-line",
|
|
31
|
+
":first-letter"
|
|
32
|
+
].includes(node.value)).reverse(), searchFor = new Set([
|
|
33
|
+
"tag",
|
|
34
|
+
"class",
|
|
35
|
+
"id",
|
|
36
|
+
"attribute"
|
|
37
|
+
]), splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
|
|
38
|
+
if (-1 === splitPointIdx) return rest.reverse().join("").trim();
|
|
39
|
+
let node = rest[splitPointIdx], bestNode = getNode[node.type] ? getNode[node.type](node) : node, combinatorIdx = (rest = rest.slice(0, splitPointIdx)).findIndex((n)=>"combinator" === n.type && ">" === n.value);
|
|
40
|
+
return -1 !== combinatorIdx && (rest.splice(0, combinatorIdx), rest.unshift(_postcssSelectorParser.default.universal())), [
|
|
41
|
+
bestNode,
|
|
42
|
+
...rest.reverse()
|
|
43
|
+
].join("").trim();
|
|
44
|
+
})(s.split((n)=>"combinator" === n.type && " " === n.value).pop()))), cache = new Map();
|
|
83
45
|
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
84
46
|
return (root)=>{
|
|
85
|
-
let variableNodeMap = new Map();
|
|
86
|
-
|
|
87
|
-
root.walkAtRules("defaults", (rule)=>{
|
|
47
|
+
let variableNodeMap = new Map(), universals = new Set();
|
|
48
|
+
if (root.walkAtRules("defaults", (rule)=>{
|
|
88
49
|
if (rule.nodes && rule.nodes.length > 0) {
|
|
89
50
|
universals.add(rule);
|
|
90
51
|
return;
|
|
91
52
|
}
|
|
92
53
|
let variable = rule.params;
|
|
93
|
-
|
|
94
|
-
|
|
54
|
+
variableNodeMap.has(variable) || variableNodeMap.set(variable, new Set()), variableNodeMap.get(variable).add(rule.parent), rule.remove();
|
|
55
|
+
}), (0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) for (let universal of universals){
|
|
56
|
+
var _variableNodeMap_get, _selectorGroups_get, selector;
|
|
57
|
+
let selectorGroups = new Map();
|
|
58
|
+
for (let rule of null !== (_variableNodeMap_get = variableNodeMap.get(universal.params)) && void 0 !== _variableNodeMap_get ? _variableNodeMap_get : [])for (let selector1 of (selector = rule.selector, cache.has(selector) || cache.set(selector, elementSelectorParser.transformSync(selector)), cache.get(selector))){
|
|
59
|
+
let selectorGroupName = selector1.includes(":-") || selector1.includes("::-") ? selector1 : "__DEFAULT__", selectors = null !== (_selectorGroups_get = selectorGroups.get(selectorGroupName)) && void 0 !== _selectorGroups_get ? _selectorGroups_get : new Set();
|
|
60
|
+
selectorGroups.set(selectorGroupName, selectors), selectors.add(selector1);
|
|
95
61
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (let universal of universals){
|
|
101
|
-
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
102
|
-
var _variableNodeMap_get;
|
|
103
|
-
let rules = (_variableNodeMap_get = variableNodeMap.get(universal.params)) !== null && _variableNodeMap_get !== void 0 ? _variableNodeMap_get : [];
|
|
104
|
-
for (let rule of rules){
|
|
105
|
-
for (let selector of extractElementSelector(rule.selector)){
|
|
106
|
-
// If selector contains a vendor prefix after a pseudo element or class,
|
|
107
|
-
// we consider them separately because merging the declarations into
|
|
108
|
-
// a single rule will cause browsers that do not understand the
|
|
109
|
-
// vendor prefix to throw out the whole rule
|
|
110
|
-
let selectorGroupName = selector.includes(":-") || selector.includes("::-") ? selector : "__DEFAULT__";
|
|
111
|
-
var _selectorGroups_get;
|
|
112
|
-
let selectors = (_selectorGroups_get = selectorGroups.get(selectorGroupName)) !== null && _selectorGroups_get !== void 0 ? _selectorGroups_get : new Set();
|
|
113
|
-
selectorGroups.set(selectorGroupName, selectors);
|
|
114
|
-
selectors.add(selector);
|
|
115
|
-
}
|
|
62
|
+
if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
63
|
+
if (0 === selectorGroups.size) {
|
|
64
|
+
universal.remove();
|
|
65
|
+
continue;
|
|
116
66
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
universal.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
source: universal.source
|
|
125
|
-
});
|
|
126
|
-
universalRule.selectors = [
|
|
127
|
-
...selectors
|
|
128
|
-
];
|
|
129
|
-
universalRule.append(universal.nodes.map((node)=>node.clone()));
|
|
130
|
-
universal.before(universalRule);
|
|
131
|
-
}
|
|
67
|
+
for (let [, selectors] of selectorGroups){
|
|
68
|
+
let universalRule = _postcss.default.rule({
|
|
69
|
+
source: universal.source
|
|
70
|
+
});
|
|
71
|
+
universalRule.selectors = [
|
|
72
|
+
...selectors
|
|
73
|
+
], universalRule.append(universal.nodes.map((node)=>node.clone())), universal.before(universalRule);
|
|
132
74
|
}
|
|
133
|
-
universal.remove();
|
|
134
75
|
}
|
|
135
|
-
|
|
76
|
+
universal.remove();
|
|
77
|
+
}
|
|
78
|
+
else if (universals.size) {
|
|
136
79
|
let universalRule = _postcss.default.rule({
|
|
137
80
|
selectors: [
|
|
138
81
|
"*",
|
|
@@ -140,16 +83,7 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
140
83
|
"::after"
|
|
141
84
|
]
|
|
142
85
|
});
|
|
143
|
-
for (let universal of universals)
|
|
144
|
-
universalRule.append(universal.nodes);
|
|
145
|
-
if (!universalRule.parent) {
|
|
146
|
-
universal.before(universalRule);
|
|
147
|
-
}
|
|
148
|
-
if (!universalRule.source) {
|
|
149
|
-
universalRule.source = universal.source;
|
|
150
|
-
}
|
|
151
|
-
universal.remove();
|
|
152
|
-
}
|
|
86
|
+
for (let universal of universals)universalRule.append(universal.nodes), universalRule.parent || universal.before(universalRule), universalRule.source || (universalRule.source = universal.source), universal.remove();
|
|
153
87
|
let backdropRule = universalRule.clone({
|
|
154
88
|
selectors: [
|
|
155
89
|
"::backdrop"
|