tailwindcss 0.0.0-insiders.e3f9ea4 → 0.0.0-insiders.e40b73a
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/lib/cli/build/index.js +4 -1
- package/lib/cli/build/plugin.js +5 -1
- package/lib/corePlugins.js +10 -19
- package/lib/featureFlags.js +8 -1
- package/lib/lib/generateRules.js +18 -15
- package/lib/lib/setupContextUtils.js +10 -2
- package/lib/oxide/cli/build/index.js +4 -1
- package/lib/oxide/cli/build/plugin.js +5 -1
- package/lib/util/formatVariantSelector.js +2 -12
- package/lib/util/normalizeConfig.js +2 -3
- package/lib/util/pluginUtils.js +5 -24
- package/lib/util/splitAtTopLevelOnly.js +7 -1
- package/package.json +1 -1
- package/src/cli/build/index.js +4 -1
- package/src/cli/build/plugin.js +5 -1
- package/src/corePlugins.js +6 -19
- package/src/featureFlags.js +7 -0
- package/src/lib/generateRules.js +33 -14
- package/src/lib/setupContextUtils.js +9 -2
- package/src/oxide/cli/build/index.ts +4 -1
- package/src/oxide/cli/build/plugin.ts +5 -1
- package/src/util/formatVariantSelector.js +1 -1
- package/src/util/normalizeConfig.js +2 -1
- package/src/util/pluginUtils.js +10 -29
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/stubs/defaultConfig.stub.js +2 -2
package/lib/cli/build/index.js
CHANGED
package/lib/cli/build/plugin.js
CHANGED
|
@@ -326,7 +326,11 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
326
326
|
// If you fix it and then save the main CSS file so there's no error
|
|
327
327
|
// The watcher will start watching the imported CSS files and will be
|
|
328
328
|
// resilient to future errors.
|
|
329
|
-
|
|
329
|
+
if (state.watcher) {
|
|
330
|
+
console.error(err);
|
|
331
|
+
} else {
|
|
332
|
+
return Promise.reject(err);
|
|
333
|
+
}
|
|
330
334
|
});
|
|
331
335
|
}
|
|
332
336
|
/**
|
package/lib/corePlugins.js
CHANGED
|
@@ -257,20 +257,8 @@ let variantPlugins = {
|
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
directionVariants: ({ addVariant })=>{
|
|
260
|
-
addVariant("ltr", ()
|
|
261
|
-
|
|
262
|
-
"The RTL features in Tailwind CSS are currently in preview.",
|
|
263
|
-
"Preview features are not covered by semver, and may be improved in breaking ways at any time."
|
|
264
|
-
]);
|
|
265
|
-
return '[dir="ltr"] &';
|
|
266
|
-
});
|
|
267
|
-
addVariant("rtl", ()=>{
|
|
268
|
-
_log.default.warn("rtl-experimental", [
|
|
269
|
-
"The RTL features in Tailwind CSS are currently in preview.",
|
|
270
|
-
"Preview features are not covered by semver, and may be improved in breaking ways at any time."
|
|
271
|
-
]);
|
|
272
|
-
return '[dir="rtl"] &';
|
|
273
|
-
});
|
|
260
|
+
addVariant("ltr", ':is([dir="ltr"] &)');
|
|
261
|
+
addVariant("rtl", ':is([dir="rtl"] &)');
|
|
274
262
|
},
|
|
275
263
|
reducedMotionVariants: ({ addVariant })=>{
|
|
276
264
|
addVariant("motion-safe", "@media (prefers-reduced-motion: no-preference)");
|
|
@@ -287,7 +275,7 @@ let variantPlugins = {
|
|
|
287
275
|
]);
|
|
288
276
|
}
|
|
289
277
|
if (mode === "class") {
|
|
290
|
-
addVariant("dark",
|
|
278
|
+
addVariant("dark", `:is(${className} &)`);
|
|
291
279
|
} else if (mode === "media") {
|
|
292
280
|
addVariant("dark", "@media (prefers-color-scheme: dark)");
|
|
293
281
|
}
|
|
@@ -646,10 +634,7 @@ let corePlugins = {
|
|
|
646
634
|
[
|
|
647
635
|
"inset",
|
|
648
636
|
[
|
|
649
|
-
"
|
|
650
|
-
"right",
|
|
651
|
-
"bottom",
|
|
652
|
-
"left"
|
|
637
|
+
"inset"
|
|
653
638
|
]
|
|
654
639
|
],
|
|
655
640
|
[
|
|
@@ -1805,6 +1790,9 @@ let corePlugins = {
|
|
|
1805
1790
|
},
|
|
1806
1791
|
alignContent: ({ addUtilities })=>{
|
|
1807
1792
|
addUtilities({
|
|
1793
|
+
".content-normal": {
|
|
1794
|
+
"align-content": "normal"
|
|
1795
|
+
},
|
|
1808
1796
|
".content-center": {
|
|
1809
1797
|
"align-content": "center"
|
|
1810
1798
|
},
|
|
@@ -1825,6 +1813,9 @@ let corePlugins = {
|
|
|
1825
1813
|
},
|
|
1826
1814
|
".content-baseline": {
|
|
1827
1815
|
"align-content": "baseline"
|
|
1816
|
+
},
|
|
1817
|
+
".content-stretch": {
|
|
1818
|
+
"align-content": "stretch"
|
|
1828
1819
|
}
|
|
1829
1820
|
});
|
|
1830
1821
|
},
|
package/lib/featureFlags.js
CHANGED
|
@@ -15,6 +15,7 @@ _export(exports, {
|
|
|
15
15
|
});
|
|
16
16
|
const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
|
|
17
17
|
const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
|
|
18
|
+
const _sharedState = require("./lib/sharedState");
|
|
18
19
|
function _interopRequireDefault(obj) {
|
|
19
20
|
return obj && obj.__esModule ? obj : {
|
|
20
21
|
default: obj
|
|
@@ -22,7 +23,13 @@ function _interopRequireDefault(obj) {
|
|
|
22
23
|
}
|
|
23
24
|
let defaults = {
|
|
24
25
|
optimizeUniversalDefaults: false,
|
|
25
|
-
generalizedModifiers: true
|
|
26
|
+
generalizedModifiers: true,
|
|
27
|
+
get disableColorOpacityUtilitiesByDefault () {
|
|
28
|
+
return _sharedState.env.OXIDE;
|
|
29
|
+
},
|
|
30
|
+
get relativeContentPathsByDefault () {
|
|
31
|
+
return _sharedState.env.OXIDE;
|
|
32
|
+
}
|
|
26
33
|
};
|
|
27
34
|
let featureFlags = {
|
|
28
35
|
future: [
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -162,12 +162,12 @@ function applyImportant(matches, classCandidate) {
|
|
|
162
162
|
]
|
|
163
163
|
});
|
|
164
164
|
container.walkRules((r)=>{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
let ast = (0, _postcssSelectorParser.default)().astSync(r.selector);
|
|
166
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
167
|
+
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
168
|
+
// Update all instances of the base candidate to include the important marker
|
|
169
|
+
(0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
|
|
170
|
+
r.selector = ast.toString();
|
|
171
171
|
r.walkDecls((d)=>d.important = true);
|
|
172
172
|
});
|
|
173
173
|
result.push([
|
|
@@ -235,18 +235,21 @@ function applyVariant(variant, matches, context) {
|
|
|
235
235
|
}
|
|
236
236
|
// Register arbitrary variants
|
|
237
237
|
if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
|
|
238
|
+
let sort = context.offsets.recordVariant(variant);
|
|
238
239
|
let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
|
|
239
|
-
|
|
240
|
+
let selectors = (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(selector, ",");
|
|
241
|
+
// We do not support multiple selectors for arbitrary variants
|
|
242
|
+
if (selectors.length > 1) {
|
|
240
243
|
return [];
|
|
241
244
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
sort,
|
|
247
|
-
|
|
248
|
-
]
|
|
249
|
-
|
|
245
|
+
if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
|
|
246
|
+
return [];
|
|
247
|
+
}
|
|
248
|
+
let records = selectors.map((sel, idx)=>[
|
|
249
|
+
context.offsets.applyParallelOffset(sort, idx),
|
|
250
|
+
(0, _setupContextUtils.parseVariant)(sel.trim())
|
|
251
|
+
]);
|
|
252
|
+
context.variantMap.set(variant, records);
|
|
250
253
|
}
|
|
251
254
|
if (context.variantMap.has(variant)) {
|
|
252
255
|
let isArbitraryVariant = isArbitraryValue(variant);
|
|
@@ -895,14 +895,22 @@ function registerPlugins(plugins, context) {
|
|
|
895
895
|
prefix(context, "peer")
|
|
896
896
|
];
|
|
897
897
|
context.getClassOrder = function getClassOrder(classes) {
|
|
898
|
+
// Sort classes so they're ordered in a deterministic manner
|
|
899
|
+
let sorted = [
|
|
900
|
+
...classes
|
|
901
|
+
].sort((a, z)=>{
|
|
902
|
+
if (a === z) return 0;
|
|
903
|
+
if (a < z) return -1;
|
|
904
|
+
return 1;
|
|
905
|
+
});
|
|
898
906
|
// Non-util classes won't be generated, so we default them to null
|
|
899
|
-
let sortedClassNames = new Map(
|
|
907
|
+
let sortedClassNames = new Map(sorted.map((className)=>[
|
|
900
908
|
className,
|
|
901
909
|
null
|
|
902
910
|
]));
|
|
903
911
|
// Sort all classes in order
|
|
904
912
|
// Non-tailwind classes won't be generated and will be left as `null`
|
|
905
|
-
let rules = (0, _generateRules.generateRules)(new Set(
|
|
913
|
+
let rules = (0, _generateRules.generateRules)(new Set(sorted), context);
|
|
906
914
|
rules = context.offsets.sort(rules);
|
|
907
915
|
let idx = BigInt(parasiteUtilities.length);
|
|
908
916
|
for (const [, rule] of rules){
|
|
@@ -323,7 +323,11 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
323
323
|
// If you fix it and then save the main CSS file so there's no error
|
|
324
324
|
// The watcher will start watching the imported CSS files and will be
|
|
325
325
|
// resilient to future errors.
|
|
326
|
-
|
|
326
|
+
if (state.watcher) {
|
|
327
|
+
console.error(err);
|
|
328
|
+
} else {
|
|
329
|
+
return Promise.reject(err);
|
|
330
|
+
}
|
|
327
331
|
});
|
|
328
332
|
}
|
|
329
333
|
/**
|
|
@@ -10,6 +10,7 @@ function _export(target, all) {
|
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
12
|
formatVariantSelector: ()=>formatVariantSelector,
|
|
13
|
+
eliminateIrrelevantSelectors: ()=>eliminateIrrelevantSelectors,
|
|
13
14
|
finalizeSelector: ()=>finalizeSelector,
|
|
14
15
|
handleMergePseudo: ()=>handleMergePseudo
|
|
15
16
|
});
|
|
@@ -98,18 +99,7 @@ function formatVariantSelector(formats, { context , candidate }) {
|
|
|
98
99
|
});
|
|
99
100
|
return sel;
|
|
100
101
|
}
|
|
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) {
|
|
102
|
+
function eliminateIrrelevantSelectors(sel, base) {
|
|
113
103
|
let hasClassesMatchingCandidate = false;
|
|
114
104
|
sel.walk((child)=>{
|
|
115
105
|
if (child.type === "class" && child.value === base) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "normalizeConfig", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>normalizeConfig
|
|
8
8
|
});
|
|
9
|
+
const _featureFlags = require("../featureFlags");
|
|
9
10
|
const _log = /*#__PURE__*/ _interopRequireWildcard(require("./log"));
|
|
10
11
|
function _getRequireWildcardCache(nodeInterop) {
|
|
11
12
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -191,13 +192,11 @@ function normalizeConfig(config) {
|
|
|
191
192
|
// Normalize the `content`
|
|
192
193
|
config.content = {
|
|
193
194
|
relative: (()=>{
|
|
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
|
-
|
|
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;
|
|
199
|
+
return (0, _featureFlags.flagEnabled)(config, "relativeContentPathsByDefault");
|
|
201
200
|
})(),
|
|
202
201
|
files: (()=>{
|
|
203
202
|
let { content , purge } = config;
|
package/lib/util/pluginUtils.js
CHANGED
|
@@ -10,7 +10,6 @@ function _export(target, all) {
|
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
12
|
updateAllClasses: ()=>updateAllClasses,
|
|
13
|
-
filterSelectorsForClass: ()=>filterSelectorsForClass,
|
|
14
13
|
asValue: ()=>asValue,
|
|
15
14
|
parseColorFormat: ()=>parseColorFormat,
|
|
16
15
|
asColor: ()=>asColor,
|
|
@@ -19,7 +18,6 @@ _export(exports, {
|
|
|
19
18
|
coerceValue: ()=>coerceValue,
|
|
20
19
|
getMatchingTypes: ()=>getMatchingTypes
|
|
21
20
|
});
|
|
22
|
-
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
23
21
|
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
24
22
|
const _withAlphaVariable = require("./withAlphaVariable");
|
|
25
23
|
const _dataTypes = require("./dataTypes");
|
|
@@ -32,29 +30,12 @@ function _interopRequireDefault(obj) {
|
|
|
32
30
|
};
|
|
33
31
|
}
|
|
34
32
|
function updateAllClasses(selectors, updateClass) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sel.value =
|
|
39
|
-
|
|
40
|
-
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
let result = parser.processSync(selectors);
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
function filterSelectorsForClass(selectors, classCandidate) {
|
|
48
|
-
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
49
|
-
selectors.each((sel)=>{
|
|
50
|
-
const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
|
|
51
|
-
if (!containsClass) {
|
|
52
|
-
sel.remove();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
33
|
+
selectors.walkClasses((sel)=>{
|
|
34
|
+
sel.value = updateClass(sel.value);
|
|
35
|
+
if (sel.raws && sel.raws.value) {
|
|
36
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
37
|
+
}
|
|
55
38
|
});
|
|
56
|
-
let result = parser.processSync(selectors);
|
|
57
|
-
return result;
|
|
58
39
|
}
|
|
59
40
|
function resolveArbitraryValue(modifier, validate) {
|
|
60
41
|
if (!isArbitraryValue(modifier)) {
|
|
@@ -24,14 +24,20 @@ function splitAtTopLevelOnly(input, separator) {
|
|
|
24
24
|
let stack = [];
|
|
25
25
|
let parts = [];
|
|
26
26
|
let lastPos = 0;
|
|
27
|
+
let isEscaped = false;
|
|
27
28
|
for(let idx = 0; idx < input.length; idx++){
|
|
28
29
|
let char = input[idx];
|
|
29
|
-
if (stack.length === 0 && char === separator[0]) {
|
|
30
|
+
if (stack.length === 0 && char === separator[0] && !isEscaped) {
|
|
30
31
|
if (separator.length === 1 || input.slice(idx, idx + separator.length) === separator) {
|
|
31
32
|
parts.push(input.slice(lastPos, idx));
|
|
32
33
|
lastPos = idx + separator.length;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
if (isEscaped) {
|
|
37
|
+
isEscaped = false;
|
|
38
|
+
} else if (char === "\\") {
|
|
39
|
+
isEscaped = true;
|
|
40
|
+
}
|
|
35
41
|
if (char === "(" || char === "[" || char === "{") {
|
|
36
42
|
stack.push(char);
|
|
37
43
|
} else if (char === ")" && stack[stack.length - 1] === "(" || char === "]" && stack[stack.length - 1] === "[" || char === "}" && stack[stack.length - 1] === "{") {
|
package/package.json
CHANGED
package/src/cli/build/index.js
CHANGED
package/src/cli/build/plugin.js
CHANGED
|
@@ -383,7 +383,11 @@ export async function createProcessor(args, cliConfigPath) {
|
|
|
383
383
|
// The watcher will start watching the imported CSS files and will be
|
|
384
384
|
// resilient to future errors.
|
|
385
385
|
|
|
386
|
-
|
|
386
|
+
if (state.watcher) {
|
|
387
|
+
console.error(err)
|
|
388
|
+
} else {
|
|
389
|
+
return Promise.reject(err)
|
|
390
|
+
}
|
|
387
391
|
}
|
|
388
392
|
)
|
|
389
393
|
}
|
package/src/corePlugins.js
CHANGED
|
@@ -199,23 +199,8 @@ export let variantPlugins = {
|
|
|
199
199
|
},
|
|
200
200
|
|
|
201
201
|
directionVariants: ({ addVariant }) => {
|
|
202
|
-
addVariant('ltr', ()
|
|
203
|
-
|
|
204
|
-
'The RTL features in Tailwind CSS are currently in preview.',
|
|
205
|
-
'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
|
|
206
|
-
])
|
|
207
|
-
|
|
208
|
-
return '[dir="ltr"] &'
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
addVariant('rtl', () => {
|
|
212
|
-
log.warn('rtl-experimental', [
|
|
213
|
-
'The RTL features in Tailwind CSS are currently in preview.',
|
|
214
|
-
'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
|
|
215
|
-
])
|
|
216
|
-
|
|
217
|
-
return '[dir="rtl"] &'
|
|
218
|
-
})
|
|
202
|
+
addVariant('ltr', ':is([dir="ltr"] &)')
|
|
203
|
+
addVariant('rtl', ':is([dir="rtl"] &)')
|
|
219
204
|
},
|
|
220
205
|
|
|
221
206
|
reducedMotionVariants: ({ addVariant }) => {
|
|
@@ -236,7 +221,7 @@ export let variantPlugins = {
|
|
|
236
221
|
}
|
|
237
222
|
|
|
238
223
|
if (mode === 'class') {
|
|
239
|
-
addVariant('dark',
|
|
224
|
+
addVariant('dark', `:is(${className} &)`)
|
|
240
225
|
} else if (mode === 'media') {
|
|
241
226
|
addVariant('dark', '@media (prefers-color-scheme: dark)')
|
|
242
227
|
}
|
|
@@ -641,7 +626,7 @@ export let corePlugins = {
|
|
|
641
626
|
inset: createUtilityPlugin(
|
|
642
627
|
'inset',
|
|
643
628
|
[
|
|
644
|
-
['inset', ['
|
|
629
|
+
['inset', ['inset']],
|
|
645
630
|
[
|
|
646
631
|
['inset-x', ['left', 'right']],
|
|
647
632
|
['inset-y', ['top', 'bottom']],
|
|
@@ -1196,6 +1181,7 @@ export let corePlugins = {
|
|
|
1196
1181
|
|
|
1197
1182
|
alignContent: ({ addUtilities }) => {
|
|
1198
1183
|
addUtilities({
|
|
1184
|
+
'.content-normal': { 'align-content': 'normal' },
|
|
1199
1185
|
'.content-center': { 'align-content': 'center' },
|
|
1200
1186
|
'.content-start': { 'align-content': 'flex-start' },
|
|
1201
1187
|
'.content-end': { 'align-content': 'flex-end' },
|
|
@@ -1203,6 +1189,7 @@ export let corePlugins = {
|
|
|
1203
1189
|
'.content-around': { 'align-content': 'space-around' },
|
|
1204
1190
|
'.content-evenly': { 'align-content': 'space-evenly' },
|
|
1205
1191
|
'.content-baseline': { 'align-content': 'baseline' },
|
|
1192
|
+
'.content-stretch': { 'align-content': 'stretch' },
|
|
1206
1193
|
})
|
|
1207
1194
|
},
|
|
1208
1195
|
|
package/src/featureFlags.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import colors from 'picocolors'
|
|
2
2
|
import log from './util/log'
|
|
3
|
+
import { env } from './lib/sharedState'
|
|
3
4
|
|
|
4
5
|
let defaults = {
|
|
5
6
|
optimizeUniversalDefaults: false,
|
|
6
7
|
generalizedModifiers: true,
|
|
8
|
+
get disableColorOpacityUtilitiesByDefault() {
|
|
9
|
+
return env.OXIDE
|
|
10
|
+
},
|
|
11
|
+
get relativeContentPathsByDefault() {
|
|
12
|
+
return env.OXIDE
|
|
13
|
+
},
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
let featureFlags = {
|
package/src/lib/generateRules.js
CHANGED
|
@@ -3,10 +3,14 @@ import selectorParser from 'postcss-selector-parser'
|
|
|
3
3
|
import parseObjectStyles from '../util/parseObjectStyles'
|
|
4
4
|
import isPlainObject from '../util/isPlainObject'
|
|
5
5
|
import prefixSelector from '../util/prefixSelector'
|
|
6
|
-
import { updateAllClasses,
|
|
6
|
+
import { updateAllClasses, getMatchingTypes } from '../util/pluginUtils'
|
|
7
7
|
import log from '../util/log'
|
|
8
8
|
import * as sharedState from './sharedState'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
formatVariantSelector,
|
|
11
|
+
finalizeSelector,
|
|
12
|
+
eliminateIrrelevantSelectors,
|
|
13
|
+
} from '../util/formatVariantSelector'
|
|
10
14
|
import { asClass } from '../util/nameClass'
|
|
11
15
|
import { normalize } from '../util/dataTypes'
|
|
12
16
|
import { isValidVariantFormatString, parseVariant } from './setupContextUtils'
|
|
@@ -111,22 +115,28 @@ function applyImportant(matches, classCandidate) {
|
|
|
111
115
|
if (matches.length === 0) {
|
|
112
116
|
return matches
|
|
113
117
|
}
|
|
118
|
+
|
|
114
119
|
let result = []
|
|
115
120
|
|
|
116
121
|
for (let [meta, rule] of matches) {
|
|
117
122
|
let container = postcss.root({ nodes: [rule.clone()] })
|
|
123
|
+
|
|
118
124
|
container.walkRules((r) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
125
|
+
let ast = selectorParser().astSync(r.selector)
|
|
126
|
+
|
|
127
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
128
|
+
ast.each((sel) => eliminateIrrelevantSelectors(sel, classCandidate))
|
|
129
|
+
|
|
130
|
+
// Update all instances of the base candidate to include the important marker
|
|
131
|
+
updateAllClasses(ast, (className) =>
|
|
132
|
+
className === classCandidate ? `!${className}` : className
|
|
127
133
|
)
|
|
134
|
+
|
|
135
|
+
r.selector = ast.toString()
|
|
136
|
+
|
|
128
137
|
r.walkDecls((d) => (d.important = true))
|
|
129
138
|
})
|
|
139
|
+
|
|
130
140
|
result.push([{ ...meta, important: true }, container.nodes[0]])
|
|
131
141
|
}
|
|
132
142
|
|
|
@@ -195,17 +205,26 @@ function applyVariant(variant, matches, context) {
|
|
|
195
205
|
|
|
196
206
|
// Register arbitrary variants
|
|
197
207
|
if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
|
|
208
|
+
let sort = context.offsets.recordVariant(variant)
|
|
209
|
+
|
|
198
210
|
let selector = normalize(variant.slice(1, -1))
|
|
211
|
+
let selectors = splitAtTopLevelOnly(selector, ',')
|
|
199
212
|
|
|
200
|
-
|
|
213
|
+
// We do not support multiple selectors for arbitrary variants
|
|
214
|
+
if (selectors.length > 1) {
|
|
201
215
|
return []
|
|
202
216
|
}
|
|
203
217
|
|
|
204
|
-
|
|
218
|
+
if (!selectors.every(isValidVariantFormatString)) {
|
|
219
|
+
return []
|
|
220
|
+
}
|
|
205
221
|
|
|
206
|
-
let
|
|
222
|
+
let records = selectors.map((sel, idx) => [
|
|
223
|
+
context.offsets.applyParallelOffset(sort, idx),
|
|
224
|
+
parseVariant(sel.trim()),
|
|
225
|
+
])
|
|
207
226
|
|
|
208
|
-
context.variantMap.set(variant,
|
|
227
|
+
context.variantMap.set(variant, records)
|
|
209
228
|
}
|
|
210
229
|
|
|
211
230
|
if (context.variantMap.has(variant)) {
|
|
@@ -931,12 +931,19 @@ function registerPlugins(plugins, context) {
|
|
|
931
931
|
prefix(context, 'peer'),
|
|
932
932
|
]
|
|
933
933
|
context.getClassOrder = function getClassOrder(classes) {
|
|
934
|
+
// Sort classes so they're ordered in a deterministic manner
|
|
935
|
+
let sorted = [...classes].sort((a, z) => {
|
|
936
|
+
if (a === z) return 0
|
|
937
|
+
if (a < z) return -1
|
|
938
|
+
return 1
|
|
939
|
+
})
|
|
940
|
+
|
|
934
941
|
// Non-util classes won't be generated, so we default them to null
|
|
935
|
-
let sortedClassNames = new Map(
|
|
942
|
+
let sortedClassNames = new Map(sorted.map((className) => [className, null]))
|
|
936
943
|
|
|
937
944
|
// Sort all classes in order
|
|
938
945
|
// Non-tailwind classes won't be generated and will be left as `null`
|
|
939
|
-
let rules = generateRules(new Set(
|
|
946
|
+
let rules = generateRules(new Set(sorted), context)
|
|
940
947
|
rules = context.offsets.sort(rules)
|
|
941
948
|
|
|
942
949
|
let idx = BigInt(parasiteUtilities.length)
|
|
@@ -380,7 +380,11 @@ export async function createProcessor(args, cliConfigPath) {
|
|
|
380
380
|
// The watcher will start watching the imported CSS files and will be
|
|
381
381
|
// resilient to future errors.
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
if (state.watcher) {
|
|
384
|
+
console.error(err)
|
|
385
|
+
} else {
|
|
386
|
+
return Promise.reject(err)
|
|
387
|
+
}
|
|
384
388
|
}
|
|
385
389
|
)
|
|
386
390
|
}
|
|
@@ -120,7 +120,7 @@ function resortSelector(sel) {
|
|
|
120
120
|
* @param {Selector} ast
|
|
121
121
|
* @param {string} base
|
|
122
122
|
*/
|
|
123
|
-
function eliminateIrrelevantSelectors(sel, base) {
|
|
123
|
+
export function eliminateIrrelevantSelectors(sel, base) {
|
|
124
124
|
let hasClassesMatchingCandidate = false
|
|
125
125
|
|
|
126
126
|
sel.walk((child) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { flagEnabled } from '../featureFlags'
|
|
1
2
|
import log, { dim } from './log'
|
|
2
3
|
|
|
3
4
|
export function normalizeConfig(config) {
|
|
@@ -189,7 +190,7 @@ export function normalizeConfig(config) {
|
|
|
189
190
|
return content.relative
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
return config
|
|
193
|
+
return flagEnabled(config, 'relativeContentPathsByDefault')
|
|
193
194
|
})(),
|
|
194
195
|
|
|
195
196
|
files: (() => {
|
package/src/util/pluginUtils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import selectorParser from 'postcss-selector-parser'
|
|
2
1
|
import escapeCommas from './escapeCommas'
|
|
3
2
|
import { withAlphaValue } from './withAlphaVariable'
|
|
4
3
|
import {
|
|
@@ -21,37 +20,19 @@ import negateValue from './negateValue'
|
|
|
21
20
|
import { backgroundSize } from './validateFormalSyntax'
|
|
22
21
|
import { flagEnabled } from '../featureFlags.js'
|
|
23
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('postcss-selector-parser').Container} selectors
|
|
25
|
+
* @param {(className: string) => string} updateClass
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
24
28
|
export function updateAllClasses(selectors, updateClass) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let updatedClass = updateClass(sel.value)
|
|
28
|
-
sel.value = updatedClass
|
|
29
|
-
if (sel.raws && sel.raws.value) {
|
|
30
|
-
sel.raws.value = escapeCommas(sel.raws.value)
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
let result = parser.processSync(selectors)
|
|
29
|
+
selectors.walkClasses((sel) => {
|
|
30
|
+
sel.value = updateClass(sel.value)
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export function filterSelectorsForClass(selectors, classCandidate) {
|
|
41
|
-
let parser = selectorParser((selectors) => {
|
|
42
|
-
selectors.each((sel) => {
|
|
43
|
-
const containsClass = sel.nodes.some(
|
|
44
|
-
(node) => node.type === 'class' && node.value === classCandidate
|
|
45
|
-
)
|
|
46
|
-
if (!containsClass) {
|
|
47
|
-
sel.remove()
|
|
48
|
-
}
|
|
49
|
-
})
|
|
32
|
+
if (sel.raws && sel.raws.value) {
|
|
33
|
+
sel.raws.value = escapeCommas(sel.raws.value)
|
|
34
|
+
}
|
|
50
35
|
})
|
|
51
|
-
|
|
52
|
-
let result = parser.processSync(selectors)
|
|
53
|
-
|
|
54
|
-
return result
|
|
55
36
|
}
|
|
56
37
|
|
|
57
38
|
function resolveArbitraryValue(modifier, validate) {
|
|
@@ -17,17 +17,24 @@ export function splitAtTopLevelOnly(input, separator) {
|
|
|
17
17
|
let stack = []
|
|
18
18
|
let parts = []
|
|
19
19
|
let lastPos = 0
|
|
20
|
+
let isEscaped = false
|
|
20
21
|
|
|
21
22
|
for (let idx = 0; idx < input.length; idx++) {
|
|
22
23
|
let char = input[idx]
|
|
23
24
|
|
|
24
|
-
if (stack.length === 0 && char === separator[0]) {
|
|
25
|
+
if (stack.length === 0 && char === separator[0] && !isEscaped) {
|
|
25
26
|
if (separator.length === 1 || input.slice(idx, idx + separator.length) === separator) {
|
|
26
27
|
parts.push(input.slice(lastPos, idx))
|
|
27
28
|
lastPos = idx + separator.length
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
if (isEscaped) {
|
|
33
|
+
isEscaped = false
|
|
34
|
+
} else if (char === '\\') {
|
|
35
|
+
isEscaped = true
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
if (char === '(' || char === '[' || char === '{') {
|
|
32
39
|
stack.push(char)
|
|
33
40
|
} else if (
|
|
@@ -879,8 +879,8 @@ module.exports = {
|
|
|
879
879
|
none: 'none',
|
|
880
880
|
all: 'all',
|
|
881
881
|
DEFAULT:
|
|
882
|
-
'color, background-color, border-color,
|
|
883
|
-
colors: 'color, background-color, border-color,
|
|
882
|
+
'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
|
|
883
|
+
colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
|
|
884
884
|
opacity: 'opacity',
|
|
885
885
|
shadow: 'box-shadow',
|
|
886
886
|
transform: 'transform',
|