tailwindcss 3.0.22 → 3.1.0
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 +92 -2
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +3 -0
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +266 -203
- package/lib/constants.js +8 -8
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +1662 -1554
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +14 -12
- package/lib/index.js +16 -6
- package/lib/lib/cacheInvalidation.js +87 -0
- package/lib/lib/collapseAdjacentRules.js +30 -15
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +191 -30
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +37 -28
- package/lib/lib/expandApplyAtRules.js +379 -189
- package/lib/lib/expandTailwindAtRules.js +168 -144
- package/lib/lib/generateRules.js +190 -81
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +80 -79
- package/lib/lib/setupContextUtils.js +207 -170
- package/lib/lib/setupTrackingContext.js +61 -63
- package/lib/lib/sharedState.js +11 -8
- package/lib/lib/substituteScreenAtRules.js +3 -4
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +40 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -3
- package/lib/util/cloneDeep.js +3 -5
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +42 -51
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -7
- package/lib/util/dataTypes.js +85 -81
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +4 -7
- package/lib/util/formatVariantSelector.js +82 -75
- package/lib/util/getAllConfigs.js +15 -10
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +26 -27
- package/lib/util/log.js +9 -10
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -5
- package/lib/util/normalizeConfig.js +68 -58
- package/lib/util/normalizeScreens.js +5 -6
- package/lib/util/parseAnimationValue.js +56 -57
- package/lib/util/parseBoxShadowValue.js +19 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +20 -12
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +81 -58
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +90 -0
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +23 -23
- package/package.json +33 -27
- package/peers/index.js +7728 -5848
- package/plugin.d.ts +11 -0
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +118 -24
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +142 -30
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +4 -4
- package/src/index.js +15 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/defaultExtractor.js +177 -33
- package/src/lib/evaluateTailwindFunctions.js +20 -4
- package/src/lib/expandApplyAtRules.js +418 -186
- package/src/lib/expandTailwindAtRules.js +30 -10
- package/src/lib/generateRules.js +142 -51
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +7 -3
- package/src/lib/setupContextUtils.js +142 -87
- package/src/lib/setupTrackingContext.js +7 -3
- package/src/lib/sharedState.js +2 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +14 -6
- package/src/util/formatVariantSelector.js +79 -62
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/log.js +8 -8
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -2
- package/src/util/pluginUtils.js +13 -1
- package/src/util/resolveConfig.js +66 -22
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +1 -0
|
@@ -3,10 +3,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandApplyAtRules;
|
|
6
|
+
function expandApplyAtRules() {
|
|
7
|
+
return (root)=>{
|
|
8
|
+
partitionRules(root);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
6
11
|
function partitionRules(root) {
|
|
7
12
|
if (!root.walkAtRules) return;
|
|
8
13
|
let applyParents = new Set();
|
|
9
|
-
root.walkAtRules(
|
|
14
|
+
root.walkAtRules("apply", (rule)=>{
|
|
10
15
|
applyParents.add(rule.parent);
|
|
11
16
|
});
|
|
12
17
|
if (applyParents.size === 0) {
|
|
@@ -16,7 +21,7 @@ function partitionRules(root) {
|
|
|
16
21
|
let nodeGroups = [];
|
|
17
22
|
let lastGroup = [];
|
|
18
23
|
for (let node of rule1.nodes){
|
|
19
|
-
if (node.type ===
|
|
24
|
+
if (node.type === "atrule" && node.name === "apply") {
|
|
20
25
|
if (lastGroup.length > 0) {
|
|
21
26
|
nodeGroups.push(lastGroup);
|
|
22
27
|
lastGroup = [];
|
|
@@ -46,8 +51,3 @@ function partitionRules(root) {
|
|
|
46
51
|
rule1.remove();
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
function expandApplyAtRules() {
|
|
50
|
-
return (root)=>{
|
|
51
|
-
partitionRules(root);
|
|
52
|
-
};
|
|
53
|
-
}
|
package/lib/lib/regex.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.pattern = pattern;
|
|
6
|
+
exports.withoutCapturing = withoutCapturing;
|
|
7
|
+
exports.any = any;
|
|
8
|
+
exports.optional = optional;
|
|
9
|
+
exports.zeroOrMore = zeroOrMore;
|
|
10
|
+
exports.nestedBrackets = nestedBrackets;
|
|
11
|
+
exports.escape = escape;
|
|
12
|
+
const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
|
|
13
|
+
const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
|
|
14
|
+
/**
|
|
15
|
+
* @param {string|RegExp|Array<string|RegExp>} source
|
|
16
|
+
*/ function toSource(source) {
|
|
17
|
+
source = Array.isArray(source) ? source : [
|
|
18
|
+
source
|
|
19
|
+
];
|
|
20
|
+
source = source.map((item)=>item instanceof RegExp ? item.source : item);
|
|
21
|
+
return source.join("");
|
|
22
|
+
}
|
|
23
|
+
function pattern(source) {
|
|
24
|
+
return new RegExp(toSource(source), "g");
|
|
25
|
+
}
|
|
26
|
+
function withoutCapturing(source) {
|
|
27
|
+
return new RegExp(`(?:${toSource(source)})`, "g");
|
|
28
|
+
}
|
|
29
|
+
function any(sources) {
|
|
30
|
+
return `(?:${sources.map(toSource).join("|")})`;
|
|
31
|
+
}
|
|
32
|
+
function optional(source) {
|
|
33
|
+
return `(?:${toSource(source)})?`;
|
|
34
|
+
}
|
|
35
|
+
function zeroOrMore(source) {
|
|
36
|
+
return `(?:${toSource(source)})*`;
|
|
37
|
+
}
|
|
38
|
+
function nestedBrackets(open, close, depth = 1) {
|
|
39
|
+
return withoutCapturing([
|
|
40
|
+
escape(open),
|
|
41
|
+
/[^\s]*/,
|
|
42
|
+
depth === 1 ? `[^${escape(open)}${escape(close)}\s]*` : any([
|
|
43
|
+
`[^${escape(open)}${escape(close)}\s]*`,
|
|
44
|
+
nestedBrackets(open, close, depth - 1)
|
|
45
|
+
]),
|
|
46
|
+
/[^\s]*/,
|
|
47
|
+
escape(close),
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
function escape(string) {
|
|
51
|
+
return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
|
|
52
|
+
}
|
|
@@ -7,80 +7,11 @@ exports.elementSelectorParser = void 0;
|
|
|
7
7
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
8
8
|
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
9
9
|
var _featureFlags = require("../featureFlags");
|
|
10
|
-
function _interopRequireDefault(obj) {
|
|
11
|
-
return obj && obj.__esModule ? obj : {
|
|
12
|
-
default: obj
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
let getNode = {
|
|
16
|
-
id (node) {
|
|
17
|
-
return _postcssSelectorParser.default.attribute({
|
|
18
|
-
attribute: 'id',
|
|
19
|
-
operator: '=',
|
|
20
|
-
value: node.value,
|
|
21
|
-
quoteMark: '"'
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
function minimumImpactSelector(nodes) {
|
|
26
|
-
let rest = nodes.filter((node)=>{
|
|
27
|
-
// Keep non-pseudo nodes
|
|
28
|
-
if (node.type !== 'pseudo') return true;
|
|
29
|
-
// Keep pseudo nodes that have subnodes
|
|
30
|
-
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
31
|
-
if (node.nodes.length > 0) return true;
|
|
32
|
-
// Keep pseudo `elements`
|
|
33
|
-
// This implicitly means that we ignore pseudo `classes`
|
|
34
|
-
return node.value.startsWith('::') || [
|
|
35
|
-
':before',
|
|
36
|
-
':after',
|
|
37
|
-
':first-line',
|
|
38
|
-
':first-letter'
|
|
39
|
-
].includes(node.value);
|
|
40
|
-
}).reverse();
|
|
41
|
-
let searchFor = new Set([
|
|
42
|
-
'tag',
|
|
43
|
-
'class',
|
|
44
|
-
'id',
|
|
45
|
-
'attribute'
|
|
46
|
-
]);
|
|
47
|
-
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type)
|
|
48
|
-
);
|
|
49
|
-
if (splitPointIdx === -1) return rest.reverse().join('').trim();
|
|
50
|
-
let node1 = rest[splitPointIdx];
|
|
51
|
-
let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
|
|
52
|
-
rest = rest.slice(0, splitPointIdx);
|
|
53
|
-
let combinatorIdx = rest.findIndex((n)=>n.type === 'combinator' && n.value === '>'
|
|
54
|
-
);
|
|
55
|
-
if (combinatorIdx !== -1) {
|
|
56
|
-
rest.splice(0, combinatorIdx);
|
|
57
|
-
rest.unshift(_postcssSelectorParser.default.universal());
|
|
58
|
-
}
|
|
59
|
-
return [
|
|
60
|
-
bestNode,
|
|
61
|
-
...rest.reverse()
|
|
62
|
-
].join('').trim();
|
|
63
|
-
}
|
|
64
|
-
let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
65
|
-
return selectors.map((s)=>{
|
|
66
|
-
let nodes = s.split((n)=>n.type === 'combinator' && n.value === ' '
|
|
67
|
-
).pop();
|
|
68
|
-
return minimumImpactSelector(nodes);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
exports.elementSelectorParser = elementSelectorParser;
|
|
72
|
-
let cache = new Map();
|
|
73
|
-
function extractElementSelector(selector) {
|
|
74
|
-
if (!cache.has(selector)) {
|
|
75
|
-
cache.set(selector, elementSelectorParser.transformSync(selector));
|
|
76
|
-
}
|
|
77
|
-
return cache.get(selector);
|
|
78
|
-
}
|
|
79
10
|
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
80
11
|
return (root)=>{
|
|
81
12
|
let variableNodeMap = new Map();
|
|
82
13
|
/** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
|
|
83
|
-
root.walkAtRules(
|
|
14
|
+
root.walkAtRules("defaults", (rule)=>{
|
|
84
15
|
if (rule.nodes && rule.nodes.length > 0) {
|
|
85
16
|
universals.add(rule);
|
|
86
17
|
return;
|
|
@@ -102,33 +33,37 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
102
33
|
// we consider them separately because merging the declarations into
|
|
103
34
|
// a single rule will cause browsers that do not understand the
|
|
104
35
|
// vendor prefix to throw out the whole rule
|
|
105
|
-
let selectorGroupName = selector.includes(
|
|
36
|
+
let selectorGroupName = selector.includes(":-") || selector.includes("::-") ? selector : "__DEFAULT__";
|
|
106
37
|
var ref1;
|
|
107
38
|
let selectors = (ref1 = selectorGroups.get(selectorGroupName)) !== null && ref1 !== void 0 ? ref1 : new Set();
|
|
108
39
|
selectorGroups.set(selectorGroupName, selectors);
|
|
109
40
|
selectors.add(selector);
|
|
110
41
|
}
|
|
111
42
|
}
|
|
112
|
-
if ((0, _featureFlags).flagEnabled(tailwindConfig,
|
|
43
|
+
if ((0, _featureFlags).flagEnabled(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
113
44
|
if (selectorGroups.size === 0) {
|
|
114
45
|
universal.remove();
|
|
115
46
|
continue;
|
|
116
47
|
}
|
|
117
48
|
for (let [, selectors] of selectorGroups){
|
|
118
|
-
let universalRule = _postcss.default.rule(
|
|
49
|
+
let universalRule = _postcss.default.rule({
|
|
50
|
+
source: universal.source
|
|
51
|
+
});
|
|
119
52
|
universalRule.selectors = [
|
|
120
53
|
...selectors
|
|
121
54
|
];
|
|
122
|
-
universalRule.append(universal.nodes.map((node)=>node.clone()
|
|
123
|
-
));
|
|
55
|
+
universalRule.append(universal.nodes.map((node)=>node.clone()));
|
|
124
56
|
universal.before(universalRule);
|
|
125
57
|
}
|
|
126
58
|
} else {
|
|
127
|
-
let universalRule = _postcss.default.rule(
|
|
59
|
+
let universalRule = _postcss.default.rule({
|
|
60
|
+
source: universal.source
|
|
61
|
+
});
|
|
128
62
|
universalRule.selectors = [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
63
|
+
"*",
|
|
64
|
+
"::before",
|
|
65
|
+
"::after",
|
|
66
|
+
"::backdrop"
|
|
132
67
|
];
|
|
133
68
|
universalRule.append(universal.nodes);
|
|
134
69
|
universal.before(universalRule);
|
|
@@ -137,3 +72,69 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
137
72
|
}
|
|
138
73
|
};
|
|
139
74
|
}
|
|
75
|
+
function _interopRequireDefault(obj) {
|
|
76
|
+
return obj && obj.__esModule ? obj : {
|
|
77
|
+
default: obj
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
let getNode = {
|
|
81
|
+
id (node) {
|
|
82
|
+
return _postcssSelectorParser.default.attribute({
|
|
83
|
+
attribute: "id",
|
|
84
|
+
operator: "=",
|
|
85
|
+
value: node.value,
|
|
86
|
+
quoteMark: '"'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
function minimumImpactSelector(nodes) {
|
|
91
|
+
let rest = nodes.filter((node)=>{
|
|
92
|
+
// Keep non-pseudo nodes
|
|
93
|
+
if (node.type !== "pseudo") return true;
|
|
94
|
+
// Keep pseudo nodes that have subnodes
|
|
95
|
+
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
96
|
+
if (node.nodes.length > 0) return true;
|
|
97
|
+
// Keep pseudo `elements`
|
|
98
|
+
// This implicitly means that we ignore pseudo `classes`
|
|
99
|
+
return node.value.startsWith("::") || [
|
|
100
|
+
":before",
|
|
101
|
+
":after",
|
|
102
|
+
":first-line",
|
|
103
|
+
":first-letter"
|
|
104
|
+
].includes(node.value);
|
|
105
|
+
}).reverse();
|
|
106
|
+
let searchFor = new Set([
|
|
107
|
+
"tag",
|
|
108
|
+
"class",
|
|
109
|
+
"id",
|
|
110
|
+
"attribute"
|
|
111
|
+
]);
|
|
112
|
+
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
|
|
113
|
+
if (splitPointIdx === -1) return rest.reverse().join("").trim();
|
|
114
|
+
let node1 = rest[splitPointIdx];
|
|
115
|
+
let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
|
|
116
|
+
rest = rest.slice(0, splitPointIdx);
|
|
117
|
+
let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
|
|
118
|
+
if (combinatorIdx !== -1) {
|
|
119
|
+
rest.splice(0, combinatorIdx);
|
|
120
|
+
rest.unshift(_postcssSelectorParser.default.universal());
|
|
121
|
+
}
|
|
122
|
+
return [
|
|
123
|
+
bestNode,
|
|
124
|
+
...rest.reverse()
|
|
125
|
+
].join("").trim();
|
|
126
|
+
}
|
|
127
|
+
let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
128
|
+
return selectors.map((s)=>{
|
|
129
|
+
let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
|
|
130
|
+
return minimumImpactSelector(nodes);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
exports.elementSelectorParser = elementSelectorParser;
|
|
134
|
+
let cache = new Map();
|
|
135
|
+
function extractElementSelector(selector) {
|
|
136
|
+
if (!cache.has(selector)) {
|
|
137
|
+
cache.set(selector, elementSelectorParser.transformSync(selector));
|
|
138
|
+
}
|
|
139
|
+
return cache.get(selector);
|
|
140
|
+
}
|