tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421
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/README.md +1 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +12 -15
- package/lib/cli/build/plugin.js +107 -167
- package/lib/cli/build/utils.js +13 -13
- package/lib/cli/build/watching.js +10 -10
- package/lib/cli/help/index.js +11 -11
- package/lib/cli/index.js +60 -61
- package/lib/cli/init/index.js +16 -16
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +2018 -1905
- package/lib/css/preflight.css +18 -12
- package/lib/featureFlags.js +17 -23
- package/lib/index.js +1 -1
- package/lib/lib/cacheInvalidation.js +3 -3
- package/lib/lib/collapseAdjacentRules.js +6 -6
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/content.js +39 -32
- package/lib/lib/defaultExtractor.js +40 -17
- package/lib/lib/evaluateTailwindFunctions.js +23 -23
- package/lib/lib/expandApplyAtRules.js +37 -18
- package/lib/lib/expandTailwindAtRules.js +49 -85
- package/lib/lib/findAtConfigPath.js +5 -5
- package/lib/lib/generateRules.js +82 -55
- package/lib/lib/getModuleDependencies.js +23 -23
- package/lib/lib/load-config.js +21 -6
- package/lib/lib/normalizeTailwindDirectives.js +36 -21
- package/lib/lib/offsets.js +97 -48
- package/lib/lib/partitionApplyAtRules.js +2 -2
- package/lib/lib/regex.js +5 -5
- package/lib/lib/resolveDefaultsAtRules.js +27 -25
- package/lib/lib/setupContextUtils.js +195 -167
- package/lib/lib/setupTrackingContext.js +4 -5
- package/lib/lib/sharedState.js +10 -10
- package/lib/lib/substituteScreenAtRules.js +4 -4
- package/lib/plugin.js +8 -124
- package/lib/postcss-plugins/nesting/index.js +2 -2
- package/lib/postcss-plugins/nesting/plugin.js +11 -11
- package/lib/processTailwindFeatures.js +3 -5
- package/lib/public/colors.js +264 -264
- package/lib/util/applyImportantSelector.js +2 -2
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +19 -19
- package/lib/util/createUtilityPlugin.js +3 -3
- package/lib/util/dataTypes.js +170 -113
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +24 -19
- package/lib/util/getAllConfigs.js +4 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +2 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
- package/lib/util/log.js +6 -23
- package/lib/util/nameClass.js +4 -4
- package/lib/util/negateValue.js +8 -8
- package/lib/util/normalizeConfig.js +63 -94
- package/lib/util/normalizeScreens.js +18 -18
- package/lib/util/parseAnimationValue.js +38 -38
- package/lib/util/parseBoxShadowValue.js +18 -18
- package/lib/util/parseDependency.js +4 -4
- package/lib/util/parseGlob.js +4 -4
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +36 -21
- package/lib/util/prefixSelector.js +4 -4
- package/lib/util/pseudoElements.js +72 -69
- package/lib/util/removeAlphaVariables.js +1 -1
- package/lib/util/resolveConfig.js +11 -15
- package/lib/util/resolveConfigPath.js +6 -6
- package/lib/util/responsive.js +1 -1
- package/lib/util/splitAtTopLevelOnly.js +3 -3
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +24 -24
- package/lib/util/validateConfig.js +9 -20
- package/lib/util/validateFormalSyntax.js +5 -5
- package/lib/util/withAlphaVariable.js +5 -5
- package/lib/value-parser/index.js +5 -5
- package/lib/value-parser/parse.js +43 -43
- package/lib/value-parser/stringify.js +11 -11
- package/lib/value-parser/unit.js +5 -5
- package/lib/value-parser/walk.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +41 -36
- package/peers/index.js +96503 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +118 -31
- package/src/css/preflight.css +18 -12
- package/src/featureFlags.js +3 -5
- package/src/lib/content.js +39 -30
- package/src/lib/defaultExtractor.js +29 -6
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +39 -8
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/dataTypes.js +72 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +20 -0
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +68 -8
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +28 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
|
@@ -33,11 +33,10 @@ function _interop_require_default(obj) {
|
|
|
33
33
|
default: obj
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
/** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, respectPrefix: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE =
|
|
37
|
-
function formatVariantSelector(formats, { context, candidate
|
|
38
|
-
var _context;
|
|
36
|
+
/** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, respectPrefix: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
|
|
37
|
+
function formatVariantSelector(formats, { context , candidate }) {
|
|
39
38
|
var _context_tailwindConfig_prefix;
|
|
40
|
-
let prefix = (_context_tailwindConfig_prefix =
|
|
39
|
+
let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
|
|
41
40
|
// Parse the format selector into an AST
|
|
42
41
|
let parsedFormats = formats.map((format)=>{
|
|
43
42
|
let ast = (0, _postcssselectorparser.default)().astSync(format.format);
|
|
@@ -59,7 +58,7 @@ function formatVariantSelector(formats, { context, candidate }) {
|
|
|
59
58
|
]
|
|
60
59
|
});
|
|
61
60
|
// And iteratively merge each format selector into the candidate selector
|
|
62
|
-
for (let { ast
|
|
61
|
+
for (let { ast } of parsedFormats){
|
|
63
62
|
[formatAst, ast] = handleMergePseudo(formatAst, ast);
|
|
64
63
|
// 2. Merge the format selector into the current selector AST
|
|
65
64
|
ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
|
|
@@ -79,11 +78,11 @@ function formatVariantSelector(formats, { context, candidate }) {
|
|
|
79
78
|
**/ function simpleSelectorForNode(node) {
|
|
80
79
|
/** @type {Node[]} */ let nodes = [];
|
|
81
80
|
// Walk backwards until we hit a combinator node (or the start)
|
|
82
|
-
while(node.prev() && node.prev().type !==
|
|
81
|
+
while(node.prev() && node.prev().type !== "combinator"){
|
|
83
82
|
node = node.prev();
|
|
84
83
|
}
|
|
85
84
|
// Now record all non-combinator nodes until we hit one (or the end)
|
|
86
|
-
while(node && node.type !==
|
|
85
|
+
while(node && node.type !== "combinator"){
|
|
87
86
|
nodes.push(node);
|
|
88
87
|
node = node.next();
|
|
89
88
|
}
|
|
@@ -97,13 +96,13 @@ function formatVariantSelector(formats, { context, candidate }) {
|
|
|
97
96
|
* @returns {Selector}
|
|
98
97
|
**/ function resortSelector(sel) {
|
|
99
98
|
sel.sort((a, b)=>{
|
|
100
|
-
if (a.type ===
|
|
99
|
+
if (a.type === "tag" && b.type === "class") {
|
|
101
100
|
return -1;
|
|
102
|
-
} else if (a.type ===
|
|
101
|
+
} else if (a.type === "class" && b.type === "tag") {
|
|
103
102
|
return 1;
|
|
104
|
-
} else if (a.type ===
|
|
103
|
+
} else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
|
|
105
104
|
return -1;
|
|
106
|
-
} else if (a.type ===
|
|
105
|
+
} else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
|
|
107
106
|
return 1;
|
|
108
107
|
}
|
|
109
108
|
return sel.index(a) - sel.index(b);
|
|
@@ -113,7 +112,7 @@ function formatVariantSelector(formats, { context, candidate }) {
|
|
|
113
112
|
function eliminateIrrelevantSelectors(sel, base) {
|
|
114
113
|
let hasClassesMatchingCandidate = false;
|
|
115
114
|
sel.walk((child)=>{
|
|
116
|
-
if (child.type ===
|
|
115
|
+
if (child.type === "class" && child.value === base) {
|
|
117
116
|
hasClassesMatchingCandidate = true;
|
|
118
117
|
return false // Stop walking
|
|
119
118
|
;
|
|
@@ -129,10 +128,10 @@ function eliminateIrrelevantSelectors(sel, base) {
|
|
|
129
128
|
// meaning of the selector.
|
|
130
129
|
// TODO: Can we do this for :matches, :is, and :where?
|
|
131
130
|
}
|
|
132
|
-
function finalizeSelector(current, formats, { context, candidate, base
|
|
133
|
-
var _context_tailwindConfig
|
|
131
|
+
function finalizeSelector(current, formats, { context , candidate , base }) {
|
|
132
|
+
var _context_tailwindConfig;
|
|
134
133
|
var _context_tailwindConfig_separator;
|
|
135
|
-
let separator = (_context_tailwindConfig_separator =
|
|
134
|
+
let separator = (_context_tailwindConfig_separator = context === null || context === void 0 ? void 0 : (_context_tailwindConfig = context.tailwindConfig) === null || _context_tailwindConfig === void 0 ? void 0 : _context_tailwindConfig.separator) !== null && _context_tailwindConfig_separator !== void 0 ? _context_tailwindConfig_separator : ":";
|
|
136
135
|
// Split by the separator, but ignore the separator inside square brackets:
|
|
137
136
|
//
|
|
138
137
|
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
@@ -161,6 +160,12 @@ function finalizeSelector(current, formats, { context, candidate, base }) {
|
|
|
161
160
|
});
|
|
162
161
|
// Remove extraneous selectors that do not include the base candidate
|
|
163
162
|
selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
|
|
163
|
+
// If ffter eliminating irrelevant selectors, we end up with nothing
|
|
164
|
+
// Then the whole "rule" this is associated with does not need to exist
|
|
165
|
+
// We use `null` as a marker value for that case
|
|
166
|
+
if (selector.length === 0) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
164
169
|
// If there are no formats that means there were no variants added to the candidate
|
|
165
170
|
// so we can just return the selector as-is
|
|
166
171
|
let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
|
|
@@ -171,10 +176,10 @@ function finalizeSelector(current, formats, { context, candidate, base }) {
|
|
|
171
176
|
return selector.toString();
|
|
172
177
|
}
|
|
173
178
|
let simpleStart = _postcssselectorparser.default.comment({
|
|
174
|
-
value:
|
|
179
|
+
value: "/*__simple__*/"
|
|
175
180
|
});
|
|
176
181
|
let simpleEnd = _postcssselectorparser.default.comment({
|
|
177
|
-
value:
|
|
182
|
+
value: "/*__simple__*/"
|
|
178
183
|
});
|
|
179
184
|
// We can safely replace the escaped base now, since the `base` section is
|
|
180
185
|
// now in a normalized escaped value.
|
|
@@ -241,7 +246,7 @@ function handleMergePseudo(selector, format) {
|
|
|
241
246
|
// Everything after `:merge()` up to the next combinator is what is attached to the merged selector
|
|
242
247
|
let attachments = [];
|
|
243
248
|
let next = pseudo.next();
|
|
244
|
-
while(next && next.type !==
|
|
249
|
+
while(next && next.type !== "combinator"){
|
|
245
250
|
attachments.push(next);
|
|
246
251
|
next = next.next();
|
|
247
252
|
}
|
|
@@ -254,7 +259,7 @@ function handleMergePseudo(selector, format) {
|
|
|
254
259
|
// What about this case:
|
|
255
260
|
// :merge(.group):focus > &
|
|
256
261
|
// :merge(.group):hover &
|
|
257
|
-
if (combinator && combinator.type ===
|
|
262
|
+
if (combinator && combinator.type === "combinator") {
|
|
258
263
|
combinator.remove();
|
|
259
264
|
}
|
|
260
265
|
});
|
|
@@ -16,18 +16,17 @@ function _interop_require_default(obj) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function getAllConfigs(config) {
|
|
19
|
-
var _config;
|
|
20
19
|
var _config_presets;
|
|
21
|
-
const configs = ((_config_presets =
|
|
20
|
+
const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
|
|
22
21
|
_configfull.default
|
|
23
22
|
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
24
23
|
const features = {
|
|
25
24
|
// Add experimental configs here...
|
|
26
25
|
respectDefaultRingColorOpacity: {
|
|
27
26
|
theme: {
|
|
28
|
-
ringColor: ({ theme
|
|
29
|
-
DEFAULT:
|
|
30
|
-
...theme(
|
|
27
|
+
ringColor: ({ theme })=>({
|
|
28
|
+
DEFAULT: "#3b82f67f",
|
|
29
|
+
...theme("colors")
|
|
31
30
|
})
|
|
32
31
|
}
|
|
33
32
|
},
|
|
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
function isKeyframeRule(rule) {
|
|
12
|
-
return rule.parent && rule.parent.type ===
|
|
12
|
+
return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
|
|
13
13
|
}
|
|
@@ -9,9 +9,9 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
function isPlainObject(value) {
|
|
12
|
-
if (Object.prototype.toString.call(value) !==
|
|
12
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
const prototype = Object.getPrototypeOf(value);
|
|
16
|
-
return prototype === null || prototype ===
|
|
16
|
+
return prototype === null || Object.getPrototypeOf(prototype) === null;
|
|
17
17
|
}
|
|
@@ -16,16 +16,16 @@ Object.defineProperty(exports, // Arbitrary values must contain balanced bracket
|
|
|
16
16
|
});
|
|
17
17
|
let matchingBrackets = new Map([
|
|
18
18
|
[
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
"{",
|
|
20
|
+
"}"
|
|
21
21
|
],
|
|
22
22
|
[
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
"[",
|
|
24
|
+
"]"
|
|
25
25
|
],
|
|
26
26
|
[
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
"(",
|
|
28
|
+
")"
|
|
29
29
|
]
|
|
30
30
|
]);
|
|
31
31
|
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
@@ -35,22 +35,22 @@ let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map
|
|
|
35
35
|
let quotes = new Set([
|
|
36
36
|
'"',
|
|
37
37
|
"'",
|
|
38
|
-
|
|
38
|
+
"`"
|
|
39
39
|
]);
|
|
40
40
|
function isSyntacticallyValidPropertyValue(value) {
|
|
41
41
|
let stack = [];
|
|
42
42
|
let inQuotes = false;
|
|
43
43
|
for(let i = 0; i < value.length; i++){
|
|
44
44
|
let char = value[i];
|
|
45
|
-
if (char ===
|
|
45
|
+
if (char === ":" && !inQuotes && stack.length === 0) {
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
// Non-escaped quotes allow us to "allow" anything in between
|
|
49
|
-
if (quotes.has(char) && value[i - 1] !==
|
|
49
|
+
if (quotes.has(char) && value[i - 1] !== "\\") {
|
|
50
50
|
inQuotes = !inQuotes;
|
|
51
51
|
}
|
|
52
52
|
if (inQuotes) continue;
|
|
53
|
-
if (value[i - 1] ===
|
|
53
|
+
if (value[i - 1] === "\\") continue; // Escaped
|
|
54
54
|
if (matchingBrackets.has(char)) {
|
|
55
55
|
stack.push(char);
|
|
56
56
|
} else if (inverseMatchingBrackets.has(char)) {
|
package/lib/util/log.js
CHANGED
|
@@ -24,35 +24,18 @@ function _interop_require_default(obj) {
|
|
|
24
24
|
}
|
|
25
25
|
let alreadyShown = new Set();
|
|
26
26
|
function log(type, messages, key) {
|
|
27
|
-
if (typeof process !==
|
|
27
|
+
if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) return;
|
|
28
28
|
if (key && alreadyShown.has(key)) return;
|
|
29
29
|
if (key) alreadyShown.add(key);
|
|
30
|
-
console.warn(
|
|
31
|
-
messages.forEach((message)=>console.warn(type,
|
|
30
|
+
console.warn("");
|
|
31
|
+
messages.forEach((message)=>console.warn(type, "-", message));
|
|
32
32
|
}
|
|
33
33
|
function dim(input) {
|
|
34
34
|
return _picocolors.default.dim(input);
|
|
35
35
|
}
|
|
36
36
|
const _default = {
|
|
37
|
-
group (key, cb) {
|
|
38
|
-
if (typeof process !== 'undefined' && process.env.JEST_WORKER_ID) return;
|
|
39
|
-
if (key && alreadyShown.has(key)) return;
|
|
40
|
-
if (key) alreadyShown.add(key);
|
|
41
|
-
console.warn('');
|
|
42
|
-
cb({
|
|
43
|
-
info (messages) {
|
|
44
|
-
messages.forEach((message)=>console.warn(_picocolors.default.bold(_picocolors.default.cyan('info')), '-', message));
|
|
45
|
-
},
|
|
46
|
-
warn (messages) {
|
|
47
|
-
messages.forEach((message)=>console.warn(_picocolors.default.bold(_picocolors.default.yellow('warn')), '-', message));
|
|
48
|
-
},
|
|
49
|
-
risk (messages) {
|
|
50
|
-
messages.forEach((message)=>console.warn(_picocolors.default.bold(_picocolors.default.magenta('risk')), '-', message));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
37
|
info (key, messages) {
|
|
55
|
-
log(_picocolors.default.bold(_picocolors.default.cyan(
|
|
38
|
+
log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
|
|
56
39
|
key
|
|
57
40
|
] : [
|
|
58
41
|
messages,
|
|
@@ -60,7 +43,7 @@ const _default = {
|
|
|
60
43
|
]);
|
|
61
44
|
},
|
|
62
45
|
warn (key, messages) {
|
|
63
|
-
log(_picocolors.default.bold(_picocolors.default.yellow(
|
|
46
|
+
log(_picocolors.default.bold(_picocolors.default.yellow("warn")), ...Array.isArray(key) ? [
|
|
64
47
|
key
|
|
65
48
|
] : [
|
|
66
49
|
messages,
|
|
@@ -68,7 +51,7 @@ const _default = {
|
|
|
68
51
|
]);
|
|
69
52
|
},
|
|
70
53
|
risk (key, messages) {
|
|
71
|
-
log(_picocolors.default.bold(_picocolors.default.magenta(
|
|
54
|
+
log(_picocolors.default.bold(_picocolors.default.magenta("risk")), ...Array.isArray(key) ? [
|
|
72
55
|
key
|
|
73
56
|
] : [
|
|
74
57
|
messages,
|
package/lib/util/nameClass.js
CHANGED
|
@@ -33,16 +33,16 @@ function nameClass(classPrefix, key) {
|
|
|
33
33
|
return asClass(formatClass(classPrefix, key));
|
|
34
34
|
}
|
|
35
35
|
function formatClass(classPrefix, key) {
|
|
36
|
-
if (key ===
|
|
36
|
+
if (key === "DEFAULT") {
|
|
37
37
|
return classPrefix;
|
|
38
38
|
}
|
|
39
|
-
if (key ===
|
|
39
|
+
if (key === "-" || key === "-DEFAULT") {
|
|
40
40
|
return `-${classPrefix}`;
|
|
41
41
|
}
|
|
42
|
-
if (key.startsWith(
|
|
42
|
+
if (key.startsWith("-")) {
|
|
43
43
|
return `-${classPrefix}${key}`;
|
|
44
44
|
}
|
|
45
|
-
if (key.startsWith(
|
|
45
|
+
if (key.startsWith("/")) {
|
|
46
46
|
return `${classPrefix}${key}`;
|
|
47
47
|
}
|
|
48
48
|
return `${classPrefix}-${key}`;
|
package/lib/util/negateValue.js
CHANGED
|
@@ -10,23 +10,23 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
function negateValue(value) {
|
|
12
12
|
value = `${value}`;
|
|
13
|
-
if (value ===
|
|
14
|
-
return
|
|
13
|
+
if (value === "0") {
|
|
14
|
+
return "0";
|
|
15
15
|
}
|
|
16
16
|
// Flip sign of numbers
|
|
17
17
|
if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
|
|
18
|
-
return value.replace(/^[+-]?/, (sign)=>sign ===
|
|
18
|
+
return value.replace(/^[+-]?/, (sign)=>sign === "-" ? "" : "-");
|
|
19
19
|
}
|
|
20
20
|
// What functions we support negating numeric values for
|
|
21
21
|
// var() isn't inherently a numeric function but we support it anyway
|
|
22
22
|
// The trigonometric functions are omitted because you'll need to use calc(…) with them _anyway_
|
|
23
23
|
// to produce generally useful results and that will be covered already
|
|
24
24
|
let numericFunctions = [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
"var",
|
|
26
|
+
"calc",
|
|
27
|
+
"min",
|
|
28
|
+
"max",
|
|
29
|
+
"clamp"
|
|
30
30
|
];
|
|
31
31
|
for (const fn of numericFunctions){
|
|
32
32
|
if (value.includes(`${fn}(`)) {
|
|
@@ -65,9 +65,6 @@ function normalizeConfig(config) {
|
|
|
65
65
|
* transform?: TransformerFn | { [extension: string]: TransformerFn }
|
|
66
66
|
* }
|
|
67
67
|
*/ let valid = (()=>{
|
|
68
|
-
if (config.content === 'auto') {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
68
|
// `config.purge` should not exist anymore
|
|
72
69
|
if (config.purge) {
|
|
73
70
|
return false;
|
|
@@ -77,47 +74,45 @@ function normalizeConfig(config) {
|
|
|
77
74
|
return false;
|
|
78
75
|
}
|
|
79
76
|
// `config.content` should be an object or an array
|
|
80
|
-
if (!Array.isArray(config.content) && !(typeof config.content ===
|
|
77
|
+
if (!Array.isArray(config.content) && !(typeof config.content === "object" && config.content !== null)) {
|
|
81
78
|
return false;
|
|
82
79
|
}
|
|
83
80
|
// When `config.content` is an array, it should consist of FilePaths or RawFiles
|
|
84
81
|
if (Array.isArray(config.content)) {
|
|
85
82
|
return config.content.every((path)=>{
|
|
86
|
-
var _path, _path1, _path2;
|
|
87
83
|
// `path` can be a string
|
|
88
|
-
if (typeof path ===
|
|
84
|
+
if (typeof path === "string") return true;
|
|
89
85
|
// `path` can be an object { raw: string, extension?: string }
|
|
90
86
|
// `raw` must be a string
|
|
91
|
-
if (typeof (
|
|
87
|
+
if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
|
|
92
88
|
// `extension` (if provided) should also be a string
|
|
93
|
-
if ((
|
|
89
|
+
if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
|
|
94
90
|
return false;
|
|
95
91
|
}
|
|
96
92
|
return true;
|
|
97
93
|
});
|
|
98
94
|
}
|
|
99
95
|
// When `config.content` is an object
|
|
100
|
-
if (typeof config.content ===
|
|
96
|
+
if (typeof config.content === "object" && config.content !== null) {
|
|
101
97
|
// Only `files`, `relative`, `extract`, and `transform` can exist in `config.content`
|
|
102
98
|
if (Object.keys(config.content).some((key)=>![
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
"files",
|
|
100
|
+
"relative",
|
|
101
|
+
"extract",
|
|
102
|
+
"transform"
|
|
107
103
|
].includes(key))) {
|
|
108
104
|
return false;
|
|
109
105
|
}
|
|
110
106
|
// `config.content.files` should exist of FilePaths or RawFiles
|
|
111
107
|
if (Array.isArray(config.content.files)) {
|
|
112
108
|
if (!config.content.files.every((path)=>{
|
|
113
|
-
var _path, _path1, _path2;
|
|
114
109
|
// `path` can be a string
|
|
115
|
-
if (typeof path ===
|
|
110
|
+
if (typeof path === "string") return true;
|
|
116
111
|
// `path` can be an object { raw: string, extension?: string }
|
|
117
112
|
// `raw` must be a string
|
|
118
|
-
if (typeof (
|
|
113
|
+
if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
|
|
119
114
|
// `extension` (if provided) should also be a string
|
|
120
|
-
if ((
|
|
115
|
+
if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
|
|
121
116
|
return false;
|
|
122
117
|
}
|
|
123
118
|
return true;
|
|
@@ -125,27 +120,27 @@ function normalizeConfig(config) {
|
|
|
125
120
|
return false;
|
|
126
121
|
}
|
|
127
122
|
// `config.content.extract` is optional, and can be a Function or a Record<String, Function>
|
|
128
|
-
if (typeof config.content.extract ===
|
|
123
|
+
if (typeof config.content.extract === "object") {
|
|
129
124
|
for (let value of Object.values(config.content.extract)){
|
|
130
|
-
if (typeof value !==
|
|
125
|
+
if (typeof value !== "function") {
|
|
131
126
|
return false;
|
|
132
127
|
}
|
|
133
128
|
}
|
|
134
|
-
} else if (!(config.content.extract === undefined || typeof config.content.extract ===
|
|
129
|
+
} else if (!(config.content.extract === undefined || typeof config.content.extract === "function")) {
|
|
135
130
|
return false;
|
|
136
131
|
}
|
|
137
132
|
// `config.content.transform` is optional, and can be a Function or a Record<String, Function>
|
|
138
|
-
if (typeof config.content.transform ===
|
|
133
|
+
if (typeof config.content.transform === "object") {
|
|
139
134
|
for (let value of Object.values(config.content.transform)){
|
|
140
|
-
if (typeof value !==
|
|
135
|
+
if (typeof value !== "function") {
|
|
141
136
|
return false;
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
|
-
} else if (!(config.content.transform === undefined || typeof config.content.transform ===
|
|
139
|
+
} else if (!(config.content.transform === undefined || typeof config.content.transform === "function")) {
|
|
145
140
|
return false;
|
|
146
141
|
}
|
|
147
142
|
// `config.content.relative` is optional and can be a boolean
|
|
148
|
-
if (typeof config.content.relative !==
|
|
143
|
+
if (typeof config.content.relative !== "boolean" && typeof config.content.relative !== "undefined") {
|
|
149
144
|
return false;
|
|
150
145
|
}
|
|
151
146
|
}
|
|
@@ -154,79 +149,69 @@ function normalizeConfig(config) {
|
|
|
154
149
|
return false;
|
|
155
150
|
})();
|
|
156
151
|
if (!valid) {
|
|
157
|
-
_log.default.warn(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
_log.default.warn("purge-deprecation", [
|
|
153
|
+
"The `purge`/`content` options have changed in Tailwind CSS v3.0.",
|
|
154
|
+
"Update your configuration file to eliminate this warning.",
|
|
155
|
+
"https://tailwindcss.com/docs/upgrade-guide#configure-content-sources"
|
|
161
156
|
]);
|
|
162
157
|
}
|
|
163
158
|
// Normalize the `safelist`
|
|
164
159
|
config.safelist = (()=>{
|
|
165
|
-
var
|
|
166
|
-
let { content, purge, safelist
|
|
160
|
+
var _purge_options;
|
|
161
|
+
let { content , purge , safelist } = config;
|
|
167
162
|
if (Array.isArray(safelist)) return safelist;
|
|
168
|
-
if (Array.isArray(
|
|
169
|
-
if (Array.isArray(
|
|
170
|
-
if (Array.isArray(
|
|
163
|
+
if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return content.safelist;
|
|
164
|
+
if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return purge.safelist;
|
|
165
|
+
if (Array.isArray(purge === null || purge === void 0 ? void 0 : (_purge_options = purge.options) === null || _purge_options === void 0 ? void 0 : _purge_options.safelist)) return purge.options.safelist;
|
|
171
166
|
return [];
|
|
172
167
|
})();
|
|
173
168
|
// Normalize the `blocklist`
|
|
174
169
|
config.blocklist = (()=>{
|
|
175
|
-
let { blocklist
|
|
170
|
+
let { blocklist } = config;
|
|
176
171
|
if (Array.isArray(blocklist)) {
|
|
177
|
-
if (blocklist.every((item)=>typeof item ===
|
|
172
|
+
if (blocklist.every((item)=>typeof item === "string")) {
|
|
178
173
|
return blocklist;
|
|
179
174
|
}
|
|
180
|
-
_log.default.warn(
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
_log.default.warn("blocklist-invalid", [
|
|
176
|
+
"The `blocklist` option must be an array of strings.",
|
|
177
|
+
"https://tailwindcss.com/docs/content-configuration#discarding-classes"
|
|
183
178
|
]);
|
|
184
179
|
}
|
|
185
180
|
return [];
|
|
186
181
|
})();
|
|
187
182
|
// Normalize prefix option
|
|
188
|
-
if (typeof config.prefix ===
|
|
189
|
-
_log.default.warn(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
183
|
+
if (typeof config.prefix === "function") {
|
|
184
|
+
_log.default.warn("prefix-function", [
|
|
185
|
+
"As of Tailwind CSS v3.0, `prefix` cannot be a function.",
|
|
186
|
+
"Update `prefix` in your configuration to be a string to eliminate this warning.",
|
|
187
|
+
"https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function"
|
|
193
188
|
]);
|
|
194
|
-
config.prefix =
|
|
189
|
+
config.prefix = "";
|
|
195
190
|
} else {
|
|
196
191
|
var _config_prefix;
|
|
197
|
-
config.prefix = (_config_prefix = config.prefix) !== null && _config_prefix !== void 0 ? _config_prefix :
|
|
192
|
+
config.prefix = (_config_prefix = config.prefix) !== null && _config_prefix !== void 0 ? _config_prefix : "";
|
|
198
193
|
}
|
|
199
194
|
// Normalize the `content`
|
|
200
195
|
config.content = {
|
|
201
196
|
relative: (()=>{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if ((_content = content) === null || _content === void 0 ? void 0 : _content.relative) {
|
|
197
|
+
let { content } = config;
|
|
198
|
+
if (content === null || content === void 0 ? void 0 : content.relative) {
|
|
205
199
|
return content.relative;
|
|
206
200
|
}
|
|
207
|
-
return (0, _featureFlags.flagEnabled)(config,
|
|
201
|
+
return (0, _featureFlags.flagEnabled)(config, "relativeContentPathsByDefault");
|
|
208
202
|
})(),
|
|
209
203
|
files: (()=>{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
if (purge) {
|
|
214
|
-
var _purge;
|
|
215
|
-
if (Array.isArray(purge)) return purge;
|
|
216
|
-
if (Array.isArray((_purge = purge) === null || _purge === void 0 ? void 0 : _purge.content)) return purge.content;
|
|
217
|
-
return [];
|
|
218
|
-
}
|
|
204
|
+
let { content , purge } = config;
|
|
205
|
+
if (Array.isArray(purge)) return purge;
|
|
206
|
+
if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
|
|
219
207
|
if (Array.isArray(content)) return content;
|
|
220
|
-
if (Array.isArray(
|
|
221
|
-
if (Array.isArray(
|
|
222
|
-
if (content === 'auto') return [
|
|
223
|
-
'auto'
|
|
224
|
-
];
|
|
208
|
+
if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
|
|
209
|
+
if (Array.isArray(content === null || content === void 0 ? void 0 : content.files)) return content.files;
|
|
225
210
|
return [];
|
|
226
211
|
})(),
|
|
227
212
|
extract: (()=>{
|
|
228
213
|
let extract = (()=>{
|
|
229
|
-
var _config_purge, _config_content, _config_purge_extract,
|
|
214
|
+
var _config_purge, _config_content, _config_purge1, _config_purge_extract, _config_content1, _config_content_extract, _config_purge2, _config_purge_options, _config_content2, _config_content_options;
|
|
230
215
|
if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : _config_purge.extract) return config.purge.extract;
|
|
231
216
|
if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : _config_content.extract) return config.content.extract;
|
|
232
217
|
if ((_config_purge1 = config.purge) === null || _config_purge1 === void 0 ? void 0 : (_config_purge_extract = _config_purge1.extract) === null || _config_purge_extract === void 0 ? void 0 : _config_purge_extract.DEFAULT) return config.purge.extract.DEFAULT;
|
|
@@ -237,7 +222,7 @@ function normalizeConfig(config) {
|
|
|
237
222
|
})();
|
|
238
223
|
let extractors = {};
|
|
239
224
|
let defaultExtractor = (()=>{
|
|
240
|
-
var _config_purge_options,
|
|
225
|
+
var _config_purge, _config_purge_options, _config_content, _config_content_options;
|
|
241
226
|
if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : (_config_purge_options = _config_purge.options) === null || _config_purge_options === void 0 ? void 0 : _config_purge_options.defaultExtractor) {
|
|
242
227
|
return config.purge.options.defaultExtractor;
|
|
243
228
|
}
|
|
@@ -250,22 +235,22 @@ function normalizeConfig(config) {
|
|
|
250
235
|
extractors.DEFAULT = defaultExtractor;
|
|
251
236
|
}
|
|
252
237
|
// Functions
|
|
253
|
-
if (typeof extract ===
|
|
238
|
+
if (typeof extract === "function") {
|
|
254
239
|
extractors.DEFAULT = extract;
|
|
255
240
|
} else if (Array.isArray(extract)) {
|
|
256
|
-
for (let { extensions, extractor
|
|
241
|
+
for (let { extensions , extractor } of extract !== null && extract !== void 0 ? extract : []){
|
|
257
242
|
for (let extension of extensions){
|
|
258
243
|
extractors[extension] = extractor;
|
|
259
244
|
}
|
|
260
245
|
}
|
|
261
|
-
} else if (typeof extract ===
|
|
246
|
+
} else if (typeof extract === "object" && extract !== null) {
|
|
262
247
|
Object.assign(extractors, extract);
|
|
263
248
|
}
|
|
264
249
|
return extractors;
|
|
265
250
|
})(),
|
|
266
251
|
transform: (()=>{
|
|
267
252
|
let transform = (()=>{
|
|
268
|
-
var _config_purge, _config_content, _config_purge_transform,
|
|
253
|
+
var _config_purge, _config_content, _config_purge1, _config_purge_transform, _config_content1, _config_content_transform;
|
|
269
254
|
if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : _config_purge.transform) return config.purge.transform;
|
|
270
255
|
if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : _config_content.transform) return config.content.transform;
|
|
271
256
|
if ((_config_purge1 = config.purge) === null || _config_purge1 === void 0 ? void 0 : (_config_purge_transform = _config_purge1.transform) === null || _config_purge_transform === void 0 ? void 0 : _config_purge_transform.DEFAULT) return config.purge.transform.DEFAULT;
|
|
@@ -273,40 +258,24 @@ function normalizeConfig(config) {
|
|
|
273
258
|
return {};
|
|
274
259
|
})();
|
|
275
260
|
let transformers = {};
|
|
276
|
-
if (typeof transform ===
|
|
261
|
+
if (typeof transform === "function") {
|
|
277
262
|
transformers.DEFAULT = transform;
|
|
278
263
|
}
|
|
279
|
-
if (typeof transform ===
|
|
264
|
+
if (typeof transform === "object" && transform !== null) {
|
|
280
265
|
Object.assign(transformers, transform);
|
|
281
266
|
}
|
|
282
267
|
return transformers;
|
|
283
268
|
})()
|
|
284
269
|
};
|
|
285
|
-
// Force disable the `oxideParser` feature flag when using unsupported features.
|
|
286
|
-
// TODO: Remove once we have prefix or separator support in the oxide parser.
|
|
287
|
-
if (config.prefix !== '' || config.separator !== ':') {
|
|
288
|
-
if (config.experimental === 'all') {
|
|
289
|
-
config.experimental = {};
|
|
290
|
-
for (let key of _featureFlags.featureFlags.experimental){
|
|
291
|
-
config.experimental[key] = true;
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
var _config_experimental;
|
|
295
|
-
config.experimental = (_config_experimental = config.experimental) !== null && _config_experimental !== void 0 ? _config_experimental : {};
|
|
296
|
-
}
|
|
297
|
-
config.experimental.oxideParser = false;
|
|
298
|
-
}
|
|
299
270
|
// Validate globs to prevent bogus globs.
|
|
300
271
|
// E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
_log.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
272
|
+
for (let file of config.content.files){
|
|
273
|
+
if (typeof file === "string" && /{([^,]*?)}/g.test(file)) {
|
|
274
|
+
_log.default.warn("invalid-glob-braces", [
|
|
275
|
+
`The glob pattern ${(0, _log.dim)(file)} in your Tailwind CSS configuration is invalid.`,
|
|
276
|
+
`Update it to ${(0, _log.dim)(file.replace(/{([^,]*?)}/g, "$1"))} to silence this warning.`
|
|
277
|
+
]);
|
|
278
|
+
break;
|
|
310
279
|
}
|
|
311
280
|
}
|
|
312
281
|
return config;
|