tailwindcss 0.0.0-insiders.bbafc8e → 0.0.0-insiders.bbf2b1b
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 +163 -8
- package/README.md +6 -3
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +314 -247
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +1719 -1628
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +27 -18
- package/lib/index.js +17 -15
- package/lib/lib/cacheInvalidation.js +45 -24
- package/lib/lib/collapseAdjacentRules.js +14 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/defaultExtractor.js +220 -33
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +101 -54
- package/lib/lib/expandApplyAtRules.js +254 -209
- package/lib/lib/expandTailwindAtRules.js +86 -69
- package/lib/lib/generateRules.js +244 -145
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +35 -32
- package/lib/lib/partitionApplyAtRules.js +11 -8
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -71
- package/lib/lib/setupContextUtils.js +290 -205
- package/lib/lib/setupTrackingContext.js +44 -37
- package/lib/lib/sharedState.js +22 -16
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +8 -6
- package/lib/postcss-plugins/nesting/plugin.js +18 -16
- package/lib/processTailwindFeatures.js +31 -28
- package/lib/public/colors.js +247 -245
- 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 +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +7 -5
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +10 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +9 -7
- package/lib/util/dataTypes.js +110 -100
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -10
- package/lib/util/formatVariantSelector.js +100 -85
- package/lib/util/getAllConfigs.js +17 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +21 -13
- package/lib/util/log.js +18 -12
- package/lib/util/nameClass.js +17 -9
- package/lib/util/negateValue.js +8 -6
- package/lib/util/normalizeConfig.js +84 -71
- package/lib/util/normalizeScreens.js +22 -8
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +29 -62
- package/lib/util/parseDependency.js +18 -15
- package/lib/util/parseObjectStyles.js +10 -7
- package/lib/util/pluginUtils.js +47 -31
- package/lib/util/prefixSelector.js +7 -4
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +88 -84
- package/lib/util/resolveConfigPath.js +10 -7
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +93 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -2
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +30 -25
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/package.json +32 -27
- package/peers/index.js +8612 -4245
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +3 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +125 -25
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +145 -49
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +2 -2
- package/src/lib/collapseAdjacentRules.js +5 -1
- package/src/lib/defaultExtractor.js +193 -35
- package/src/lib/evaluateTailwindFunctions.js +56 -6
- package/src/lib/expandApplyAtRules.js +252 -187
- package/src/lib/expandTailwindAtRules.js +4 -4
- package/src/lib/generateRules.js +156 -59
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +142 -46
- package/src/lib/setupTrackingContext.js +5 -1
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +13 -7
- package/src/util/formatVariantSelector.js +82 -63
- package/src/util/getAllConfigs.js +8 -0
- package/src/util/log.js +1 -1
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/pluginUtils.js +13 -1
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +66 -52
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +327 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +331 -0
- package/types/index.d.ts +7 -0
package/lib/lib/detectNesting.js
CHANGED
|
@@ -2,19 +2,22 @@
|
|
|
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;
|
|
9
|
-
root.walkAtRules(
|
|
12
|
+
root.walkAtRules("tailwind", (node)=>{
|
|
10
13
|
if (found) return false;
|
|
11
|
-
if (node.parent && node.parent.type !==
|
|
14
|
+
if (node.parent && node.parent.type !== "root") {
|
|
12
15
|
found = true;
|
|
13
16
|
node.warn(result, [
|
|
14
|
-
|
|
17
|
+
"Nested @tailwind rules were detected, but are not supported.",
|
|
15
18
|
"Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
|
|
16
|
-
|
|
17
|
-
].join(
|
|
19
|
+
"Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy",
|
|
20
|
+
].join("\n"));
|
|
18
21
|
return false;
|
|
19
22
|
}
|
|
20
23
|
});
|
|
@@ -23,10 +26,10 @@ function _default(_context) {
|
|
|
23
26
|
rule.walkRules((nestedRule)=>{
|
|
24
27
|
found = true;
|
|
25
28
|
nestedRule.warn(result, [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
].join(
|
|
29
|
+
"Nested CSS was detected, but CSS nesting has not been configured correctly.",
|
|
30
|
+
"Please enable a CSS nesting plugin *before* Tailwind in your configuration.",
|
|
31
|
+
"See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting",
|
|
32
|
+
].join("\n"));
|
|
30
33
|
return false;
|
|
31
34
|
});
|
|
32
35
|
});
|
|
@@ -2,59 +2,62 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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");
|
|
13
18
|
function _interopRequireDefault(obj) {
|
|
14
19
|
return obj && obj.__esModule ? obj : {
|
|
15
20
|
default: obj
|
|
16
21
|
};
|
|
17
22
|
}
|
|
18
23
|
function isObject(input) {
|
|
19
|
-
return typeof input ===
|
|
24
|
+
return typeof input === "object" && input !== null;
|
|
20
25
|
}
|
|
21
26
|
function findClosestExistingPath(theme, path) {
|
|
22
|
-
let parts = (0, _toPath
|
|
27
|
+
let parts = (0, _toPath.toPath)(path);
|
|
23
28
|
do {
|
|
24
29
|
parts.pop();
|
|
25
|
-
if ((0, _dlv
|
|
26
|
-
}while (parts.length)
|
|
30
|
+
if ((0, _dlv.default)(theme, parts) !== undefined) break;
|
|
31
|
+
}while (parts.length);
|
|
27
32
|
return parts.length ? parts : undefined;
|
|
28
33
|
}
|
|
29
34
|
function pathToString(path) {
|
|
30
|
-
if (typeof path ===
|
|
35
|
+
if (typeof path === "string") return path;
|
|
31
36
|
return path.reduce((acc, cur, i)=>{
|
|
32
|
-
if (cur.includes(
|
|
37
|
+
if (cur.includes(".")) return `${acc}[${cur}]`;
|
|
33
38
|
return i === 0 ? cur : `${acc}.${cur}`;
|
|
34
|
-
},
|
|
39
|
+
}, "");
|
|
35
40
|
}
|
|
36
41
|
function list(items) {
|
|
37
|
-
return items.map((key)=>`'${key}'`
|
|
38
|
-
).join(', ');
|
|
42
|
+
return items.map((key)=>`'${key}'`).join(", ");
|
|
39
43
|
}
|
|
40
44
|
function listKeys(obj) {
|
|
41
45
|
return list(Object.keys(obj));
|
|
42
46
|
}
|
|
43
|
-
function validatePath(config, path, defaultValue) {
|
|
44
|
-
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]
|
|
45
|
-
const pathSegments = Array.isArray(path) ? path : (0, _toPath
|
|
46
|
-
const value = (0, _dlv
|
|
47
|
+
function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
48
|
+
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, "");
|
|
49
|
+
const pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString);
|
|
50
|
+
const value = (0, _dlv.default)(config.theme, pathSegments, defaultValue);
|
|
47
51
|
if (value === undefined) {
|
|
48
52
|
let error = `'${pathString}' does not exist in your theme config.`;
|
|
49
53
|
const parentSegments = pathSegments.slice(0, -1);
|
|
50
|
-
const parentValue = (0, _dlv
|
|
54
|
+
const parentValue = (0, _dlv.default)(config.theme, parentSegments);
|
|
51
55
|
if (isObject(parentValue)) {
|
|
52
56
|
const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
|
|
53
57
|
...parentSegments,
|
|
54
58
|
key
|
|
55
|
-
]).isValid
|
|
56
|
-
);
|
|
57
|
-
const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
|
|
59
|
+
]).isValid);
|
|
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) {
|
|
|
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 {
|
|
@@ -81,82 +84,126 @@ function validatePath(config, path, defaultValue) {
|
|
|
81
84
|
error
|
|
82
85
|
};
|
|
83
86
|
}
|
|
84
|
-
if (!(typeof value ===
|
|
85
|
-
let
|
|
87
|
+
if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
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
|
-
]).isValid
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
error += ` Did you mean something like '${pathToString([
|
|
93
|
+
]).isValid);
|
|
94
|
+
if (validKeys1.length) {
|
|
95
|
+
error1 += ` Did you mean something like '${pathToString([
|
|
94
96
|
...pathSegments,
|
|
95
|
-
|
|
97
|
+
validKeys1[0]
|
|
96
98
|
])}'?`;
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
return {
|
|
100
102
|
isValid: false,
|
|
101
|
-
error
|
|
103
|
+
error: error1
|
|
102
104
|
};
|
|
103
105
|
}
|
|
104
106
|
const [themeSection] = pathSegments;
|
|
105
107
|
return {
|
|
106
108
|
isValid: true,
|
|
107
|
-
value: (0, _transformThemeValue
|
|
109
|
+
value: (0, _transformThemeValue.default)(themeSection)(value, themeOpts)
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
112
|
function extractArgs(node, vNodes, functions) {
|
|
111
|
-
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
|
|
112
|
-
);
|
|
113
|
+
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
|
|
113
114
|
let args = [
|
|
114
|
-
|
|
115
|
+
""
|
|
115
116
|
];
|
|
116
|
-
for (let
|
|
117
|
-
if (
|
|
118
|
-
args.push(
|
|
117
|
+
for (let vNode of vNodes){
|
|
118
|
+
if (vNode.type === "div" && vNode.value === ",") {
|
|
119
|
+
args.push("");
|
|
119
120
|
} else {
|
|
120
|
-
args[args.length - 1] += _postcssValueParser.default.stringify(
|
|
121
|
+
args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
return args;
|
|
124
125
|
}
|
|
125
126
|
function resolveVNode(node, vNode, functions) {
|
|
126
|
-
if (vNode.type ===
|
|
127
|
+
if (vNode.type === "function" && functions[vNode.value] !== undefined) {
|
|
127
128
|
let args = extractArgs(node, vNode.nodes, functions);
|
|
128
|
-
vNode.type =
|
|
129
|
+
vNode.type = "word";
|
|
129
130
|
vNode.value = functions[vNode.value](node, ...args);
|
|
130
131
|
}
|
|
131
132
|
return vNode;
|
|
132
133
|
}
|
|
133
134
|
function resolveFunctions(node, input, functions) {
|
|
134
|
-
return (0, _postcssValueParser
|
|
135
|
+
return (0, _postcssValueParser.default)(input).walk((vNode)=>{
|
|
135
136
|
resolveVNode(node, vNode, functions);
|
|
136
137
|
}).toString();
|
|
137
138
|
}
|
|
138
139
|
let nodeTypePropertyMap = {
|
|
139
|
-
atrule:
|
|
140
|
-
decl:
|
|
140
|
+
atrule: "params",
|
|
141
|
+
decl: "value"
|
|
141
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
|
+
}
|
|
142
182
|
function _default({ tailwindConfig: config }) {
|
|
143
183
|
let functions = {
|
|
144
184
|
theme: (node, path, ...defaultValue)=>{
|
|
145
|
-
|
|
185
|
+
let { isValid , value , error , alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
|
|
146
186
|
if (!isValid) {
|
|
147
187
|
throw node.error(error);
|
|
148
188
|
}
|
|
189
|
+
let maybeColor = (0, _pluginUtils.parseColorFormat)(value);
|
|
190
|
+
let isColorFunction = maybeColor !== undefined && typeof maybeColor === "function";
|
|
191
|
+
if (alpha !== undefined || isColorFunction) {
|
|
192
|
+
if (alpha === undefined) {
|
|
193
|
+
alpha = 1.0;
|
|
194
|
+
}
|
|
195
|
+
value = (0, _withAlphaVariable.withAlphaValue)(maybeColor, alpha, maybeColor);
|
|
196
|
+
}
|
|
149
197
|
return value;
|
|
150
198
|
},
|
|
151
199
|
screen: (node, screen)=>{
|
|
152
|
-
screen = screen.replace(/^['"]+/g,
|
|
153
|
-
let screens = (0, _normalizeScreens
|
|
154
|
-
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
|
-
);
|
|
200
|
+
screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
201
|
+
let screens = (0, _normalizeScreens.normalizeScreens)(config.theme.screens);
|
|
202
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
156
203
|
if (!screenDefinition) {
|
|
157
204
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
158
205
|
}
|
|
159
|
-
return (0, _buildMediaQuery
|
|
206
|
+
return (0, _buildMediaQuery.default)(screenDefinition);
|
|
160
207
|
}
|
|
161
208
|
};
|
|
162
209
|
return (root)=>{
|