tailwindcss 3.2.4 → 3.2.6
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 +51 -1
- package/README.md +1 -1
- package/lib/cli/build/index.js +5 -1
- package/lib/cli/build/plugin.js +39 -34
- package/lib/cli/index.js +231 -10
- package/lib/cli/init/index.js +2 -2
- package/lib/cli.js +4 -226
- package/lib/corePlugins.js +45 -27
- package/lib/featureFlags.js +8 -8
- package/lib/index.js +4 -46
- package/lib/lib/collapseAdjacentRules.js +2 -2
- package/lib/lib/collapseDuplicateDeclarations.js +2 -2
- package/lib/lib/content.js +16 -16
- package/lib/lib/defaultExtractor.js +10 -5
- package/lib/lib/detectNesting.js +7 -1
- package/lib/lib/evaluateTailwindFunctions.js +4 -4
- package/lib/lib/expandApplyAtRules.js +2 -2
- package/lib/lib/expandTailwindAtRules.js +34 -9
- package/lib/lib/findAtConfigPath.js +3 -3
- package/lib/lib/generateRules.js +105 -50
- package/lib/lib/offsets.js +88 -1
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +4 -4
- package/lib/lib/setupContextUtils.js +121 -80
- package/lib/lib/setupTrackingContext.js +25 -4
- package/lib/lib/sharedState.js +19 -1
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +47 -0
- package/lib/oxide/cli/build/plugin.js +364 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +220 -0
- package/lib/oxide/cli/init/index.js +35 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/lib/postcss-plugins/nesting/plugin.js +2 -2
- package/lib/util/cloneNodes.js +2 -2
- package/lib/util/color.js +20 -6
- package/lib/util/createUtilityPlugin.js +2 -2
- package/lib/util/dataTypes.js +26 -2
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +3 -3
- package/lib/util/formatVariantSelector.js +171 -105
- package/lib/util/getAllConfigs.js +2 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +2 -2
- package/lib/util/negateValue.js +2 -2
- package/lib/util/normalizeConfig.js +22 -22
- package/lib/util/pluginUtils.js +38 -40
- package/lib/util/prefixSelector.js +22 -8
- package/lib/util/resolveConfig.js +8 -10
- package/package.json +30 -19
- package/peers/index.js +61 -42
- package/resolveConfig.d.ts +11 -2
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/index.js +6 -2
- package/src/cli/build/plugin.js +14 -9
- package/src/cli/index.js +234 -3
- package/src/cli.js +4 -220
- package/src/corePlugins.js +31 -3
- package/src/index.js +4 -46
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandTailwindAtRules.js +35 -6
- package/src/lib/generateRules.js +90 -28
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +97 -55
- package/src/lib/setupTrackingContext.js +31 -6
- package/src/lib/sharedState.js +17 -0
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +436 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +212 -0
- package/src/oxide/cli/init/index.ts +32 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/util/color.js +17 -2
- package/src/util/dataTypes.js +29 -4
- package/src/util/formatVariantSelector.js +215 -122
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/negateValue.js +1 -1
- package/src/util/pluginUtils.js +22 -19
- package/src/util/prefixSelector.js +28 -10
- package/src/util/resolveConfig.js +0 -2
- package/stubs/defaultConfig.stub.js +149 -165
- package/types/config.d.ts +7 -2
- package/types/generated/default-theme.d.ts +77 -77
- package/lib/cli/shared.js +0 -12
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
|
@@ -9,9 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
selectorFunctions: ()=>selectorFunctions,
|
|
13
12
|
formatVariantSelector: ()=>formatVariantSelector,
|
|
14
|
-
finalizeSelector: ()=>finalizeSelector
|
|
13
|
+
finalizeSelector: ()=>finalizeSelector,
|
|
14
|
+
handleMergePseudo: ()=>handleMergePseudo
|
|
15
15
|
});
|
|
16
16
|
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
17
17
|
const _unesc = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
|
|
@@ -22,28 +22,39 @@ function _interopRequireDefault(obj) {
|
|
|
22
22
|
default: obj
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
/** @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, isArbitraryVariant: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
|
|
26
|
+
function formatVariantSelector(formats, { context , candidate }) {
|
|
27
|
+
var _context_tailwindConfig_prefix;
|
|
28
|
+
let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
|
|
29
|
+
// Parse the format selector into an AST
|
|
30
|
+
let parsedFormats = formats.map((format)=>{
|
|
31
|
+
let ast = (0, _postcssSelectorParser.default)().astSync(format.format);
|
|
32
|
+
return {
|
|
33
|
+
...format,
|
|
34
|
+
ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
// We start with the candidate selector
|
|
38
|
+
let formatAst = _postcssSelectorParser.default.root({
|
|
39
|
+
nodes: [
|
|
40
|
+
_postcssSelectorParser.default.selector({
|
|
41
|
+
nodes: [
|
|
42
|
+
_postcssSelectorParser.default.className({
|
|
43
|
+
value: (0, _escapeClassName.default)(candidate)
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
// And iteratively merge each format selector into the candidate selector
|
|
50
|
+
for (let { ast } of parsedFormats){
|
|
51
|
+
[formatAst, ast] = handleMergePseudo(formatAst, ast);
|
|
52
|
+
// 2. Merge the format selector into the current selector AST
|
|
53
|
+
ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
|
|
54
|
+
// 3. Keep going!
|
|
55
|
+
formatAst = ast;
|
|
45
56
|
}
|
|
46
|
-
return
|
|
57
|
+
return formatAst;
|
|
47
58
|
}
|
|
48
59
|
/**
|
|
49
60
|
* Given any node in a selector this gets the "simple" selector it's a part of
|
|
@@ -51,10 +62,10 @@ function formatVariantSelector(current, ...others) {
|
|
|
51
62
|
* Technically :is(), :not(), :has(), etc… can have combinators but those are nested
|
|
52
63
|
* inside the relevant node and won't be picked up so they're fine to ignore
|
|
53
64
|
*
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {
|
|
65
|
+
* @param {Node} node
|
|
66
|
+
* @returns {Node[]}
|
|
56
67
|
**/ function simpleSelectorForNode(node) {
|
|
57
|
-
/** @type {
|
|
68
|
+
/** @type {Node[]} */ let nodes = [];
|
|
58
69
|
// Walk backwards until we hit a combinator node (or the start)
|
|
59
70
|
while(node.prev() && node.prev().type !== "combinator"){
|
|
60
71
|
node = node.prev();
|
|
@@ -70,8 +81,8 @@ function formatVariantSelector(current, ...others) {
|
|
|
70
81
|
* Resorts the nodes in a selector to ensure they're in the correct order
|
|
71
82
|
* Tags go before classes, and pseudo classes go after classes
|
|
72
83
|
*
|
|
73
|
-
* @param {
|
|
74
|
-
* @returns {
|
|
84
|
+
* @param {Selector} sel
|
|
85
|
+
* @returns {Selector}
|
|
75
86
|
**/ function resortSelector(sel) {
|
|
76
87
|
sel.sort((a, b)=>{
|
|
77
88
|
if (a.type === "tag" && b.type === "class") {
|
|
@@ -87,7 +98,18 @@ function formatVariantSelector(current, ...others) {
|
|
|
87
98
|
});
|
|
88
99
|
return sel;
|
|
89
100
|
}
|
|
90
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Remove extraneous selectors that do not include the base class/candidate
|
|
103
|
+
*
|
|
104
|
+
* Example:
|
|
105
|
+
* Given the utility `.a, .b { color: red}`
|
|
106
|
+
* Given the candidate `sm:b`
|
|
107
|
+
*
|
|
108
|
+
* The final selector should be `.sm\:b` and not `.a, .sm\:b`
|
|
109
|
+
*
|
|
110
|
+
* @param {Selector} ast
|
|
111
|
+
* @param {string} base
|
|
112
|
+
*/ function eliminateIrrelevantSelectors(sel, base) {
|
|
91
113
|
let hasClassesMatchingCandidate = false;
|
|
92
114
|
sel.walk((child)=>{
|
|
93
115
|
if (child.type === "class" && child.value === base) {
|
|
@@ -106,27 +128,20 @@ function eliminateIrrelevantSelectors(sel, base) {
|
|
|
106
128
|
// meaning of the selector.
|
|
107
129
|
// TODO: Can we do this for :matches, :is, and :where?
|
|
108
130
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
format = format.replace(PARENT, `.${(0, _escapeClassName.default)(candidate)}`);
|
|
125
|
-
let formatAst = (0, _postcssSelectorParser.default)().astSync(format);
|
|
126
|
-
// Remove extraneous selectors that do not include the base class/candidate being matched against
|
|
127
|
-
// For example if we have a utility defined `.a, .b { color: red}`
|
|
128
|
-
// And the formatted variant is sm:b then we want the final selector to be `.sm\:b` and not `.a, .sm\:b`
|
|
129
|
-
ast.each((sel)=>eliminateIrrelevantSelectors(sel, base));
|
|
131
|
+
function finalizeSelector(current, formats, { context , candidate , base }) {
|
|
132
|
+
var _context_tailwindConfig;
|
|
133
|
+
var _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 : ":";
|
|
135
|
+
// Split by the separator, but ignore the separator inside square brackets:
|
|
136
|
+
//
|
|
137
|
+
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
138
|
+
// ┬ ┬ ┬ ┬
|
|
139
|
+
// │ │ │ ╰── We will not split here
|
|
140
|
+
// ╰──┴─────┴─────────────── We will split here
|
|
141
|
+
//
|
|
142
|
+
base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
|
|
143
|
+
// Parse the selector into an AST
|
|
144
|
+
let selector = (0, _postcssSelectorParser.default)().astSync(current);
|
|
130
145
|
// Normalize escaped classes, e.g.:
|
|
131
146
|
//
|
|
132
147
|
// The idea would be to replace the escaped `base` in the selector with the
|
|
@@ -138,11 +153,22 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
|
|
|
138
153
|
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
139
154
|
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
140
155
|
//
|
|
141
|
-
|
|
156
|
+
selector.walkClasses((node)=>{
|
|
142
157
|
if (node.raws && node.value.includes(base)) {
|
|
143
158
|
node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
|
|
144
159
|
}
|
|
145
160
|
});
|
|
161
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
162
|
+
selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
|
|
163
|
+
// If there are no formats that means there were no variants added to the candidate
|
|
164
|
+
// so we can just return the selector as-is
|
|
165
|
+
let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
|
|
166
|
+
context,
|
|
167
|
+
candidate
|
|
168
|
+
}) : formats;
|
|
169
|
+
if (formatAst === null) {
|
|
170
|
+
return selector.toString();
|
|
171
|
+
}
|
|
146
172
|
let simpleStart = _postcssSelectorParser.default.comment({
|
|
147
173
|
value: "/*__simple__*/"
|
|
148
174
|
});
|
|
@@ -151,7 +177,7 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
|
|
|
151
177
|
});
|
|
152
178
|
// We can safely replace the escaped base now, since the `base` section is
|
|
153
179
|
// now in a normalized escaped value.
|
|
154
|
-
|
|
180
|
+
selector.walkClasses((node)=>{
|
|
155
181
|
if (node.value !== base) {
|
|
156
182
|
return;
|
|
157
183
|
}
|
|
@@ -166,7 +192,7 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
|
|
|
166
192
|
parent.insertBefore(simpleSelector[0], simpleStart);
|
|
167
193
|
parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
|
|
168
194
|
for (let child of formatNodes){
|
|
169
|
-
parent.insertBefore(simpleSelector[0], child);
|
|
195
|
+
parent.insertBefore(simpleSelector[0], child.clone());
|
|
170
196
|
}
|
|
171
197
|
node.remove();
|
|
172
198
|
// Re-sort the simple selector to ensure it's in the correct order
|
|
@@ -178,41 +204,68 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
|
|
|
178
204
|
simpleStart.remove();
|
|
179
205
|
simpleEnd.remove();
|
|
180
206
|
});
|
|
181
|
-
// This will make sure to move pseudo's to the correct spot (the end for
|
|
182
|
-
// pseudo elements) because otherwise the selector will never work
|
|
183
|
-
// anyway.
|
|
184
|
-
//
|
|
185
|
-
// E.g.:
|
|
186
|
-
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
187
|
-
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
188
|
-
//
|
|
189
|
-
// `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
190
|
-
function collectPseudoElements(selector) {
|
|
191
|
-
let nodes = [];
|
|
192
|
-
for (let node of selector.nodes){
|
|
193
|
-
if (isPseudoElement(node)) {
|
|
194
|
-
nodes.push(node);
|
|
195
|
-
selector.removeChild(node);
|
|
196
|
-
}
|
|
197
|
-
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
198
|
-
nodes.push(...collectPseudoElements(node));
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return nodes;
|
|
202
|
-
}
|
|
203
207
|
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
selector.walkPseudos((p)=>{
|
|
209
|
+
if (p.value === MERGE) {
|
|
210
|
+
p.replaceWith(p.nodes);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
// Move pseudo elements to the end of the selector (if necessary)
|
|
214
|
+
selector.each((sel)=>{
|
|
215
|
+
let pseudoElements = collectPseudoElements(sel);
|
|
211
216
|
if (pseudoElements.length > 0) {
|
|
212
|
-
|
|
217
|
+
sel.nodes.push(pseudoElements.sort(sortSelector));
|
|
213
218
|
}
|
|
214
219
|
});
|
|
215
|
-
return
|
|
220
|
+
return selector.toString();
|
|
221
|
+
}
|
|
222
|
+
function handleMergePseudo(selector, format) {
|
|
223
|
+
/** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
|
|
224
|
+
// Find all :merge() pseudo-classes in `selector`
|
|
225
|
+
selector.walkPseudos((pseudo)=>{
|
|
226
|
+
if (pseudo.value === MERGE) {
|
|
227
|
+
merges.push({
|
|
228
|
+
pseudo,
|
|
229
|
+
value: pseudo.nodes[0].toString()
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
// Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
|
|
234
|
+
format.walkPseudos((pseudo)=>{
|
|
235
|
+
if (pseudo.value !== MERGE) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
let value = pseudo.nodes[0].toString();
|
|
239
|
+
// Does `selector` contain a :merge() pseudo-class with the same value?
|
|
240
|
+
let existing = merges.find((merge)=>merge.value === value);
|
|
241
|
+
// Nope so there's nothing to do
|
|
242
|
+
if (!existing) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
// Everything after `:merge()` up to the next combinator is what is attached to the merged selector
|
|
246
|
+
let attachments = [];
|
|
247
|
+
let next = pseudo.next();
|
|
248
|
+
while(next && next.type !== "combinator"){
|
|
249
|
+
attachments.push(next);
|
|
250
|
+
next = next.next();
|
|
251
|
+
}
|
|
252
|
+
let combinator = next;
|
|
253
|
+
existing.pseudo.parent.insertAfter(existing.pseudo, _postcssSelectorParser.default.selector({
|
|
254
|
+
nodes: attachments.map((node)=>node.clone())
|
|
255
|
+
}));
|
|
256
|
+
pseudo.remove();
|
|
257
|
+
attachments.forEach((node)=>node.remove());
|
|
258
|
+
// What about this case:
|
|
259
|
+
// :merge(.group):focus > &
|
|
260
|
+
// :merge(.group):hover &
|
|
261
|
+
if (combinator && combinator.type === "combinator") {
|
|
262
|
+
combinator.remove();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return [
|
|
266
|
+
selector,
|
|
267
|
+
format
|
|
268
|
+
];
|
|
216
269
|
}
|
|
217
270
|
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
218
271
|
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
@@ -226,8 +279,41 @@ let pseudoElementsBC = [
|
|
|
226
279
|
];
|
|
227
280
|
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
228
281
|
let pseudoElementExceptions = [
|
|
229
|
-
"::file-selector-button"
|
|
282
|
+
"::file-selector-button",
|
|
283
|
+
// Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
|
|
284
|
+
"::-webkit-scrollbar",
|
|
285
|
+
"::-webkit-scrollbar-button",
|
|
286
|
+
"::-webkit-scrollbar-thumb",
|
|
287
|
+
"::-webkit-scrollbar-track",
|
|
288
|
+
"::-webkit-scrollbar-track-piece",
|
|
289
|
+
"::-webkit-scrollbar-corner",
|
|
290
|
+
"::-webkit-resizer"
|
|
230
291
|
];
|
|
292
|
+
/**
|
|
293
|
+
* This will make sure to move pseudo's to the correct spot (the end for
|
|
294
|
+
* pseudo elements) because otherwise the selector will never work
|
|
295
|
+
* anyway.
|
|
296
|
+
*
|
|
297
|
+
* E.g.:
|
|
298
|
+
* - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
299
|
+
* - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
300
|
+
*
|
|
301
|
+
* `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
302
|
+
*
|
|
303
|
+
* @param {Selector} selector
|
|
304
|
+
**/ function collectPseudoElements(selector) {
|
|
305
|
+
/** @type {Node[]} */ let nodes = [];
|
|
306
|
+
for (let node of selector.nodes){
|
|
307
|
+
if (isPseudoElement(node)) {
|
|
308
|
+
nodes.push(node);
|
|
309
|
+
selector.removeChild(node);
|
|
310
|
+
}
|
|
311
|
+
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
312
|
+
nodes.push(...collectPseudoElements(node));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return nodes;
|
|
316
|
+
}
|
|
231
317
|
// This will make sure to move pseudo's to the correct spot (the end for
|
|
232
318
|
// pseudo elements) because otherwise the selector will never work
|
|
233
319
|
// anyway.
|
|
@@ -263,23 +349,3 @@ function isPseudoElement(node) {
|
|
|
263
349
|
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
264
350
|
return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
|
|
265
351
|
}
|
|
266
|
-
function resolveFunctionArgument(haystack, needle, arg) {
|
|
267
|
-
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
268
|
-
if (startIdx === -1) return null;
|
|
269
|
-
// Start inside the `(`
|
|
270
|
-
startIdx += needle.length + 1;
|
|
271
|
-
let target = "";
|
|
272
|
-
let count = 0;
|
|
273
|
-
for (let char of haystack.slice(startIdx)){
|
|
274
|
-
if (char !== "(" && char !== ")") {
|
|
275
|
-
target += char;
|
|
276
|
-
} else if (char === "(") {
|
|
277
|
-
target += char;
|
|
278
|
-
count++;
|
|
279
|
-
} else if (char === ")") {
|
|
280
|
-
if (--count < 0) break; // unbalanced
|
|
281
|
-
target += char;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return target;
|
|
285
|
-
}
|
|
@@ -14,8 +14,8 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function getAllConfigs(config) {
|
|
17
|
-
var
|
|
18
|
-
const configs = ((
|
|
17
|
+
var _config_presets;
|
|
18
|
+
const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
|
|
19
19
|
_defaultConfigStubJs.default
|
|
20
20
|
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
21
21
|
const features = {
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, // Arbitrary values must contain balanced bracket
|
|
|
10
10
|
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
11
11
|
"default", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: ()=>
|
|
13
|
+
get: ()=>isSyntacticallyValidPropertyValue
|
|
14
14
|
});
|
|
15
15
|
let matchingBrackets = new Map([
|
|
16
16
|
[
|
|
@@ -35,7 +35,7 @@ let quotes = new Set([
|
|
|
35
35
|
"'",
|
|
36
36
|
"`"
|
|
37
37
|
]);
|
|
38
|
-
function
|
|
38
|
+
function isSyntacticallyValidPropertyValue(value) {
|
|
39
39
|
let stack = [];
|
|
40
40
|
let inQuotes = false;
|
|
41
41
|
for(let i = 0; i < value.length; i++){
|
package/lib/util/negateValue.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()=>
|
|
7
|
+
get: ()=>negateValue
|
|
8
8
|
});
|
|
9
|
-
function
|
|
9
|
+
function negateValue(value) {
|
|
10
10
|
value = `${value}`;
|
|
11
11
|
if (value === "0") {
|
|
12
12
|
return "0";
|
|
@@ -154,12 +154,12 @@ function normalizeConfig(config) {
|
|
|
154
154
|
}
|
|
155
155
|
// Normalize the `safelist`
|
|
156
156
|
config.safelist = (()=>{
|
|
157
|
-
var
|
|
157
|
+
var _purge_options;
|
|
158
158
|
let { content , purge , safelist } = config;
|
|
159
159
|
if (Array.isArray(safelist)) return safelist;
|
|
160
160
|
if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return content.safelist;
|
|
161
161
|
if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return purge.safelist;
|
|
162
|
-
if (Array.isArray(purge === null || purge === void 0 ? void 0 : (
|
|
162
|
+
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;
|
|
163
163
|
return [];
|
|
164
164
|
})();
|
|
165
165
|
// Normalize the `blocklist`
|
|
@@ -185,19 +185,19 @@ function normalizeConfig(config) {
|
|
|
185
185
|
]);
|
|
186
186
|
config.prefix = "";
|
|
187
187
|
} else {
|
|
188
|
-
var
|
|
189
|
-
config.prefix = (
|
|
188
|
+
var _config_prefix;
|
|
189
|
+
config.prefix = (_config_prefix = config.prefix) !== null && _config_prefix !== void 0 ? _config_prefix : "";
|
|
190
190
|
}
|
|
191
191
|
// Normalize the `content`
|
|
192
192
|
config.content = {
|
|
193
193
|
relative: (()=>{
|
|
194
|
-
var
|
|
194
|
+
var _config_future;
|
|
195
195
|
let { content } = config;
|
|
196
196
|
if (content === null || content === void 0 ? void 0 : content.relative) {
|
|
197
197
|
return content.relative;
|
|
198
198
|
}
|
|
199
|
-
var
|
|
200
|
-
return (
|
|
199
|
+
var _config_future_relativeContentPathsByDefault;
|
|
200
|
+
return (_config_future_relativeContentPathsByDefault = (_config_future = config.future) === null || _config_future === void 0 ? void 0 : _config_future.relativeContentPathsByDefault) !== null && _config_future_relativeContentPathsByDefault !== void 0 ? _config_future_relativeContentPathsByDefault : false;
|
|
201
201
|
})(),
|
|
202
202
|
files: (()=>{
|
|
203
203
|
let { content , purge } = config;
|
|
@@ -210,22 +210,22 @@ function normalizeConfig(config) {
|
|
|
210
210
|
})(),
|
|
211
211
|
extract: (()=>{
|
|
212
212
|
let extract = (()=>{
|
|
213
|
-
var
|
|
214
|
-
if ((
|
|
215
|
-
if ((
|
|
216
|
-
if ((
|
|
217
|
-
if ((
|
|
218
|
-
if ((
|
|
219
|
-
if ((
|
|
213
|
+
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;
|
|
214
|
+
if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : _config_purge.extract) return config.purge.extract;
|
|
215
|
+
if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : _config_content.extract) return config.content.extract;
|
|
216
|
+
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;
|
|
217
|
+
if ((_config_content1 = config.content) === null || _config_content1 === void 0 ? void 0 : (_config_content_extract = _config_content1.extract) === null || _config_content_extract === void 0 ? void 0 : _config_content_extract.DEFAULT) return config.content.extract.DEFAULT;
|
|
218
|
+
if ((_config_purge2 = config.purge) === null || _config_purge2 === void 0 ? void 0 : (_config_purge_options = _config_purge2.options) === null || _config_purge_options === void 0 ? void 0 : _config_purge_options.extractors) return config.purge.options.extractors;
|
|
219
|
+
if ((_config_content2 = config.content) === null || _config_content2 === void 0 ? void 0 : (_config_content_options = _config_content2.options) === null || _config_content_options === void 0 ? void 0 : _config_content_options.extractors) return config.content.options.extractors;
|
|
220
220
|
return {};
|
|
221
221
|
})();
|
|
222
222
|
let extractors = {};
|
|
223
223
|
let defaultExtractor = (()=>{
|
|
224
|
-
var
|
|
225
|
-
if ((
|
|
224
|
+
var _config_purge, _config_purge_options, _config_content, _config_content_options;
|
|
225
|
+
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) {
|
|
226
226
|
return config.purge.options.defaultExtractor;
|
|
227
227
|
}
|
|
228
|
-
if ((
|
|
228
|
+
if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : (_config_content_options = _config_content.options) === null || _config_content_options === void 0 ? void 0 : _config_content_options.defaultExtractor) {
|
|
229
229
|
return config.content.options.defaultExtractor;
|
|
230
230
|
}
|
|
231
231
|
return undefined;
|
|
@@ -249,11 +249,11 @@ function normalizeConfig(config) {
|
|
|
249
249
|
})(),
|
|
250
250
|
transform: (()=>{
|
|
251
251
|
let transform = (()=>{
|
|
252
|
-
var
|
|
253
|
-
if ((
|
|
254
|
-
if ((
|
|
255
|
-
if ((
|
|
256
|
-
if ((
|
|
252
|
+
var _config_purge, _config_content, _config_purge1, _config_purge_transform, _config_content1, _config_content_transform;
|
|
253
|
+
if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : _config_purge.transform) return config.purge.transform;
|
|
254
|
+
if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : _config_content.transform) return config.content.transform;
|
|
255
|
+
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;
|
|
256
|
+
if ((_config_content1 = config.content) === null || _config_content1 === void 0 ? void 0 : (_config_content_transform = _config_content1.transform) === null || _config_content_transform === void 0 ? void 0 : _config_content_transform.DEFAULT) return config.content.transform.DEFAULT;
|
|
257
257
|
return {};
|
|
258
258
|
})();
|
|
259
259
|
let transformers = {};
|
package/lib/util/pluginUtils.js
CHANGED
|
@@ -80,8 +80,8 @@ function asNegativeValue(modifier, lookup = {}, validate) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
83
|
-
var
|
|
84
|
-
let value = (
|
|
83
|
+
var _options_values;
|
|
84
|
+
let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
85
85
|
if (value !== undefined) {
|
|
86
86
|
return value;
|
|
87
87
|
}
|
|
@@ -123,19 +123,19 @@ function parseColorFormat(value) {
|
|
|
123
123
|
}
|
|
124
124
|
return value;
|
|
125
125
|
}
|
|
126
|
-
function asColor(
|
|
127
|
-
var
|
|
128
|
-
if (((
|
|
129
|
-
var
|
|
130
|
-
return parseColorFormat((
|
|
126
|
+
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
127
|
+
var _options_values;
|
|
128
|
+
if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
|
|
129
|
+
var _options_values1;
|
|
130
|
+
return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
|
|
131
131
|
}
|
|
132
132
|
// TODO: Hoist this up to getMatchingTypes or something
|
|
133
133
|
// We do this here because we need the alpha value (if any)
|
|
134
|
-
let [color, alpha] = splitUtilityModifier(
|
|
134
|
+
let [color, alpha] = splitUtilityModifier(modifier);
|
|
135
135
|
if (alpha !== undefined) {
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
let normalizedColor = (
|
|
136
|
+
var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
|
|
137
|
+
var _options_values_color;
|
|
138
|
+
let normalizedColor = (_options_values_color = (_options_values2 = options.values) === null || _options_values2 === void 0 ? void 0 : _options_values2[color]) !== null && _options_values_color !== void 0 ? _options_values_color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
|
|
139
139
|
if (normalizedColor === undefined) {
|
|
140
140
|
return undefined;
|
|
141
141
|
}
|
|
@@ -143,25 +143,22 @@ function asColor(_, options = {}, { tailwindConfig ={} , utilityModifier , rawMo
|
|
|
143
143
|
if (isArbitraryValue(alpha)) {
|
|
144
144
|
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, alpha.slice(1, -1));
|
|
145
145
|
}
|
|
146
|
-
if (((
|
|
146
|
+
if (((_tailwindConfig_theme = tailwindConfig.theme) === null || _tailwindConfig_theme === void 0 ? void 0 : (_tailwindConfig_theme_opacity = _tailwindConfig_theme.opacity) === null || _tailwindConfig_theme_opacity === void 0 ? void 0 : _tailwindConfig_theme_opacity[alpha]) === undefined) {
|
|
147
147
|
return undefined;
|
|
148
148
|
}
|
|
149
149
|
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
|
|
150
150
|
}
|
|
151
|
-
return asValue(
|
|
152
|
-
rawModifier,
|
|
153
|
-
utilityModifier,
|
|
151
|
+
return asValue(modifier, options, {
|
|
154
152
|
validate: _dataTypes.color
|
|
155
153
|
});
|
|
156
154
|
}
|
|
157
155
|
function asLookupValue(modifier, options = {}) {
|
|
158
|
-
var
|
|
159
|
-
return (
|
|
156
|
+
var _options_values;
|
|
157
|
+
return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
160
158
|
}
|
|
161
159
|
function guess(validate) {
|
|
162
|
-
return (modifier, options
|
|
160
|
+
return (modifier, options)=>{
|
|
163
161
|
return asValue(modifier, options, {
|
|
164
|
-
...extras,
|
|
165
162
|
validate
|
|
166
163
|
});
|
|
167
164
|
};
|
|
@@ -197,6 +194,21 @@ function splitAtFirst(input, delim) {
|
|
|
197
194
|
];
|
|
198
195
|
}
|
|
199
196
|
function coerceValue(types, modifier, options, tailwindConfig) {
|
|
197
|
+
if (options.values && modifier in options.values) {
|
|
198
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
199
|
+
let result = typeMap[type](modifier, options, {
|
|
200
|
+
tailwindConfig
|
|
201
|
+
});
|
|
202
|
+
if (result === undefined) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
return [
|
|
206
|
+
result,
|
|
207
|
+
type,
|
|
208
|
+
null
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
200
212
|
if (isArbitraryValue(modifier)) {
|
|
201
213
|
let arbitraryValue = modifier.slice(1, -1);
|
|
202
214
|
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
@@ -238,39 +250,25 @@ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
|
238
250
|
// TODO: Move to asValue… somehow
|
|
239
251
|
if (utilityModifier !== undefined) {
|
|
240
252
|
if (typeof options.modifiers === "object") {
|
|
241
|
-
var
|
|
242
|
-
var
|
|
243
|
-
let configValue = (
|
|
253
|
+
var _options_modifiers;
|
|
254
|
+
var _options_modifiers_utilityModifier;
|
|
255
|
+
let configValue = (_options_modifiers_utilityModifier = (_options_modifiers = options.modifiers) === null || _options_modifiers === void 0 ? void 0 : _options_modifiers[utilityModifier]) !== null && _options_modifiers_utilityModifier !== void 0 ? _options_modifiers_utilityModifier : null;
|
|
244
256
|
if (configValue !== null) {
|
|
245
257
|
utilityModifier = configValue;
|
|
246
258
|
} else if (isArbitraryValue(utilityModifier)) {
|
|
247
259
|
utilityModifier = utilityModifier.slice(1, -1);
|
|
248
260
|
}
|
|
249
261
|
}
|
|
250
|
-
let result = asValue(rawModifier, options, {
|
|
251
|
-
rawModifier,
|
|
252
|
-
utilityModifier,
|
|
253
|
-
tailwindConfig
|
|
254
|
-
});
|
|
255
|
-
if (result !== undefined) {
|
|
256
|
-
yield [
|
|
257
|
-
result,
|
|
258
|
-
"any",
|
|
259
|
-
null
|
|
260
|
-
];
|
|
261
|
-
}
|
|
262
262
|
}
|
|
263
|
-
for (
|
|
264
|
-
let
|
|
265
|
-
rawModifier,
|
|
266
|
-
utilityModifier,
|
|
263
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
264
|
+
let result = typeMap[type](modifier, options, {
|
|
267
265
|
tailwindConfig
|
|
268
266
|
});
|
|
269
|
-
if (
|
|
267
|
+
if (result === undefined) {
|
|
270
268
|
continue;
|
|
271
269
|
}
|
|
272
270
|
yield [
|
|
273
|
-
|
|
271
|
+
result,
|
|
274
272
|
type,
|
|
275
273
|
utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
|
|
276
274
|
];
|