tailwindcss 0.0.0-insiders.f9fb2ce → 0.0.0-insiders.fb545bc
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 +84 -3
- package/colors.js +2 -1
- package/defaultConfig.js +2 -1
- package/defaultTheme.js +2 -1
- package/lib/cli.js +32 -32
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +4 -0
- package/lib/corePlugins.js +257 -172
- package/lib/css/preflight.css +4 -3
- package/lib/featureFlags.js +6 -4
- 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 +26 -9
- package/lib/lib/expandTailwindAtRules.js +27 -1
- package/lib/lib/generateRules.js +64 -10
- package/lib/lib/resolveDefaultsAtRules.js +25 -11
- package/lib/lib/setupContextUtils.js +55 -78
- 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 +25 -3
- package/lib/util/defaults.js +6 -0
- package/lib/util/formatVariantSelector.js +93 -9
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +4 -0
- package/lib/util/nameClass.js +1 -0
- package/lib/util/normalizeConfig.js +41 -12
- package/lib/util/normalizeScreens.js +61 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +12 -11
- package/lib/util/resolveConfig.js +12 -12
- package/package.json +15 -14
- package/peers/index.js +3798 -3098
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +232 -164
- package/src/css/preflight.css +4 -3
- package/src/featureFlags.js +5 -1
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandApplyAtRules.js +29 -2
- package/src/lib/expandTailwindAtRules.js +25 -0
- package/src/lib/generateRules.js +57 -0
- package/src/lib/resolveDefaultsAtRules.js +28 -7
- package/src/lib/setupContextUtils.js +45 -64
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/dataTypes.js +24 -6
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +92 -1
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +4 -0
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +14 -1
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +2 -0
- package/stubs/defaultConfig.stub.js +23 -5
|
@@ -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;
|
|
@@ -332,6 +271,29 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
332
271
|
]);
|
|
333
272
|
}
|
|
334
273
|
},
|
|
274
|
+
/**
|
|
275
|
+
* @param {string} group
|
|
276
|
+
* @param {Record<string, string | string[]>} declarations
|
|
277
|
+
*/ addDefaults (group, declarations) {
|
|
278
|
+
const groups = {
|
|
279
|
+
[`@defaults ${group}`]: declarations
|
|
280
|
+
};
|
|
281
|
+
for (let [identifier, rule] of withIdentifiers(groups)){
|
|
282
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
283
|
+
});
|
|
284
|
+
let offset = offsets.base++;
|
|
285
|
+
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
286
|
+
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
287
|
+
}
|
|
288
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
289
|
+
{
|
|
290
|
+
sort: offset,
|
|
291
|
+
layer: 'defaults'
|
|
292
|
+
},
|
|
293
|
+
rule
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
335
297
|
addComponents (components, options) {
|
|
336
298
|
let defaultOptions = {
|
|
337
299
|
respectPrefix: true,
|
|
@@ -409,7 +371,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
409
371
|
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
410
372
|
return [];
|
|
411
373
|
}
|
|
412
|
-
if (!
|
|
374
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
413
375
|
return [];
|
|
414
376
|
}
|
|
415
377
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -466,7 +428,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
466
428
|
return [];
|
|
467
429
|
}
|
|
468
430
|
}
|
|
469
|
-
if (!
|
|
431
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
470
432
|
return [];
|
|
471
433
|
}
|
|
472
434
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -608,7 +570,8 @@ function resolvePlugins(context, root) {
|
|
|
608
570
|
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
609
571
|
_corePlugins.variantPlugins['darkVariants'],
|
|
610
572
|
_corePlugins.variantPlugins['printVariant'],
|
|
611
|
-
_corePlugins.variantPlugins['screenVariants'],
|
|
573
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
574
|
+
_corePlugins.variantPlugins['orientationVariants'],
|
|
612
575
|
];
|
|
613
576
|
return [
|
|
614
577
|
...corePluginList,
|
|
@@ -622,6 +585,7 @@ function registerPlugins(plugins, context) {
|
|
|
622
585
|
let variantList = [];
|
|
623
586
|
let variantMap = new Map();
|
|
624
587
|
let offsets = {
|
|
588
|
+
defaults: 0n,
|
|
625
589
|
base: 0n,
|
|
626
590
|
components: 0n,
|
|
627
591
|
utilities: 0n,
|
|
@@ -647,18 +611,23 @@ function registerPlugins(plugins, context) {
|
|
|
647
611
|
)
|
|
648
612
|
)([
|
|
649
613
|
offsets.base,
|
|
614
|
+
offsets.defaults,
|
|
650
615
|
offsets.components,
|
|
651
616
|
offsets.utilities,
|
|
652
617
|
offsets.user,
|
|
653
618
|
]);
|
|
654
619
|
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
620
|
+
// A number one less than the top range of the highest offset area
|
|
621
|
+
// so arbitrary properties are always sorted at the end.
|
|
622
|
+
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
655
623
|
context.layerOrder = {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
624
|
+
defaults: 1n << reservedBits << 0n,
|
|
625
|
+
base: 1n << reservedBits << 1n,
|
|
626
|
+
components: 1n << reservedBits << 2n,
|
|
627
|
+
utilities: 1n << reservedBits << 3n,
|
|
628
|
+
user: 1n << reservedBits << 4n
|
|
660
629
|
};
|
|
661
|
-
reservedBits +=
|
|
630
|
+
reservedBits += 5n;
|
|
662
631
|
let offset = 0;
|
|
663
632
|
context.variantOrder = new Map(variantList.map((variant, i)=>{
|
|
664
633
|
let variantFunctions = variantMap.get(variant).length;
|
|
@@ -674,9 +643,9 @@ function registerPlugins(plugins, context) {
|
|
|
674
643
|
...context.variantOrder.values()
|
|
675
644
|
].shift();
|
|
676
645
|
// Build variantMap
|
|
677
|
-
for (let [variantName,
|
|
646
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
678
647
|
let sort = context.variantOrder.get(variantName);
|
|
679
|
-
context.variantMap.set(variantName,
|
|
648
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
680
649
|
sort << BigInt(idx),
|
|
681
650
|
variantFunction
|
|
682
651
|
]
|
|
@@ -686,22 +655,22 @@ function registerPlugins(plugins, context) {
|
|
|
686
655
|
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
687
656
|
if (safelist.length > 0) {
|
|
688
657
|
let checks = [];
|
|
689
|
-
for (let
|
|
690
|
-
if (typeof
|
|
658
|
+
for (let value1 of safelist){
|
|
659
|
+
if (typeof value1 === 'string') {
|
|
691
660
|
context.changedContent.push({
|
|
692
|
-
content:
|
|
661
|
+
content: value1,
|
|
693
662
|
extension: 'html'
|
|
694
663
|
});
|
|
695
664
|
continue;
|
|
696
665
|
}
|
|
697
|
-
if (
|
|
666
|
+
if (value1 instanceof RegExp) {
|
|
698
667
|
_log.default.warn('root-regex', [
|
|
699
668
|
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
700
669
|
'Update your `safelist` configuration to eliminate this warning.'
|
|
701
670
|
]);
|
|
702
671
|
continue;
|
|
703
672
|
}
|
|
704
|
-
checks.push(
|
|
673
|
+
checks.push(value1);
|
|
705
674
|
}
|
|
706
675
|
if (checks.length > 0) {
|
|
707
676
|
let patternMatchingCount = new Map();
|
|
@@ -709,9 +678,17 @@ function registerPlugins(plugins, context) {
|
|
|
709
678
|
let utils = Array.isArray(util) ? (()=>{
|
|
710
679
|
let [utilName, options] = util;
|
|
711
680
|
var ref;
|
|
712
|
-
|
|
681
|
+
let classes = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
713
682
|
}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
714
683
|
);
|
|
684
|
+
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
685
|
+
classes = [
|
|
686
|
+
...classes,
|
|
687
|
+
...classes.map((cls)=>'-' + cls
|
|
688
|
+
)
|
|
689
|
+
];
|
|
690
|
+
}
|
|
691
|
+
return classes;
|
|
715
692
|
})() : [
|
|
716
693
|
util
|
|
717
694
|
];
|
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,10 @@ let lengthUnits = [
|
|
|
72
82
|
];
|
|
73
83
|
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`;
|
|
74
84
|
function length(value) {
|
|
75
|
-
return
|
|
85
|
+
return value.split(UNDERSCORE).every((part)=>{
|
|
86
|
+
return part === '0' || new RegExp(`${lengthUnitsPattern}$`).test(part) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part)
|
|
87
|
+
);
|
|
88
|
+
});
|
|
76
89
|
}
|
|
77
90
|
let lineWidths = new Set([
|
|
78
91
|
'thin',
|
|
@@ -82,6 +95,15 @@ let lineWidths = new Set([
|
|
|
82
95
|
function lineWidth(value) {
|
|
83
96
|
return lineWidths.has(value);
|
|
84
97
|
}
|
|
98
|
+
function shadow(value) {
|
|
99
|
+
let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
|
|
100
|
+
for (let parsedShadow of parsedShadows){
|
|
101
|
+
if (!parsedShadow.valid) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
85
107
|
function color(value) {
|
|
86
108
|
let colors = 0;
|
|
87
109
|
let result = value.split(UNDERSCORE).every((part)=>{
|
package/lib/util/defaults.js
CHANGED
|
@@ -11,6 +11,12 @@ function defaults(target, ...sources) {
|
|
|
11
11
|
target[k] = source[k];
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
for (let k1 of Object.getOwnPropertySymbols(source)){
|
|
15
|
+
var ref1;
|
|
16
|
+
if (!(target === null || target === void 0 ? void 0 : (ref1 = target.hasOwnProperty) === null || ref1 === void 0 ? void 0 : ref1.call(target, k1))) {
|
|
17
|
+
target[k1] = source[k1];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
14
20
|
}
|
|
15
21
|
return target;
|
|
16
22
|
}
|
|
@@ -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/log.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
exports.dim = dim;
|
|
5
6
|
exports.default = void 0;
|
|
6
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
7
8
|
function _interopRequireDefault(obj) {
|
|
@@ -18,6 +19,9 @@ function log(chalk, messages, key) {
|
|
|
18
19
|
messages.forEach((message)=>console.warn(chalk, '-', message)
|
|
19
20
|
);
|
|
20
21
|
}
|
|
22
|
+
function dim(input) {
|
|
23
|
+
return _chalk.default.dim(input);
|
|
24
|
+
}
|
|
21
25
|
var _default = {
|
|
22
26
|
info (key, messages) {
|
|
23
27
|
log(_chalk.default.bold.cyan('info'), ...Array.isArray(key) ? [
|
package/lib/util/nameClass.js
CHANGED