tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.d1f066d
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 +60 -1
- package/lib/cli.js +73 -74
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +7 -1
- package/lib/corePlugins.js +295 -228
- package/lib/css/preflight.css +12 -0
- package/lib/featureFlags.js +12 -9
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/evaluateTailwindFunctions.js +3 -3
- package/lib/lib/expandApplyAtRules.js +7 -7
- package/lib/lib/expandTailwindAtRules.js +14 -26
- package/lib/lib/generateRules.js +170 -27
- package/lib/lib/normalizeTailwindDirectives.js +3 -2
- package/lib/lib/resolveDefaultsAtRules.js +44 -47
- package/lib/lib/setupContextUtils.js +192 -123
- package/lib/lib/setupTrackingContext.js +3 -3
- package/lib/lib/setupWatchingContext.js +8 -4
- package/lib/lib/sharedState.js +2 -12
- package/lib/processTailwindFeatures.js +4 -0
- package/lib/public/colors.js +4 -8
- package/lib/util/createUtilityPlugin.js +5 -5
- package/lib/util/dataTypes.js +24 -4
- package/lib/util/formatVariantSelector.js +102 -0
- package/lib/util/log.js +30 -18
- package/lib/util/nameClass.js +1 -1
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +62 -158
- package/lib/util/prefixSelector.js +1 -3
- package/lib/util/resolveConfig.js +18 -77
- package/lib/util/transformThemeValue.js +23 -13
- package/package.json +11 -11
- package/peers/index.js +955 -2671
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +19 -13
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +303 -366
- package/src/css/preflight.css +12 -0
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/expandTailwindAtRules.js +15 -29
- package/src/lib/generateRules.js +194 -19
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +39 -43
- package/src/lib/setupContextUtils.js +183 -105
- package/src/lib/setupTrackingContext.js +3 -5
- package/src/lib/setupWatchingContext.js +10 -5
- package/src/lib/sharedState.js +1 -4
- package/src/processTailwindFeatures.js +5 -0
- package/src/public/colors.js +4 -9
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +32 -5
- package/src/util/formatVariantSelector.js +105 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +1 -1
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +50 -146
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +11 -64
- package/src/util/transformThemeValue.js +22 -7
- package/stubs/defaultConfig.stub.js +134 -91
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = resolveDefaultsAtRules;
|
|
6
|
+
exports.elementSelectorParser = void 0;
|
|
6
7
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
8
|
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
8
9
|
var _featureFlags = require("../featureFlags");
|
|
@@ -11,58 +12,53 @@ function _interopRequireDefault(obj) {
|
|
|
11
12
|
default: obj
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
15
|
+
let getNode = {
|
|
16
|
+
id (node) {
|
|
17
|
+
return _postcssSelectorParser.default.attribute({
|
|
18
|
+
attribute: 'id',
|
|
19
|
+
operator: '=',
|
|
20
|
+
value: node.value,
|
|
21
|
+
quoteMark: '"'
|
|
22
|
+
});
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
':before',
|
|
20
|
-
':after',
|
|
21
|
-
':first-line',
|
|
22
|
-
':first-letter'
|
|
23
|
-
].includes(n.value);
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
function minimumImpactSelector(nodes) {
|
|
26
|
-
let rest = nodes
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
if (match) {
|
|
59
|
-
bestNode = getNode(match);
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
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());
|
|
62
58
|
}
|
|
63
59
|
return [
|
|
64
60
|
bestNode,
|
|
65
|
-
...rest
|
|
61
|
+
...rest.reverse()
|
|
66
62
|
].join('').trim();
|
|
67
63
|
}
|
|
68
64
|
let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
@@ -72,6 +68,7 @@ let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
|
72
68
|
return minimumImpactSelector(nodes);
|
|
73
69
|
});
|
|
74
70
|
});
|
|
71
|
+
exports.elementSelectorParser = elementSelectorParser;
|
|
75
72
|
let cache = new Map();
|
|
76
73
|
function extractElementSelector(selector) {
|
|
77
74
|
if (!cache.has(selector)) {
|
|
@@ -18,10 +18,11 @@ var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName")
|
|
|
18
18
|
var _nameClass = _interopRequireWildcard(require("../util/nameClass"));
|
|
19
19
|
var _pluginUtils = require("../util/pluginUtils");
|
|
20
20
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
21
|
-
var _corePlugins =
|
|
21
|
+
var _corePlugins = require("../corePlugins");
|
|
22
22
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
23
23
|
var _toPath = require("../util/toPath");
|
|
24
24
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
|
+
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
25
26
|
function _interopRequireDefault(obj) {
|
|
26
27
|
return obj && obj.__esModule ? obj : {
|
|
27
28
|
default: obj
|
|
@@ -50,6 +51,30 @@ function _interopRequireWildcard(obj) {
|
|
|
50
51
|
return newObj;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
function parseVariantFormatString(input) {
|
|
55
|
+
if (input.includes('{')) {
|
|
56
|
+
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
57
|
+
return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)
|
|
58
|
+
).filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
input.trim()
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function isBalanced(input) {
|
|
65
|
+
let count = 0;
|
|
66
|
+
for (let char of input){
|
|
67
|
+
if (char === '{') {
|
|
68
|
+
count++;
|
|
69
|
+
} else if (char === '}') {
|
|
70
|
+
if (--count < 0) {
|
|
71
|
+
return false // unbalanced
|
|
72
|
+
;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return count === 0;
|
|
77
|
+
}
|
|
53
78
|
function insertInto(list, value, { before =[] } = {
|
|
54
79
|
}) {
|
|
55
80
|
before = [].concat(before);
|
|
@@ -211,15 +236,41 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
211
236
|
if (!options.respectPrefix) {
|
|
212
237
|
return identifier;
|
|
213
238
|
}
|
|
214
|
-
if (typeof context.tailwindConfig.prefix === 'function') {
|
|
215
|
-
return (0, _prefixSelector).default(context.tailwindConfig.prefix, `.${identifier}`).substr(1);
|
|
216
|
-
}
|
|
217
239
|
return context.tailwindConfig.prefix + identifier;
|
|
218
240
|
}
|
|
219
241
|
return {
|
|
220
242
|
addVariant (variantName, variantFunctions, options = {
|
|
221
243
|
}) {
|
|
222
|
-
variantFunctions = [].concat(variantFunctions)
|
|
244
|
+
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
245
|
+
if (typeof variantFunction !== 'string') {
|
|
246
|
+
// Safelist public API functions
|
|
247
|
+
return ({ modifySelectors , container , separator })=>{
|
|
248
|
+
return variantFunction({
|
|
249
|
+
modifySelectors,
|
|
250
|
+
container,
|
|
251
|
+
separator
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
256
|
+
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
257
|
+
if (!str.startsWith('@')) {
|
|
258
|
+
return ({ format })=>format(str)
|
|
259
|
+
;
|
|
260
|
+
}
|
|
261
|
+
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
262
|
+
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
263
|
+
name,
|
|
264
|
+
params
|
|
265
|
+
}))
|
|
266
|
+
;
|
|
267
|
+
}).reverse();
|
|
268
|
+
return (api)=>{
|
|
269
|
+
for (let fn of fns){
|
|
270
|
+
fn(api);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
});
|
|
223
274
|
insertInto(variantList, variantName, options);
|
|
224
275
|
variantMap.set(variantName, variantFunctions);
|
|
225
276
|
},
|
|
@@ -283,14 +334,11 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
283
334
|
},
|
|
284
335
|
addComponents (components, options) {
|
|
285
336
|
let defaultOptions = {
|
|
286
|
-
variants: [],
|
|
287
337
|
respectPrefix: true,
|
|
288
|
-
respectImportant: false
|
|
289
|
-
respectVariants: true
|
|
338
|
+
respectImportant: false
|
|
290
339
|
};
|
|
291
340
|
options = Object.assign({
|
|
292
341
|
}, defaultOptions, Array.isArray(options) ? {
|
|
293
|
-
variants: options
|
|
294
342
|
} : options);
|
|
295
343
|
for (let [identifier, rule] of withIdentifiers(components)){
|
|
296
344
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
@@ -311,14 +359,11 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
311
359
|
},
|
|
312
360
|
addUtilities (utilities, options) {
|
|
313
361
|
let defaultOptions = {
|
|
314
|
-
variants: [],
|
|
315
362
|
respectPrefix: true,
|
|
316
|
-
respectImportant: true
|
|
317
|
-
respectVariants: true
|
|
363
|
+
respectImportant: true
|
|
318
364
|
};
|
|
319
365
|
options = Object.assign({
|
|
320
366
|
}, defaultOptions, Array.isArray(options) ? {
|
|
321
|
-
variants: options
|
|
322
367
|
} : options);
|
|
323
368
|
for (let [identifier, rule] of withIdentifiers(utilities)){
|
|
324
369
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
@@ -339,10 +384,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
339
384
|
},
|
|
340
385
|
matchUtilities: function(utilities, options) {
|
|
341
386
|
let defaultOptions = {
|
|
342
|
-
variants: [],
|
|
343
387
|
respectPrefix: true,
|
|
344
|
-
respectImportant: true
|
|
345
|
-
respectVariants: true
|
|
388
|
+
respectImportant: true
|
|
346
389
|
};
|
|
347
390
|
options = {
|
|
348
391
|
...defaultOptions,
|
|
@@ -359,7 +402,57 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
359
402
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
360
403
|
let { type ='any' } = options;
|
|
361
404
|
type = [].concat(type);
|
|
362
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options
|
|
405
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
406
|
+
if (value === undefined) {
|
|
407
|
+
return [];
|
|
408
|
+
}
|
|
409
|
+
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
410
|
+
return [];
|
|
411
|
+
}
|
|
412
|
+
if (!isValidArbitraryValue(value)) {
|
|
413
|
+
return [];
|
|
414
|
+
}
|
|
415
|
+
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
416
|
+
[(0, _nameClass).default(identifier, modifier)]: declaration
|
|
417
|
+
})
|
|
418
|
+
);
|
|
419
|
+
return ruleSets;
|
|
420
|
+
}
|
|
421
|
+
let withOffsets = [
|
|
422
|
+
{
|
|
423
|
+
sort: offset,
|
|
424
|
+
layer: 'utilities',
|
|
425
|
+
options
|
|
426
|
+
},
|
|
427
|
+
wrapped
|
|
428
|
+
];
|
|
429
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
430
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
431
|
+
}
|
|
432
|
+
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
matchComponents: function(components, options) {
|
|
436
|
+
let defaultOptions = {
|
|
437
|
+
respectPrefix: true,
|
|
438
|
+
respectImportant: false
|
|
439
|
+
};
|
|
440
|
+
options = {
|
|
441
|
+
...defaultOptions,
|
|
442
|
+
...options
|
|
443
|
+
};
|
|
444
|
+
let offset = offsets.components++;
|
|
445
|
+
for(let identifier in components){
|
|
446
|
+
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
447
|
+
let rule = components[identifier];
|
|
448
|
+
classList.add([
|
|
449
|
+
prefixedIdentifier,
|
|
450
|
+
options
|
|
451
|
+
]);
|
|
452
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
453
|
+
let { type ='any' } = options;
|
|
454
|
+
type = [].concat(type);
|
|
455
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
363
456
|
if (value === undefined) {
|
|
364
457
|
return [];
|
|
365
458
|
}
|
|
@@ -376,24 +469,16 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
376
469
|
if (!isValidArbitraryValue(value)) {
|
|
377
470
|
return [];
|
|
378
471
|
}
|
|
379
|
-
let
|
|
380
|
-
let ruleSets = [].concat(rule(value, {
|
|
381
|
-
includeRules (rules) {
|
|
382
|
-
includedRules.push(...rules);
|
|
383
|
-
}
|
|
384
|
-
})).filter(Boolean).map((declaration)=>({
|
|
472
|
+
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
385
473
|
[(0, _nameClass).default(identifier, modifier)]: declaration
|
|
386
474
|
})
|
|
387
475
|
);
|
|
388
|
-
return
|
|
389
|
-
...includedRules,
|
|
390
|
-
...ruleSets
|
|
391
|
-
];
|
|
476
|
+
return ruleSets;
|
|
392
477
|
}
|
|
393
478
|
let withOffsets = [
|
|
394
479
|
{
|
|
395
480
|
sort: offset,
|
|
396
|
-
layer: '
|
|
481
|
+
layer: 'components',
|
|
397
482
|
options
|
|
398
483
|
},
|
|
399
484
|
wrapped
|
|
@@ -496,7 +581,10 @@ function collectLayerPlugins(root) {
|
|
|
496
581
|
return layerPlugins;
|
|
497
582
|
}
|
|
498
583
|
function resolvePlugins(context, root) {
|
|
499
|
-
let corePluginList = Object.entries(
|
|
584
|
+
let corePluginList = Object.entries({
|
|
585
|
+
..._corePlugins.variantPlugins,
|
|
586
|
+
..._corePlugins.corePlugins
|
|
587
|
+
}).map(([name, plugin])=>{
|
|
500
588
|
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
501
589
|
return null;
|
|
502
590
|
}
|
|
@@ -512,14 +600,15 @@ function resolvePlugins(context, root) {
|
|
|
512
600
|
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
513
601
|
// were historically sorted before screen/stackable variants.
|
|
514
602
|
let beforeVariants = [
|
|
515
|
-
_corePlugins.
|
|
516
|
-
_corePlugins.
|
|
603
|
+
_corePlugins.variantPlugins['pseudoElementVariants'],
|
|
604
|
+
_corePlugins.variantPlugins['pseudoClassVariants'],
|
|
517
605
|
];
|
|
518
606
|
let afterVariants = [
|
|
519
|
-
_corePlugins.
|
|
520
|
-
_corePlugins.
|
|
521
|
-
_corePlugins.
|
|
522
|
-
_corePlugins.
|
|
607
|
+
_corePlugins.variantPlugins['directionVariants'],
|
|
608
|
+
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
609
|
+
_corePlugins.variantPlugins['darkVariants'],
|
|
610
|
+
_corePlugins.variantPlugins['printVariant'],
|
|
611
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
523
612
|
];
|
|
524
613
|
return [
|
|
525
614
|
...corePluginList,
|
|
@@ -585,116 +674,96 @@ function registerPlugins(plugins, context) {
|
|
|
585
674
|
...context.variantOrder.values()
|
|
586
675
|
].shift();
|
|
587
676
|
// Build variantMap
|
|
588
|
-
for (let [variantName,
|
|
677
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
589
678
|
let sort = context.variantOrder.get(variantName);
|
|
590
|
-
context.variantMap.set(variantName,
|
|
679
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
591
680
|
sort << BigInt(idx),
|
|
592
681
|
variantFunction
|
|
593
682
|
]
|
|
594
683
|
));
|
|
595
684
|
}
|
|
596
|
-
|
|
597
|
-
let
|
|
598
|
-
|
|
599
|
-
var _safelist;
|
|
600
|
-
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
601
|
-
if (safelist.length <= 0) return [];
|
|
602
|
-
let output = [];
|
|
685
|
+
var _safelist;
|
|
686
|
+
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
687
|
+
if (safelist.length > 0) {
|
|
603
688
|
let checks = [];
|
|
604
|
-
for (let
|
|
605
|
-
if (typeof
|
|
606
|
-
|
|
689
|
+
for (let value1 of safelist){
|
|
690
|
+
if (typeof value1 === 'string') {
|
|
691
|
+
context.changedContent.push({
|
|
692
|
+
content: value1,
|
|
693
|
+
extension: 'html'
|
|
694
|
+
});
|
|
607
695
|
continue;
|
|
608
696
|
}
|
|
609
|
-
if (
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
'Please use the object syntax instead: https://tailwindcss.com/docs/...',
|
|
615
|
-
]);
|
|
616
|
-
warnedAbout.add('root-regex');
|
|
617
|
-
}
|
|
697
|
+
if (value1 instanceof RegExp) {
|
|
698
|
+
_log.default.warn('root-regex', [
|
|
699
|
+
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
700
|
+
'Update your `safelist` configuration to eliminate this warning.'
|
|
701
|
+
]);
|
|
618
702
|
continue;
|
|
619
703
|
}
|
|
620
|
-
checks.push(
|
|
704
|
+
checks.push(value1);
|
|
621
705
|
}
|
|
622
|
-
if (checks.length
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
)
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
706
|
+
if (checks.length > 0) {
|
|
707
|
+
let patternMatchingCount = new Map();
|
|
708
|
+
for (let util of classList){
|
|
709
|
+
let utils = Array.isArray(util) ? (()=>{
|
|
710
|
+
let [utilName, options] = util;
|
|
711
|
+
var ref;
|
|
712
|
+
return Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
713
|
+
}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
714
|
+
);
|
|
715
|
+
})() : [
|
|
716
|
+
util
|
|
717
|
+
];
|
|
718
|
+
for (let util1 of utils){
|
|
719
|
+
for (let { pattern , variants =[] } of checks){
|
|
720
|
+
// RegExp with the /g flag are stateful, so let's reset the last
|
|
721
|
+
// index pointer to reset the state.
|
|
722
|
+
pattern.lastIndex = 0;
|
|
723
|
+
if (!patternMatchingCount.has(pattern)) {
|
|
724
|
+
patternMatchingCount.set(pattern, 0);
|
|
725
|
+
}
|
|
726
|
+
if (!pattern.test(util1)) continue;
|
|
727
|
+
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
|
|
728
|
+
context.changedContent.push({
|
|
729
|
+
content: util1,
|
|
730
|
+
extension: 'html'
|
|
731
|
+
});
|
|
732
|
+
for (let variant of variants){
|
|
733
|
+
context.changedContent.push({
|
|
734
|
+
content: variant + context.tailwindConfig.separator + util1,
|
|
735
|
+
extension: 'html'
|
|
736
|
+
});
|
|
737
|
+
}
|
|
651
738
|
}
|
|
652
739
|
}
|
|
653
740
|
}
|
|
741
|
+
for (let [regex, count] of patternMatchingCount.entries()){
|
|
742
|
+
if (count !== 0) continue;
|
|
743
|
+
_log.default.warn([
|
|
744
|
+
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
745
|
+
'Fix this pattern or remove it from your `safelist` configuration.',
|
|
746
|
+
]);
|
|
747
|
+
}
|
|
654
748
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
`You have a regex pattern in your "safelist" config (${regex}) that doesn't match any utilities.`,
|
|
660
|
-
'For more info, visit https://tailwindcss.com/docs/...',
|
|
661
|
-
]);
|
|
662
|
-
}
|
|
663
|
-
return output.map((value)=>({
|
|
664
|
-
raw: value,
|
|
665
|
-
extension: 'html'
|
|
666
|
-
})
|
|
667
|
-
);
|
|
668
|
-
};
|
|
669
|
-
// Generate a list of strings for autocompletion purposes. Colors will have a
|
|
670
|
-
// tuple with options, e.g.:
|
|
671
|
-
// ['uppercase', 'lowercase', ['bg-red', { color: 'rgb(255 0 0)' }]]
|
|
672
|
-
context.completions = function() {
|
|
673
|
-
// TODO: Try and detect color from components?
|
|
674
|
-
// TODO: Should we provide a simple "public api" file with functions?
|
|
749
|
+
}
|
|
750
|
+
// Generate a list of strings for autocompletion purposes, e.g.
|
|
751
|
+
// ['uppercase', 'lowercase', ...]
|
|
752
|
+
context.getClassList = function() {
|
|
675
753
|
let output = [];
|
|
676
754
|
for (let util of classList){
|
|
677
755
|
if (Array.isArray(util)) {
|
|
678
756
|
let [utilName, options] = util;
|
|
679
|
-
let
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
{
|
|
687
|
-
color
|
|
688
|
-
}
|
|
689
|
-
]);
|
|
690
|
-
}
|
|
691
|
-
} else {
|
|
692
|
-
var ref;
|
|
693
|
-
for (let value of Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
694
|
-
})){
|
|
695
|
-
output.push((0, _nameClass).formatClass(utilName, value));
|
|
757
|
+
let negativeClasses = [];
|
|
758
|
+
var ref;
|
|
759
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
760
|
+
})){
|
|
761
|
+
output.push((0, _nameClass).formatClass(utilName, key));
|
|
762
|
+
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
763
|
+
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
696
764
|
}
|
|
697
765
|
}
|
|
766
|
+
output.push(...negativeClasses);
|
|
698
767
|
} else {
|
|
699
768
|
output.push(util);
|
|
700
769
|
}
|
|
@@ -28,7 +28,7 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
28
28
|
if (candidateFilesCache.has(context)) {
|
|
29
29
|
return candidateFilesCache.get(context);
|
|
30
30
|
}
|
|
31
|
-
let candidateFiles = tailwindConfig.content.
|
|
31
|
+
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === 'string'
|
|
32
32
|
).map((contentPath)=>(0, _normalizePath).default(contentPath)
|
|
33
33
|
);
|
|
34
34
|
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
@@ -87,8 +87,8 @@ function getTailwindConfig(configOrPath) {
|
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
89
|
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
90
|
-
let changedContent = context.tailwindConfig.content.
|
|
91
|
-
).
|
|
90
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
|
|
91
|
+
).map(({ raw , extension ='html' })=>({
|
|
92
92
|
content: raw,
|
|
93
93
|
extension
|
|
94
94
|
})
|
|
@@ -75,7 +75,11 @@ function rebootWatcher(context, configPath, configDependencies, candidateFiles)
|
|
|
75
75
|
...candidateFiles,
|
|
76
76
|
...configDependencies
|
|
77
77
|
], {
|
|
78
|
-
ignoreInitial: true
|
|
78
|
+
ignoreInitial: true,
|
|
79
|
+
awaitWriteFinish: process.platform === 'win32' ? {
|
|
80
|
+
stabilityThreshold: 50,
|
|
81
|
+
pollInterval: 10
|
|
82
|
+
} : false
|
|
79
83
|
});
|
|
80
84
|
setWatcher(context, watcher);
|
|
81
85
|
watcher.on('add', (file)=>{
|
|
@@ -136,7 +140,7 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
136
140
|
if (candidateFilesCache.has(context)) {
|
|
137
141
|
return candidateFilesCache.get(context);
|
|
138
142
|
}
|
|
139
|
-
let candidateFiles = tailwindConfig.content.
|
|
143
|
+
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === 'string'
|
|
140
144
|
).map((contentPath)=>(0, _normalizePath).default(contentPath)
|
|
141
145
|
);
|
|
142
146
|
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
@@ -186,8 +190,8 @@ function getTailwindConfig(configOrPath) {
|
|
|
186
190
|
];
|
|
187
191
|
}
|
|
188
192
|
function resolvedChangedContent(context, candidateFiles) {
|
|
189
|
-
let changedContent = context.tailwindConfig.content.
|
|
190
|
-
).
|
|
193
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
|
|
194
|
+
).map(({ raw , extension ='html' })=>({
|
|
191
195
|
content: raw,
|
|
192
196
|
extension
|
|
193
197
|
})
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
6
|
-
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
7
|
-
function _interopRequireDefault(obj) {
|
|
8
|
-
return obj && obj.__esModule ? obj : {
|
|
9
|
-
default: obj
|
|
10
|
-
};
|
|
11
|
-
}
|
|
5
|
+
exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
|
|
12
6
|
const env = {
|
|
13
7
|
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
14
8
|
NODE_ENV: process.env.NODE_ENV,
|
|
15
|
-
DEBUG: process.env.DEBUG !== undefined,
|
|
9
|
+
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
|
|
16
10
|
TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
|
|
17
11
|
TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
|
|
18
12
|
};
|
|
@@ -23,7 +17,3 @@ const configContextMap = new Map();
|
|
|
23
17
|
exports.configContextMap = configContextMap;
|
|
24
18
|
const contextSourcesMap = new Map();
|
|
25
19
|
exports.contextSourcesMap = contextSourcesMap;
|
|
26
|
-
const contentMatchCache = new _quickLru.default({
|
|
27
|
-
maxSize: 25000
|
|
28
|
-
});
|
|
29
|
-
exports.contentMatchCache = contentMatchCache;
|
|
@@ -10,8 +10,10 @@ 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"));
|
|
13
14
|
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
14
15
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
16
|
+
var _featureFlags = require("./featureFlags");
|
|
15
17
|
function _interopRequireDefault(obj) {
|
|
16
18
|
return obj && obj.__esModule ? obj : {
|
|
17
19
|
default: obj
|
|
@@ -36,6 +38,7 @@ function processTailwindFeatures(setupContext) {
|
|
|
36
38
|
if (context.tailwindConfig.separator === '-') {
|
|
37
39
|
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.");
|
|
38
40
|
}
|
|
41
|
+
(0, _featureFlags).issueFlagNotices(context.tailwindConfig);
|
|
39
42
|
(0, _detectNesting).default(context)(root, result);
|
|
40
43
|
(0, _expandTailwindAtRules).default(context)(root, result);
|
|
41
44
|
(0, _expandApplyAtRules).default(context)(root, result);
|
|
@@ -43,5 +46,6 @@ function processTailwindFeatures(setupContext) {
|
|
|
43
46
|
(0, _substituteScreenAtRules).default(context)(root, result);
|
|
44
47
|
(0, _resolveDefaultsAtRules).default(context)(root, result);
|
|
45
48
|
(0, _collapseAdjacentRules).default(context)(root, result);
|
|
49
|
+
(0, _collapseDuplicateDeclarations).default(context)(root, result);
|
|
46
50
|
};
|
|
47
51
|
}
|