tailwindcss 3.1.5 → 3.1.8
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 +36 -8
- package/README.md +6 -3
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +78 -75
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +194 -187
- package/lib/featureFlags.js +14 -7
- package/lib/index.js +9 -6
- package/lib/lib/cacheInvalidation.js +18 -15
- package/lib/lib/collapseAdjacentRules.js +14 -11
- package/lib/lib/collapseDuplicateDeclarations.js +11 -8
- package/lib/lib/defaultExtractor.js +38 -35
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +75 -44
- package/lib/lib/expandApplyAtRules.js +50 -42
- package/lib/lib/expandTailwindAtRules.js +153 -150
- package/lib/lib/generateRules.js +81 -73
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +10 -7
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +15 -7
- package/lib/lib/resolveDefaultsAtRules.js +92 -85
- package/lib/lib/setupContextUtils.js +109 -97
- package/lib/lib/setupTrackingContext.js +82 -75
- package/lib/lib/sharedState.js +15 -8
- package/lib/lib/substituteScreenAtRules.js +8 -5
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +7 -4
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +6 -4
- 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 +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +5 -2
- package/lib/util/cloneDeep.js +4 -1
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +11 -3
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +5 -3
- package/lib/util/createUtilityPlugin.js +13 -10
- package/lib/util/dataTypes.js +27 -19
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +12 -9
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +21 -14
- package/lib/util/getAllConfigs.js +12 -9
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/isValidArbitraryValue.js +33 -24
- package/lib/util/log.js +12 -5
- package/lib/util/nameClass.js +16 -8
- package/lib/util/negateValue.js +4 -1
- package/lib/util/normalizeConfig.js +26 -23
- package/lib/util/normalizeScreens.js +17 -2
- package/lib/util/parseAnimationValue.js +42 -39
- package/lib/util/parseBoxShadowValue.js +12 -4
- package/lib/util/parseDependency.js +35 -32
- package/lib/util/parseObjectStyles.js +14 -11
- package/lib/util/pluginUtils.js +28 -20
- package/lib/util/prefixSelector.js +6 -3
- package/lib/util/removeAlphaVariables.js +13 -2
- package/lib/util/resolveConfig.js +56 -53
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +16 -13
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +10 -7
- package/lib/util/validateConfig.js +5 -2
- package/lib/util/withAlphaVariable.js +30 -22
- package/package.json +10 -10
- package/peers/index.js +950 -825
- package/resolveConfig.d.ts +3 -0
- package/src/lib/evaluateTailwindFunctions.js +41 -15
- package/src/lib/expandApplyAtRules.js +6 -0
- package/src/lib/generateRules.js +6 -5
- package/src/lib/setupContextUtils.js +4 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/resolveConfig.js +1 -1
|
@@ -2,11 +2,84 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
elementSelectorParser: ()=>elementSelectorParser,
|
|
13
|
+
default: ()=>resolveDefaultsAtRules
|
|
14
|
+
});
|
|
15
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
16
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
17
|
+
const _featureFlags = require("../featureFlags");
|
|
18
|
+
function _interopRequireDefault(obj) {
|
|
19
|
+
return obj && obj.__esModule ? obj : {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
let getNode = {
|
|
24
|
+
id (node) {
|
|
25
|
+
return _postcssSelectorParser.default.attribute({
|
|
26
|
+
attribute: "id",
|
|
27
|
+
operator: "=",
|
|
28
|
+
value: node.value,
|
|
29
|
+
quoteMark: '"'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function minimumImpactSelector(nodes) {
|
|
34
|
+
let rest = nodes.filter((node)=>{
|
|
35
|
+
// Keep non-pseudo nodes
|
|
36
|
+
if (node.type !== "pseudo") return true;
|
|
37
|
+
// Keep pseudo nodes that have subnodes
|
|
38
|
+
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
39
|
+
if (node.nodes.length > 0) return true;
|
|
40
|
+
// Keep pseudo `elements`
|
|
41
|
+
// This implicitly means that we ignore pseudo `classes`
|
|
42
|
+
return node.value.startsWith("::") || [
|
|
43
|
+
":before",
|
|
44
|
+
":after",
|
|
45
|
+
":first-line",
|
|
46
|
+
":first-letter"
|
|
47
|
+
].includes(node.value);
|
|
48
|
+
}).reverse();
|
|
49
|
+
let searchFor = new Set([
|
|
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
|
+
}
|
|
10
83
|
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
11
84
|
return (root)=>{
|
|
12
85
|
let variableNodeMap = new Map();
|
|
@@ -23,7 +96,7 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
23
96
|
variableNodeMap.get(variable).add(rule.parent);
|
|
24
97
|
rule.remove();
|
|
25
98
|
});
|
|
26
|
-
if ((0, _featureFlags
|
|
99
|
+
if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
27
100
|
for (let universal of universals){
|
|
28
101
|
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
29
102
|
var ref;
|
|
@@ -41,17 +114,17 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
41
114
|
selectors.add(selector);
|
|
42
115
|
}
|
|
43
116
|
}
|
|
44
|
-
if ((0, _featureFlags
|
|
117
|
+
if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
45
118
|
if (selectorGroups.size === 0) {
|
|
46
119
|
universal.remove();
|
|
47
120
|
continue;
|
|
48
121
|
}
|
|
49
|
-
for (let [,
|
|
122
|
+
for (let [, selectors1] of selectorGroups){
|
|
50
123
|
let universalRule = _postcss.default.rule({
|
|
51
124
|
source: universal.source
|
|
52
125
|
});
|
|
53
126
|
universalRule.selectors = [
|
|
54
|
-
...
|
|
127
|
+
...selectors1
|
|
55
128
|
];
|
|
56
129
|
universalRule.append(universal.nodes.map((node)=>node.clone()));
|
|
57
130
|
universal.before(universalRule);
|
|
@@ -60,95 +133,29 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
60
133
|
universal.remove();
|
|
61
134
|
}
|
|
62
135
|
} else if (universals.size) {
|
|
63
|
-
let
|
|
136
|
+
let universalRule1 = _postcss.default.rule({
|
|
64
137
|
selectors: [
|
|
65
138
|
"*",
|
|
66
139
|
"::before",
|
|
67
140
|
"::after"
|
|
68
141
|
]
|
|
69
142
|
});
|
|
70
|
-
for (let
|
|
71
|
-
|
|
72
|
-
if (!
|
|
73
|
-
|
|
143
|
+
for (let universal1 of universals){
|
|
144
|
+
universalRule1.append(universal1.nodes);
|
|
145
|
+
if (!universalRule1.parent) {
|
|
146
|
+
universal1.before(universalRule1);
|
|
74
147
|
}
|
|
75
|
-
if (!
|
|
76
|
-
|
|
148
|
+
if (!universalRule1.source) {
|
|
149
|
+
universalRule1.source = universal1.source;
|
|
77
150
|
}
|
|
78
|
-
|
|
151
|
+
universal1.remove();
|
|
79
152
|
}
|
|
80
|
-
let backdropRule =
|
|
153
|
+
let backdropRule = universalRule1.clone({
|
|
81
154
|
selectors: [
|
|
82
155
|
"::backdrop"
|
|
83
156
|
]
|
|
84
157
|
});
|
|
85
|
-
|
|
158
|
+
universalRule1.after(backdropRule);
|
|
86
159
|
}
|
|
87
160
|
};
|
|
88
161
|
}
|
|
89
|
-
function _interopRequireDefault(obj) {
|
|
90
|
-
return obj && obj.__esModule ? obj : {
|
|
91
|
-
default: obj
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
let getNode = {
|
|
95
|
-
id (node) {
|
|
96
|
-
return _postcssSelectorParser.default.attribute({
|
|
97
|
-
attribute: "id",
|
|
98
|
-
operator: "=",
|
|
99
|
-
value: node.value,
|
|
100
|
-
quoteMark: '"'
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
function minimumImpactSelector(nodes) {
|
|
105
|
-
let rest = nodes.filter((node)=>{
|
|
106
|
-
// Keep non-pseudo nodes
|
|
107
|
-
if (node.type !== "pseudo") return true;
|
|
108
|
-
// Keep pseudo nodes that have subnodes
|
|
109
|
-
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
110
|
-
if (node.nodes.length > 0) return true;
|
|
111
|
-
// Keep pseudo `elements`
|
|
112
|
-
// This implicitly means that we ignore pseudo `classes`
|
|
113
|
-
return node.value.startsWith("::") || [
|
|
114
|
-
":before",
|
|
115
|
-
":after",
|
|
116
|
-
":first-line",
|
|
117
|
-
":first-letter"
|
|
118
|
-
].includes(node.value);
|
|
119
|
-
}).reverse();
|
|
120
|
-
let searchFor = new Set([
|
|
121
|
-
"tag",
|
|
122
|
-
"class",
|
|
123
|
-
"id",
|
|
124
|
-
"attribute"
|
|
125
|
-
]);
|
|
126
|
-
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
|
|
127
|
-
if (splitPointIdx === -1) return rest.reverse().join("").trim();
|
|
128
|
-
let node1 = rest[splitPointIdx];
|
|
129
|
-
let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
|
|
130
|
-
rest = rest.slice(0, splitPointIdx);
|
|
131
|
-
let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
|
|
132
|
-
if (combinatorIdx !== -1) {
|
|
133
|
-
rest.splice(0, combinatorIdx);
|
|
134
|
-
rest.unshift(_postcssSelectorParser.default.universal());
|
|
135
|
-
}
|
|
136
|
-
return [
|
|
137
|
-
bestNode,
|
|
138
|
-
...rest.reverse()
|
|
139
|
-
].join("").trim();
|
|
140
|
-
}
|
|
141
|
-
let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
142
|
-
return selectors.map((s)=>{
|
|
143
|
-
let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
|
|
144
|
-
return minimumImpactSelector(nodes);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
exports.elementSelectorParser = elementSelectorParser;
|
|
148
|
-
let cache = new Map();
|
|
149
|
-
function extractElementSelector(selector) {
|
|
150
|
-
if (!cache.has(selector)) {
|
|
151
|
-
cache.set(selector, elementSelectorParser.transformSync(selector));
|
|
152
|
-
}
|
|
153
|
-
return cache.get(selector);
|
|
154
|
-
}
|