tailwindcss 0.0.0-insiders.7089a80 → 0.0.0-insiders.722232c
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 +34 -2
- package/README.md +8 -4
- package/lib/css/preflight.css +1 -1
- package/lib/index.js +1 -3
- package/lib/lib/collapseDuplicateDeclarations.js +52 -1
- package/lib/lib/defaultExtractor.js +42 -0
- package/lib/lib/expandApplyAtRules.js +36 -0
- package/lib/lib/expandTailwindAtRules.js +2 -24
- package/lib/lib/generateRules.js +4 -0
- package/lib/lib/normalizeTailwindDirectives.js +8 -1
- package/lib/lib/setupTrackingContext.js +11 -10
- package/lib/lib/sharedState.js +33 -4
- package/lib/processTailwindFeatures.js +2 -1
- package/lib/util/color.js +23 -8
- package/package.json +9 -10
- package/peers/index.js +72 -86
- package/src/css/preflight.css +1 -1
- package/src/index.js +1 -7
- package/src/lib/collapseDuplicateDeclarations.js +66 -1
- package/src/lib/defaultExtractor.js +48 -0
- package/src/lib/expandApplyAtRules.js +36 -0
- package/src/lib/expandTailwindAtRules.js +2 -23
- package/src/lib/generateRules.js +5 -0
- package/src/lib/normalizeTailwindDirectives.js +6 -1
- package/src/lib/setupTrackingContext.js +11 -10
- package/src/lib/sharedState.js +40 -4
- package/src/processTailwindFeatures.js +2 -1
- package/src/util/color.js +20 -7
- package/lib/lib/setupWatchingContext.js +0 -288
- package/src/lib/setupWatchingContext.js +0 -311
package/CHANGELOG.md
CHANGED
|
@@ -9,8 +9,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Fixed
|
|
11
11
|
|
|
12
|
+
- Fix `@apply` in files without `@tailwind` directives ([#6580](https://github.com/tailwindlabs/tailwindcss/pull/6580))
|
|
13
|
+
|
|
14
|
+
## [3.0.9] - 2022-01-03
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Improve `DEBUG` flag ([#6797](https://github.com/tailwindlabs/tailwindcss/pull/6797), [#6804](https://github.com/tailwindlabs/tailwindcss/pull/6804))
|
|
19
|
+
- Ensure we can use `<` and `>` characters in modifiers ([#6851](https://github.com/tailwindlabs/tailwindcss/pull/6851))
|
|
20
|
+
- Validate `theme()` works in arbitrary values ([#6852](https://github.com/tailwindlabs/tailwindcss/pull/6852))
|
|
21
|
+
- Properly detect `theme()` value usage in arbitrary properties ([#6854](https://github.com/tailwindlabs/tailwindcss/pull/6854))
|
|
22
|
+
- Improve collapsing of duplicate declarations ([#6856](https://github.com/tailwindlabs/tailwindcss/pull/6856))
|
|
23
|
+
- Remove support for `TAILWIND_MODE=watch` ([#6858](https://github.com/tailwindlabs/tailwindcss/pull/6858))
|
|
24
|
+
|
|
25
|
+
## [3.0.8] - 2021-12-28
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Reduce specificity of `abbr` rule in preflight ([#6671](https://github.com/tailwindlabs/tailwindcss/pull/6671))
|
|
30
|
+
- Support HSL with hue units in arbitrary values ([#6726](https://github.com/tailwindlabs/tailwindcss/pull/6726))
|
|
31
|
+
- Add `node16-linux-arm64` target for standalone CLI ([#6693](https://github.com/tailwindlabs/tailwindcss/pull/6693))
|
|
32
|
+
|
|
33
|
+
## [3.0.7] - 2021-12-17
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
12
37
|
- Don't mutate custom color palette when overriding per-plugin colors ([#6546](https://github.com/tailwindlabs/tailwindcss/pull/6546))
|
|
13
38
|
- Improve circular dependency detection when using `@apply` ([#6588](https://github.com/tailwindlabs/tailwindcss/pull/6588))
|
|
39
|
+
- Only generate variants for non-`user` layers ([#6589](https://github.com/tailwindlabs/tailwindcss/pull/6589))
|
|
40
|
+
- Properly extract classes with arbitrary values in arrays and classes followed by escaped quotes ([#6590](https://github.com/tailwindlabs/tailwindcss/pull/6590))
|
|
41
|
+
- Improve jsx interpolation candidate matching ([#6593](https://github.com/tailwindlabs/tailwindcss/pull/6593))
|
|
42
|
+
- Ensure `@apply` of a rule inside an AtRule works ([#6594](https://github.com/tailwindlabs/tailwindcss/pull/6594))
|
|
14
43
|
|
|
15
44
|
## [3.0.6] - 2021-12-16
|
|
16
45
|
|
|
@@ -1733,8 +1762,11 @@ No release notes
|
|
|
1733
1762
|
|
|
1734
1763
|
- Everything!
|
|
1735
1764
|
|
|
1736
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.
|
|
1737
|
-
[3.0.
|
|
1765
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.9...HEAD
|
|
1766
|
+
[3.0.9]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.8...v3.0.9
|
|
1767
|
+
[3.0.8]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.7...v3.0.8
|
|
1768
|
+
[3.0.7]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.6...v3.0.7
|
|
1769
|
+
[3.0.6]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.5...v3.0.6
|
|
1738
1770
|
[3.0.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.4...v3.0.5
|
|
1739
1771
|
[3.0.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.3...v3.0.4
|
|
1740
1772
|
[3.0.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.2...v3.0.3
|
package/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<a href="https://tailwindcss.com/#gh-light-mode-only" target="_blank">
|
|
3
|
+
<img src="./.github/logo-light.svg" alt="Tailwind CSS" width="350" height="70">
|
|
4
|
+
</a>
|
|
5
|
+
<a href="https://tailwindcss.com/#gh-dark-mode-only" target="_blank">
|
|
6
|
+
<img src="./.github/logo-dark.svg" alt="Tailwind CSS" width="350" height="70">
|
|
7
|
+
</a>
|
|
6
8
|
</p>
|
|
7
9
|
|
|
10
|
+
A utility-first CSS framework for rapidly building custom user interfaces.
|
|
11
|
+
|
|
8
12
|
<p>
|
|
9
13
|
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/workflow/status/tailwindlabs/tailwindcss/Node.js%20CI" alt="Build Status"></a>
|
|
10
14
|
<a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
|
package/lib/css/preflight.css
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _setupTrackingContext = _interopRequireDefault(require("./lib/setupTrackingContext"));
|
|
3
|
-
var _setupWatchingContext = _interopRequireDefault(require("./lib/setupWatchingContext"));
|
|
4
3
|
var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
|
|
5
4
|
var _sharedState = require("./lib/sharedState");
|
|
6
5
|
function _interopRequireDefault(obj) {
|
|
@@ -18,8 +17,7 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
18
17
|
return root;
|
|
19
18
|
},
|
|
20
19
|
function(root, result) {
|
|
21
|
-
|
|
22
|
-
(0, _processTailwindFeatures).default(setupContext)(root, result);
|
|
20
|
+
(0, _processTailwindFeatures).default((0, _setupTrackingContext).default(configOrPath))(root, result);
|
|
23
21
|
},
|
|
24
22
|
_sharedState.env.DEBUG && function(root) {
|
|
25
23
|
console.timeEnd('JIT TOTAL');
|
|
@@ -8,6 +8,7 @@ function collapseDuplicateDeclarations() {
|
|
|
8
8
|
root.walkRules((node)=>{
|
|
9
9
|
let seen = new Map();
|
|
10
10
|
let droppable = new Set([]);
|
|
11
|
+
let byProperty = new Map();
|
|
11
12
|
node.walkDecls((decl)=>{
|
|
12
13
|
// This could happen if we have nested selectors. In that case the
|
|
13
14
|
// parent will loop over all its declarations but also the declarations
|
|
@@ -17,13 +18,63 @@ function collapseDuplicateDeclarations() {
|
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
if (seen.has(decl.prop)) {
|
|
20
|
-
|
|
21
|
+
// Exact same value as what we have seen so far
|
|
22
|
+
if (seen.get(decl.prop).value === decl.value) {
|
|
23
|
+
// Keep the last one, drop the one we've seen so far
|
|
24
|
+
droppable.add(seen.get(decl.prop));
|
|
25
|
+
// Override the existing one with the new value. This is necessary
|
|
26
|
+
// so that if we happen to have more than one declaration with the
|
|
27
|
+
// same value, that we keep removing the previous one. Otherwise we
|
|
28
|
+
// will only remove the *first* one.
|
|
29
|
+
seen.set(decl.prop, decl);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Not the same value, so we need to check if we can merge it so
|
|
33
|
+
// let's collect it first.
|
|
34
|
+
if (!byProperty.has(decl.prop)) {
|
|
35
|
+
byProperty.set(decl.prop, new Set());
|
|
36
|
+
}
|
|
37
|
+
byProperty.get(decl.prop).add(seen.get(decl.prop));
|
|
38
|
+
byProperty.get(decl.prop).add(decl);
|
|
21
39
|
}
|
|
22
40
|
seen.set(decl.prop, decl);
|
|
23
41
|
});
|
|
42
|
+
// Drop all the duplicate declarations with the exact same value we've
|
|
43
|
+
// already seen so far.
|
|
24
44
|
for (let decl1 of droppable){
|
|
25
45
|
decl1.remove();
|
|
26
46
|
}
|
|
47
|
+
// Analyze the declarations based on its unit, drop all the declarations
|
|
48
|
+
// with the same unit but the last one in the list.
|
|
49
|
+
for (let declarations of byProperty.values()){
|
|
50
|
+
let byUnit = new Map();
|
|
51
|
+
for (let decl of declarations){
|
|
52
|
+
let unit = resolveUnit(decl.value);
|
|
53
|
+
if (unit === null) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!byUnit.has(unit)) {
|
|
57
|
+
byUnit.set(unit, new Set());
|
|
58
|
+
}
|
|
59
|
+
byUnit.get(unit).add(decl);
|
|
60
|
+
}
|
|
61
|
+
for (let declarations1 of byUnit.values()){
|
|
62
|
+
// Get all but the last one
|
|
63
|
+
let removableDeclarations = Array.from(declarations1).slice(0, -1);
|
|
64
|
+
for (let decl of removableDeclarations){
|
|
65
|
+
decl.remove();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
27
69
|
});
|
|
28
70
|
};
|
|
29
71
|
}
|
|
72
|
+
let UNITLESS_NUMBER = Symbol('unitless-number');
|
|
73
|
+
function resolveUnit(input) {
|
|
74
|
+
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
75
|
+
if (result) {
|
|
76
|
+
var ref;
|
|
77
|
+
return (ref = result[1]) !== null && ref !== void 0 ? ref : UNITLESS_NUMBER;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.defaultExtractor = defaultExtractor;
|
|
6
|
+
const PATTERNS = [
|
|
7
|
+
/(?:\['([^'\s]+[^<>"'`\s:\\])')/.source,
|
|
8
|
+
/(?:\["([^"\s]+[^<>"'`\s:\\])")/.source,
|
|
9
|
+
/(?:\[`([^`\s]+[^<>"'`\s:\\])`)/.source,
|
|
10
|
+
/([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
11
|
+
/([^<>"'`\s]*\[\w*"[^'`\s]*"?\])/.source,
|
|
12
|
+
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
13
|
+
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
14
|
+
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
|
|
15
|
+
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
16
|
+
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
17
|
+
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
18
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source,
|
|
19
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
20
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
21
|
+
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
22
|
+
/([^"'`\s]*[^<>"'`\s:\\])/.source,
|
|
23
|
+
/([^<>"'`\s]*[^"'`\s:\\])/.source,
|
|
24
|
+
].join('|');
|
|
25
|
+
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
26
|
+
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
|
|
27
|
+
function defaultExtractor(content) {
|
|
28
|
+
let broadMatches = content.matchAll(BROAD_MATCH_GLOBAL_REGEXP);
|
|
29
|
+
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
|
|
30
|
+
let results = [
|
|
31
|
+
...broadMatches,
|
|
32
|
+
...innerMatches
|
|
33
|
+
].flat().filter((v)=>v !== undefined
|
|
34
|
+
);
|
|
35
|
+
return results;
|
|
36
|
+
} // Regular utilities
|
|
37
|
+
// {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
|
|
38
|
+
// Arbitrary values
|
|
39
|
+
// {{modifier}:}*{namespace}-[{arbitraryValue}]{/{opacityModifier}}?
|
|
40
|
+
// arbitraryValue: no whitespace, balanced quotes unless within quotes, balanced brackets unless within quotes
|
|
41
|
+
// Arbitrary properties
|
|
42
|
+
// {{modifier}:}*[{validCssPropertyName}:{arbitraryValue}]
|
|
@@ -236,6 +236,42 @@ function processApply(root, context) {
|
|
|
236
236
|
let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
|
|
237
237
|
if (canRewriteSelector) {
|
|
238
238
|
root.walkRules((rule)=>{
|
|
239
|
+
// Let's imagine you have the following structure:
|
|
240
|
+
//
|
|
241
|
+
// .foo {
|
|
242
|
+
// @apply bar;
|
|
243
|
+
// }
|
|
244
|
+
//
|
|
245
|
+
// @supports (a: b) {
|
|
246
|
+
// .bar {
|
|
247
|
+
// color: blue
|
|
248
|
+
// }
|
|
249
|
+
//
|
|
250
|
+
// .something-unrelated {}
|
|
251
|
+
// }
|
|
252
|
+
//
|
|
253
|
+
// In this case we want to apply `.bar` but it happens to be in
|
|
254
|
+
// an atrule node. We clone that node instead of the nested one
|
|
255
|
+
// because we still want that @supports rule to be there once we
|
|
256
|
+
// applied everything.
|
|
257
|
+
//
|
|
258
|
+
// However it happens to be that the `.something-unrelated` is
|
|
259
|
+
// also in that same shared @supports atrule. This is not good,
|
|
260
|
+
// and this should not be there. The good part is that this is
|
|
261
|
+
// a clone already and it can be safely removed. The question is
|
|
262
|
+
// how do we know we can remove it. Basically what we can do is
|
|
263
|
+
// match it against the applyCandidate that you want to apply. If
|
|
264
|
+
// it doesn't match the we can safely delete it.
|
|
265
|
+
//
|
|
266
|
+
// If we didn't do this, then the `replaceSelector` function
|
|
267
|
+
// would have replaced this with something that didn't exist and
|
|
268
|
+
// therefore it removed the selector altogether. In this specific
|
|
269
|
+
// case it would result in `{}` instead of `.something-unrelated {}`
|
|
270
|
+
if (!extractClasses(rule).some((candidate)=>candidate === applyCandidate
|
|
271
|
+
)) {
|
|
272
|
+
rule.remove();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
239
275
|
rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
|
|
240
276
|
rule.walkDecls((d)=>{
|
|
241
277
|
d.important = meta.important || important;
|
|
@@ -9,6 +9,7 @@ var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
|
9
9
|
var _generateRules = require("./generateRules");
|
|
10
10
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
11
11
|
var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
|
|
12
|
+
var _defaultExtractor = require("./defaultExtractor");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
13
14
|
return obj && obj.__esModule ? obj : {
|
|
14
15
|
default: obj
|
|
@@ -38,31 +39,8 @@ function _interopRequireWildcard(obj) {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
let env = sharedState.env;
|
|
41
|
-
const PATTERNS = [
|
|
42
|
-
/([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
43
|
-
/([^<>"'`\s]*\[\w*"[^"`\s]*"?\])/.source,
|
|
44
|
-
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
45
|
-
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
46
|
-
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
|
|
47
|
-
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
48
|
-
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
49
|
-
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
50
|
-
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
51
|
-
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
52
|
-
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
53
|
-
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
54
|
-
].join('|');
|
|
55
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
56
|
-
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
|
|
57
42
|
const builtInExtractors = {
|
|
58
|
-
DEFAULT:
|
|
59
|
-
let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
|
|
60
|
-
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
|
|
61
|
-
return [
|
|
62
|
-
...broadMatches,
|
|
63
|
-
...innerMatches
|
|
64
|
-
];
|
|
65
|
-
}
|
|
43
|
+
DEFAULT: _defaultExtractor.defaultExtractor
|
|
66
44
|
};
|
|
67
45
|
const builtInTransformers = {
|
|
68
46
|
DEFAULT: (content)=>content
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -124,6 +124,10 @@ function applyVariant(variant, matches, context) {
|
|
|
124
124
|
let variantFunctionTuples = context.variantMap.get(variant);
|
|
125
125
|
let result = [];
|
|
126
126
|
for (let [meta, rule1] of matches){
|
|
127
|
+
// Don't generate variants for user css
|
|
128
|
+
if (meta.layer === 'user') {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
127
131
|
let container = _postcss.default.root({
|
|
128
132
|
nodes: [
|
|
129
133
|
rule1.clone()
|
|
@@ -12,7 +12,11 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
function normalizeTailwindDirectives(root) {
|
|
13
13
|
let tailwindDirectives = new Set();
|
|
14
14
|
let layerDirectives = new Set();
|
|
15
|
+
let applyDirectives = new Set();
|
|
15
16
|
root.walkAtRules((atRule)=>{
|
|
17
|
+
if (atRule.name === 'apply') {
|
|
18
|
+
applyDirectives.add(atRule);
|
|
19
|
+
}
|
|
16
20
|
if (atRule.name === 'import') {
|
|
17
21
|
if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
|
|
18
22
|
atRule.name = 'tailwind';
|
|
@@ -72,5 +76,8 @@ function normalizeTailwindDirectives(root) {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
tailwindDirectives,
|
|
81
|
+
applyDirectives
|
|
82
|
+
};
|
|
76
83
|
}
|
|
@@ -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.resolveDebug = resolveDebug;
|
|
5
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
|
+
}
|
|
@@ -21,9 +21,10 @@ function _interopRequireDefault(obj) {
|
|
|
21
21
|
}
|
|
22
22
|
function processTailwindFeatures(setupContext) {
|
|
23
23
|
return function(root, result) {
|
|
24
|
-
let tailwindDirectives = (0, _normalizeTailwindDirectives).default(root);
|
|
24
|
+
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
|
|
25
25
|
let context = setupContext({
|
|
26
26
|
tailwindDirectives,
|
|
27
|
+
applyDirectives,
|
|
27
28
|
registerDependency (dependency) {
|
|
28
29
|
result.messages.push({
|
|
29
30
|
plugin: 'tailwindcss',
|
package/lib/util/color.js
CHANGED
|
@@ -15,7 +15,8 @@ let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
|
|
|
15
15
|
let VALUE = `(?:\\d+|\\d*\\.\\d+)%?`;
|
|
16
16
|
let SEP = `(?:\\s*,\\s*|\\s+)`;
|
|
17
17
|
let ALPHA_SEP = `\\s*[,/]\\s*`;
|
|
18
|
-
let
|
|
18
|
+
let RGB = new RegExp(`^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
|
|
19
|
+
let HSL = new RegExp(`^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
|
|
19
20
|
function parseColor(value) {
|
|
20
21
|
if (typeof value !== 'string') {
|
|
21
22
|
return null;
|
|
@@ -62,18 +63,32 @@ function parseColor(value) {
|
|
|
62
63
|
alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
66
|
+
let rgbMatch = value.match(RGB);
|
|
67
|
+
if (rgbMatch !== null) {
|
|
67
68
|
var ref, ref1;
|
|
68
69
|
return {
|
|
69
|
-
mode:
|
|
70
|
+
mode: 'rgb',
|
|
71
|
+
color: [
|
|
72
|
+
rgbMatch[1],
|
|
73
|
+
rgbMatch[2],
|
|
74
|
+
rgbMatch[3]
|
|
75
|
+
].map((v)=>v.toString()
|
|
76
|
+
),
|
|
77
|
+
alpha: (ref = rgbMatch[4]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
let hslMatch = value.match(HSL);
|
|
81
|
+
if (hslMatch !== null) {
|
|
82
|
+
var ref2, ref3;
|
|
83
|
+
return {
|
|
84
|
+
mode: 'hsl',
|
|
70
85
|
color: [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
hslMatch[1],
|
|
87
|
+
hslMatch[2],
|
|
88
|
+
hslMatch[3]
|
|
74
89
|
].map((v)=>v.toString()
|
|
75
90
|
),
|
|
76
|
-
alpha: (
|
|
91
|
+
alpha: (ref2 = hslMatch[4]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.toString) === null || ref3 === void 0 ? void 0 : ref3.call(ref2)
|
|
77
92
|
};
|
|
78
93
|
}
|
|
79
94
|
return null;
|
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.722232c",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"prepublishOnly": "npm install --force && npm run swcify",
|
|
26
26
|
"style": "eslint .",
|
|
27
27
|
"pretest": "npm run generate:plugin-list",
|
|
28
|
-
"test": "
|
|
28
|
+
"test": "jest",
|
|
29
29
|
"test:integrations": "npm run test --prefix ./integrations",
|
|
30
30
|
"install:integrations": "node scripts/install-integrations.js",
|
|
31
31
|
"posttest": "npm run style",
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"*.js"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@swc/cli": "^0.1.
|
|
46
|
+
"@swc/cli": "^0.1.55",
|
|
47
47
|
"@swc/core": "^1.2.118",
|
|
48
|
-
"@swc/jest": "^0.2.
|
|
48
|
+
"@swc/jest": "^0.2.15",
|
|
49
49
|
"@swc/register": "^0.1.7",
|
|
50
50
|
"autoprefixer": "^10.4.0",
|
|
51
51
|
"cross-env": "^7.0.3",
|
|
52
|
-
"cssnano": "^5.0.
|
|
52
|
+
"cssnano": "^5.0.14",
|
|
53
53
|
"esbuild": "^0.14.2",
|
|
54
54
|
"eslint": "^8.4.1",
|
|
55
55
|
"eslint-config-prettier": "^8.3.0",
|
|
56
56
|
"eslint-plugin-prettier": "^4.0.0",
|
|
57
|
-
"jest": "^27.4.
|
|
57
|
+
"jest": "^27.4.5",
|
|
58
58
|
"jest-diff": "^27.4.2",
|
|
59
|
-
"postcss": "^8.4.
|
|
59
|
+
"postcss": "^8.4.5",
|
|
60
60
|
"postcss-cli": "^8.3.1",
|
|
61
|
-
"prettier": "^2.5.
|
|
61
|
+
"prettier": "^2.5.1",
|
|
62
62
|
"rimraf": "^3.0.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
@@ -85,8 +85,7 @@
|
|
|
85
85
|
"postcss-selector-parser": "^6.0.7",
|
|
86
86
|
"postcss-value-parser": "^4.2.0",
|
|
87
87
|
"quick-lru": "^5.1.1",
|
|
88
|
-
"resolve": "^1.20.0"
|
|
89
|
-
"tmp": "^0.2.1"
|
|
88
|
+
"resolve": "^1.20.0"
|
|
90
89
|
},
|
|
91
90
|
"browserslist": [
|
|
92
91
|
"> 1%",
|