tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21
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 +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -1,192 +1,171 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = _default;
|
|
7
|
-
|
|
8
6
|
var _dlv = _interopRequireDefault(require("dlv"));
|
|
9
|
-
|
|
10
7
|
var _didyoumean = _interopRequireDefault(require("didyoumean"));
|
|
11
|
-
|
|
12
8
|
var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
|
|
13
|
-
|
|
14
9
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
15
|
-
|
|
10
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
16
11
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
17
|
-
|
|
18
12
|
var _toPath = require("../util/toPath");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
function _interopRequireDefault(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
22
18
|
function isObject(input) {
|
|
23
|
-
|
|
19
|
+
return typeof input === 'object' && input !== null;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
function findClosestExistingPath(theme, path) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return parts.length ? parts : undefined;
|
|
22
|
+
let parts = (0, _toPath).toPath(path);
|
|
23
|
+
do {
|
|
24
|
+
parts.pop();
|
|
25
|
+
if ((0, _dlv).default(theme, parts) !== undefined) break;
|
|
26
|
+
}while (parts.length)
|
|
27
|
+
return parts.length ? parts : undefined;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
function pathToString(path) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
if (typeof path === 'string') return path;
|
|
31
|
+
return path.reduce((acc, cur, i)=>{
|
|
32
|
+
if (cur.includes('.')) return `${acc}[${cur}]`;
|
|
33
|
+
return i === 0 ? cur : `${acc}.${cur}`;
|
|
34
|
+
}, '');
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
function list(items) {
|
|
46
|
-
|
|
37
|
+
return items.map((key)=>`'${key}'`
|
|
38
|
+
).join(', ');
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
function listKeys(obj) {
|
|
50
|
-
|
|
41
|
+
return list(Object.keys(obj));
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
function validatePath(config, path, defaultValue) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const closestValue = (0, _dlv.default)(config.theme, closestPath);
|
|
77
|
-
|
|
78
|
-
if (isObject(closestValue)) {
|
|
79
|
-
error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
|
|
44
|
+
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
|
|
45
|
+
const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
|
|
46
|
+
const value = (0, _dlv).default(config.theme, pathString, defaultValue);
|
|
47
|
+
if (value === undefined) {
|
|
48
|
+
let error = `'${pathString}' does not exist in your theme config.`;
|
|
49
|
+
const parentSegments = pathSegments.slice(0, -1);
|
|
50
|
+
const parentValue = (0, _dlv).default(config.theme, parentSegments);
|
|
51
|
+
if (isObject(parentValue)) {
|
|
52
|
+
const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
|
|
53
|
+
...parentSegments,
|
|
54
|
+
key
|
|
55
|
+
]).isValid
|
|
56
|
+
);
|
|
57
|
+
const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
|
|
58
|
+
if (suggestion) {
|
|
59
|
+
error += ` Did you mean '${pathToString([
|
|
60
|
+
...parentSegments,
|
|
61
|
+
suggestion
|
|
62
|
+
])}'?`;
|
|
63
|
+
} else if (validKeys.length > 0) {
|
|
64
|
+
error += ` '${pathToString(parentSegments)}' has the following valid keys: ${list(validKeys)}`;
|
|
65
|
+
}
|
|
80
66
|
} else {
|
|
81
|
-
|
|
67
|
+
const closestPath = findClosestExistingPath(config.theme, pathString);
|
|
68
|
+
if (closestPath) {
|
|
69
|
+
const closestValue = (0, _dlv).default(config.theme, closestPath);
|
|
70
|
+
if (isObject(closestValue)) {
|
|
71
|
+
error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
|
|
72
|
+
} else {
|
|
73
|
+
error += ` '${pathToString(closestPath)}' is not an object.`;
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
error += ` Your theme has the following top-level keys: ${listKeys(config.theme)}`;
|
|
77
|
+
}
|
|
82
78
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
return {
|
|
80
|
+
isValid: false,
|
|
81
|
+
error
|
|
82
|
+
};
|
|
86
83
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
84
|
+
if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
85
|
+
let error = `'${pathString}' was found but does not resolve to a string.`;
|
|
86
|
+
if (isObject(value)) {
|
|
87
|
+
let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
|
|
88
|
+
...pathSegments,
|
|
89
|
+
key
|
|
90
|
+
]).isValid
|
|
91
|
+
);
|
|
92
|
+
if (validKeys.length) {
|
|
93
|
+
error += ` Did you mean something like '${pathToString([
|
|
94
|
+
...pathSegments,
|
|
95
|
+
validKeys[0]
|
|
96
|
+
])}'?`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
isValid: false,
|
|
101
|
+
error
|
|
102
|
+
};
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
const [themeSection] = pathSegments;
|
|
105
105
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
isValid: true,
|
|
107
|
+
value: (0, _transformThemeValue).default(themeSection)(value)
|
|
108
108
|
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const [themeSection] = pathSegments;
|
|
112
|
-
return {
|
|
113
|
-
isValid: true,
|
|
114
|
-
value: (0, _transformThemeValue.default)(themeSection)(value)
|
|
115
|
-
};
|
|
116
109
|
}
|
|
117
|
-
|
|
118
110
|
function extractArgs(node, vNodes, functions) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
|
|
112
|
+
);
|
|
113
|
+
let args = [
|
|
114
|
+
''
|
|
115
|
+
];
|
|
116
|
+
for (let vNode1 of vNodes){
|
|
117
|
+
if (vNode1.type === 'div' && vNode1.value === ',') {
|
|
118
|
+
args.push('');
|
|
119
|
+
} else {
|
|
120
|
+
args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
|
|
121
|
+
}
|
|
127
122
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return args;
|
|
123
|
+
return args;
|
|
131
124
|
}
|
|
132
|
-
|
|
133
125
|
function resolveVNode(node, vNode, functions) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return vNode;
|
|
126
|
+
if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
|
|
127
|
+
let args = extractArgs(node, vNode.nodes, functions);
|
|
128
|
+
vNode.type = 'word';
|
|
129
|
+
vNode.value = functions[vNode.value](node, ...args);
|
|
130
|
+
}
|
|
131
|
+
return vNode;
|
|
141
132
|
}
|
|
142
|
-
|
|
143
133
|
function resolveFunctions(node, input, functions) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
return (0, _postcssValueParser).default(input).walk((vNode)=>{
|
|
135
|
+
resolveVNode(node, vNode, functions);
|
|
136
|
+
}).toString();
|
|
147
137
|
}
|
|
148
|
-
|
|
149
138
|
let nodeTypePropertyMap = {
|
|
150
|
-
|
|
151
|
-
|
|
139
|
+
atrule: 'params',
|
|
140
|
+
decl: 'value'
|
|
152
141
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
let property = nodeTypePropertyMap[node.type];
|
|
184
|
-
|
|
185
|
-
if (property === undefined) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
node[property] = resolveFunctions(node, node[property], functions);
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
}
|
|
142
|
+
function _default({ tailwindConfig: config }) {
|
|
143
|
+
let functions = {
|
|
144
|
+
theme: (node, path, ...defaultValue)=>{
|
|
145
|
+
const { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
|
|
146
|
+
if (!isValid) {
|
|
147
|
+
throw node.error(error);
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
},
|
|
151
|
+
screen: (node, screen)=>{
|
|
152
|
+
screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
|
|
153
|
+
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
154
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
|
+
);
|
|
156
|
+
if (!screenDefinition) {
|
|
157
|
+
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
158
|
+
}
|
|
159
|
+
return (0, _buildMediaQuery).default(screenDefinition);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return (root)=>{
|
|
163
|
+
root.walk((node)=>{
|
|
164
|
+
let property = nodeTypePropertyMap[node.type];
|
|
165
|
+
if (property === undefined) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
node[property] = resolveFunctions(node, node[property], functions);
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
}
|