tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21
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 +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -1,120 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = expandApplyAtRules;
|
|
7
|
-
|
|
8
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
9
|
-
|
|
10
7
|
var _generateRules = require("./generateRules");
|
|
11
|
-
|
|
12
8
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
13
|
-
|
|
14
9
|
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function prefix1(context, selector) {
|
|
16
|
+
let prefix = context.tailwindConfig.prefix;
|
|
17
|
+
return typeof prefix === 'function' ? prefix(selector) : prefix + selector;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
function buildApplyCache(applyCandidates, context) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
for (let candidate of applyCandidates){
|
|
21
|
+
if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (context.classCache.has(candidate)) {
|
|
25
|
+
context.applyClassCache.set(candidate, context.classCache.get(candidate).map(([meta, rule])=>[
|
|
26
|
+
meta,
|
|
27
|
+
rule.clone()
|
|
28
|
+
]
|
|
29
|
+
));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
let matches = Array.from((0, _generateRules).resolveMatches(candidate, context));
|
|
33
|
+
if (matches.length === 0) {
|
|
34
|
+
context.notClassCache.add(candidate);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
context.applyClassCache.set(candidate, matches);
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
context.applyClassCache.set(candidate, matches);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return context.applyClassCache;
|
|
39
|
+
return context.applyClassCache;
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
function extractApplyCandidates(params) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
let candidates = params.split(/[\s\t\n]+/g);
|
|
43
|
+
if (candidates[candidates.length - 1] === '!important') {
|
|
44
|
+
return [
|
|
45
|
+
candidates.slice(0, -1),
|
|
46
|
+
true
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
return [
|
|
50
|
+
candidates,
|
|
51
|
+
false
|
|
52
|
+
];
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
function partitionApplyParents(root) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
let applyParents = new Set();
|
|
56
|
+
root.walkAtRules('apply', (rule)=>{
|
|
57
|
+
applyParents.add(rule.parent);
|
|
58
|
+
});
|
|
59
|
+
for (let rule1 of applyParents){
|
|
60
|
+
let nodeGroups = [];
|
|
61
|
+
let lastGroup = [];
|
|
62
|
+
for (let node of rule1.nodes){
|
|
63
|
+
if (node.type === 'atrule' && node.name === 'apply') {
|
|
64
|
+
if (lastGroup.length > 0) {
|
|
65
|
+
nodeGroups.push(lastGroup);
|
|
66
|
+
lastGroup = [];
|
|
67
|
+
}
|
|
68
|
+
nodeGroups.push([
|
|
69
|
+
node
|
|
70
|
+
]);
|
|
71
|
+
} else {
|
|
72
|
+
lastGroup.push(node);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
69
75
|
if (lastGroup.length > 0) {
|
|
70
|
-
|
|
71
|
-
lastGroup = [];
|
|
76
|
+
nodeGroups.push(lastGroup);
|
|
72
77
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
for (let group of [...nodeGroups].reverse()) {
|
|
89
|
-
let newParent = rule.clone({
|
|
90
|
-
nodes: []
|
|
91
|
-
});
|
|
92
|
-
newParent.append(group);
|
|
93
|
-
rule.after(newParent);
|
|
78
|
+
if (nodeGroups.length === 1) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
for (let group of [
|
|
82
|
+
...nodeGroups
|
|
83
|
+
].reverse()){
|
|
84
|
+
let newParent = rule1.clone({
|
|
85
|
+
nodes: []
|
|
86
|
+
});
|
|
87
|
+
newParent.append(group);
|
|
88
|
+
rule1.after(newParent);
|
|
89
|
+
}
|
|
90
|
+
rule1.remove();
|
|
94
91
|
}
|
|
95
|
-
|
|
96
|
-
rule.remove();
|
|
97
|
-
}
|
|
98
92
|
}
|
|
99
|
-
|
|
100
93
|
function processApply(root, context) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
let applyClassCache = buildApplyCache(applyCandidates, context);
|
|
117
|
-
/**
|
|
94
|
+
let applyCandidates = new Set();
|
|
95
|
+
// Collect all @apply rules and candidates
|
|
96
|
+
let applies = [];
|
|
97
|
+
root.walkAtRules('apply', (rule)=>{
|
|
98
|
+
let [candidates] = extractApplyCandidates(rule.params);
|
|
99
|
+
for (let util of candidates){
|
|
100
|
+
applyCandidates.add(util);
|
|
101
|
+
}
|
|
102
|
+
applies.push(rule);
|
|
103
|
+
});
|
|
104
|
+
// Start the @apply process if we have rules with @apply in them
|
|
105
|
+
if (applies.length > 0) {
|
|
106
|
+
// Fill up some caches!
|
|
107
|
+
let applyClassCache = buildApplyCache(applyCandidates, context);
|
|
108
|
+
/**
|
|
118
109
|
* When we have an apply like this:
|
|
119
110
|
*
|
|
120
111
|
* .abc {
|
|
@@ -133,113 +124,105 @@ function processApply(root, context) {
|
|
|
133
124
|
* What happens in this function is that we prepend a `.` and escape the candidate.
|
|
134
125
|
* This will result in `.hover\:font-bold`
|
|
135
126
|
* Which means that we can replace `.hover\:font-bold` with `.abc` in `.hover\:font-bold:hover` resulting in `.abc:hover`
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
replaced.push(replacedSelector);
|
|
127
|
+
*/ // TODO: Should we use postcss-selector-parser for this instead?
|
|
128
|
+
function replaceSelector(selector, utilitySelectors, candidate) {
|
|
129
|
+
let needle = `.${(0, _escapeClassName).default(candidate)}`;
|
|
130
|
+
let utilitySelectorsList = utilitySelectors.split(/\s*,\s*/g);
|
|
131
|
+
return selector.split(/\s*,\s*/g).map((s)=>{
|
|
132
|
+
let replaced = [];
|
|
133
|
+
for (let utilitySelector of utilitySelectorsList){
|
|
134
|
+
let replacedSelector = utilitySelector.replace(needle, s);
|
|
135
|
+
if (replacedSelector === utilitySelector) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
replaced.push(replacedSelector);
|
|
139
|
+
}
|
|
140
|
+
return replaced.join(', ');
|
|
141
|
+
}).join(', ');
|
|
153
142
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
143
|
+
let perParentApplies = new Map();
|
|
144
|
+
// Collect all apply candidates and their rules
|
|
145
|
+
for (let apply of applies){
|
|
146
|
+
let candidates = perParentApplies.get(apply.parent) || [];
|
|
147
|
+
perParentApplies.set(apply.parent, candidates);
|
|
148
|
+
let [applyCandidates, important] = extractApplyCandidates(apply.params);
|
|
149
|
+
if (apply.parent.type === 'atrule') {
|
|
150
|
+
if (apply.parent.name === 'screen') {
|
|
151
|
+
const screenType = apply.parent.params;
|
|
152
|
+
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map((c)=>`${screenType}:${c}`
|
|
153
|
+
).join(' ')} instead.`);
|
|
154
|
+
}
|
|
155
|
+
throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
|
|
156
|
+
}
|
|
157
|
+
for (let applyCandidate of applyCandidates){
|
|
158
|
+
if (!applyClassCache.has(applyCandidate)) {
|
|
159
|
+
if (applyCandidate === prefix1(context, 'group')) {
|
|
160
|
+
// TODO: Link to specific documentation page with error code.
|
|
161
|
+
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
|
|
162
|
+
}
|
|
163
|
+
throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
|
|
164
|
+
}
|
|
165
|
+
let rules = applyClassCache.get(applyCandidate);
|
|
166
|
+
candidates.push([
|
|
167
|
+
applyCandidate,
|
|
168
|
+
important,
|
|
169
|
+
rules
|
|
170
|
+
]);
|
|
171
|
+
}
|
|
170
172
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
for (const [parent, candidates] of perParentApplies){
|
|
174
|
+
let siblings = [];
|
|
175
|
+
for (let [applyCandidate, important, rules] of candidates){
|
|
176
|
+
for (let [meta, node] of rules){
|
|
177
|
+
let root = _postcss.default.root({
|
|
178
|
+
nodes: [
|
|
179
|
+
node.clone()
|
|
180
|
+
]
|
|
181
|
+
});
|
|
182
|
+
let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
|
|
183
|
+
if (canRewriteSelector) {
|
|
184
|
+
root.walkRules((rule)=>{
|
|
185
|
+
rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
|
|
186
|
+
rule.walkDecls((d)=>{
|
|
187
|
+
d.important = meta.important || important;
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Insert it
|
|
192
|
+
siblings.push([
|
|
193
|
+
// Ensure that when we are sorting, that we take the layer order into account
|
|
194
|
+
{
|
|
195
|
+
...meta,
|
|
196
|
+
sort: meta.sort | context.layerOrder[meta.layer]
|
|
197
|
+
},
|
|
198
|
+
root.nodes[0],
|
|
199
|
+
]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Inject the rules, sorted, correctly
|
|
203
|
+
let nodes = siblings.sort(([a], [z])=>(0, _bigSign).default(a.sort - z.sort)
|
|
204
|
+
).map((s)=>s[1]
|
|
205
|
+
);
|
|
206
|
+
// console.log(parent)
|
|
207
|
+
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
|
|
208
|
+
parent.after(nodes);
|
|
183
209
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
for (let [applyCandidate, important, rules] of candidates) {
|
|
194
|
-
for (let [meta, node] of rules) {
|
|
195
|
-
let root = _postcss.default.root({
|
|
196
|
-
nodes: [node.clone()]
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
|
|
200
|
-
|
|
201
|
-
if (canRewriteSelector) {
|
|
202
|
-
root.walkRules(rule => {
|
|
203
|
-
rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
|
|
204
|
-
rule.walkDecls(d => {
|
|
205
|
-
d.important = meta.important || important;
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
} // Insert it
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
siblings.push([// Ensure that when we are sorting, that we take the layer order into account
|
|
212
|
-
{ ...meta,
|
|
213
|
-
sort: meta.sort | context.layerOrder[meta.layer]
|
|
214
|
-
}, root.nodes[0]]);
|
|
210
|
+
for (let apply1 of applies){
|
|
211
|
+
// If there are left-over declarations, just remove the @apply
|
|
212
|
+
if (apply1.parent.nodes.length > 1) {
|
|
213
|
+
apply1.remove();
|
|
214
|
+
} else {
|
|
215
|
+
// The node is empty, drop the full node
|
|
216
|
+
apply1.parent.remove();
|
|
217
|
+
}
|
|
215
218
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
let nodes = siblings.sort(([a], [z]) => (0, _bigSign.default)(a.sort - z.sort)).map(s => s[1]); // console.log(parent)
|
|
220
|
-
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
|
|
221
|
-
|
|
222
|
-
parent.after(nodes);
|
|
219
|
+
// Do it again, in case we have other `@apply` rules
|
|
220
|
+
processApply(root, context);
|
|
223
221
|
}
|
|
224
|
-
|
|
225
|
-
for (let apply of applies) {
|
|
226
|
-
// If there are left-over declarations, just remove the @apply
|
|
227
|
-
if (apply.parent.nodes.length > 1) {
|
|
228
|
-
apply.remove();
|
|
229
|
-
} else {
|
|
230
|
-
// The node is empty, drop the full node
|
|
231
|
-
apply.parent.remove();
|
|
232
|
-
}
|
|
233
|
-
} // Do it again, in case we have other `@apply` rules
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
processApply(root, context);
|
|
237
|
-
}
|
|
238
222
|
}
|
|
239
|
-
|
|
240
223
|
function expandApplyAtRules(context) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
224
|
+
return (root)=>{
|
|
225
|
+
partitionApplyParents(root);
|
|
226
|
+
processApply(root, context);
|
|
227
|
+
};
|
|
228
|
+
}
|