tailwindcss 3.3.1 → 3.3.3
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 +47 -6
- package/lib/cli/build/deps.js +17 -9
- package/lib/cli/build/index.js +10 -8
- package/lib/cli/build/plugin.js +29 -27
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +12 -10
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +4 -4
- package/lib/cli/init/index.js +8 -6
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +3 -1
- package/lib/corePlugins.js +52 -42
- package/lib/css/preflight.css +9 -0
- package/lib/featureFlags.js +14 -9
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +3 -1
- package/lib/lib/collapseDuplicateDeclarations.js +10 -8
- package/lib/lib/content.js +18 -14
- package/lib/lib/defaultExtractor.js +6 -4
- package/lib/lib/detectNesting.js +3 -1
- package/lib/lib/evaluateTailwindFunctions.js +20 -16
- package/lib/lib/expandApplyAtRules.js +37 -40
- package/lib/lib/expandTailwindAtRules.js +19 -17
- package/lib/lib/findAtConfigPath.js +6 -4
- package/lib/lib/generateRules.js +52 -38
- package/lib/lib/getModuleDependencies.js +10 -8
- package/lib/lib/load-config.js +5 -3
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +7 -5
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +3 -1
- package/lib/lib/resolveDefaultsAtRules.js +24 -20
- package/lib/lib/setupContextUtils.js +91 -63
- package/lib/lib/setupTrackingContext.js +27 -24
- package/lib/lib/sharedState.js +28 -24
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/oxide/cli/build/deps.js +16 -8
- package/lib/oxide/cli/build/index.js +6 -4
- package/lib/oxide/cli/build/plugin.js +19 -17
- package/lib/oxide/cli/build/utils.js +18 -8
- package/lib/oxide/cli/build/watching.js +10 -8
- package/lib/oxide/cli/help/index.js +6 -4
- package/lib/oxide/cli/index.js +4 -4
- package/lib/oxide/cli/init/index.js +6 -4
- package/lib/plugin.js +9 -9
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +8 -6
- package/lib/processTailwindFeatures.js +16 -14
- package/lib/public/colors.js +5 -3
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +5 -3
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +9 -10
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +3 -1
- package/lib/util/color.js +10 -6
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +5 -3
- package/lib/util/dataTypes.js +59 -21
- package/lib/util/defaults.js +6 -4
- package/lib/util/escapeClassName.js +7 -5
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +30 -110
- package/lib/util/getAllConfigs.js +6 -4
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +8 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +7 -5
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +30 -18
- package/lib/util/prefixSelector.js +6 -4
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +10 -8
- package/lib/util/resolveConfigPath.js +9 -5
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +3 -1
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +5 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/package.json +30 -35
- package/peers/index.js +65828 -48819
- package/src/cli/build/plugin.js +3 -3
- package/src/cli.js +1 -1
- package/src/corePlugins.js +29 -24
- package/src/css/preflight.css +9 -0
- package/src/featureFlags.js +2 -3
- package/src/index.js +1 -5
- package/src/lib/defaultExtractor.js +1 -1
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +2 -8
- package/src/lib/expandTailwindAtRules.js +12 -10
- package/src/lib/generateRules.js +15 -8
- package/src/lib/setupContextUtils.js +18 -5
- package/src/lib/setupTrackingContext.js +2 -4
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +4 -4
- package/src/processTailwindFeatures.js +3 -2
- package/src/util/applyImportantSelector.js +2 -5
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +17 -6
- package/src/util/formatVariantSelector.js +4 -126
- package/src/util/pluginUtils.js +1 -5
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +167 -0
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/config.full.js +1 -0
- package/types/generated/default-theme.d.ts +1 -0
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandApplyAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _postcss = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
12
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
11
13
|
const _generateRules = require("./generateRules");
|
|
12
|
-
const _escapeClassName = /*#__PURE__*/
|
|
14
|
+
const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
|
|
13
15
|
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
14
|
-
const
|
|
15
|
-
function
|
|
16
|
+
const _pseudoElements = require("../util/pseudoElements");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
16
18
|
return obj && obj.__esModule ? obj : {
|
|
17
19
|
default: obj
|
|
18
20
|
};
|
|
@@ -25,7 +27,7 @@ function _interopRequireDefault(obj) {
|
|
|
25
27
|
]
|
|
26
28
|
});
|
|
27
29
|
container.walkRules((rule)=>{
|
|
28
|
-
(0,
|
|
30
|
+
(0, _postcssselectorparser.default)((selectors)=>{
|
|
29
31
|
selectors.walkClasses((classSelector)=>{
|
|
30
32
|
let parentSelector = classSelector.parent.toString();
|
|
31
33
|
let classes = groups.get(parentSelector);
|
|
@@ -42,7 +44,7 @@ function _interopRequireDefault(obj) {
|
|
|
42
44
|
groups: normalizedGroups
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
|
-
let selectorExtractor = (0,
|
|
47
|
+
let selectorExtractor = (0, _postcssselectorparser.default)();
|
|
46
48
|
/**
|
|
47
49
|
* @param {string} ruleSelectors
|
|
48
50
|
*/ function extractSelectors(ruleSelectors) {
|
|
@@ -311,11 +313,11 @@ function processApply(root, context, localCache) {
|
|
|
311
313
|
// Sort tag names before class names (but only sort each group (separated by a combinator)
|
|
312
314
|
// separately and not in total)
|
|
313
315
|
// This happens when replacing `.bar` in `.foo.bar` with a tag like `section`
|
|
314
|
-
for (let
|
|
316
|
+
for (let sel of replaced){
|
|
315
317
|
let groups = [
|
|
316
318
|
[]
|
|
317
319
|
];
|
|
318
|
-
for (let node of
|
|
320
|
+
for (let node of sel.nodes){
|
|
319
321
|
if (node.type === "combinator") {
|
|
320
322
|
groups.push(node);
|
|
321
323
|
groups.push([]);
|
|
@@ -324,7 +326,7 @@ function processApply(root, context, localCache) {
|
|
|
324
326
|
last.push(node);
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
|
-
|
|
329
|
+
sel.nodes = [];
|
|
328
330
|
for (let group of groups){
|
|
329
331
|
if (Array.isArray(group)) {
|
|
330
332
|
group.sort((a, b)=>{
|
|
@@ -340,7 +342,7 @@ function processApply(root, context, localCache) {
|
|
|
340
342
|
return 0;
|
|
341
343
|
});
|
|
342
344
|
}
|
|
343
|
-
|
|
345
|
+
sel.nodes = sel.nodes.concat(group);
|
|
344
346
|
}
|
|
345
347
|
}
|
|
346
348
|
sel.replaceWith(...replaced);
|
|
@@ -358,15 +360,15 @@ function processApply(root, context, localCache) {
|
|
|
358
360
|
candidates,
|
|
359
361
|
apply.source
|
|
360
362
|
]);
|
|
361
|
-
let [
|
|
363
|
+
let [applyCandidates, important] = extractApplyCandidates(apply.params);
|
|
362
364
|
if (apply.parent.type === "atrule") {
|
|
363
365
|
if (apply.parent.name === "screen") {
|
|
364
366
|
let screenType = apply.parent.params;
|
|
365
|
-
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${
|
|
367
|
+
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}`).join(" ")} instead.`);
|
|
366
368
|
}
|
|
367
369
|
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}.`);
|
|
368
370
|
}
|
|
369
|
-
for (let applyCandidate of
|
|
371
|
+
for (let applyCandidate of applyCandidates){
|
|
370
372
|
if ([
|
|
371
373
|
prefix(context, "group"),
|
|
372
374
|
prefix(context, "peer")
|
|
@@ -385,16 +387,16 @@ function processApply(root, context, localCache) {
|
|
|
385
387
|
]);
|
|
386
388
|
}
|
|
387
389
|
}
|
|
388
|
-
for (let [parent, [
|
|
390
|
+
for (let [parent, [candidates, atApplySource]] of perParentApplies){
|
|
389
391
|
let siblings = [];
|
|
390
|
-
for (let [
|
|
392
|
+
for (let [applyCandidate, important, rules] of candidates){
|
|
391
393
|
let potentialApplyCandidates = [
|
|
392
|
-
|
|
394
|
+
applyCandidate,
|
|
393
395
|
...extractBaseCandidates([
|
|
394
|
-
|
|
396
|
+
applyCandidate
|
|
395
397
|
], context.tailwindConfig.separator)
|
|
396
398
|
];
|
|
397
|
-
for (let [meta, node] of
|
|
399
|
+
for (let [meta, node] of rules){
|
|
398
400
|
let parentClasses = extractClasses(parent);
|
|
399
401
|
let nodeClasses = extractClasses(node);
|
|
400
402
|
// When we encounter a rule like `.dark .a, .b { … }` we only want to be left with `[.dark, .a]` if the base applyCandidate is `.a` or with `[.b]` if the base applyCandidate is `.b`
|
|
@@ -425,20 +427,20 @@ function processApply(root, context, localCache) {
|
|
|
425
427
|
nodeClasses = nodeClasses.concat(extractBaseCandidates(nodeClasses, context.tailwindConfig.separator));
|
|
426
428
|
let intersects = parentClasses.some((selector)=>nodeClasses.includes(selector));
|
|
427
429
|
if (intersects) {
|
|
428
|
-
throw node.error(`You cannot \`@apply\` the \`${
|
|
430
|
+
throw node.error(`You cannot \`@apply\` the \`${applyCandidate}\` utility here because it creates a circular dependency.`);
|
|
429
431
|
}
|
|
430
|
-
let
|
|
432
|
+
let root = _postcss.default.root({
|
|
431
433
|
nodes: [
|
|
432
434
|
node.clone()
|
|
433
435
|
]
|
|
434
436
|
});
|
|
435
437
|
// Make sure every node in the entire tree points back at the @apply rule that generated it
|
|
436
|
-
|
|
438
|
+
root.walk((node)=>{
|
|
437
439
|
node.source = atApplySource;
|
|
438
440
|
});
|
|
439
441
|
let canRewriteSelector = node.type !== "atrule" || node.type === "atrule" && node.name !== "keyframes";
|
|
440
442
|
if (canRewriteSelector) {
|
|
441
|
-
|
|
443
|
+
root.walkRules((rule)=>{
|
|
442
444
|
// Let's imagine you have the following structure:
|
|
443
445
|
//
|
|
444
446
|
// .foo {
|
|
@@ -470,7 +472,7 @@ function processApply(root, context, localCache) {
|
|
|
470
472
|
// would have replaced this with something that didn't exist and
|
|
471
473
|
// therefore it removed the selector altogether. In this specific
|
|
472
474
|
// case it would result in `{}` instead of `.something-unrelated {}`
|
|
473
|
-
if (!extractClasses(rule).some((candidate)=>candidate ===
|
|
475
|
+
if (!extractClasses(rule).some((candidate)=>candidate === applyCandidate)) {
|
|
474
476
|
rule.remove();
|
|
475
477
|
return;
|
|
476
478
|
}
|
|
@@ -480,34 +482,29 @@ function processApply(root, context, localCache) {
|
|
|
480
482
|
// We do *not* want to do this for user CSS that happens to be structured the same
|
|
481
483
|
let isGenerated = parent.raws.tailwind !== undefined;
|
|
482
484
|
let parentSelector = isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0 ? parent.selector.slice(importantSelector.length) : parent.selector;
|
|
483
|
-
rule.selector = replaceSelector(parentSelector, rule.selector,
|
|
485
|
+
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate);
|
|
484
486
|
// And then re-add it if it was removed
|
|
485
487
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
486
488
|
rule.selector = (0, _applyImportantSelector.applyImportantSelector)(rule.selector, importantSelector);
|
|
487
489
|
}
|
|
488
490
|
rule.walkDecls((d)=>{
|
|
489
|
-
d.important = meta.important ||
|
|
491
|
+
d.important = meta.important || important;
|
|
490
492
|
});
|
|
491
493
|
// Move pseudo elements to the end of the selector (if necessary)
|
|
492
|
-
let selector = (0,
|
|
493
|
-
selector.each((sel)=>
|
|
494
|
-
let [pseudoElements] = (0, _formatVariantSelectorJs.collectPseudoElements)(sel);
|
|
495
|
-
if (pseudoElements.length > 0) {
|
|
496
|
-
sel.nodes.push(...pseudoElements.sort(_formatVariantSelectorJs.sortSelector));
|
|
497
|
-
}
|
|
498
|
-
});
|
|
494
|
+
let selector = (0, _postcssselectorparser.default)().astSync(rule.selector);
|
|
495
|
+
selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
|
|
499
496
|
rule.selector = selector.toString();
|
|
500
497
|
});
|
|
501
498
|
}
|
|
502
499
|
// It could be that the node we were inserted was removed because the class didn't match
|
|
503
500
|
// If that was the *only* rule in the parent, then we have nothing add so we skip it
|
|
504
|
-
if (!
|
|
501
|
+
if (!root.nodes[0]) {
|
|
505
502
|
continue;
|
|
506
503
|
}
|
|
507
504
|
// Insert it
|
|
508
505
|
siblings.push([
|
|
509
506
|
meta.sort,
|
|
510
|
-
|
|
507
|
+
root.nodes[0]
|
|
511
508
|
]);
|
|
512
509
|
}
|
|
513
510
|
}
|
|
@@ -516,13 +513,13 @@ function processApply(root, context, localCache) {
|
|
|
516
513
|
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
|
|
517
514
|
parent.after(nodes);
|
|
518
515
|
}
|
|
519
|
-
for (let
|
|
516
|
+
for (let apply of applies){
|
|
520
517
|
// If there are left-over declarations, just remove the @apply
|
|
521
|
-
if (
|
|
522
|
-
|
|
518
|
+
if (apply.parent.nodes.length > 1) {
|
|
519
|
+
apply.remove();
|
|
523
520
|
} else {
|
|
524
521
|
// The node is empty, drop the full node
|
|
525
|
-
|
|
522
|
+
apply.parent.remove();
|
|
526
523
|
}
|
|
527
524
|
}
|
|
528
525
|
// Do it again, in case we have other `@apply` rules
|
|
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandTailwindAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const _sharedState = /*#__PURE__*/
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
|
|
13
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
12
14
|
const _generateRules = require("./generateRules");
|
|
13
|
-
const _log = /*#__PURE__*/
|
|
14
|
-
const _cloneNodes = /*#__PURE__*/
|
|
15
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
16
|
+
const _cloneNodes = /*#__PURE__*/ _interop_require_default(require("../util/cloneNodes"));
|
|
15
17
|
const _defaultExtractor = require("./defaultExtractor");
|
|
16
|
-
function
|
|
18
|
+
function _interop_require_default(obj) {
|
|
17
19
|
return obj && obj.__esModule ? obj : {
|
|
18
20
|
default: obj
|
|
19
21
|
};
|
|
@@ -26,7 +28,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
26
28
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
29
|
})(nodeInterop);
|
|
28
30
|
}
|
|
29
|
-
function
|
|
31
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
30
32
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
33
|
return obj;
|
|
32
34
|
}
|
|
@@ -79,7 +81,7 @@ let extractorCache = new WeakMap();
|
|
|
79
81
|
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
80
82
|
function getClassCandidates(content, extractor, candidates, seen) {
|
|
81
83
|
if (!extractorCache.has(extractor)) {
|
|
82
|
-
extractorCache.set(extractor, new
|
|
84
|
+
extractorCache.set(extractor, new _quicklru.default({
|
|
83
85
|
maxSize: 25000
|
|
84
86
|
}));
|
|
85
87
|
}
|
|
@@ -96,8 +98,8 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
96
98
|
} else {
|
|
97
99
|
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
98
100
|
let lineMatchesSet = new Set(extractorMatches);
|
|
99
|
-
for (let
|
|
100
|
-
candidates.add(
|
|
101
|
+
for (let match of lineMatchesSet){
|
|
102
|
+
candidates.add(match);
|
|
101
103
|
}
|
|
102
104
|
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
103
105
|
}
|
|
@@ -122,7 +124,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
122
124
|
return returnValue;
|
|
123
125
|
}
|
|
124
126
|
function expandTailwindAtRules(context) {
|
|
125
|
-
return (root)=>{
|
|
127
|
+
return async (root)=>{
|
|
126
128
|
let layerNodes = {
|
|
127
129
|
base: null,
|
|
128
130
|
components: null,
|
|
@@ -152,7 +154,7 @@ function expandTailwindAtRules(context) {
|
|
|
152
154
|
]);
|
|
153
155
|
let seen = new Set();
|
|
154
156
|
env.DEBUG && console.time("Reading changed files");
|
|
155
|
-
if (
|
|
157
|
+
if (false) {
|
|
156
158
|
// TODO: Pass through or implement `extractor`
|
|
157
159
|
for (let candidate of require("@tailwindcss/oxide").parseCandidateStringsFromFiles(context.changedContent)){
|
|
158
160
|
candidates.add(candidate);
|
|
@@ -163,12 +165,12 @@ function expandTailwindAtRules(context) {
|
|
|
163
165
|
// getClassCandidatesOxide(file, transformer(content), extractor, candidates, seen)
|
|
164
166
|
// }
|
|
165
167
|
} else {
|
|
166
|
-
|
|
168
|
+
await Promise.all(context.changedContent.map(async ({ file , content , extension })=>{
|
|
167
169
|
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
168
170
|
let extractor = getExtractor(context, extension);
|
|
169
|
-
content = file ? _fs.default.
|
|
171
|
+
content = file ? await _fs.default.promises.readFile(file, "utf8") : content;
|
|
170
172
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
171
|
-
}
|
|
173
|
+
}));
|
|
172
174
|
}
|
|
173
175
|
env.DEBUG && console.timeEnd("Reading changed files");
|
|
174
176
|
// ---
|
|
@@ -176,7 +178,7 @@ function expandTailwindAtRules(context) {
|
|
|
176
178
|
let classCacheCount = context.classCache.size;
|
|
177
179
|
env.DEBUG && console.time("Generate rules");
|
|
178
180
|
env.DEBUG && console.time("Sorting candidates");
|
|
179
|
-
let sortedCandidates =
|
|
181
|
+
let sortedCandidates = false ? candidates : new Set([
|
|
180
182
|
...candidates
|
|
181
183
|
].sort((a, z)=>{
|
|
182
184
|
if (a === z) return 0;
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "findAtConfigPath", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return findAtConfigPath;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
-
function
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -9,27 +9,33 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
getClassNameFromSelector: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
getClassNameFromSelector: function() {
|
|
13
|
+
return getClassNameFromSelector;
|
|
14
|
+
},
|
|
15
|
+
resolveMatches: function() {
|
|
16
|
+
return resolveMatches;
|
|
17
|
+
},
|
|
18
|
+
generateRules: function() {
|
|
19
|
+
return generateRules;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
|
-
const _postcss = /*#__PURE__*/
|
|
17
|
-
const
|
|
18
|
-
const _parseObjectStyles = /*#__PURE__*/
|
|
19
|
-
const _isPlainObject = /*#__PURE__*/
|
|
20
|
-
const _prefixSelector = /*#__PURE__*/
|
|
22
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
23
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
24
|
+
const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
|
|
25
|
+
const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
|
|
26
|
+
const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
|
|
21
27
|
const _pluginUtils = require("../util/pluginUtils");
|
|
22
|
-
const _log = /*#__PURE__*/
|
|
23
|
-
const _sharedState = /*#__PURE__*/
|
|
28
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
29
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
24
30
|
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
25
31
|
const _nameClass = require("../util/nameClass");
|
|
26
32
|
const _dataTypes = require("../util/dataTypes");
|
|
27
33
|
const _setupContextUtils = require("./setupContextUtils");
|
|
28
|
-
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/
|
|
29
|
-
const
|
|
34
|
+
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
|
|
35
|
+
const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
|
|
30
36
|
const _featureFlags = require("../featureFlags");
|
|
31
37
|
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
32
|
-
function
|
|
38
|
+
function _interop_require_default(obj) {
|
|
33
39
|
return obj && obj.__esModule ? obj : {
|
|
34
40
|
default: obj
|
|
35
41
|
};
|
|
@@ -42,7 +48,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
42
48
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
43
49
|
})(nodeInterop);
|
|
44
50
|
}
|
|
45
|
-
function
|
|
51
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
46
52
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
47
53
|
return obj;
|
|
48
54
|
}
|
|
@@ -73,7 +79,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
73
79
|
}
|
|
74
80
|
return newObj;
|
|
75
81
|
}
|
|
76
|
-
let classNameParser = (0,
|
|
82
|
+
let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
77
83
|
return selectors.first.filter(({ type })=>type === "class").pop().value;
|
|
78
84
|
});
|
|
79
85
|
function getClassNameFromSelector(selector) {
|
|
@@ -163,7 +169,7 @@ function applyImportant(matches, classCandidate) {
|
|
|
163
169
|
]
|
|
164
170
|
});
|
|
165
171
|
container.walkRules((r)=>{
|
|
166
|
-
let ast = (0,
|
|
172
|
+
let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
|
|
167
173
|
// Remove extraneous selectors that do not include the base candidate
|
|
168
174
|
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
169
175
|
// Update all instances of the base candidate to include the important marker
|
|
@@ -199,7 +205,7 @@ function applyVariant(variant, matches, context) {
|
|
|
199
205
|
};
|
|
200
206
|
// Retrieve "modifier"
|
|
201
207
|
{
|
|
202
|
-
let [baseVariant, ...modifiers] = (0,
|
|
208
|
+
let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, "/");
|
|
203
209
|
// This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
|
|
204
210
|
// In this case 1/10 is a value but /20 is a modifier
|
|
205
211
|
if (modifiers.length > 1) {
|
|
@@ -225,12 +231,12 @@ function applyVariant(variant, matches, context) {
|
|
|
225
231
|
// group[:hover] (`-` is missing)
|
|
226
232
|
let match = /(.)(-?)\[(.*)\]/g.exec(variant);
|
|
227
233
|
if (match) {
|
|
228
|
-
let [, char,
|
|
234
|
+
let [, char, separator, value] = match;
|
|
229
235
|
// @-[200px] case
|
|
230
|
-
if (char === "@" &&
|
|
236
|
+
if (char === "@" && separator === "-") return [];
|
|
231
237
|
// group[:hover] case
|
|
232
|
-
if (char !== "@" &&
|
|
233
|
-
variant = variant.replace(`${
|
|
238
|
+
if (char !== "@" && separator === "") return [];
|
|
239
|
+
variant = variant.replace(`${separator}[${value}]`, "");
|
|
234
240
|
args.value = value;
|
|
235
241
|
}
|
|
236
242
|
}
|
|
@@ -238,7 +244,7 @@ function applyVariant(variant, matches, context) {
|
|
|
238
244
|
if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
|
|
239
245
|
let sort = context.offsets.recordVariant(variant);
|
|
240
246
|
let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
|
|
241
|
-
let selectors = (0,
|
|
247
|
+
let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ",");
|
|
242
248
|
// We do not support multiple selectors for arbitrary variants
|
|
243
249
|
if (selectors.length > 1) {
|
|
244
250
|
return [];
|
|
@@ -253,9 +259,17 @@ function applyVariant(variant, matches, context) {
|
|
|
253
259
|
context.variantMap.set(variant, records);
|
|
254
260
|
}
|
|
255
261
|
if (context.variantMap.has(variant)) {
|
|
262
|
+
var _context_variantOptions_get;
|
|
256
263
|
let isArbitraryVariant = isArbitraryValue(variant);
|
|
264
|
+
var _context_variantOptions_get_INTERNAL_FEATURES;
|
|
265
|
+
let internalFeatures = (_context_variantOptions_get_INTERNAL_FEATURES = (_context_variantOptions_get = context.variantOptions.get(variant)) === null || _context_variantOptions_get === void 0 ? void 0 : _context_variantOptions_get[_setupContextUtils.INTERNAL_FEATURES]) !== null && _context_variantOptions_get_INTERNAL_FEATURES !== void 0 ? _context_variantOptions_get_INTERNAL_FEATURES : {};
|
|
257
266
|
let variantFunctionTuples = context.variantMap.get(variant).slice();
|
|
258
267
|
let result = [];
|
|
268
|
+
let respectPrefix = (()=>{
|
|
269
|
+
if (isArbitraryVariant) return false;
|
|
270
|
+
if (internalFeatures.respectPrefix === false) return false;
|
|
271
|
+
return true;
|
|
272
|
+
})();
|
|
259
273
|
for (let [meta, rule] of matches){
|
|
260
274
|
// Don't generate variants for user css
|
|
261
275
|
if (meta.layer === "user") {
|
|
@@ -312,7 +326,7 @@ function applyVariant(variant, matches, context) {
|
|
|
312
326
|
format (selectorFormat) {
|
|
313
327
|
collectedFormats.push({
|
|
314
328
|
format: selectorFormat,
|
|
315
|
-
|
|
329
|
+
respectPrefix
|
|
316
330
|
});
|
|
317
331
|
},
|
|
318
332
|
args
|
|
@@ -320,14 +334,14 @@ function applyVariant(variant, matches, context) {
|
|
|
320
334
|
// It can happen that a list of format strings is returned from within the function. In that
|
|
321
335
|
// case, we have to process them as well. We can use the existing `variantSort`.
|
|
322
336
|
if (Array.isArray(ruleWithVariant)) {
|
|
323
|
-
for (let [idx,
|
|
337
|
+
for (let [idx, variantFunction] of ruleWithVariant.entries()){
|
|
324
338
|
// This is a little bit scary since we are pushing to an array of items that we are
|
|
325
339
|
// currently looping over. However, you can also think of it like a processing queue
|
|
326
340
|
// where you keep handling jobs until everything is done and each job can queue more
|
|
327
341
|
// jobs if needed.
|
|
328
342
|
variantFunctionTuples.push([
|
|
329
343
|
context.offsets.applyParallelOffset(variantSort, idx),
|
|
330
|
-
|
|
344
|
+
variantFunction,
|
|
331
345
|
// If the clone has been modified we have to pass that back
|
|
332
346
|
// though so each rule can use the modified container
|
|
333
347
|
clone.clone()
|
|
@@ -338,7 +352,7 @@ function applyVariant(variant, matches, context) {
|
|
|
338
352
|
if (typeof ruleWithVariant === "string") {
|
|
339
353
|
collectedFormats.push({
|
|
340
354
|
format: ruleWithVariant,
|
|
341
|
-
|
|
355
|
+
respectPrefix
|
|
342
356
|
});
|
|
343
357
|
}
|
|
344
358
|
if (ruleWithVariant === null) {
|
|
@@ -359,7 +373,7 @@ function applyVariant(variant, matches, context) {
|
|
|
359
373
|
// as well. E.g.: `${variant}${separator}${className}`.
|
|
360
374
|
// However, plugin authors probably also prepend or append certain
|
|
361
375
|
// classes, pseudos, ids, ...
|
|
362
|
-
let rebuiltBase = (0,
|
|
376
|
+
let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
|
|
363
377
|
selectors.walkClasses((classNode)=>{
|
|
364
378
|
classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
|
|
365
379
|
});
|
|
@@ -377,7 +391,7 @@ function applyVariant(variant, matches, context) {
|
|
|
377
391
|
// format: .foo &
|
|
378
392
|
collectedFormats.push({
|
|
379
393
|
format: modified.replace(rebuiltBase, "&"),
|
|
380
|
-
|
|
394
|
+
respectPrefix
|
|
381
395
|
});
|
|
382
396
|
rule.selector = before;
|
|
383
397
|
});
|
|
@@ -550,7 +564,7 @@ function splitWithSeparator(input, separator) {
|
|
|
550
564
|
_sharedState.NOT_ON_DEMAND
|
|
551
565
|
];
|
|
552
566
|
}
|
|
553
|
-
return (0,
|
|
567
|
+
return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
|
|
554
568
|
}
|
|
555
569
|
function* recordCandidates(matches, classCandidate) {
|
|
556
570
|
for (const match of matches){
|
|
@@ -575,7 +589,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
575
589
|
if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
|
|
576
590
|
if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
|
|
577
591
|
let base = variants.slice().reverse().join(separator);
|
|
578
|
-
for (let part of (0,
|
|
592
|
+
for (let part of (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
|
|
579
593
|
yield* resolveMatches(base + separator + part, context, original);
|
|
580
594
|
}
|
|
581
595
|
}
|
|
@@ -617,18 +631,18 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
617
631
|
}
|
|
618
632
|
}
|
|
619
633
|
} else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
|
|
620
|
-
let
|
|
621
|
-
let [
|
|
622
|
-
for (let
|
|
634
|
+
let ruleSet = plugin;
|
|
635
|
+
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
|
|
636
|
+
for (let rule of rules){
|
|
623
637
|
matchesPerPlugin.push([
|
|
624
638
|
{
|
|
625
639
|
...sort,
|
|
626
640
|
options: {
|
|
627
641
|
...sort.options,
|
|
628
|
-
...
|
|
642
|
+
...options
|
|
629
643
|
}
|
|
630
644
|
},
|
|
631
|
-
|
|
645
|
+
rule
|
|
632
646
|
]);
|
|
633
647
|
}
|
|
634
648
|
}
|
|
@@ -704,11 +718,11 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
704
718
|
}
|
|
705
719
|
let messages = [];
|
|
706
720
|
for (let [idx, group] of typesPerPlugin.entries()){
|
|
707
|
-
for (let
|
|
708
|
-
let
|
|
721
|
+
for (let type of group){
|
|
722
|
+
let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
|
|
709
723
|
.map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
|
|
710
724
|
.join("\n")).join("\n\n");
|
|
711
|
-
messages.push(` Use \`${candidate.replace("[", `[${
|
|
725
|
+
messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
|
|
712
726
|
break;
|
|
713
727
|
}
|
|
714
728
|
}
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return getModuleDependencies;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
-
function
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
|
@@ -59,10 +61,10 @@ function resolveWithExtension(file, extensions) {
|
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
// Try to find `./a/index.js` from `./a`
|
|
62
|
-
for (let
|
|
63
|
-
let
|
|
64
|
-
if (_fs.default.existsSync(
|
|
65
|
-
return
|
|
64
|
+
for (let ext of extensions){
|
|
65
|
+
let full = `${file}/index${ext}`;
|
|
66
|
+
if (_fs.default.existsSync(full)) {
|
|
67
|
+
return full;
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
return null;
|
package/lib/lib/load-config.js
CHANGED
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "loadConfig", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return loadConfig;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _jiti = /*#__PURE__*/
|
|
11
|
+
const _jiti = /*#__PURE__*/ _interop_require_default(require("jiti"));
|
|
10
12
|
const _sucrase = require("sucrase");
|
|
11
|
-
function
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return normalizeTailwindDirectives;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _log = /*#__PURE__*/
|
|
10
|
-
function
|
|
11
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
11
13
|
return obj && obj.__esModule ? obj : {
|
|
12
14
|
default: obj
|
|
13
15
|
};
|
package/lib/lib/offsets.js
CHANGED
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "Offsets", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return Offsets;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const _bigSign = /*#__PURE__*/
|
|
11
|
-
const
|
|
12
|
-
function
|
|
12
|
+
const _bigSign = /*#__PURE__*/ _interop_require_default(require("../util/bigSign"));
|
|
13
|
+
const _remapbitfield = require("./remap-bitfield.js");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
13
15
|
return obj && obj.__esModule ? obj : {
|
|
14
16
|
default: obj
|
|
15
17
|
};
|
|
@@ -253,7 +255,7 @@ class Offsets {
|
|
|
253
255
|
let [offset, rule] = item;
|
|
254
256
|
offset = {
|
|
255
257
|
...offset,
|
|
256
|
-
variants: (0,
|
|
258
|
+
variants: (0, _remapbitfield.remapBitfield)(offset.variants, mapping)
|
|
257
259
|
};
|
|
258
260
|
return [
|
|
259
261
|
offset,
|