tailwindcss 0.0.0-insiders.d2b53cd → 0.0.0-insiders.d2fdf9e
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 +364 -2
- package/LICENSE +1 -2
- package/README.md +8 -4
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +3 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +306 -203
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +10 -1
- package/lib/corePlugins.js +1835 -1760
- package/lib/css/preflight.css +19 -13
- package/lib/featureFlags.js +18 -15
- package/lib/index.js +17 -8
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +30 -14
- package/lib/lib/collapseDuplicateDeclarations.js +80 -0
- package/lib/lib/defaultExtractor.js +187 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +40 -24
- package/lib/lib/expandApplyAtRules.js +414 -157
- package/lib/lib/expandTailwindAtRules.js +145 -126
- package/lib/lib/generateRules.js +403 -103
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +43 -35
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/regex.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +83 -65
- package/lib/lib/setupContextUtils.js +315 -204
- package/lib/lib/setupTrackingContext.js +60 -56
- package/lib/lib/sharedState.js +38 -5
- package/lib/lib/substituteScreenAtRules.js +9 -6
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +85 -0
- package/lib/processTailwindFeatures.js +19 -9
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +43 -32
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +11 -15
- package/lib/util/dataTypes.js +114 -74
- package/lib/util/defaults.js +6 -0
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -4
- package/lib/util/formatVariantSelector.js +194 -0
- package/lib/util/getAllConfigs.js +13 -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 +64 -0
- package/lib/util/log.js +11 -7
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +84 -45
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +76 -0
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +34 -165
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +115 -66
- package/lib/util/resolveConfigPath.js +17 -18
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +72 -0
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +42 -34
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +19 -19
- package/nesting/index.js +2 -12
- package/package.json +39 -40
- package/peers/index.js +11511 -10819
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +164 -30
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +540 -535
- package/src/css/preflight.css +19 -13
- package/src/featureFlags.js +5 -5
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/defaultExtractor.js +192 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +24 -7
- package/src/lib/expandApplyAtRules.js +442 -154
- package/src/lib/expandTailwindAtRules.js +79 -37
- package/src/lib/generateRules.js +400 -83
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +35 -10
- package/src/lib/setupContextUtils.js +273 -112
- package/src/lib/setupTrackingContext.js +12 -7
- package/src/lib/sharedState.js +42 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +14 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +31 -14
- package/src/util/dataTypes.js +56 -16
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +213 -0
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +10 -6
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +32 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/pluginUtils.js +15 -138
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +97 -15
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +24 -7
- package/src/util/validateConfig.js +13 -0
- package/stubs/defaultConfig.stub.js +47 -17
- package/types/config.d.ts +325 -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/index.d.ts +1 -0
- package/types.d.ts +1 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -304
|
@@ -7,42 +7,44 @@ var _dlv = _interopRequireDefault(require("dlv"));
|
|
|
7
7
|
var _didyoumean = _interopRequireDefault(require("didyoumean"));
|
|
8
8
|
var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
|
|
9
9
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
10
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
10
11
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
11
12
|
var _toPath = require("../util/toPath");
|
|
13
|
+
var _withAlphaVariable = require("../util/withAlphaVariable");
|
|
12
14
|
function _interopRequireDefault(obj) {
|
|
13
15
|
return obj && obj.__esModule ? obj : {
|
|
14
16
|
default: obj
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
function isObject(input) {
|
|
18
|
-
return typeof input ===
|
|
20
|
+
return typeof input === "object" && input !== null;
|
|
19
21
|
}
|
|
20
22
|
function findClosestExistingPath(theme, path) {
|
|
21
23
|
let parts = (0, _toPath).toPath(path);
|
|
22
24
|
do {
|
|
23
25
|
parts.pop();
|
|
24
26
|
if ((0, _dlv).default(theme, parts) !== undefined) break;
|
|
25
|
-
}while (parts.length)
|
|
27
|
+
}while (parts.length);
|
|
26
28
|
return parts.length ? parts : undefined;
|
|
27
29
|
}
|
|
28
30
|
function pathToString(path) {
|
|
29
|
-
if (typeof path ===
|
|
31
|
+
if (typeof path === "string") return path;
|
|
30
32
|
return path.reduce((acc, cur, i)=>{
|
|
31
|
-
if (cur.includes(
|
|
33
|
+
if (cur.includes(".")) return `${acc}[${cur}]`;
|
|
32
34
|
return i === 0 ? cur : `${acc}.${cur}`;
|
|
33
|
-
},
|
|
35
|
+
}, "");
|
|
34
36
|
}
|
|
35
37
|
function list(items) {
|
|
36
38
|
return items.map((key)=>`'${key}'`
|
|
37
|
-
).join(
|
|
39
|
+
).join(", ");
|
|
38
40
|
}
|
|
39
41
|
function listKeys(obj) {
|
|
40
42
|
return list(Object.keys(obj));
|
|
41
43
|
}
|
|
42
|
-
function validatePath(config, path, defaultValue) {
|
|
43
|
-
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g,
|
|
44
|
+
function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
45
|
+
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
44
46
|
const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
|
|
45
|
-
const value = (0, _dlv).default(config.theme,
|
|
47
|
+
const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
|
|
46
48
|
if (value === undefined) {
|
|
47
49
|
let error = `'${pathString}' does not exist in your theme config.`;
|
|
48
50
|
const parentSegments = pathSegments.slice(0, -1);
|
|
@@ -80,7 +82,7 @@ function validatePath(config, path, defaultValue) {
|
|
|
80
82
|
error
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
|
-
if (!(typeof value ===
|
|
85
|
+
if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
84
86
|
let error = `'${pathString}' was found but does not resolve to a string.`;
|
|
85
87
|
if (isObject(value)) {
|
|
86
88
|
let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
|
|
@@ -103,28 +105,28 @@ function validatePath(config, path, defaultValue) {
|
|
|
103
105
|
const [themeSection] = pathSegments;
|
|
104
106
|
return {
|
|
105
107
|
isValid: true,
|
|
106
|
-
value: (0, _transformThemeValue).default(themeSection)(value)
|
|
108
|
+
value: (0, _transformThemeValue).default(themeSection)(value, themeOpts)
|
|
107
109
|
};
|
|
108
110
|
}
|
|
109
111
|
function extractArgs(node, vNodes, functions) {
|
|
110
112
|
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
|
|
111
113
|
);
|
|
112
114
|
let args = [
|
|
113
|
-
|
|
115
|
+
""
|
|
114
116
|
];
|
|
115
|
-
for (let
|
|
116
|
-
if (
|
|
117
|
-
args.push(
|
|
117
|
+
for (let vNode1 of vNodes){
|
|
118
|
+
if (vNode1.type === "div" && vNode1.value === ",") {
|
|
119
|
+
args.push("");
|
|
118
120
|
} else {
|
|
119
|
-
args[args.length - 1] += _postcssValueParser.default.stringify(
|
|
121
|
+
args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
return args;
|
|
123
125
|
}
|
|
124
126
|
function resolveVNode(node, vNode, functions) {
|
|
125
|
-
if (vNode.type ===
|
|
127
|
+
if (vNode.type === "function" && functions[vNode.value] !== undefined) {
|
|
126
128
|
let args = extractArgs(node, vNode.nodes, functions);
|
|
127
|
-
vNode.type =
|
|
129
|
+
vNode.type = "word";
|
|
128
130
|
vNode.value = functions[vNode.value](node, ...args);
|
|
129
131
|
}
|
|
130
132
|
return vNode;
|
|
@@ -135,24 +137,38 @@ function resolveFunctions(node, input, functions) {
|
|
|
135
137
|
}).toString();
|
|
136
138
|
}
|
|
137
139
|
let nodeTypePropertyMap = {
|
|
138
|
-
atrule:
|
|
139
|
-
decl:
|
|
140
|
+
atrule: "params",
|
|
141
|
+
decl: "value"
|
|
140
142
|
};
|
|
141
143
|
function _default({ tailwindConfig: config }) {
|
|
142
144
|
let functions = {
|
|
143
145
|
theme: (node, path, ...defaultValue)=>{
|
|
144
|
-
|
|
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
|
+
});
|
|
145
155
|
if (!isValid) {
|
|
146
156
|
throw node.error(error);
|
|
147
157
|
}
|
|
158
|
+
if (alpha !== undefined) {
|
|
159
|
+
value = (0, _withAlphaVariable).withAlphaValue(value, alpha, value);
|
|
160
|
+
}
|
|
148
161
|
return value;
|
|
149
162
|
},
|
|
150
163
|
screen: (node, screen)=>{
|
|
151
|
-
screen = screen.replace(/^['"]+/g,
|
|
152
|
-
|
|
164
|
+
screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
165
|
+
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
166
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
167
|
+
);
|
|
168
|
+
if (!screenDefinition) {
|
|
153
169
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
154
170
|
}
|
|
155
|
-
return (0, _buildMediaQuery).default(
|
|
171
|
+
return (0, _buildMediaQuery).default(screenDefinition);
|
|
156
172
|
}
|
|
157
173
|
};
|
|
158
174
|
return (root)=>{
|