tailwindcss 3.1.5 → 3.1.8
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 +36 -8
- package/README.md +6 -3
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +78 -75
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +194 -187
- package/lib/featureFlags.js +14 -7
- package/lib/index.js +9 -6
- package/lib/lib/cacheInvalidation.js +18 -15
- package/lib/lib/collapseAdjacentRules.js +14 -11
- package/lib/lib/collapseDuplicateDeclarations.js +11 -8
- package/lib/lib/defaultExtractor.js +38 -35
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +75 -44
- package/lib/lib/expandApplyAtRules.js +50 -42
- package/lib/lib/expandTailwindAtRules.js +153 -150
- package/lib/lib/generateRules.js +81 -73
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +10 -7
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +15 -7
- package/lib/lib/resolveDefaultsAtRules.js +92 -85
- package/lib/lib/setupContextUtils.js +109 -97
- package/lib/lib/setupTrackingContext.js +82 -75
- package/lib/lib/sharedState.js +15 -8
- package/lib/lib/substituteScreenAtRules.js +8 -5
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +7 -4
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +6 -4
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +5 -2
- package/lib/util/cloneDeep.js +4 -1
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +11 -3
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +5 -3
- package/lib/util/createUtilityPlugin.js +13 -10
- package/lib/util/dataTypes.js +27 -19
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +12 -9
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +21 -14
- package/lib/util/getAllConfigs.js +12 -9
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/isValidArbitraryValue.js +33 -24
- package/lib/util/log.js +12 -5
- package/lib/util/nameClass.js +16 -8
- package/lib/util/negateValue.js +4 -1
- package/lib/util/normalizeConfig.js +26 -23
- package/lib/util/normalizeScreens.js +17 -2
- package/lib/util/parseAnimationValue.js +42 -39
- package/lib/util/parseBoxShadowValue.js +12 -4
- package/lib/util/parseDependency.js +35 -32
- package/lib/util/parseObjectStyles.js +14 -11
- package/lib/util/pluginUtils.js +28 -20
- package/lib/util/prefixSelector.js +6 -3
- package/lib/util/removeAlphaVariables.js +13 -2
- package/lib/util/resolveConfig.js +56 -53
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +16 -13
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +10 -7
- package/lib/util/validateConfig.js +5 -2
- package/lib/util/withAlphaVariable.js +30 -22
- package/package.json +10 -10
- package/peers/index.js +950 -825
- package/resolveConfig.d.ts +3 -0
- package/src/lib/evaluateTailwindFunctions.js +41 -15
- package/src/lib/expandApplyAtRules.js +6 -0
- package/src/lib/generateRules.js +6 -5
- package/src/lib/setupContextUtils.js +4 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/resolveConfig.js +1 -1
package/lib/featureFlags.js
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
flagEnabled: ()=>flagEnabled,
|
|
13
|
+
issueFlagNotices: ()=>issueFlagNotices,
|
|
14
|
+
default: ()=>_default
|
|
15
|
+
});
|
|
16
|
+
const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
|
|
17
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
|
|
10
18
|
function _interopRequireDefault(obj) {
|
|
11
19
|
return obj && obj.__esModule ? obj : {
|
|
12
20
|
default: obj
|
|
@@ -57,5 +65,4 @@ function issueFlagNotices(config) {
|
|
|
57
65
|
]);
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
|
-
|
|
61
|
-
exports.default = _default;
|
|
68
|
+
const _default = featureFlags;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _setupTrackingContext = /*#__PURE__*/ _interopRequireDefault(require("./lib/setupTrackingContext"));
|
|
6
|
+
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
|
|
7
|
+
const _sharedState = require("./lib/sharedState");
|
|
5
8
|
function _interopRequireDefault(obj) {
|
|
6
9
|
return obj && obj.__esModule ? obj : {
|
|
7
10
|
default: obj
|
|
@@ -17,17 +20,17 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
17
20
|
return root;
|
|
18
21
|
},
|
|
19
22
|
function(root, result) {
|
|
20
|
-
let context = (0, _setupTrackingContext
|
|
23
|
+
let context = (0, _setupTrackingContext.default)(configOrPath);
|
|
21
24
|
if (root.type === "document") {
|
|
22
25
|
let roots = root.nodes.filter((node)=>node.type === "root");
|
|
23
26
|
for (const root1 of roots){
|
|
24
27
|
if (root1.type === "root") {
|
|
25
|
-
(0, _processTailwindFeatures
|
|
28
|
+
(0, _processTailwindFeatures.default)(context)(root1, result);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
return;
|
|
29
32
|
}
|
|
30
|
-
(0, _processTailwindFeatures
|
|
33
|
+
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
31
34
|
},
|
|
32
35
|
_sharedState.env.DEBUG && function(root) {
|
|
33
36
|
console.timeEnd("JIT TOTAL");
|
|
@@ -2,24 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "hasContentChanged", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>hasContentChanged
|
|
8
|
+
});
|
|
9
|
+
const _crypto = /*#__PURE__*/ _interopRequireDefault(require("crypto"));
|
|
10
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
8
11
|
function _interopRequireDefault(obj) {
|
|
9
12
|
return obj && obj.__esModule ? obj : {
|
|
10
13
|
default: obj
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
|
-
function _getRequireWildcardCache() {
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
14
17
|
if (typeof WeakMap !== "function") return null;
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var cacheBabelInterop = new WeakMap();
|
|
19
|
+
var cacheNodeInterop = new WeakMap();
|
|
20
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
+
})(nodeInterop);
|
|
20
23
|
}
|
|
21
|
-
function _interopRequireWildcard(obj) {
|
|
22
|
-
if (obj && obj.__esModule) {
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
25
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
26
|
return obj;
|
|
24
27
|
}
|
|
25
28
|
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
@@ -27,14 +30,14 @@ function _interopRequireWildcard(obj) {
|
|
|
27
30
|
default: obj
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
|
-
var cache = _getRequireWildcardCache();
|
|
33
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
34
|
if (cache && cache.has(obj)) {
|
|
32
35
|
return cache.get(obj);
|
|
33
36
|
}
|
|
34
37
|
var newObj = {};
|
|
35
38
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
39
|
for(var key in obj){
|
|
37
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
38
41
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
39
42
|
if (desc && (desc.get || desc.set)) {
|
|
40
43
|
Object.defineProperty(newObj, key, desc);
|
|
@@ -79,9 +82,9 @@ function hasContentChanged(sourcePath, root) {
|
|
|
79
82
|
if (!css.includes("@tailwind")) {
|
|
80
83
|
return false;
|
|
81
84
|
}
|
|
82
|
-
let existingHash =
|
|
85
|
+
let existingHash = _sharedState.sourceHashMap.get(sourcePath);
|
|
83
86
|
let rootHash = getHash(css);
|
|
84
87
|
let didChange = existingHash !== rootHash;
|
|
85
|
-
|
|
88
|
+
_sharedState.sourceHashMap.set(sourcePath, rootHash);
|
|
86
89
|
return didChange;
|
|
87
90
|
}
|
|
@@ -2,7 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>collapseAdjacentRules
|
|
8
|
+
});
|
|
9
|
+
let comparisonMap = {
|
|
10
|
+
atrule: [
|
|
11
|
+
"name",
|
|
12
|
+
"params"
|
|
13
|
+
],
|
|
14
|
+
rule: [
|
|
15
|
+
"selector"
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
let types = new Set(Object.keys(comparisonMap));
|
|
6
19
|
function collapseAdjacentRules() {
|
|
7
20
|
function collapseRulesIn(root) {
|
|
8
21
|
let currentRule = null;
|
|
@@ -44,13 +57,3 @@ function collapseAdjacentRules() {
|
|
|
44
57
|
collapseRulesIn(root);
|
|
45
58
|
};
|
|
46
59
|
}
|
|
47
|
-
let comparisonMap = {
|
|
48
|
-
atrule: [
|
|
49
|
-
"name",
|
|
50
|
-
"params"
|
|
51
|
-
],
|
|
52
|
-
rule: [
|
|
53
|
-
"selector"
|
|
54
|
-
]
|
|
55
|
-
};
|
|
56
|
-
let types = new Set(Object.keys(comparisonMap));
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>collapseDuplicateDeclarations
|
|
8
|
+
});
|
|
6
9
|
function collapseDuplicateDeclarations() {
|
|
7
10
|
return (root)=>{
|
|
8
11
|
root.walkRules((node)=>{
|
|
@@ -41,28 +44,28 @@ function collapseDuplicateDeclarations() {
|
|
|
41
44
|
});
|
|
42
45
|
// Drop all the duplicate declarations with the exact same value we've
|
|
43
46
|
// already seen so far.
|
|
44
|
-
for (let
|
|
45
|
-
|
|
47
|
+
for (let decl of droppable){
|
|
48
|
+
decl.remove();
|
|
46
49
|
}
|
|
47
50
|
// Analyze the declarations based on its unit, drop all the declarations
|
|
48
51
|
// with the same unit but the last one in the list.
|
|
49
52
|
for (let declarations of byProperty.values()){
|
|
50
53
|
let byUnit = new Map();
|
|
51
|
-
for (let
|
|
52
|
-
let unit = resolveUnit(
|
|
54
|
+
for (let decl1 of declarations){
|
|
55
|
+
let unit = resolveUnit(decl1.value);
|
|
53
56
|
if (unit === null) {
|
|
54
57
|
continue;
|
|
55
58
|
}
|
|
56
59
|
if (!byUnit.has(unit)) {
|
|
57
60
|
byUnit.set(unit, new Set());
|
|
58
61
|
}
|
|
59
|
-
byUnit.get(unit).add(
|
|
62
|
+
byUnit.get(unit).add(decl1);
|
|
60
63
|
}
|
|
61
64
|
for (let declarations1 of byUnit.values()){
|
|
62
65
|
// Get all but the last one
|
|
63
66
|
let removableDeclarations = Array.from(declarations1).slice(0, -1);
|
|
64
|
-
for (let
|
|
65
|
-
|
|
67
|
+
for (let decl2 of removableDeclarations){
|
|
68
|
+
decl2.remove();
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
}
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "defaultExtractor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>defaultExtractor
|
|
8
|
+
});
|
|
9
|
+
const _featureFlags = require("../featureFlags");
|
|
10
|
+
const _regex = /*#__PURE__*/ _interopRequireWildcard(require("./regex"));
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
9
12
|
if (typeof WeakMap !== "function") return null;
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var cacheBabelInterop = new WeakMap();
|
|
14
|
+
var cacheNodeInterop = new WeakMap();
|
|
15
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
16
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
17
|
+
})(nodeInterop);
|
|
15
18
|
}
|
|
16
|
-
function _interopRequireWildcard(obj) {
|
|
17
|
-
if (obj && obj.__esModule) {
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
20
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
18
21
|
return obj;
|
|
19
22
|
}
|
|
20
23
|
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
@@ -22,14 +25,14 @@ function _interopRequireWildcard(obj) {
|
|
|
22
25
|
default: obj
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
|
-
var cache = _getRequireWildcardCache();
|
|
28
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
26
29
|
if (cache && cache.has(obj)) {
|
|
27
30
|
return cache.get(obj);
|
|
28
31
|
}
|
|
29
32
|
var newObj = {};
|
|
30
33
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
31
34
|
for(var key in obj){
|
|
32
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
35
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
33
36
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
34
37
|
if (desc && (desc.get || desc.set)) {
|
|
35
38
|
Object.defineProperty(newObj, key, desc);
|
|
@@ -62,21 +65,21 @@ function defaultExtractor(context) {
|
|
|
62
65
|
}
|
|
63
66
|
function* buildRegExps(context) {
|
|
64
67
|
let separator = context.tailwindConfig.separator;
|
|
65
|
-
let variantGroupingEnabled = (0, _featureFlags
|
|
66
|
-
let prefix = context.tailwindConfig.prefix !== "" ?
|
|
68
|
+
let variantGroupingEnabled = (0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping");
|
|
69
|
+
let prefix = context.tailwindConfig.prefix !== "" ? _regex.optional(_regex.pattern([
|
|
67
70
|
/-?/,
|
|
68
|
-
|
|
71
|
+
_regex.escape(context.tailwindConfig.prefix)
|
|
69
72
|
])) : "";
|
|
70
|
-
let utility =
|
|
73
|
+
let utility = _regex.any([
|
|
71
74
|
// Arbitrary properties
|
|
72
75
|
/\[[^\s:'"`]+:[^\s\]]+\]/,
|
|
73
76
|
// Utilities
|
|
74
|
-
|
|
77
|
+
_regex.pattern([
|
|
75
78
|
// Utility Name / Group Name
|
|
76
79
|
/-?(?:\w+)/,
|
|
77
80
|
// Normal/Arbitrary values
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
_regex.optional(_regex.any([
|
|
82
|
+
_regex.pattern([
|
|
80
83
|
// Arbitrary values
|
|
81
84
|
/-(?:\w+-)*\[[^\s:]+\]/,
|
|
82
85
|
// Not immediately followed by an `{[(`
|
|
@@ -84,7 +87,7 @@ function* buildRegExps(context) {
|
|
|
84
87
|
// optionally followed by an opacity modifier
|
|
85
88
|
/(?:\/[^\s'"`\\><$]*)?/,
|
|
86
89
|
]),
|
|
87
|
-
|
|
90
|
+
_regex.pattern([
|
|
88
91
|
// Arbitrary values
|
|
89
92
|
/-(?:\w+-)*\[[^\s]+\]/,
|
|
90
93
|
// Not immediately followed by an `{[(`
|
|
@@ -99,30 +102,30 @@ function* buildRegExps(context) {
|
|
|
99
102
|
]);
|
|
100
103
|
let variantPatterns = [
|
|
101
104
|
// Without quotes
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
_regex.any([
|
|
106
|
+
_regex.pattern([
|
|
104
107
|
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
|
|
105
108
|
separator
|
|
106
109
|
]),
|
|
107
|
-
|
|
110
|
+
_regex.pattern([
|
|
108
111
|
/[^\s"'`\[\\]+/,
|
|
109
112
|
separator
|
|
110
113
|
]),
|
|
111
114
|
]),
|
|
112
115
|
// With quotes allowed
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
_regex.any([
|
|
117
|
+
_regex.pattern([
|
|
115
118
|
/([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
|
|
116
119
|
separator
|
|
117
120
|
]),
|
|
118
|
-
|
|
121
|
+
_regex.pattern([
|
|
119
122
|
/[^\s`\[\\]+/,
|
|
120
123
|
separator
|
|
121
124
|
]),
|
|
122
125
|
]),
|
|
123
126
|
];
|
|
124
127
|
for (const variantPattern of variantPatterns){
|
|
125
|
-
yield
|
|
128
|
+
yield _regex.pattern([
|
|
126
129
|
// Variants
|
|
127
130
|
"((?=((",
|
|
128
131
|
variantPattern,
|
|
@@ -130,12 +133,12 @@ function* buildRegExps(context) {
|
|
|
130
133
|
// Important (optional)
|
|
131
134
|
/!?/,
|
|
132
135
|
prefix,
|
|
133
|
-
variantGroupingEnabled ?
|
|
136
|
+
variantGroupingEnabled ? _regex.any([
|
|
134
137
|
// Or any of those things but grouped separated by commas
|
|
135
|
-
|
|
138
|
+
_regex.pattern([
|
|
136
139
|
/\(/,
|
|
137
140
|
utility,
|
|
138
|
-
|
|
141
|
+
_regex.zeroOrMore([
|
|
139
142
|
/,/,
|
|
140
143
|
utility
|
|
141
144
|
]),
|
|
@@ -187,8 +190,8 @@ let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
|
|
|
187
190
|
0: group
|
|
188
191
|
}));
|
|
189
192
|
});
|
|
190
|
-
for (let
|
|
191
|
-
let char =
|
|
193
|
+
for (let match of matches){
|
|
194
|
+
let char = match[0];
|
|
192
195
|
let inStringType = openStringTypes[openStringTypes.length - 1];
|
|
193
196
|
if (char === inStringType) {
|
|
194
197
|
openStringTypes.pop();
|
|
@@ -208,14 +211,14 @@ let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
|
|
|
208
211
|
// This means that there was an extra closing `]`
|
|
209
212
|
// We'll clip to just before it
|
|
210
213
|
if (depth < 0) {
|
|
211
|
-
return input.substring(0,
|
|
214
|
+
return input.substring(0, match.index);
|
|
212
215
|
}
|
|
213
216
|
// We've finished balancing the brackets but there still may be characters that can be included
|
|
214
217
|
// For example in the class `text-[#336699]/[.35]`
|
|
215
218
|
// The depth goes to `0` at the closing `]` but goes up again at the `[`
|
|
216
219
|
// If we're at zero and encounter a non-class character then we clip the class there
|
|
217
220
|
if (depth === 0 && !ALLOWED_CLASS_CHARACTERS.test(char)) {
|
|
218
|
-
return input.substring(0,
|
|
221
|
+
return input.substring(0, match.index);
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
return input;
|
package/lib/lib/detectNesting.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
6
9
|
function _default(_context) {
|
|
7
10
|
return (root, result)=>{
|
|
8
11
|
let found = false;
|
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _dlv = /*#__PURE__*/ _interopRequireDefault(require("dlv"));
|
|
10
|
+
const _didyoumean = /*#__PURE__*/ _interopRequireDefault(require("didyoumean"));
|
|
11
|
+
const _transformThemeValue = /*#__PURE__*/ _interopRequireDefault(require("../util/transformThemeValue"));
|
|
12
|
+
const _postcssValueParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-value-parser"));
|
|
13
|
+
const _normalizeScreens = require("../util/normalizeScreens");
|
|
14
|
+
const _buildMediaQuery = /*#__PURE__*/ _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
15
|
+
const _toPath = require("../util/toPath");
|
|
16
|
+
const _withAlphaVariable = require("../util/withAlphaVariable");
|
|
17
|
+
const _pluginUtils = require("../util/pluginUtils");
|
|
15
18
|
function _interopRequireDefault(obj) {
|
|
16
19
|
return obj && obj.__esModule ? obj : {
|
|
17
20
|
default: obj
|
|
@@ -21,10 +24,10 @@ function isObject(input) {
|
|
|
21
24
|
return typeof input === "object" && input !== null;
|
|
22
25
|
}
|
|
23
26
|
function findClosestExistingPath(theme, path) {
|
|
24
|
-
let parts = (0, _toPath
|
|
27
|
+
let parts = (0, _toPath.toPath)(path);
|
|
25
28
|
do {
|
|
26
29
|
parts.pop();
|
|
27
|
-
if ((0, _dlv
|
|
30
|
+
if ((0, _dlv.default)(theme, parts) !== undefined) break;
|
|
28
31
|
}while (parts.length);
|
|
29
32
|
return parts.length ? parts : undefined;
|
|
30
33
|
}
|
|
@@ -43,18 +46,18 @@ function listKeys(obj) {
|
|
|
43
46
|
}
|
|
44
47
|
function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
45
48
|
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, "");
|
|
46
|
-
const pathSegments = Array.isArray(path) ? path : (0, _toPath
|
|
47
|
-
const value = (0, _dlv
|
|
49
|
+
const pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString);
|
|
50
|
+
const value = (0, _dlv.default)(config.theme, pathSegments, defaultValue);
|
|
48
51
|
if (value === undefined) {
|
|
49
52
|
let error = `'${pathString}' does not exist in your theme config.`;
|
|
50
53
|
const parentSegments = pathSegments.slice(0, -1);
|
|
51
|
-
const parentValue = (0, _dlv
|
|
54
|
+
const parentValue = (0, _dlv.default)(config.theme, parentSegments);
|
|
52
55
|
if (isObject(parentValue)) {
|
|
53
56
|
const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
|
|
54
57
|
...parentSegments,
|
|
55
58
|
key
|
|
56
59
|
]).isValid);
|
|
57
|
-
const suggestion = (0, _didyoumean
|
|
60
|
+
const suggestion = (0, _didyoumean.default)(pathSegments[pathSegments.length - 1], validKeys);
|
|
58
61
|
if (suggestion) {
|
|
59
62
|
error += ` Did you mean '${pathToString([
|
|
60
63
|
...parentSegments,
|
|
@@ -66,7 +69,7 @@ function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
|
66
69
|
} else {
|
|
67
70
|
const closestPath = findClosestExistingPath(config.theme, pathString);
|
|
68
71
|
if (closestPath) {
|
|
69
|
-
const closestValue = (0, _dlv
|
|
72
|
+
const closestValue = (0, _dlv.default)(config.theme, closestPath);
|
|
70
73
|
if (isObject(closestValue)) {
|
|
71
74
|
error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
|
|
72
75
|
} else {
|
|
@@ -82,28 +85,28 @@ function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
|
82
85
|
};
|
|
83
86
|
}
|
|
84
87
|
if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
85
|
-
let
|
|
88
|
+
let error1 = `'${pathString}' was found but does not resolve to a string.`;
|
|
86
89
|
if (isObject(value)) {
|
|
87
|
-
let
|
|
90
|
+
let validKeys1 = Object.keys(value).filter((key)=>validatePath(config, [
|
|
88
91
|
...pathSegments,
|
|
89
92
|
key
|
|
90
93
|
]).isValid);
|
|
91
|
-
if (
|
|
92
|
-
|
|
94
|
+
if (validKeys1.length) {
|
|
95
|
+
error1 += ` Did you mean something like '${pathToString([
|
|
93
96
|
...pathSegments,
|
|
94
|
-
|
|
97
|
+
validKeys1[0]
|
|
95
98
|
])}'?`;
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
return {
|
|
99
102
|
isValid: false,
|
|
100
|
-
error
|
|
103
|
+
error: error1
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
106
|
const [themeSection] = pathSegments;
|
|
104
107
|
return {
|
|
105
108
|
isValid: true,
|
|
106
|
-
value: (0, _transformThemeValue
|
|
109
|
+
value: (0, _transformThemeValue.default)(themeSection)(value, themeOpts)
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
112
|
function extractArgs(node, vNodes, functions) {
|
|
@@ -111,11 +114,11 @@ function extractArgs(node, vNodes, functions) {
|
|
|
111
114
|
let args = [
|
|
112
115
|
""
|
|
113
116
|
];
|
|
114
|
-
for (let
|
|
115
|
-
if (
|
|
117
|
+
for (let vNode of vNodes){
|
|
118
|
+
if (vNode.type === "div" && vNode.value === ",") {
|
|
116
119
|
args.push("");
|
|
117
120
|
} else {
|
|
118
|
-
args[args.length - 1] += _postcssValueParser.default.stringify(
|
|
121
|
+
args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
return args;
|
|
@@ -129,7 +132,7 @@ function resolveVNode(node, vNode, functions) {
|
|
|
129
132
|
return vNode;
|
|
130
133
|
}
|
|
131
134
|
function resolveFunctions(node, input, functions) {
|
|
132
|
-
return (0, _postcssValueParser
|
|
135
|
+
return (0, _postcssValueParser.default)(input).walk((vNode)=>{
|
|
133
136
|
resolveVNode(node, vNode, functions);
|
|
134
137
|
}).toString();
|
|
135
138
|
}
|
|
@@ -137,42 +140,70 @@ let nodeTypePropertyMap = {
|
|
|
137
140
|
atrule: "params",
|
|
138
141
|
decl: "value"
|
|
139
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* @param {string} path
|
|
145
|
+
* @returns {Iterable<[path: string, alpha: string|undefined]>}
|
|
146
|
+
*/ function* toPaths(path) {
|
|
147
|
+
// Strip quotes from beginning and end of string
|
|
148
|
+
// This allows the alpha value to be present inside of quotes
|
|
149
|
+
path = path.replace(/^['"]+|['"]+$/g, "");
|
|
150
|
+
let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
|
|
151
|
+
let alpha = undefined;
|
|
152
|
+
yield [
|
|
153
|
+
path,
|
|
154
|
+
undefined
|
|
155
|
+
];
|
|
156
|
+
if (matches) {
|
|
157
|
+
path = matches[1];
|
|
158
|
+
alpha = matches[2];
|
|
159
|
+
yield [
|
|
160
|
+
path,
|
|
161
|
+
alpha
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
*
|
|
167
|
+
* @param {any} config
|
|
168
|
+
* @param {string} path
|
|
169
|
+
* @param {any} defaultValue
|
|
170
|
+
*/ function resolvePath(config, path, defaultValue) {
|
|
171
|
+
const results = Array.from(toPaths(path)).map(([path, alpha])=>{
|
|
172
|
+
return Object.assign(validatePath(config, path, defaultValue, {
|
|
173
|
+
opacityValue: alpha
|
|
174
|
+
}), {
|
|
175
|
+
resolvedPath: path,
|
|
176
|
+
alpha
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
var ref;
|
|
180
|
+
return (ref = results.find((result)=>result.isValid)) !== null && ref !== void 0 ? ref : results[0];
|
|
181
|
+
}
|
|
140
182
|
function _default({ tailwindConfig: config }) {
|
|
141
183
|
let functions = {
|
|
142
184
|
theme: (node, path, ...defaultValue)=>{
|
|
143
|
-
|
|
144
|
-
// This allows the alpha value to be present inside of quotes
|
|
145
|
-
path = path.replace(/^['"]+|['"]+$/g, "");
|
|
146
|
-
let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
|
|
147
|
-
let alpha = undefined;
|
|
148
|
-
if (matches) {
|
|
149
|
-
path = matches[1];
|
|
150
|
-
alpha = matches[2];
|
|
151
|
-
}
|
|
152
|
-
let { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined, {
|
|
153
|
-
opacityValue: alpha
|
|
154
|
-
});
|
|
185
|
+
let { isValid , value , error , alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
|
|
155
186
|
if (!isValid) {
|
|
156
187
|
throw node.error(error);
|
|
157
188
|
}
|
|
158
|
-
let maybeColor = (0, _pluginUtils
|
|
189
|
+
let maybeColor = (0, _pluginUtils.parseColorFormat)(value);
|
|
159
190
|
let isColorFunction = maybeColor !== undefined && typeof maybeColor === "function";
|
|
160
191
|
if (alpha !== undefined || isColorFunction) {
|
|
161
192
|
if (alpha === undefined) {
|
|
162
193
|
alpha = 1.0;
|
|
163
194
|
}
|
|
164
|
-
value = (0, _withAlphaVariable
|
|
195
|
+
value = (0, _withAlphaVariable.withAlphaValue)(maybeColor, alpha, maybeColor);
|
|
165
196
|
}
|
|
166
197
|
return value;
|
|
167
198
|
},
|
|
168
199
|
screen: (node, screen)=>{
|
|
169
200
|
screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
170
|
-
let screens = (0, _normalizeScreens
|
|
201
|
+
let screens = (0, _normalizeScreens.normalizeScreens)(config.theme.screens);
|
|
171
202
|
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
172
203
|
if (!screenDefinition) {
|
|
173
204
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
174
205
|
}
|
|
175
|
-
return (0, _buildMediaQuery
|
|
206
|
+
return (0, _buildMediaQuery.default)(screenDefinition);
|
|
176
207
|
}
|
|
177
208
|
};
|
|
178
209
|
return (root)=>{
|