tailwindcss 0.0.0-insiders.8259dfd → 0.0.0-insiders.8293c2d
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 +207 -2
- package/README.md +8 -4
- package/colors.js +2 -1
- package/defaultConfig.js +2 -1
- package/defaultTheme.js +2 -1
- package/lib/cli.js +94 -61
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +8 -1
- package/lib/corePlugins.js +477 -517
- package/lib/css/preflight.css +18 -5
- package/lib/featureFlags.js +5 -6
- package/lib/index.js +1 -3
- package/lib/lib/collapseDuplicateDeclarations.js +80 -0
- package/lib/lib/defaultExtractor.js +42 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +10 -6
- package/lib/lib/expandApplyAtRules.js +94 -45
- package/lib/lib/expandTailwindAtRules.js +32 -33
- package/lib/lib/generateRules.js +167 -21
- package/lib/lib/normalizeTailwindDirectives.js +8 -1
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +28 -14
- package/lib/lib/setupContextUtils.js +153 -129
- package/lib/lib/setupTrackingContext.js +11 -10
- package/lib/lib/sharedState.js +34 -5
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/processTailwindFeatures.js +7 -2
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/color.js +23 -8
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -10
- package/lib/util/dataTypes.js +38 -7
- package/lib/util/defaults.js +6 -0
- package/lib/util/flattenColorPalette.js +1 -3
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +4 -0
- package/lib/util/nameClass.js +1 -0
- package/lib/util/normalizeConfig.js +63 -21
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +27 -158
- package/lib/util/prefixSelector.js +1 -3
- package/lib/util/resolveConfig.js +30 -31
- package/lib/util/resolveConfigPath.js +1 -2
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +19 -13
- package/nesting/plugin.js +4 -1
- package/package.json +19 -21
- package/peers/index.js +4621 -5626
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/src/cli.js +66 -14
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +406 -518
- package/src/css/preflight.css +18 -5
- package/src/featureFlags.js +1 -1
- package/src/index.js +1 -7
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/defaultExtractor.js +48 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +6 -3
- package/src/lib/expandApplyAtRules.js +101 -45
- package/src/lib/expandTailwindAtRules.js +33 -27
- package/src/lib/generateRules.js +178 -11
- package/src/lib/normalizeTailwindDirectives.js +6 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/resolveDefaultsAtRules.js +31 -10
- package/src/lib/setupContextUtils.js +140 -84
- package/src/lib/setupTrackingContext.js +11 -10
- package/src/lib/sharedState.js +40 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/color.js +20 -7
- package/src/util/dataTypes.js +43 -11
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +4 -0
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +37 -2
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +15 -138
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +11 -1
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +22 -7
- package/stubs/defaultConfig.stub.js +42 -16
- package/lib/lib/setupWatchingContext.js +0 -284
- package/src/lib/setupWatchingContext.js +0 -304
|
@@ -23,6 +23,7 @@ var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
|
23
23
|
var _toPath = require("../util/toPath");
|
|
24
24
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
25
|
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
26
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
26
27
|
function _interopRequireDefault(obj) {
|
|
27
28
|
return obj && obj.__esModule ? obj : {
|
|
28
29
|
default: obj
|
|
@@ -32,13 +33,11 @@ function _interopRequireWildcard(obj) {
|
|
|
32
33
|
if (obj && obj.__esModule) {
|
|
33
34
|
return obj;
|
|
34
35
|
} else {
|
|
35
|
-
var newObj = {
|
|
36
|
-
};
|
|
36
|
+
var newObj = {};
|
|
37
37
|
if (obj != null) {
|
|
38
38
|
for(var key in obj){
|
|
39
39
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
41
|
-
};
|
|
40
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
42
41
|
if (desc.get || desc.set) {
|
|
43
42
|
Object.defineProperty(newObj, key, desc);
|
|
44
43
|
} else {
|
|
@@ -51,8 +50,31 @@ function _interopRequireWildcard(obj) {
|
|
|
51
50
|
return newObj;
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
53
|
+
function parseVariantFormatString(input) {
|
|
54
|
+
if (input.includes('{')) {
|
|
55
|
+
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
56
|
+
return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)
|
|
57
|
+
).filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
return [
|
|
60
|
+
input.trim()
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
function isBalanced(input) {
|
|
64
|
+
let count = 0;
|
|
65
|
+
for (let char of input){
|
|
66
|
+
if (char === '{') {
|
|
67
|
+
count++;
|
|
68
|
+
} else if (char === '}') {
|
|
69
|
+
if (--count < 0) {
|
|
70
|
+
return false // unbalanced
|
|
71
|
+
;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return count === 0;
|
|
76
|
+
}
|
|
77
|
+
function insertInto(list, value, { before =[] } = {}) {
|
|
56
78
|
before = [].concat(before);
|
|
57
79
|
if (before.length <= 0) {
|
|
58
80
|
list.push(value);
|
|
@@ -87,44 +109,49 @@ function getClasses(selector) {
|
|
|
87
109
|
});
|
|
88
110
|
return parser.transformSync(selector);
|
|
89
111
|
}
|
|
90
|
-
function extractCandidates(node
|
|
112
|
+
function extractCandidates(node, state = {
|
|
113
|
+
containsNonOnDemandable: false
|
|
114
|
+
}, depth = 0) {
|
|
91
115
|
let classes = [];
|
|
116
|
+
// Handle normal rules
|
|
92
117
|
if (node.type === 'rule') {
|
|
93
118
|
for (let selector of node.selectors){
|
|
94
119
|
let classCandidates = getClasses(selector);
|
|
95
120
|
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
96
|
-
if (classCandidates.length === 0)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
if (classCandidates.length === 0) {
|
|
122
|
+
state.containsNonOnDemandable = true;
|
|
123
|
+
}
|
|
124
|
+
for (let classCandidate of classCandidates){
|
|
125
|
+
classes.push(classCandidate);
|
|
126
|
+
}
|
|
101
127
|
}
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
if (node.type === 'atrule') {
|
|
128
|
+
} else if (node.type === 'atrule') {
|
|
105
129
|
node.walkRules((rule)=>{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
];
|
|
130
|
+
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector, state, depth + 1)
|
|
131
|
+
)){
|
|
132
|
+
classes.push(classCandidate);
|
|
133
|
+
}
|
|
111
134
|
});
|
|
112
135
|
}
|
|
136
|
+
if (depth === 0) {
|
|
137
|
+
return [
|
|
138
|
+
state.containsNonOnDemandable || classes.length === 0,
|
|
139
|
+
classes
|
|
140
|
+
];
|
|
141
|
+
}
|
|
113
142
|
return classes;
|
|
114
143
|
}
|
|
115
144
|
function withIdentifiers(styles) {
|
|
116
145
|
return parseStyles(styles).flatMap((node)=>{
|
|
117
146
|
let nodeMap = new Map();
|
|
118
|
-
let candidates = extractCandidates(node);
|
|
119
|
-
// If this isn't "on-demandable", assign it a universal candidate.
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
[
|
|
123
|
-
'*',
|
|
124
|
-
node
|
|
125
|
-
]
|
|
126
|
-
];
|
|
147
|
+
let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
|
|
148
|
+
// If this isn't "on-demandable", assign it a universal candidate to always include it.
|
|
149
|
+
if (containsNonOnDemandableSelectors) {
|
|
150
|
+
candidates.unshift('*');
|
|
127
151
|
}
|
|
152
|
+
// However, it could be that it also contains "on-demandable" candidates.
|
|
153
|
+
// E.g.: `span, .foo {}`, in that case it should still be possible to use
|
|
154
|
+
// `@apply foo` for example.
|
|
128
155
|
return candidates.map((c)=>{
|
|
129
156
|
if (!nodeMap.has(node)) {
|
|
130
157
|
nodeMap.set(node, node);
|
|
@@ -136,68 +163,6 @@ function withIdentifiers(styles) {
|
|
|
136
163
|
});
|
|
137
164
|
});
|
|
138
165
|
}
|
|
139
|
-
let matchingBrackets = new Map([
|
|
140
|
-
[
|
|
141
|
-
'{',
|
|
142
|
-
'}'
|
|
143
|
-
],
|
|
144
|
-
[
|
|
145
|
-
'[',
|
|
146
|
-
']'
|
|
147
|
-
],
|
|
148
|
-
[
|
|
149
|
-
'(',
|
|
150
|
-
')'
|
|
151
|
-
],
|
|
152
|
-
]);
|
|
153
|
-
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
154
|
-
v,
|
|
155
|
-
k
|
|
156
|
-
]
|
|
157
|
-
));
|
|
158
|
-
let quotes = new Set([
|
|
159
|
-
'"',
|
|
160
|
-
"'",
|
|
161
|
-
'`'
|
|
162
|
-
]);
|
|
163
|
-
// Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
164
|
-
// values don't count, and brackets inside quotes also don't count.
|
|
165
|
-
//
|
|
166
|
-
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
167
|
-
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
168
|
-
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
169
|
-
function isValidArbitraryValue(value) {
|
|
170
|
-
let stack = [];
|
|
171
|
-
let inQuotes = false;
|
|
172
|
-
for(let i = 0; i < value.length; i++){
|
|
173
|
-
let char = value[i];
|
|
174
|
-
// Non-escaped quotes allow us to "allow" anything in between
|
|
175
|
-
if (quotes.has(char) && value[i - 1] !== '\\') {
|
|
176
|
-
inQuotes = !inQuotes;
|
|
177
|
-
}
|
|
178
|
-
if (inQuotes) continue;
|
|
179
|
-
if (value[i - 1] === '\\') continue; // Escaped
|
|
180
|
-
if (matchingBrackets.has(char)) {
|
|
181
|
-
stack.push(char);
|
|
182
|
-
} else if (inverseMatchingBrackets.has(char)) {
|
|
183
|
-
let inverse = inverseMatchingBrackets.get(char);
|
|
184
|
-
// Nothing to pop from, therefore it is unbalanced
|
|
185
|
-
if (stack.length <= 0) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
// Popped value must match the inverse value, otherwise it is unbalanced
|
|
189
|
-
if (stack.pop() !== inverse) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
// If there is still something on the stack, it is also unbalanced
|
|
195
|
-
if (stack.length > 0) {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
// All good, totally balanced!
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
166
|
function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
202
167
|
function getConfigValue(path, defaultValue) {
|
|
203
168
|
return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
@@ -212,15 +177,40 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
212
177
|
if (!options.respectPrefix) {
|
|
213
178
|
return identifier;
|
|
214
179
|
}
|
|
215
|
-
if (typeof context.tailwindConfig.prefix === 'function') {
|
|
216
|
-
return (0, _prefixSelector).default(context.tailwindConfig.prefix, `.${identifier}`).substr(1);
|
|
217
|
-
}
|
|
218
180
|
return context.tailwindConfig.prefix + identifier;
|
|
219
181
|
}
|
|
220
182
|
return {
|
|
221
|
-
addVariant (variantName, variantFunctions, options = {
|
|
222
|
-
|
|
223
|
-
|
|
183
|
+
addVariant (variantName, variantFunctions, options = {}) {
|
|
184
|
+
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
185
|
+
if (typeof variantFunction !== 'string') {
|
|
186
|
+
// Safelist public API functions
|
|
187
|
+
return ({ modifySelectors , container , separator })=>{
|
|
188
|
+
return variantFunction({
|
|
189
|
+
modifySelectors,
|
|
190
|
+
container,
|
|
191
|
+
separator
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
196
|
+
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
197
|
+
if (!str.startsWith('@')) {
|
|
198
|
+
return ({ format })=>format(str)
|
|
199
|
+
;
|
|
200
|
+
}
|
|
201
|
+
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
202
|
+
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
203
|
+
name,
|
|
204
|
+
params
|
|
205
|
+
}))
|
|
206
|
+
;
|
|
207
|
+
}).reverse();
|
|
208
|
+
return (api)=>{
|
|
209
|
+
for (let fn of fns){
|
|
210
|
+
fn(api);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
});
|
|
224
214
|
insertInto(variantList, variantName, options);
|
|
225
215
|
variantMap.set(variantName, variantFunctions);
|
|
226
216
|
},
|
|
@@ -267,8 +257,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
267
257
|
},
|
|
268
258
|
addBase (base) {
|
|
269
259
|
for (let [identifier, rule] of withIdentifiers(base)){
|
|
270
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
271
|
-
});
|
|
260
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
272
261
|
let offset = offsets.base++;
|
|
273
262
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
274
263
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
@@ -282,24 +271,42 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
282
271
|
]);
|
|
283
272
|
}
|
|
284
273
|
},
|
|
274
|
+
/**
|
|
275
|
+
* @param {string} group
|
|
276
|
+
* @param {Record<string, string | string[]>} declarations
|
|
277
|
+
*/ addDefaults (group, declarations) {
|
|
278
|
+
const groups = {
|
|
279
|
+
[`@defaults ${group}`]: declarations
|
|
280
|
+
};
|
|
281
|
+
for (let [identifier, rule] of withIdentifiers(groups)){
|
|
282
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
283
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
284
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
285
|
+
}
|
|
286
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
287
|
+
{
|
|
288
|
+
sort: offsets.base++,
|
|
289
|
+
layer: 'defaults'
|
|
290
|
+
},
|
|
291
|
+
rule
|
|
292
|
+
]);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
285
295
|
addComponents (components, options) {
|
|
286
296
|
let defaultOptions = {
|
|
287
297
|
respectPrefix: true,
|
|
288
298
|
respectImportant: false
|
|
289
299
|
};
|
|
290
|
-
options = Object.assign({
|
|
291
|
-
}, defaultOptions, Array.isArray(options) ? {
|
|
292
|
-
} : options);
|
|
300
|
+
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
|
|
293
301
|
for (let [identifier, rule] of withIdentifiers(components)){
|
|
294
302
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
295
|
-
let offset = offsets.components++;
|
|
296
303
|
classList.add(prefixedIdentifier);
|
|
297
304
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
298
305
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
299
306
|
}
|
|
300
307
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
301
308
|
{
|
|
302
|
-
sort:
|
|
309
|
+
sort: offsets.components++,
|
|
303
310
|
layer: 'components',
|
|
304
311
|
options
|
|
305
312
|
},
|
|
@@ -312,19 +319,16 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
312
319
|
respectPrefix: true,
|
|
313
320
|
respectImportant: true
|
|
314
321
|
};
|
|
315
|
-
options = Object.assign({
|
|
316
|
-
}, defaultOptions, Array.isArray(options) ? {
|
|
317
|
-
} : options);
|
|
322
|
+
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
|
|
318
323
|
for (let [identifier, rule] of withIdentifiers(utilities)){
|
|
319
324
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
320
|
-
let offset = offsets.utilities++;
|
|
321
325
|
classList.add(prefixedIdentifier);
|
|
322
326
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
323
327
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
324
328
|
}
|
|
325
329
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
326
330
|
{
|
|
327
|
-
sort:
|
|
331
|
+
sort: offsets.utilities++,
|
|
328
332
|
layer: 'utilities',
|
|
329
333
|
options
|
|
330
334
|
},
|
|
@@ -359,7 +363,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
359
363
|
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
360
364
|
return [];
|
|
361
365
|
}
|
|
362
|
-
if (!
|
|
366
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
363
367
|
return [];
|
|
364
368
|
}
|
|
365
369
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -416,7 +420,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
416
420
|
return [];
|
|
417
421
|
}
|
|
418
422
|
}
|
|
419
|
-
if (!
|
|
423
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
420
424
|
return [];
|
|
421
425
|
}
|
|
422
426
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -451,11 +455,17 @@ function getFileModifiedMap(context) {
|
|
|
451
455
|
function trackModified(files, fileModifiedMap) {
|
|
452
456
|
let changed = false;
|
|
453
457
|
for (let file of files){
|
|
458
|
+
var ref;
|
|
454
459
|
if (!file) continue;
|
|
455
460
|
let parsed = _url.default.parse(file);
|
|
456
461
|
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href;
|
|
457
462
|
pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname;
|
|
458
|
-
let newModified = _fs.default.statSync(decodeURIComponent(pathname)
|
|
463
|
+
let newModified = (ref = _fs.default.statSync(decodeURIComponent(pathname), {
|
|
464
|
+
throwIfNoEntry: false
|
|
465
|
+
})) === null || ref === void 0 ? void 0 : ref.mtimeMs;
|
|
466
|
+
if (!newModified) {
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
459
469
|
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
460
470
|
changed = true;
|
|
461
471
|
}
|
|
@@ -557,7 +567,9 @@ function resolvePlugins(context, root) {
|
|
|
557
567
|
_corePlugins.variantPlugins['directionVariants'],
|
|
558
568
|
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
559
569
|
_corePlugins.variantPlugins['darkVariants'],
|
|
560
|
-
_corePlugins.variantPlugins['
|
|
570
|
+
_corePlugins.variantPlugins['printVariant'],
|
|
571
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
572
|
+
_corePlugins.variantPlugins['orientationVariants'],
|
|
561
573
|
];
|
|
562
574
|
return [
|
|
563
575
|
...corePluginList,
|
|
@@ -571,6 +583,7 @@ function registerPlugins(plugins, context) {
|
|
|
571
583
|
let variantList = [];
|
|
572
584
|
let variantMap = new Map();
|
|
573
585
|
let offsets = {
|
|
586
|
+
defaults: 0n,
|
|
574
587
|
base: 0n,
|
|
575
588
|
components: 0n,
|
|
576
589
|
utilities: 0n,
|
|
@@ -596,18 +609,23 @@ function registerPlugins(plugins, context) {
|
|
|
596
609
|
)
|
|
597
610
|
)([
|
|
598
611
|
offsets.base,
|
|
612
|
+
offsets.defaults,
|
|
599
613
|
offsets.components,
|
|
600
614
|
offsets.utilities,
|
|
601
615
|
offsets.user,
|
|
602
616
|
]);
|
|
603
617
|
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
618
|
+
// A number one less than the top range of the highest offset area
|
|
619
|
+
// so arbitrary properties are always sorted at the end.
|
|
620
|
+
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
604
621
|
context.layerOrder = {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
622
|
+
defaults: 1n << reservedBits << 0n,
|
|
623
|
+
base: 1n << reservedBits << 1n,
|
|
624
|
+
components: 1n << reservedBits << 2n,
|
|
625
|
+
utilities: 1n << reservedBits << 3n,
|
|
626
|
+
user: 1n << reservedBits << 4n
|
|
609
627
|
};
|
|
610
|
-
reservedBits +=
|
|
628
|
+
reservedBits += 5n;
|
|
611
629
|
let offset = 0;
|
|
612
630
|
context.variantOrder = new Map(variantList.map((variant, i)=>{
|
|
613
631
|
let variantFunctions = variantMap.get(variant).length;
|
|
@@ -623,9 +641,9 @@ function registerPlugins(plugins, context) {
|
|
|
623
641
|
...context.variantOrder.values()
|
|
624
642
|
].shift();
|
|
625
643
|
// Build variantMap
|
|
626
|
-
for (let [variantName,
|
|
644
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
627
645
|
let sort = context.variantOrder.get(variantName);
|
|
628
|
-
context.variantMap.set(variantName,
|
|
646
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
629
647
|
sort << BigInt(idx),
|
|
630
648
|
variantFunction
|
|
631
649
|
]
|
|
@@ -635,22 +653,22 @@ function registerPlugins(plugins, context) {
|
|
|
635
653
|
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
636
654
|
if (safelist.length > 0) {
|
|
637
655
|
let checks = [];
|
|
638
|
-
for (let
|
|
639
|
-
if (typeof
|
|
656
|
+
for (let value1 of safelist){
|
|
657
|
+
if (typeof value1 === 'string') {
|
|
640
658
|
context.changedContent.push({
|
|
641
|
-
content:
|
|
659
|
+
content: value1,
|
|
642
660
|
extension: 'html'
|
|
643
661
|
});
|
|
644
662
|
continue;
|
|
645
663
|
}
|
|
646
|
-
if (
|
|
664
|
+
if (value1 instanceof RegExp) {
|
|
647
665
|
_log.default.warn('root-regex', [
|
|
648
666
|
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
649
667
|
'Update your `safelist` configuration to eliminate this warning.'
|
|
650
668
|
]);
|
|
651
669
|
continue;
|
|
652
670
|
}
|
|
653
|
-
checks.push(
|
|
671
|
+
checks.push(value1);
|
|
654
672
|
}
|
|
655
673
|
if (checks.length > 0) {
|
|
656
674
|
let patternMatchingCount = new Map();
|
|
@@ -658,9 +676,16 @@ function registerPlugins(plugins, context) {
|
|
|
658
676
|
let utils = Array.isArray(util) ? (()=>{
|
|
659
677
|
let [utilName, options] = util;
|
|
660
678
|
var ref;
|
|
661
|
-
|
|
662
|
-
}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
679
|
+
let classes = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
663
680
|
);
|
|
681
|
+
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
682
|
+
classes = [
|
|
683
|
+
...classes,
|
|
684
|
+
...classes.map((cls)=>'-' + cls
|
|
685
|
+
)
|
|
686
|
+
];
|
|
687
|
+
}
|
|
688
|
+
return classes;
|
|
664
689
|
})() : [
|
|
665
690
|
util
|
|
666
691
|
];
|
|
@@ -705,8 +730,7 @@ function registerPlugins(plugins, context) {
|
|
|
705
730
|
let [utilName, options] = util;
|
|
706
731
|
let negativeClasses = [];
|
|
707
732
|
var ref;
|
|
708
|
-
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
709
|
-
})){
|
|
733
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
710
734
|
output.push((0, _nameClass).formatClass(utilName, key));
|
|
711
735
|
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
712
736
|
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
@@ -119,16 +119,17 @@ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
|
119
119
|
return changedFiles;
|
|
120
120
|
}
|
|
121
121
|
function setupTrackingContext(configOrPath) {
|
|
122
|
-
return ({ tailwindDirectives , registerDependency })=>{
|
|
122
|
+
return ({ tailwindDirectives , registerDependency , applyDirectives })=>{
|
|
123
123
|
return (root, result)=>{
|
|
124
124
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
125
125
|
let contextDependencies = new Set(configDependencies);
|
|
126
|
-
// If there are no @tailwind rules, we don't consider this CSS
|
|
127
|
-
// to be dependencies of the context. Can reuse
|
|
128
|
-
// We may want to think about `@layer`
|
|
129
|
-
//
|
|
130
|
-
// in
|
|
131
|
-
|
|
126
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS
|
|
127
|
+
// file or its dependencies to be dependencies of the context. Can reuse
|
|
128
|
+
// the context even if they change. We may want to think about `@layer`
|
|
129
|
+
// being part of this trigger too, but it's tough because it's impossible
|
|
130
|
+
// for a layer in one file to end up in the actual @tailwind rule in
|
|
131
|
+
// another file since independent sources are effectively isolated.
|
|
132
|
+
if (tailwindDirectives.size > 0 || applyDirectives.size > 0) {
|
|
132
133
|
// Add current css file as a context dependencies.
|
|
133
134
|
contextDependencies.add(result.opts.from);
|
|
134
135
|
// Add all css @import dependencies as context dependencies.
|
|
@@ -140,12 +141,12 @@ function setupTrackingContext(configOrPath) {
|
|
|
140
141
|
}
|
|
141
142
|
let [context] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
142
143
|
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
143
|
-
// If there are no @tailwind rules, we don't consider this CSS file or it's
|
|
144
|
-
// to be dependencies of the context. Can reuse the context even if they change.
|
|
144
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
145
|
+
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
145
146
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
146
147
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
147
148
|
// in another file since independent sources are effectively isolated.
|
|
148
|
-
if (tailwindDirectives.size > 0) {
|
|
149
|
+
if (tailwindDirectives.size > 0 || applyDirectives.size > 0) {
|
|
149
150
|
let fileModifiedMap = (0, _setupContextUtils).getFileModifiedMap(context);
|
|
150
151
|
// Add template paths as postcss dependencies.
|
|
151
152
|
for (let fileOrGlob of candidateFiles){
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
5
|
+
exports.resolveDebug = resolveDebug;
|
|
6
|
+
exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
|
|
6
7
|
const env = {
|
|
7
|
-
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
8
8
|
NODE_ENV: process.env.NODE_ENV,
|
|
9
|
-
DEBUG: process.env.DEBUG
|
|
10
|
-
TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
|
|
11
|
-
TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
|
|
9
|
+
DEBUG: resolveDebug(process.env.DEBUG)
|
|
12
10
|
};
|
|
13
11
|
exports.env = env;
|
|
14
12
|
const contextMap = new Map();
|
|
@@ -17,3 +15,34 @@ const configContextMap = new Map();
|
|
|
17
15
|
exports.configContextMap = configContextMap;
|
|
18
16
|
const contextSourcesMap = new Map();
|
|
19
17
|
exports.contextSourcesMap = contextSourcesMap;
|
|
18
|
+
function resolveDebug(debug) {
|
|
19
|
+
if (debug === undefined) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
// Environment variables are strings, so convert to boolean
|
|
23
|
+
if (debug === 'true' || debug === '1') {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (debug === 'false' || debug === '0') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// Keep the debug convention into account:
|
|
30
|
+
// DEBUG=* -> This enables all debug modes
|
|
31
|
+
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
32
|
+
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
33
|
+
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
34
|
+
if (debug === '*') {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
let debuggers = debug.split(',').map((d)=>d.split(':')[0]
|
|
38
|
+
);
|
|
39
|
+
// Ignoring tailwindcss
|
|
40
|
+
if (debuggers.includes('-tailwindcss')) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
// Including tailwindcss
|
|
44
|
+
if (debuggers.includes('tailwindcss')) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = _default;
|
|
6
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
6
7
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
7
8
|
function _interopRequireDefault(obj) {
|
|
8
9
|
return obj && obj.__esModule ? obj : {
|
|
@@ -12,13 +13,15 @@ function _interopRequireDefault(obj) {
|
|
|
12
13
|
function _default({ tailwindConfig: { theme } }) {
|
|
13
14
|
return function(css) {
|
|
14
15
|
css.walkAtRules('screen', (atRule)=>{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let screen = atRule.params;
|
|
17
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
|
|
18
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
+
);
|
|
20
|
+
if (!screenDefinition) {
|
|
18
21
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
19
22
|
}
|
|
20
23
|
atRule.name = 'media';
|
|
21
|
-
atRule.params = (0, _buildMediaQuery).default(
|
|
24
|
+
atRule.params = (0, _buildMediaQuery).default(screenDefinition);
|
|
22
25
|
});
|
|
23
26
|
};
|
|
24
27
|
}
|
|
@@ -10,6 +10,8 @@ var _evaluateTailwindFunctions = _interopRequireDefault(require("./lib/evaluateT
|
|
|
10
10
|
var _substituteScreenAtRules = _interopRequireDefault(require("./lib/substituteScreenAtRules"));
|
|
11
11
|
var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
12
12
|
var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
13
|
+
var _collapseDuplicateDeclarations = _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
14
|
+
var _partitionApplyAtRules = _interopRequireDefault(require("./lib/partitionApplyAtRules"));
|
|
13
15
|
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
14
16
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
15
17
|
var _featureFlags = require("./featureFlags");
|
|
@@ -20,9 +22,12 @@ function _interopRequireDefault(obj) {
|
|
|
20
22
|
}
|
|
21
23
|
function processTailwindFeatures(setupContext) {
|
|
22
24
|
return function(root, result) {
|
|
23
|
-
let tailwindDirectives = (0, _normalizeTailwindDirectives).default(root);
|
|
25
|
+
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
|
|
26
|
+
(0, _detectNesting).default()(root, result);
|
|
27
|
+
(0, _partitionApplyAtRules).default()(root, result);
|
|
24
28
|
let context = setupContext({
|
|
25
29
|
tailwindDirectives,
|
|
30
|
+
applyDirectives,
|
|
26
31
|
registerDependency (dependency) {
|
|
27
32
|
result.messages.push({
|
|
28
33
|
plugin: 'tailwindcss',
|
|
@@ -38,12 +43,12 @@ function processTailwindFeatures(setupContext) {
|
|
|
38
43
|
throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
|
|
39
44
|
}
|
|
40
45
|
(0, _featureFlags).issueFlagNotices(context.tailwindConfig);
|
|
41
|
-
(0, _detectNesting).default(context)(root, result);
|
|
42
46
|
(0, _expandTailwindAtRules).default(context)(root, result);
|
|
43
47
|
(0, _expandApplyAtRules).default(context)(root, result);
|
|
44
48
|
(0, _evaluateTailwindFunctions).default(context)(root, result);
|
|
45
49
|
(0, _substituteScreenAtRules).default(context)(root, result);
|
|
46
50
|
(0, _resolveDefaultsAtRules).default(context)(root, result);
|
|
47
51
|
(0, _collapseAdjacentRules).default(context)(root, result);
|
|
52
|
+
(0, _collapseDuplicateDeclarations).default(context)(root, result);
|
|
48
53
|
};
|
|
49
54
|
}
|