tailwindcss 0.0.0-insiders.e7dbc1a → 0.0.0-insiders.f2bc50a
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/README.md +1 -1
- package/defaultConfig.js +1 -1
- package/defaultTheme.js +1 -1
- package/lib/lib/detectNesting.js +21 -0
- package/lib/lib/setupContextUtils.js +94 -4
- package/lib/lib/setupTrackingContext.js +1 -1
- package/lib/lib/setupWatchingContext.js +1 -1
- package/lib/processTailwindFeatures.js +3 -0
- package/lib/util/nameClass.js +9 -4
- package/package.json +3 -3
- package/src/lib/detectNesting.js +20 -0
- package/src/lib/setupContextUtils.js +89 -2
- package/src/lib/setupTrackingContext.js +1 -0
- package/src/lib/setupWatchingContext.js +1 -0
- package/src/processTailwindFeatures.js +2 -0
- package/src/util/nameClass.js +8 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p>
|
|
2
2
|
<a href="https://tailwindcss.com/" target="_blank">
|
|
3
|
-
<img alt="Tailwind CSS" width="350" src="https://refactoringui.nyc3.cdn.digitaloceanspaces.com/tailwind-logo.svg">
|
|
3
|
+
<img alt="Tailwind CSS" width="350" src="https://refactoringui.nyc3.cdn.digitaloceanspaces.com/tailwind-logo-sticker.svg">
|
|
4
4
|
</a><br>
|
|
5
5
|
A utility-first CSS framework for rapidly building custom user interfaces.
|
|
6
6
|
</p>
|
package/defaultConfig.js
CHANGED
package/defaultTheme.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
|
|
8
|
+
function _default(_context) {
|
|
9
|
+
return (root, result) => {
|
|
10
|
+
let found = false;
|
|
11
|
+
root.walkRules(rule => {
|
|
12
|
+
if (found) return false;
|
|
13
|
+
rule.walkRules(nestedRule => {
|
|
14
|
+
found = true;
|
|
15
|
+
nestedRule.warn(result, // TODO: Improve this warning message
|
|
16
|
+
'Nested CSS detected, checkout the docs on how to support nesting: https://tailwindcss.com/docs/using-with-preprocessors#nesting');
|
|
17
|
+
return false;
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -27,7 +27,7 @@ var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
|
|
|
27
27
|
|
|
28
28
|
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
29
29
|
|
|
30
|
-
var _nameClass =
|
|
30
|
+
var _nameClass = _interopRequireWildcard(require("../util/nameClass"));
|
|
31
31
|
|
|
32
32
|
var _pluginUtils = require("../util/pluginUtils");
|
|
33
33
|
|
|
@@ -39,6 +39,8 @@ var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
|
39
39
|
|
|
40
40
|
var _toPath = require("../util/toPath");
|
|
41
41
|
|
|
42
|
+
var _log = _interopRequireDefault(require("../util/log"));
|
|
43
|
+
|
|
42
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
45
|
|
|
44
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -170,7 +172,8 @@ function isValidArbitraryValue(value) {
|
|
|
170
172
|
function buildPluginApi(tailwindConfig, context, {
|
|
171
173
|
variantList,
|
|
172
174
|
variantMap,
|
|
173
|
-
offsets
|
|
175
|
+
offsets,
|
|
176
|
+
classList
|
|
174
177
|
}) {
|
|
175
178
|
function getConfigValue(path, defaultValue) {
|
|
176
179
|
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
@@ -271,6 +274,7 @@ function buildPluginApi(tailwindConfig, context, {
|
|
|
271
274
|
for (let [identifier, rule] of withIdentifiers(components)) {
|
|
272
275
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
273
276
|
let offset = offsets.components++;
|
|
277
|
+
classList.add(prefixedIdentifier);
|
|
274
278
|
|
|
275
279
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
276
280
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
@@ -298,6 +302,7 @@ function buildPluginApi(tailwindConfig, context, {
|
|
|
298
302
|
for (let [identifier, rule] of withIdentifiers(utilities)) {
|
|
299
303
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
300
304
|
let offset = offsets.utilities++;
|
|
305
|
+
classList.add(prefixedIdentifier);
|
|
301
306
|
|
|
302
307
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
303
308
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
@@ -326,6 +331,7 @@ function buildPluginApi(tailwindConfig, context, {
|
|
|
326
331
|
for (let identifier in utilities) {
|
|
327
332
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
328
333
|
let rule = utilities[identifier];
|
|
334
|
+
classList.add([prefixedIdentifier, options]);
|
|
329
335
|
|
|
330
336
|
function wrapped(modifier) {
|
|
331
337
|
let {
|
|
@@ -510,10 +516,12 @@ function registerPlugins(plugins, context) {
|
|
|
510
516
|
utilities: 0n,
|
|
511
517
|
user: 0n
|
|
512
518
|
};
|
|
519
|
+
let classList = new Set();
|
|
513
520
|
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
514
521
|
variantList,
|
|
515
522
|
variantMap,
|
|
516
|
-
offsets
|
|
523
|
+
offsets,
|
|
524
|
+
classList
|
|
517
525
|
});
|
|
518
526
|
|
|
519
527
|
for (let plugin of plugins) {
|
|
@@ -548,7 +556,89 @@ function registerPlugins(plugins, context) {
|
|
|
548
556
|
for (let [variantName, variantFunctions] of variantMap.entries()) {
|
|
549
557
|
let sort = context.variantOrder.get(variantName);
|
|
550
558
|
context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx) => [sort << BigInt(idx), variantFunction]));
|
|
551
|
-
}
|
|
559
|
+
} //
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
let warnedAbout = new Set([]);
|
|
563
|
+
|
|
564
|
+
context.safelist = function () {
|
|
565
|
+
var _context$tailwindConf;
|
|
566
|
+
|
|
567
|
+
let safelist = ((_context$tailwindConf = context.tailwindConfig.safelist) !== null && _context$tailwindConf !== void 0 ? _context$tailwindConf : []).filter(Boolean);
|
|
568
|
+
if (safelist.length <= 0) return [];
|
|
569
|
+
let output = [];
|
|
570
|
+
let checks = [];
|
|
571
|
+
|
|
572
|
+
for (let value of safelist) {
|
|
573
|
+
if (typeof value === 'string') {
|
|
574
|
+
output.push(value);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (value instanceof RegExp) {
|
|
579
|
+
if (!warnedAbout.has('root-regex')) {
|
|
580
|
+
_log.default.warn([// TODO: Improve this warning message
|
|
581
|
+
'RegExp in the safelist option is not supported.', 'Please use the object syntax instead: https://tailwindcss.com/docs/...']);
|
|
582
|
+
|
|
583
|
+
warnedAbout.add('root-regex');
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
checks.push(value);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
if (checks.length <= 0) return output.map(value => ({
|
|
593
|
+
raw: value,
|
|
594
|
+
extension: 'html'
|
|
595
|
+
}));
|
|
596
|
+
let patternMatchingCount = new Map();
|
|
597
|
+
|
|
598
|
+
for (let util of classList) {
|
|
599
|
+
let utils = Array.isArray(util) ? (() => {
|
|
600
|
+
var _options$values;
|
|
601
|
+
|
|
602
|
+
let [utilName, options] = util;
|
|
603
|
+
return Object.keys((_options$values = options === null || options === void 0 ? void 0 : options.values) !== null && _options$values !== void 0 ? _options$values : {}).map(value => (0, _nameClass.formatClass)(utilName, value));
|
|
604
|
+
})() : [util];
|
|
605
|
+
|
|
606
|
+
for (let util of utils) {
|
|
607
|
+
for (let {
|
|
608
|
+
pattern,
|
|
609
|
+
variants = []
|
|
610
|
+
} of checks) {
|
|
611
|
+
// RegExp with the /g flag are stateful, so let's reset the last
|
|
612
|
+
// index pointer to reset the state.
|
|
613
|
+
pattern.lastIndex = 0;
|
|
614
|
+
|
|
615
|
+
if (!patternMatchingCount.has(pattern)) {
|
|
616
|
+
patternMatchingCount.set(pattern, 0);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (!pattern.test(util)) continue;
|
|
620
|
+
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
|
|
621
|
+
output.push(util);
|
|
622
|
+
|
|
623
|
+
for (let variant of variants) {
|
|
624
|
+
output.push(variant + context.tailwindConfig.separator + util);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
for (let [regex, count] of patternMatchingCount.entries()) {
|
|
631
|
+
if (count !== 0) continue;
|
|
632
|
+
|
|
633
|
+
_log.default.warn([// TODO: Improve this warning message
|
|
634
|
+
`You have a regex pattern in your "safelist" config (${regex}) that doesn't match any utilities.`, 'For more info, visit https://tailwindcss.com/docs/...']);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
return output.map(value => ({
|
|
638
|
+
raw: value,
|
|
639
|
+
extension: 'html'
|
|
640
|
+
}));
|
|
641
|
+
};
|
|
552
642
|
}
|
|
553
643
|
|
|
554
644
|
function createContext(tailwindConfig, changedContent = [], tailwindDirectives = new Set(), root = _postcss.default.root()) {
|
|
@@ -87,7 +87,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
90
|
-
let changedContent = context.tailwindConfig.content.content.filter(item => typeof item.raw === 'string').concat(context.tailwindConfig.content.safelist).map(({
|
|
90
|
+
let changedContent = context.tailwindConfig.content.content.filter(item => typeof item.raw === 'string').concat(context.tailwindConfig.content.safelist).concat(context.safelist()).map(({
|
|
91
91
|
raw,
|
|
92
92
|
extension
|
|
93
93
|
}) => ({
|
|
@@ -204,7 +204,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
function resolvedChangedContent(context, candidateFiles) {
|
|
207
|
-
let changedContent = context.tailwindConfig.content.content.filter(item => typeof item.raw === 'string').concat(context.tailwindConfig.content.safelist).map(({
|
|
207
|
+
let changedContent = context.tailwindConfig.content.content.filter(item => typeof item.raw === 'string').concat(context.tailwindConfig.content.safelist).concat(context.safelist()).map(({
|
|
208
208
|
raw,
|
|
209
209
|
extension
|
|
210
210
|
}) => ({
|
|
@@ -19,6 +19,8 @@ var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefau
|
|
|
19
19
|
|
|
20
20
|
var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
21
21
|
|
|
22
|
+
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
23
|
+
|
|
22
24
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -47,6 +49,7 @@ function processTailwindFeatures(setupContext) {
|
|
|
47
49
|
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.");
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
(0, _detectNesting.default)(context)(root, result);
|
|
50
53
|
(0, _expandTailwindAtRules.default)(context)(root, result);
|
|
51
54
|
(0, _expandApplyAtRules.default)(context)(root, result);
|
|
52
55
|
(0, _evaluateTailwindFunctions.default)(context)(root, result);
|
package/lib/util/nameClass.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = nameClass;
|
|
7
|
+
exports.formatClass = formatClass;
|
|
7
8
|
|
|
8
9
|
var _escapeClassName = _interopRequireDefault(require("./escapeClassName"));
|
|
9
10
|
|
|
@@ -16,17 +17,21 @@ function asClass(name) {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
function nameClass(classPrefix, key) {
|
|
20
|
+
return asClass(formatClass(classPrefix, key));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function formatClass(classPrefix, key) {
|
|
19
24
|
if (key === 'DEFAULT') {
|
|
20
|
-
return
|
|
25
|
+
return classPrefix;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
if (key === '-') {
|
|
24
|
-
return
|
|
29
|
+
return `-${classPrefix}`;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
if (key.startsWith('-')) {
|
|
28
|
-
return
|
|
33
|
+
return `-${classPrefix}${key}`;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
return
|
|
36
|
+
return `${classPrefix}-${key}`;
|
|
32
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "0.0.0-insiders.
|
|
3
|
+
"version": "0.0.0-insiders.f2bc50a",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@babel/node": "^7.12.13",
|
|
48
48
|
"@babel/preset-env": "^7.15.0",
|
|
49
49
|
"@tailwindcss/aspect-ratio": "^0.2.1",
|
|
50
|
-
"@vercel/ncc": "^0.
|
|
50
|
+
"@vercel/ncc": "^0.31.1",
|
|
51
51
|
"autoprefixer": "^10.3.3",
|
|
52
52
|
"babel-jest": "^27.1.0",
|
|
53
53
|
"cross-env": "^7.0.3",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"jest-diff": "^27.1.0",
|
|
60
60
|
"postcss": "^8.3.6",
|
|
61
61
|
"postcss-cli": "^8.3.1",
|
|
62
|
-
"prettier": "^2.
|
|
62
|
+
"prettier": "^2.4.1",
|
|
63
63
|
"rimraf": "^3.0.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function (_context) {
|
|
2
|
+
return (root, result) => {
|
|
3
|
+
let found = false
|
|
4
|
+
|
|
5
|
+
root.walkRules((rule) => {
|
|
6
|
+
if (found) return false
|
|
7
|
+
|
|
8
|
+
rule.walkRules((nestedRule) => {
|
|
9
|
+
found = true
|
|
10
|
+
nestedRule.warn(
|
|
11
|
+
result,
|
|
12
|
+
// TODO: Improve this warning message
|
|
13
|
+
'Nested CSS detected, checkout the docs on how to support nesting: https://tailwindcss.com/docs/using-with-preprocessors#nesting'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
return false
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -9,13 +9,14 @@ import parseObjectStyles from '../util/parseObjectStyles'
|
|
|
9
9
|
import prefixSelector from '../util/prefixSelector'
|
|
10
10
|
import isPlainObject from '../util/isPlainObject'
|
|
11
11
|
import escapeClassName from '../util/escapeClassName'
|
|
12
|
-
import nameClass from '../util/nameClass'
|
|
12
|
+
import nameClass, { formatClass } from '../util/nameClass'
|
|
13
13
|
import { coerceValue } from '../util/pluginUtils'
|
|
14
14
|
import bigSign from '../util/bigSign'
|
|
15
15
|
import * as corePlugins from '../corePlugins'
|
|
16
16
|
import * as sharedState from './sharedState'
|
|
17
17
|
import { env } from './sharedState'
|
|
18
18
|
import { toPath } from '../util/toPath'
|
|
19
|
+
import log from '../util/log'
|
|
19
20
|
|
|
20
21
|
function insertInto(list, value, { before = [] } = {}) {
|
|
21
22
|
before = [].concat(before)
|
|
@@ -146,7 +147,7 @@ function isValidArbitraryValue(value) {
|
|
|
146
147
|
return true
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offsets }) {
|
|
150
|
+
function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offsets, classList }) {
|
|
150
151
|
function getConfigValue(path, defaultValue) {
|
|
151
152
|
return path ? dlv(tailwindConfig, path, defaultValue) : tailwindConfig
|
|
152
153
|
}
|
|
@@ -241,6 +242,8 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
|
|
|
241
242
|
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
242
243
|
let offset = offsets.components++
|
|
243
244
|
|
|
245
|
+
classList.add(prefixedIdentifier)
|
|
246
|
+
|
|
244
247
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
245
248
|
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
246
249
|
}
|
|
@@ -268,6 +271,8 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
|
|
|
268
271
|
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
269
272
|
let offset = offsets.utilities++
|
|
270
273
|
|
|
274
|
+
classList.add(prefixedIdentifier)
|
|
275
|
+
|
|
271
276
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
272
277
|
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
273
278
|
}
|
|
@@ -293,6 +298,8 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
|
|
|
293
298
|
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
294
299
|
let rule = utilities[identifier]
|
|
295
300
|
|
|
301
|
+
classList.add([prefixedIdentifier, options])
|
|
302
|
+
|
|
296
303
|
function wrapped(modifier) {
|
|
297
304
|
let { type = 'any' } = options
|
|
298
305
|
type = [].concat(type)
|
|
@@ -468,10 +475,13 @@ function registerPlugins(plugins, context) {
|
|
|
468
475
|
user: 0n,
|
|
469
476
|
}
|
|
470
477
|
|
|
478
|
+
let classList = new Set()
|
|
479
|
+
|
|
471
480
|
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
472
481
|
variantList,
|
|
473
482
|
variantMap,
|
|
474
483
|
offsets,
|
|
484
|
+
classList,
|
|
475
485
|
})
|
|
476
486
|
|
|
477
487
|
for (let plugin of plugins) {
|
|
@@ -523,6 +533,83 @@ function registerPlugins(plugins, context) {
|
|
|
523
533
|
variantFunctions.map((variantFunction, idx) => [sort << BigInt(idx), variantFunction])
|
|
524
534
|
)
|
|
525
535
|
}
|
|
536
|
+
|
|
537
|
+
//
|
|
538
|
+
let warnedAbout = new Set([])
|
|
539
|
+
context.safelist = function () {
|
|
540
|
+
let safelist = (context.tailwindConfig.safelist ?? []).filter(Boolean)
|
|
541
|
+
if (safelist.length <= 0) return []
|
|
542
|
+
|
|
543
|
+
let output = []
|
|
544
|
+
let checks = []
|
|
545
|
+
|
|
546
|
+
for (let value of safelist) {
|
|
547
|
+
if (typeof value === 'string') {
|
|
548
|
+
output.push(value)
|
|
549
|
+
continue
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (value instanceof RegExp) {
|
|
553
|
+
if (!warnedAbout.has('root-regex')) {
|
|
554
|
+
log.warn([
|
|
555
|
+
// TODO: Improve this warning message
|
|
556
|
+
'RegExp in the safelist option is not supported.',
|
|
557
|
+
'Please use the object syntax instead: https://tailwindcss.com/docs/...',
|
|
558
|
+
])
|
|
559
|
+
warnedAbout.add('root-regex')
|
|
560
|
+
}
|
|
561
|
+
continue
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
checks.push(value)
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (checks.length <= 0) return output.map((value) => ({ raw: value, extension: 'html' }))
|
|
568
|
+
|
|
569
|
+
let patternMatchingCount = new Map()
|
|
570
|
+
|
|
571
|
+
for (let util of classList) {
|
|
572
|
+
let utils = Array.isArray(util)
|
|
573
|
+
? (() => {
|
|
574
|
+
let [utilName, options] = util
|
|
575
|
+
return Object.keys(options?.values ?? {}).map((value) => formatClass(utilName, value))
|
|
576
|
+
})()
|
|
577
|
+
: [util]
|
|
578
|
+
|
|
579
|
+
for (let util of utils) {
|
|
580
|
+
for (let { pattern, variants = [] } of checks) {
|
|
581
|
+
// RegExp with the /g flag are stateful, so let's reset the last
|
|
582
|
+
// index pointer to reset the state.
|
|
583
|
+
pattern.lastIndex = 0
|
|
584
|
+
|
|
585
|
+
if (!patternMatchingCount.has(pattern)) {
|
|
586
|
+
patternMatchingCount.set(pattern, 0)
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
if (!pattern.test(util)) continue
|
|
590
|
+
|
|
591
|
+
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1)
|
|
592
|
+
|
|
593
|
+
output.push(util)
|
|
594
|
+
for (let variant of variants) {
|
|
595
|
+
output.push(variant + context.tailwindConfig.separator + util)
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
for (let [regex, count] of patternMatchingCount.entries()) {
|
|
602
|
+
if (count !== 0) continue
|
|
603
|
+
|
|
604
|
+
log.warn([
|
|
605
|
+
// TODO: Improve this warning message
|
|
606
|
+
`You have a regex pattern in your "safelist" config (${regex}) that doesn't match any utilities.`,
|
|
607
|
+
'For more info, visit https://tailwindcss.com/docs/...',
|
|
608
|
+
])
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return output.map((value) => ({ raw: value, extension: 'html' }))
|
|
612
|
+
}
|
|
526
613
|
}
|
|
527
614
|
|
|
528
615
|
export function createContext(
|
|
@@ -80,6 +80,7 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
80
80
|
let changedContent = context.tailwindConfig.content.content
|
|
81
81
|
.filter((item) => typeof item.raw === 'string')
|
|
82
82
|
.concat(context.tailwindConfig.content.safelist)
|
|
83
|
+
.concat(context.safelist())
|
|
83
84
|
.map(({ raw, extension }) => ({ content: raw, extension }))
|
|
84
85
|
|
|
85
86
|
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)) {
|
|
@@ -188,6 +188,7 @@ function resolvedChangedContent(context, candidateFiles) {
|
|
|
188
188
|
let changedContent = context.tailwindConfig.content.content
|
|
189
189
|
.filter((item) => typeof item.raw === 'string')
|
|
190
190
|
.concat(context.tailwindConfig.content.safelist)
|
|
191
|
+
.concat(context.safelist())
|
|
191
192
|
.map(({ raw, extension }) => ({ content: raw, extension }))
|
|
192
193
|
|
|
193
194
|
for (let changedFile of resolveChangedFiles(context, candidateFiles)) {
|
|
@@ -5,6 +5,7 @@ import evaluateTailwindFunctions from './lib/evaluateTailwindFunctions'
|
|
|
5
5
|
import substituteScreenAtRules from './lib/substituteScreenAtRules'
|
|
6
6
|
import resolveDefaultsAtRules from './lib/resolveDefaultsAtRules'
|
|
7
7
|
import collapseAdjacentRules from './lib/collapseAdjacentRules'
|
|
8
|
+
import detectNesting from './lib/detectNesting'
|
|
8
9
|
import { createContext } from './lib/setupContextUtils'
|
|
9
10
|
|
|
10
11
|
export default function processTailwindFeatures(setupContext) {
|
|
@@ -31,6 +32,7 @@ export default function processTailwindFeatures(setupContext) {
|
|
|
31
32
|
)
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
detectNesting(context)(root, result)
|
|
34
36
|
expandTailwindAtRules(context)(root, result)
|
|
35
37
|
expandApplyAtRules(context)(root, result)
|
|
36
38
|
evaluateTailwindFunctions(context)(root, result)
|
package/src/util/nameClass.js
CHANGED
|
@@ -6,17 +6,21 @@ function asClass(name) {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export default function nameClass(classPrefix, key) {
|
|
9
|
+
return asClass(formatClass(classPrefix, key))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function formatClass(classPrefix, key) {
|
|
9
13
|
if (key === 'DEFAULT') {
|
|
10
|
-
return
|
|
14
|
+
return classPrefix
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
if (key === '-') {
|
|
14
|
-
return
|
|
18
|
+
return `-${classPrefix}`
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
if (key.startsWith('-')) {
|
|
18
|
-
return
|
|
22
|
+
return `-${classPrefix}${key}`
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
return
|
|
25
|
+
return `${classPrefix}-${key}`
|
|
22
26
|
}
|