tailwindcss 3.0.21 → 3.0.24
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 +45 -2
- package/lib/cli-peer-dependencies.js +3 -3
- package/lib/cli.js +183 -161
- package/lib/constants.js +8 -8
- package/lib/corePlugins.js +1597 -1518
- package/lib/featureFlags.js +9 -9
- package/lib/index.js +19 -6
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +26 -13
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +8 -6
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +16 -16
- package/lib/lib/expandApplyAtRules.js +180 -27
- package/lib/lib/expandTailwindAtRules.js +132 -122
- package/lib/lib/generateRules.js +117 -72
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/resolveDefaultsAtRules.js +81 -77
- package/lib/lib/setupContextUtils.js +83 -98
- package/lib/lib/setupTrackingContext.js +57 -57
- package/lib/lib/sharedState.js +11 -7
- package/lib/lib/substituteScreenAtRules.js +2 -2
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +41 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +21 -20
- package/lib/util/createUtilityPlugin.js +6 -6
- package/lib/util/dataTypes.js +77 -75
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +19 -19
- package/lib/util/getAllConfigs.js +5 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +27 -27
- package/lib/util/log.js +8 -8
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +39 -39
- package/lib/util/normalizeScreens.js +4 -4
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +60 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +9 -9
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +28 -28
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +27 -27
- package/lib/util/withAlphaVariable.js +19 -19
- package/package.json +26 -25
- package/peers/index.js +4803 -4857
- package/scripts/generate-types.js +52 -0
- package/src/cli.js +41 -11
- package/src/corePlugins.js +104 -9
- package/src/featureFlags.js +2 -2
- package/src/index.js +17 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +16 -1
- package/src/lib/defaultExtractor.js +6 -4
- package/src/lib/expandApplyAtRules.js +179 -6
- package/src/lib/expandTailwindAtRules.js +26 -6
- package/src/lib/generateRules.js +73 -46
- package/src/lib/resolveDefaultsAtRules.js +6 -2
- package/src/lib/setupContextUtils.js +39 -48
- package/src/lib/setupTrackingContext.js +3 -3
- package/src/lib/sharedState.js +2 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +7 -5
- package/src/util/dataTypes.js +3 -1
- package/src/util/log.js +7 -7
- package/src/util/parseBoxShadowValue.js +50 -2
- package/src/util/resolveConfig.js +32 -0
- package/stubs/defaultConfig.stub.js +5 -0
package/lib/featureFlags.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.flagEnabled = flagEnabled;
|
|
6
6
|
exports.issueFlagNotices = issueFlagNotices;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
9
9
|
var _log = _interopRequireDefault(require("./util/log"));
|
|
10
10
|
function _interopRequireDefault(obj) {
|
|
11
11
|
return obj && obj.__esModule ? obj : {
|
|
@@ -18,24 +18,24 @@ let defaults = {
|
|
|
18
18
|
let featureFlags = {
|
|
19
19
|
future: [],
|
|
20
20
|
experimental: [
|
|
21
|
-
|
|
21
|
+
"optimizeUniversalDefaults"
|
|
22
22
|
]
|
|
23
23
|
};
|
|
24
24
|
function flagEnabled(config, flag) {
|
|
25
25
|
if (featureFlags.future.includes(flag)) {
|
|
26
26
|
var ref;
|
|
27
27
|
var ref1, ref2;
|
|
28
|
-
return config.future ===
|
|
28
|
+
return config.future === "all" || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
|
|
29
29
|
}
|
|
30
30
|
if (featureFlags.experimental.includes(flag)) {
|
|
31
31
|
var ref3;
|
|
32
32
|
var ref4, ref5;
|
|
33
|
-
return config.experimental ===
|
|
33
|
+
return config.experimental === "all" || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
|
|
34
34
|
}
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
function experimentalFlagsEnabled(config) {
|
|
38
|
-
if (config.experimental ===
|
|
38
|
+
if (config.experimental === "all") {
|
|
39
39
|
return featureFlags.experimental;
|
|
40
40
|
}
|
|
41
41
|
var ref;
|
|
@@ -47,11 +47,11 @@ function issueFlagNotices(config) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
if (experimentalFlagsEnabled(config).length > 0) {
|
|
50
|
-
let changes = experimentalFlagsEnabled(config).map((s)=>
|
|
51
|
-
).join(
|
|
52
|
-
_log.default.warn(
|
|
50
|
+
let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)
|
|
51
|
+
).join(", ");
|
|
52
|
+
_log.default.warn("experimental-flags-enabled", [
|
|
53
53
|
`You have enabled experimental features: ${changes}`,
|
|
54
|
-
|
|
54
|
+
"Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.",
|
|
55
55
|
]);
|
|
56
56
|
}
|
|
57
57
|
}
|
package/lib/index.js
CHANGED
|
@@ -9,19 +9,32 @@ function _interopRequireDefault(obj) {
|
|
|
9
9
|
}
|
|
10
10
|
module.exports = function tailwindcss(configOrPath) {
|
|
11
11
|
return {
|
|
12
|
-
postcssPlugin:
|
|
12
|
+
postcssPlugin: "tailwindcss",
|
|
13
13
|
plugins: [
|
|
14
14
|
_sharedState.env.DEBUG && function(root) {
|
|
15
|
-
console.log(
|
|
16
|
-
console.time(
|
|
15
|
+
console.log("\n");
|
|
16
|
+
console.time("JIT TOTAL");
|
|
17
17
|
return root;
|
|
18
18
|
},
|
|
19
19
|
function(root, result) {
|
|
20
|
-
|
|
20
|
+
let context = (0, _setupTrackingContext).default(configOrPath);
|
|
21
|
+
/*
|
|
22
|
+
if (root.type === 'document') {
|
|
23
|
+
let roots = root.nodes.filter((node) => node.type === 'root')
|
|
24
|
+
|
|
25
|
+
for (const root of roots) {
|
|
26
|
+
if (root.type === 'root') {
|
|
27
|
+
processTailwindFeatures(context)(root, result)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
*/ (0, _processTailwindFeatures).default(context)(root, result);
|
|
21
34
|
},
|
|
22
35
|
_sharedState.env.DEBUG && function(root) {
|
|
23
|
-
console.timeEnd(
|
|
24
|
-
console.log(
|
|
36
|
+
console.timeEnd("JIT TOTAL");
|
|
37
|
+
console.log("\n");
|
|
25
38
|
return root;
|
|
26
39
|
},
|
|
27
40
|
].filter(Boolean)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.hasContentChanged = hasContentChanged;
|
|
6
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
7
|
+
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function _interopRequireWildcard(obj) {
|
|
14
|
+
if (obj && obj.__esModule) {
|
|
15
|
+
return obj;
|
|
16
|
+
} else {
|
|
17
|
+
var newObj = {};
|
|
18
|
+
if (obj != null) {
|
|
19
|
+
for(var key in obj){
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
21
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
22
|
+
if (desc.get || desc.set) {
|
|
23
|
+
Object.defineProperty(newObj, key, desc);
|
|
24
|
+
} else {
|
|
25
|
+
newObj[key] = obj[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
newObj.default = obj;
|
|
31
|
+
return newObj;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculate the hash of a string.
|
|
36
|
+
*
|
|
37
|
+
* This doesn't need to be cryptographically secure or
|
|
38
|
+
* anything like that since it's used only to detect
|
|
39
|
+
* when the CSS changes to invalidate the context.
|
|
40
|
+
*
|
|
41
|
+
* This is wrapped in a try/catch because it's really dependent
|
|
42
|
+
* on how Node itself is build and the environment and OpenSSL
|
|
43
|
+
* version / build that is installed on the user's machine.
|
|
44
|
+
*
|
|
45
|
+
* Based on the environment this can just outright fail.
|
|
46
|
+
*
|
|
47
|
+
* See https://github.com/nodejs/node/issues/40455
|
|
48
|
+
*
|
|
49
|
+
* @param {string} str
|
|
50
|
+
*/ function getHash(str) {
|
|
51
|
+
try {
|
|
52
|
+
return _crypto.default.createHash("md5").update(str, "utf-8").digest("binary");
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function hasContentChanged(sourcePath, root) {
|
|
58
|
+
let css = root.toString();
|
|
59
|
+
// We only care about files with @tailwind directives
|
|
60
|
+
// Other files use an existing context
|
|
61
|
+
if (!css.includes("@tailwind")) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
let existingHash = sharedState.sourceHashMap.get(sourcePath);
|
|
65
|
+
let rootHash = getHash(css);
|
|
66
|
+
let didChange = existingHash !== rootHash;
|
|
67
|
+
sharedState.sourceHashMap.set(sourcePath, rootHash);
|
|
68
|
+
return didChange;
|
|
69
|
+
}
|
|
@@ -3,18 +3,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = collapseAdjacentRules;
|
|
6
|
-
let comparisonMap = {
|
|
7
|
-
atrule: [
|
|
8
|
-
'name',
|
|
9
|
-
'params'
|
|
10
|
-
],
|
|
11
|
-
rule: [
|
|
12
|
-
'selector'
|
|
13
|
-
]
|
|
14
|
-
};
|
|
15
|
-
let types = new Set(Object.keys(comparisonMap));
|
|
16
6
|
function collapseAdjacentRules() {
|
|
17
|
-
|
|
7
|
+
function collapseRulesIn(root) {
|
|
18
8
|
let currentRule = null;
|
|
19
9
|
root.each((node)=>{
|
|
20
10
|
if (!types.has(node.type)) {
|
|
@@ -27,9 +17,9 @@ function collapseAdjacentRules() {
|
|
|
27
17
|
}
|
|
28
18
|
let properties = comparisonMap[node.type];
|
|
29
19
|
var _property, _property1;
|
|
30
|
-
if (node.type ===
|
|
20
|
+
if (node.type === "atrule" && node.name === "font-face") {
|
|
31
21
|
currentRule = node;
|
|
32
|
-
} else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property :
|
|
22
|
+
} else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property : "").replace(/\s+/g, " ") === ((_property1 = currentRule[property]) !== null && _property1 !== void 0 ? _property1 : "").replace(/\s+/g, " ")
|
|
33
23
|
)) {
|
|
34
24
|
currentRule.append(node.nodes);
|
|
35
25
|
node.remove();
|
|
@@ -37,5 +27,28 @@ function collapseAdjacentRules() {
|
|
|
37
27
|
currentRule = node;
|
|
38
28
|
}
|
|
39
29
|
});
|
|
30
|
+
// After we've collapsed adjacent rules & at-rules, we need to collapse
|
|
31
|
+
// adjacent rules & at-rules that are children of at-rules.
|
|
32
|
+
// We do not care about nesting rules because Tailwind CSS
|
|
33
|
+
// explicitly does not handle rule nesting on its own as
|
|
34
|
+
// the user is expected to use a nesting plugin
|
|
35
|
+
root.each((node)=>{
|
|
36
|
+
if (node.type === "atrule") {
|
|
37
|
+
collapseRulesIn(node);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return (root)=>{
|
|
42
|
+
collapseRulesIn(root);
|
|
40
43
|
};
|
|
41
44
|
}
|
|
45
|
+
let comparisonMap = {
|
|
46
|
+
atrule: [
|
|
47
|
+
"name",
|
|
48
|
+
"params"
|
|
49
|
+
],
|
|
50
|
+
rule: [
|
|
51
|
+
"selector"
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
let types = new Set(Object.keys(comparisonMap));
|
|
@@ -69,7 +69,7 @@ function collapseDuplicateDeclarations() {
|
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
let UNITLESS_NUMBER = Symbol(
|
|
72
|
+
let UNITLESS_NUMBER = Symbol("unitless-number");
|
|
73
73
|
function resolveUnit(input) {
|
|
74
74
|
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
75
75
|
if (result) {
|
|
@@ -7,22 +7,24 @@ const PATTERNS = [
|
|
|
7
7
|
/(?:\['([^'\s]+[^<>"'`\s:\\])')/.source,
|
|
8
8
|
/(?:\["([^"\s]+[^<>"'`\s:\\])")/.source,
|
|
9
9
|
/(?:\[`([^`\s]+[^<>"'`\s:\\])`)/.source,
|
|
10
|
-
/([
|
|
11
|
-
/([
|
|
10
|
+
/([^${(<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
11
|
+
/([^${(<>"'`\s]*\[\w*"[^'`\s]*"?\])/.source,
|
|
12
12
|
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
13
13
|
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
14
14
|
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
|
|
15
15
|
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
16
|
-
/([^<>"'`\s]*\['[^"
|
|
17
|
-
/([^<>"'`\s]*\["[^
|
|
16
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*\('[^"`\s]*'\)+\])/.source,
|
|
17
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*\("[^'`\s]*"\)+\])/.source,
|
|
18
|
+
/([^${(<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
19
|
+
/([^${(<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
18
20
|
/([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source,
|
|
19
21
|
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
20
22
|
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
21
23
|
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
22
24
|
/([^"'`\s]*[^<>"'`\s:\\])/.source,
|
|
23
25
|
/([^<>"'`\s]*[^"'`\s:\\])/.source,
|
|
24
|
-
].join(
|
|
25
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS,
|
|
26
|
+
].join("|");
|
|
27
|
+
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, "g");
|
|
26
28
|
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
|
|
27
29
|
function defaultExtractor(content) {
|
|
28
30
|
let broadMatches = content.matchAll(BROAD_MATCH_GLOBAL_REGEXP);
|
package/lib/lib/detectNesting.js
CHANGED
|
@@ -6,15 +6,15 @@ exports.default = _default;
|
|
|
6
6
|
function _default(_context) {
|
|
7
7
|
return (root, result)=>{
|
|
8
8
|
let found = false;
|
|
9
|
-
root.walkAtRules(
|
|
9
|
+
root.walkAtRules("tailwind", (node)=>{
|
|
10
10
|
if (found) return false;
|
|
11
|
-
if (node.parent && node.parent.type !==
|
|
11
|
+
if (node.parent && node.parent.type !== "root") {
|
|
12
12
|
found = true;
|
|
13
13
|
node.warn(result, [
|
|
14
|
-
|
|
14
|
+
"Nested @tailwind rules were detected, but are not supported.",
|
|
15
15
|
"Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
|
|
16
|
-
|
|
17
|
-
].join(
|
|
16
|
+
"Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy",
|
|
17
|
+
].join("\n"));
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -23,10 +23,10 @@ function _default(_context) {
|
|
|
23
23
|
rule.walkRules((nestedRule)=>{
|
|
24
24
|
found = true;
|
|
25
25
|
nestedRule.warn(result, [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
].join(
|
|
26
|
+
"Nested CSS was detected, but CSS nesting has not been configured correctly.",
|
|
27
|
+
"Please enable a CSS nesting plugin *before* Tailwind in your configuration.",
|
|
28
|
+
"See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting",
|
|
29
|
+
].join("\n"));
|
|
30
30
|
return false;
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -16,32 +16,32 @@ function _interopRequireDefault(obj) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function isObject(input) {
|
|
19
|
-
return typeof input ===
|
|
19
|
+
return typeof input === "object" && input !== null;
|
|
20
20
|
}
|
|
21
21
|
function findClosestExistingPath(theme, path) {
|
|
22
22
|
let parts = (0, _toPath).toPath(path);
|
|
23
23
|
do {
|
|
24
24
|
parts.pop();
|
|
25
25
|
if ((0, _dlv).default(theme, parts) !== undefined) break;
|
|
26
|
-
}while (parts.length)
|
|
26
|
+
}while (parts.length);
|
|
27
27
|
return parts.length ? parts : undefined;
|
|
28
28
|
}
|
|
29
29
|
function pathToString(path) {
|
|
30
|
-
if (typeof path ===
|
|
30
|
+
if (typeof path === "string") return path;
|
|
31
31
|
return path.reduce((acc, cur, i)=>{
|
|
32
|
-
if (cur.includes(
|
|
32
|
+
if (cur.includes(".")) return `${acc}[${cur}]`;
|
|
33
33
|
return i === 0 ? cur : `${acc}.${cur}`;
|
|
34
|
-
},
|
|
34
|
+
}, "");
|
|
35
35
|
}
|
|
36
36
|
function list(items) {
|
|
37
37
|
return items.map((key)=>`'${key}'`
|
|
38
|
-
).join(
|
|
38
|
+
).join(", ");
|
|
39
39
|
}
|
|
40
40
|
function listKeys(obj) {
|
|
41
41
|
return list(Object.keys(obj));
|
|
42
42
|
}
|
|
43
43
|
function validatePath(config, path, defaultValue) {
|
|
44
|
-
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g,
|
|
44
|
+
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
45
45
|
const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
|
|
46
46
|
const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
|
|
47
47
|
if (value === undefined) {
|
|
@@ -81,7 +81,7 @@ function validatePath(config, path, defaultValue) {
|
|
|
81
81
|
error
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
if (!(typeof value ===
|
|
84
|
+
if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
85
85
|
let error = `'${pathString}' was found but does not resolve to a string.`;
|
|
86
86
|
if (isObject(value)) {
|
|
87
87
|
let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
|
|
@@ -111,11 +111,11 @@ function extractArgs(node, vNodes, functions) {
|
|
|
111
111
|
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
|
|
112
112
|
);
|
|
113
113
|
let args = [
|
|
114
|
-
|
|
114
|
+
""
|
|
115
115
|
];
|
|
116
116
|
for (let vNode1 of vNodes){
|
|
117
|
-
if (vNode1.type ===
|
|
118
|
-
args.push(
|
|
117
|
+
if (vNode1.type === "div" && vNode1.value === ",") {
|
|
118
|
+
args.push("");
|
|
119
119
|
} else {
|
|
120
120
|
args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
|
|
121
121
|
}
|
|
@@ -123,9 +123,9 @@ function extractArgs(node, vNodes, functions) {
|
|
|
123
123
|
return args;
|
|
124
124
|
}
|
|
125
125
|
function resolveVNode(node, vNode, functions) {
|
|
126
|
-
if (vNode.type ===
|
|
126
|
+
if (vNode.type === "function" && functions[vNode.value] !== undefined) {
|
|
127
127
|
let args = extractArgs(node, vNode.nodes, functions);
|
|
128
|
-
vNode.type =
|
|
128
|
+
vNode.type = "word";
|
|
129
129
|
vNode.value = functions[vNode.value](node, ...args);
|
|
130
130
|
}
|
|
131
131
|
return vNode;
|
|
@@ -136,8 +136,8 @@ function resolveFunctions(node, input, functions) {
|
|
|
136
136
|
}).toString();
|
|
137
137
|
}
|
|
138
138
|
let nodeTypePropertyMap = {
|
|
139
|
-
atrule:
|
|
140
|
-
decl:
|
|
139
|
+
atrule: "params",
|
|
140
|
+
decl: "value"
|
|
141
141
|
};
|
|
142
142
|
function _default({ tailwindConfig: config }) {
|
|
143
143
|
let functions = {
|
|
@@ -149,7 +149,7 @@ function _default({ tailwindConfig: config }) {
|
|
|
149
149
|
return value;
|
|
150
150
|
},
|
|
151
151
|
screen: (node, screen)=>{
|
|
152
|
-
screen = screen.replace(/^['"]+/g,
|
|
152
|
+
screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
153
153
|
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
154
154
|
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
155
|
);
|