tailwindcss 0.0.0-insiders.d6301bd → 0.0.0-insiders.e2d5f21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -3
- package/lib/cli.js +60 -60
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +4 -0
- package/lib/corePlugins.js +157 -54
- package/lib/css/preflight.css +2 -1
- package/lib/featureFlags.js +3 -3
- package/lib/lib/collapseDuplicateDeclarations.js +2 -2
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +9 -5
- package/lib/lib/expandApplyAtRules.js +7 -7
- package/lib/lib/expandTailwindAtRules.js +2 -0
- package/lib/lib/generateRules.js +46 -10
- package/lib/lib/resolveDefaultsAtRules.js +2 -2
- package/lib/lib/setupContextUtils.js +15 -72
- package/lib/lib/sharedState.js +1 -1
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/createUtilityPlugin.js +2 -2
- package/lib/util/dataTypes.js +23 -3
- package/lib/util/formatVariantSelector.js +93 -9
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/nameClass.js +1 -0
- package/lib/util/normalizeConfig.js +7 -7
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +12 -11
- package/lib/util/resolveConfig.js +8 -8
- package/package.json +10 -10
- package/peers/index.js +3772 -3072
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +143 -61
- package/src/css/preflight.css +2 -1
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +2 -0
- package/src/lib/generateRules.js +34 -0
- package/src/lib/setupContextUtils.js +6 -58
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/dataTypes.js +19 -3
- package/src/util/formatVariantSelector.js +92 -1
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +2 -0
- package/stubs/defaultConfig.stub.js +25 -9
|
@@ -23,6 +23,7 @@ var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
|
23
23
|
var _toPath = require("../util/toPath");
|
|
24
24
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
25
|
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
26
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
26
27
|
function _interopRequireDefault(obj) {
|
|
27
28
|
return obj && obj.__esModule ? obj : {
|
|
28
29
|
default: obj
|
|
@@ -160,68 +161,6 @@ function withIdentifiers(styles) {
|
|
|
160
161
|
});
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
|
-
let matchingBrackets = new Map([
|
|
164
|
-
[
|
|
165
|
-
'{',
|
|
166
|
-
'}'
|
|
167
|
-
],
|
|
168
|
-
[
|
|
169
|
-
'[',
|
|
170
|
-
']'
|
|
171
|
-
],
|
|
172
|
-
[
|
|
173
|
-
'(',
|
|
174
|
-
')'
|
|
175
|
-
],
|
|
176
|
-
]);
|
|
177
|
-
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
178
|
-
v,
|
|
179
|
-
k
|
|
180
|
-
]
|
|
181
|
-
));
|
|
182
|
-
let quotes = new Set([
|
|
183
|
-
'"',
|
|
184
|
-
"'",
|
|
185
|
-
'`'
|
|
186
|
-
]);
|
|
187
|
-
// Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
188
|
-
// values don't count, and brackets inside quotes also don't count.
|
|
189
|
-
//
|
|
190
|
-
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
191
|
-
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
192
|
-
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
193
|
-
function isValidArbitraryValue(value) {
|
|
194
|
-
let stack = [];
|
|
195
|
-
let inQuotes = false;
|
|
196
|
-
for(let i = 0; i < value.length; i++){
|
|
197
|
-
let char = value[i];
|
|
198
|
-
// Non-escaped quotes allow us to "allow" anything in between
|
|
199
|
-
if (quotes.has(char) && value[i - 1] !== '\\') {
|
|
200
|
-
inQuotes = !inQuotes;
|
|
201
|
-
}
|
|
202
|
-
if (inQuotes) continue;
|
|
203
|
-
if (value[i - 1] === '\\') continue; // Escaped
|
|
204
|
-
if (matchingBrackets.has(char)) {
|
|
205
|
-
stack.push(char);
|
|
206
|
-
} else if (inverseMatchingBrackets.has(char)) {
|
|
207
|
-
let inverse = inverseMatchingBrackets.get(char);
|
|
208
|
-
// Nothing to pop from, therefore it is unbalanced
|
|
209
|
-
if (stack.length <= 0) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
// Popped value must match the inverse value, otherwise it is unbalanced
|
|
213
|
-
if (stack.pop() !== inverse) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// If there is still something on the stack, it is also unbalanced
|
|
219
|
-
if (stack.length > 0) {
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
// All good, totally balanced!
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
164
|
function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
226
165
|
function getConfigValue(path, defaultValue) {
|
|
227
166
|
return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
@@ -409,7 +348,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
409
348
|
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
410
349
|
return [];
|
|
411
350
|
}
|
|
412
|
-
if (!
|
|
351
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
413
352
|
return [];
|
|
414
353
|
}
|
|
415
354
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -466,7 +405,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
466
405
|
return [];
|
|
467
406
|
}
|
|
468
407
|
}
|
|
469
|
-
if (!
|
|
408
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
470
409
|
return [];
|
|
471
410
|
}
|
|
472
411
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -608,7 +547,8 @@ function resolvePlugins(context, root) {
|
|
|
608
547
|
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
609
548
|
_corePlugins.variantPlugins['darkVariants'],
|
|
610
549
|
_corePlugins.variantPlugins['printVariant'],
|
|
611
|
-
_corePlugins.variantPlugins['screenVariants'],
|
|
550
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
551
|
+
_corePlugins.variantPlugins['orientationVariants'],
|
|
612
552
|
];
|
|
613
553
|
return [
|
|
614
554
|
...corePluginList,
|
|
@@ -652,6 +592,9 @@ function registerPlugins(plugins, context) {
|
|
|
652
592
|
offsets.user,
|
|
653
593
|
]);
|
|
654
594
|
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
595
|
+
// A number one less than the top range of the highest offset area
|
|
596
|
+
// so arbitrary properties are always sorted at the end.
|
|
597
|
+
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
655
598
|
context.layerOrder = {
|
|
656
599
|
base: 1n << reservedBits << 0n,
|
|
657
600
|
components: 1n << reservedBits << 1n,
|
|
@@ -674,9 +617,9 @@ function registerPlugins(plugins, context) {
|
|
|
674
617
|
...context.variantOrder.values()
|
|
675
618
|
].shift();
|
|
676
619
|
// Build variantMap
|
|
677
|
-
for (let [variantName,
|
|
620
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
678
621
|
let sort = context.variantOrder.get(variantName);
|
|
679
|
-
context.variantMap.set(variantName,
|
|
622
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
680
623
|
sort << BigInt(idx),
|
|
681
624
|
variantFunction
|
|
682
625
|
]
|
|
@@ -686,22 +629,22 @@ function registerPlugins(plugins, context) {
|
|
|
686
629
|
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
687
630
|
if (safelist.length > 0) {
|
|
688
631
|
let checks = [];
|
|
689
|
-
for (let
|
|
690
|
-
if (typeof
|
|
632
|
+
for (let value1 of safelist){
|
|
633
|
+
if (typeof value1 === 'string') {
|
|
691
634
|
context.changedContent.push({
|
|
692
|
-
content:
|
|
635
|
+
content: value1,
|
|
693
636
|
extension: 'html'
|
|
694
637
|
});
|
|
695
638
|
continue;
|
|
696
639
|
}
|
|
697
|
-
if (
|
|
640
|
+
if (value1 instanceof RegExp) {
|
|
698
641
|
_log.default.warn('root-regex', [
|
|
699
642
|
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
700
643
|
'Update your `safelist` configuration to eliminate this warning.'
|
|
701
644
|
]);
|
|
702
645
|
continue;
|
|
703
646
|
}
|
|
704
|
-
checks.push(
|
|
647
|
+
checks.push(value1);
|
|
705
648
|
}
|
|
706
649
|
if (checks.length > 0) {
|
|
707
650
|
let patternMatchingCount = new Map();
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.contextSourcesMap = exports.configContextMap = exports.
|
|
5
|
+
exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
|
|
6
6
|
const env = {
|
|
7
7
|
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
8
8
|
NODE_ENV: process.env.NODE_ENV,
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = _default;
|
|
6
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
6
7
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
7
8
|
function _interopRequireDefault(obj) {
|
|
8
9
|
return obj && obj.__esModule ? obj : {
|
|
@@ -12,13 +13,15 @@ function _interopRequireDefault(obj) {
|
|
|
12
13
|
function _default({ tailwindConfig: { theme } }) {
|
|
13
14
|
return function(css) {
|
|
14
15
|
css.walkAtRules('screen', (atRule)=>{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let screen = atRule.params;
|
|
17
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
|
|
18
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
+
);
|
|
20
|
+
if (!screenDefinition) {
|
|
18
21
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
19
22
|
}
|
|
20
23
|
atRule.name = 'media';
|
|
21
|
-
atRule.params = (0, _buildMediaQuery).default(
|
|
24
|
+
atRule.params = (0, _buildMediaQuery).default(screenDefinition);
|
|
22
25
|
});
|
|
23
26
|
};
|
|
24
27
|
}
|
|
@@ -4,28 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = buildMediaQuery;
|
|
6
6
|
function buildMediaQuery(screens) {
|
|
7
|
-
|
|
8
|
-
screens
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return screen.raw;
|
|
21
|
-
}
|
|
22
|
-
return Object.entries(screen).map(([feature, value])=>{
|
|
23
|
-
var _feature;
|
|
24
|
-
feature = (_feature = ({
|
|
25
|
-
min: 'min-width',
|
|
26
|
-
max: 'max-width'
|
|
27
|
-
})[feature]) !== null && _feature !== void 0 ? _feature : feature;
|
|
28
|
-
return `(${feature}: ${value})`;
|
|
29
|
-
}).join(' and ');
|
|
30
|
-
}).join(', ');
|
|
7
|
+
screens = Array.isArray(screens) ? screens : [
|
|
8
|
+
screens
|
|
9
|
+
];
|
|
10
|
+
return screens.map((screen1)=>screen1.values.map((screen)=>{
|
|
11
|
+
if (screen.raw !== undefined) {
|
|
12
|
+
return screen.raw;
|
|
13
|
+
}
|
|
14
|
+
return [
|
|
15
|
+
screen.min && `(min-width: ${screen.min})`,
|
|
16
|
+
screen.max && `(max-width: ${screen.max})`,
|
|
17
|
+
].filter(Boolean).join(' and ');
|
|
18
|
+
})
|
|
19
|
+
).join(', ');
|
|
31
20
|
}
|
|
@@ -25,8 +25,8 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
25
25
|
utilityVariation
|
|
26
26
|
];
|
|
27
27
|
var ref;
|
|
28
|
-
matchUtilities(group.reduce((
|
|
29
|
-
return Object.assign(
|
|
28
|
+
matchUtilities(group.reduce((obj1, [classPrefix, properties])=>{
|
|
29
|
+
return Object.assign(obj1, {
|
|
30
30
|
[classPrefix]: (value)=>{
|
|
31
31
|
return properties.reduce((obj, name)=>{
|
|
32
32
|
if (Array.isArray(name)) {
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.number = number;
|
|
|
8
8
|
exports.percentage = percentage;
|
|
9
9
|
exports.length = length;
|
|
10
10
|
exports.lineWidth = lineWidth;
|
|
11
|
+
exports.shadow = shadow;
|
|
11
12
|
exports.color = color;
|
|
12
13
|
exports.image = image;
|
|
13
14
|
exports.gradient = gradient;
|
|
@@ -17,6 +18,13 @@ exports.genericName = genericName;
|
|
|
17
18
|
exports.absoluteSize = absoluteSize;
|
|
18
19
|
exports.relativeSize = relativeSize;
|
|
19
20
|
var _color = require("./color");
|
|
21
|
+
var _parseBoxShadowValue = require("./parseBoxShadowValue");
|
|
22
|
+
let cssFunctions = [
|
|
23
|
+
'min',
|
|
24
|
+
'max',
|
|
25
|
+
'clamp',
|
|
26
|
+
'calc'
|
|
27
|
+
];
|
|
20
28
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
21
29
|
let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
22
30
|
;
|
|
@@ -47,10 +55,12 @@ function url(value) {
|
|
|
47
55
|
return value.startsWith('url(');
|
|
48
56
|
}
|
|
49
57
|
function number(value) {
|
|
50
|
-
return !isNaN(Number(value))
|
|
58
|
+
return !isNaN(Number(value)) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?`).test(value)
|
|
59
|
+
);
|
|
51
60
|
}
|
|
52
61
|
function percentage(value) {
|
|
53
|
-
return /%$/g.test(value) ||
|
|
62
|
+
return /%$/g.test(value) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?%`).test(value)
|
|
63
|
+
);
|
|
54
64
|
}
|
|
55
65
|
let lengthUnits = [
|
|
56
66
|
'cm',
|
|
@@ -72,7 +82,8 @@ let lengthUnits = [
|
|
|
72
82
|
];
|
|
73
83
|
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`;
|
|
74
84
|
function length(value) {
|
|
75
|
-
return new RegExp(`${lengthUnitsPattern}$`).test(value) || new RegExp(
|
|
85
|
+
return value === '0' || new RegExp(`${lengthUnitsPattern}$`).test(value) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(value)
|
|
86
|
+
);
|
|
76
87
|
}
|
|
77
88
|
let lineWidths = new Set([
|
|
78
89
|
'thin',
|
|
@@ -82,6 +93,15 @@ let lineWidths = new Set([
|
|
|
82
93
|
function lineWidth(value) {
|
|
83
94
|
return lineWidths.has(value);
|
|
84
95
|
}
|
|
96
|
+
function shadow(value) {
|
|
97
|
+
let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
|
|
98
|
+
for (let parsedShadow of parsedShadows){
|
|
99
|
+
if (!parsedShadow.valid) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
85
105
|
function color(value) {
|
|
86
106
|
let colors = 0;
|
|
87
107
|
let result = value.split(UNDERSCORE).every((part)=>{
|
|
@@ -37,10 +37,19 @@ function formatVariantSelector(current, ...others) {
|
|
|
37
37
|
}
|
|
38
38
|
return current;
|
|
39
39
|
}
|
|
40
|
-
function finalizeSelector(format, { selector , candidate , context }) {
|
|
40
|
+
function finalizeSelector(format, { selector: selector1 , candidate , context }) {
|
|
41
41
|
var ref, ref1;
|
|
42
42
|
var ref2;
|
|
43
|
-
let
|
|
43
|
+
let separator = (ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ':';
|
|
44
|
+
// Split by the separator, but ignore the separator inside square brackets:
|
|
45
|
+
//
|
|
46
|
+
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
47
|
+
// ┬ ┬ ┬ ┬
|
|
48
|
+
// │ │ │ ╰── We will not split here
|
|
49
|
+
// ╰──┴─────┴─────────────── We will split here
|
|
50
|
+
//
|
|
51
|
+
let splitter = new RegExp(`\\${separator}(?![^[]*\\])`);
|
|
52
|
+
let base = candidate.split(splitter).pop();
|
|
44
53
|
if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
|
|
45
54
|
format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
|
|
46
55
|
}
|
|
@@ -56,29 +65,104 @@ function finalizeSelector(format, { selector , candidate , context }) {
|
|
|
56
65
|
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
57
66
|
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
58
67
|
//
|
|
59
|
-
|
|
68
|
+
selector1 = (0, _postcssSelectorParser).default((selectors)=>{
|
|
60
69
|
return selectors.walkClasses((node)=>{
|
|
61
70
|
if (node.raws && node.value.includes(base)) {
|
|
62
71
|
node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
|
|
63
72
|
}
|
|
64
73
|
return node;
|
|
65
74
|
});
|
|
66
|
-
}).processSync(
|
|
75
|
+
}).processSync(selector1);
|
|
67
76
|
// We can safely replace the escaped base now, since the `base` section is
|
|
68
77
|
// now in a normalized escaped value.
|
|
69
|
-
|
|
78
|
+
selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
|
|
70
79
|
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
71
80
|
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
72
|
-
return selectors.map((
|
|
73
|
-
|
|
81
|
+
return selectors.map((selector2)=>{
|
|
82
|
+
selector2.walkPseudos((p)=>{
|
|
74
83
|
if (selectorFunctions.has(p.value)) {
|
|
75
84
|
p.replaceWith(p.nodes);
|
|
76
85
|
}
|
|
77
86
|
return p;
|
|
78
87
|
});
|
|
79
|
-
|
|
88
|
+
// This will make sure to move pseudo's to the correct spot (the end for
|
|
89
|
+
// pseudo elements) because otherwise the selector will never work
|
|
90
|
+
// anyway.
|
|
91
|
+
//
|
|
92
|
+
// E.g.:
|
|
93
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
94
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
95
|
+
//
|
|
96
|
+
// `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
97
|
+
function collectPseudoElements(selector) {
|
|
98
|
+
let nodes = [];
|
|
99
|
+
for (let node of selector.nodes){
|
|
100
|
+
if (isPseudoElement(node)) {
|
|
101
|
+
nodes.push(node);
|
|
102
|
+
selector.removeChild(node);
|
|
103
|
+
}
|
|
104
|
+
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
105
|
+
nodes.push(...collectPseudoElements(node));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return nodes;
|
|
109
|
+
}
|
|
110
|
+
let pseudoElements = collectPseudoElements(selector2);
|
|
111
|
+
if (pseudoElements.length > 0) {
|
|
112
|
+
selector2.nodes.push(pseudoElements.sort(sortSelector));
|
|
113
|
+
}
|
|
114
|
+
return selector2;
|
|
80
115
|
});
|
|
81
|
-
}).processSync(
|
|
116
|
+
}).processSync(selector1);
|
|
117
|
+
}
|
|
118
|
+
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
119
|
+
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
120
|
+
// this distinction was not present in older versions of the W3C spec, most
|
|
121
|
+
// browsers support both syntaxes for the original pseudo-elements.
|
|
122
|
+
let pseudoElementsBC = [
|
|
123
|
+
':before',
|
|
124
|
+
':after',
|
|
125
|
+
':first-line',
|
|
126
|
+
':first-letter'
|
|
127
|
+
];
|
|
128
|
+
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
129
|
+
let pseudoElementExceptions = [
|
|
130
|
+
'::file-selector-button'
|
|
131
|
+
];
|
|
132
|
+
// This will make sure to move pseudo's to the correct spot (the end for
|
|
133
|
+
// pseudo elements) because otherwise the selector will never work
|
|
134
|
+
// anyway.
|
|
135
|
+
//
|
|
136
|
+
// E.g.:
|
|
137
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
138
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
139
|
+
//
|
|
140
|
+
// `::before:hover` doesn't work, which means that we can make it work
|
|
141
|
+
// for you by flipping the order.
|
|
142
|
+
function sortSelector(a, z) {
|
|
143
|
+
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
144
|
+
// them in the same order.
|
|
145
|
+
if (a.type !== 'pseudo' && z.type !== 'pseudo') {
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
// If one of them is a combinator, we need to keep it in the same order
|
|
149
|
+
// because that means it will start a new "section" in the selector.
|
|
150
|
+
if (a.type === 'combinator' ^ z.type === 'combinator') {
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
// One of the items is a pseudo and the other one isn't. Let's move
|
|
154
|
+
// the pseudo to the right.
|
|
155
|
+
if (a.type === 'pseudo' ^ z.type === 'pseudo') {
|
|
156
|
+
return (a.type === 'pseudo') - (z.type === 'pseudo');
|
|
157
|
+
}
|
|
158
|
+
// Both are pseudo's, move the pseudo elements (except for
|
|
159
|
+
// ::file-selector-button) to the right.
|
|
160
|
+
return isPseudoElement(a) - isPseudoElement(z);
|
|
161
|
+
}
|
|
162
|
+
function isPseudoElement(node) {
|
|
163
|
+
if (node.type !== 'pseudo') return false;
|
|
164
|
+
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
165
|
+
return node.value.startsWith('::') || pseudoElementsBC.includes(node.value);
|
|
82
166
|
}
|
|
83
167
|
function resolveFunctionArgument(haystack, needle, arg) {
|
|
84
168
|
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = isValidArbitraryValue;
|
|
6
|
+
let matchingBrackets = new Map([
|
|
7
|
+
[
|
|
8
|
+
'{',
|
|
9
|
+
'}'
|
|
10
|
+
],
|
|
11
|
+
[
|
|
12
|
+
'[',
|
|
13
|
+
']'
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
'(',
|
|
17
|
+
')'
|
|
18
|
+
],
|
|
19
|
+
]);
|
|
20
|
+
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
21
|
+
v,
|
|
22
|
+
k
|
|
23
|
+
]
|
|
24
|
+
));
|
|
25
|
+
let quotes = new Set([
|
|
26
|
+
'"',
|
|
27
|
+
"'",
|
|
28
|
+
'`'
|
|
29
|
+
]);
|
|
30
|
+
function isValidArbitraryValue(value) {
|
|
31
|
+
let stack = [];
|
|
32
|
+
let inQuotes = false;
|
|
33
|
+
for(let i = 0; i < value.length; i++){
|
|
34
|
+
let char = value[i];
|
|
35
|
+
if (char === ':' && !inQuotes && stack.length === 0) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
// Non-escaped quotes allow us to "allow" anything in between
|
|
39
|
+
if (quotes.has(char) && value[i - 1] !== '\\') {
|
|
40
|
+
inQuotes = !inQuotes;
|
|
41
|
+
}
|
|
42
|
+
if (inQuotes) continue;
|
|
43
|
+
if (value[i - 1] === '\\') continue; // Escaped
|
|
44
|
+
if (matchingBrackets.has(char)) {
|
|
45
|
+
stack.push(char);
|
|
46
|
+
} else if (inverseMatchingBrackets.has(char)) {
|
|
47
|
+
let inverse = inverseMatchingBrackets.get(char);
|
|
48
|
+
// Nothing to pop from, therefore it is unbalanced
|
|
49
|
+
if (stack.length <= 0) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
// Popped value must match the inverse value, otherwise it is unbalanced
|
|
53
|
+
if (stack.pop() !== inverse) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// If there is still something on the stack, it is also unbalanced
|
|
59
|
+
if (stack.length > 0) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// All good, totally balanced!
|
|
63
|
+
return true;
|
|
64
|
+
}
|
package/lib/util/nameClass.js
CHANGED
|
@@ -157,11 +157,11 @@ function normalizeConfig(config) {
|
|
|
157
157
|
let extractors = {
|
|
158
158
|
};
|
|
159
159
|
let defaultExtractor = (()=>{
|
|
160
|
-
var ref,
|
|
161
|
-
if ((ref = config.purge) === null || ref === void 0 ? void 0 : (
|
|
160
|
+
var ref, ref10, ref11, ref12;
|
|
161
|
+
if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
|
|
162
162
|
return config.purge.options.defaultExtractor;
|
|
163
163
|
}
|
|
164
|
-
if ((
|
|
164
|
+
if ((ref11 = config.content) === null || ref11 === void 0 ? void 0 : (ref12 = ref11.options) === null || ref12 === void 0 ? void 0 : ref12.defaultExtractor) {
|
|
165
165
|
return config.content.options.defaultExtractor;
|
|
166
166
|
}
|
|
167
167
|
return undefined;
|
|
@@ -185,11 +185,11 @@ function normalizeConfig(config) {
|
|
|
185
185
|
})(),
|
|
186
186
|
transform: (()=>{
|
|
187
187
|
let transform = (()=>{
|
|
188
|
-
var ref,
|
|
188
|
+
var ref, ref13, ref14, ref15, ref16, ref17;
|
|
189
189
|
if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
|
|
190
|
-
if ((
|
|
191
|
-
if ((
|
|
192
|
-
if ((
|
|
190
|
+
if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
|
|
191
|
+
if ((ref14 = config.purge) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.transform) === null || ref15 === void 0 ? void 0 : ref15.DEFAULT) return config.purge.transform.DEFAULT;
|
|
192
|
+
if ((ref16 = config.content) === null || ref16 === void 0 ? void 0 : (ref17 = ref16.transform) === null || ref17 === void 0 ? void 0 : ref17.DEFAULT) return config.content.transform.DEFAULT;
|
|
193
193
|
return {
|
|
194
194
|
};
|
|
195
195
|
})();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.normalizeScreens = normalizeScreens;
|
|
6
|
+
function normalizeScreens(screens) {
|
|
7
|
+
if (Array.isArray(screens)) {
|
|
8
|
+
return screens.map((screen)=>{
|
|
9
|
+
if (typeof screen === 'string') {
|
|
10
|
+
return {
|
|
11
|
+
name: screen.toString(),
|
|
12
|
+
values: [
|
|
13
|
+
{
|
|
14
|
+
min: screen,
|
|
15
|
+
max: undefined
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
let [name, options] = screen;
|
|
21
|
+
name = name.toString();
|
|
22
|
+
if (typeof options === 'string') {
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
values: [
|
|
26
|
+
{
|
|
27
|
+
min: options,
|
|
28
|
+
max: undefined
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(options)) {
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
values: options.map((option)=>resolveValue(option)
|
|
37
|
+
)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
values: [
|
|
43
|
+
resolveValue(options)
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {
|
|
52
|
+
}) {
|
|
53
|
+
return {
|
|
54
|
+
min,
|
|
55
|
+
max,
|
|
56
|
+
raw
|
|
57
|
+
};
|
|
58
|
+
}
|