tailwindcss 0.0.0-insiders.ba2fd32 → 0.0.0-insiders.bbafc8e
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 +292 -3
- package/LICENSE +1 -2
- package/README.md +8 -4
- package/colors.js +2 -1
- package/defaultConfig.js +2 -1
- package/defaultTheme.js +2 -1
- package/lib/cli.js +96 -61
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +4 -0
- package/lib/corePlugins.js +399 -374
- package/lib/css/preflight.css +6 -5
- package/lib/featureFlags.js +7 -8
- package/lib/index.js +12 -3
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +14 -1
- package/lib/lib/collapseDuplicateDeclarations.js +54 -3
- package/lib/lib/defaultExtractor.js +44 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +10 -6
- package/lib/lib/expandApplyAtRules.js +264 -59
- package/lib/lib/expandTailwindAtRules.js +63 -46
- package/lib/lib/generateRules.js +181 -43
- package/lib/lib/normalizeTailwindDirectives.js +10 -2
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +32 -14
- package/lib/lib/setupContextUtils.js +152 -153
- package/lib/lib/setupTrackingContext.js +8 -7
- package/lib/lib/sharedState.js +38 -5
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +85 -0
- package/lib/processTailwindFeatures.js +10 -2
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +23 -8
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -10
- package/lib/util/dataTypes.js +25 -3
- package/lib/util/defaults.js +6 -0
- package/lib/util/flattenColorPalette.js +1 -3
- package/lib/util/formatVariantSelector.js +93 -9
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +10 -6
- package/lib/util/nameClass.js +1 -0
- package/lib/util/normalizeConfig.js +54 -22
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseBoxShadowValue.js +117 -0
- package/lib/util/pluginUtils.js +18 -24
- package/lib/util/prefixSelector.js +4 -5
- package/lib/util/resolveConfig.js +52 -31
- package/lib/util/resolveConfigPath.js +1 -2
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +4 -8
- package/nesting/index.js +2 -12
- package/package.json +28 -33
- package/peers/index.js +6970 -7268
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/src/cli.js +62 -15
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +329 -255
- package/src/css/preflight.css +6 -5
- package/src/featureFlags.js +3 -3
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +16 -1
- package/src/lib/collapseDuplicateDeclarations.js +66 -1
- package/src/lib/defaultExtractor.js +50 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +6 -3
- package/src/lib/expandApplyAtRules.js +285 -56
- package/src/lib/expandTailwindAtRules.js +75 -35
- package/src/lib/generateRules.js +154 -26
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/resolveDefaultsAtRules.js +35 -10
- package/src/lib/setupContextUtils.js +133 -103
- package/src/lib/setupTrackingContext.js +8 -7
- package/src/lib/sharedState.js +42 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +12 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +20 -7
- 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 +10 -6
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +24 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +119 -0
- package/src/util/pluginUtils.js +3 -1
- package/src/util/prefixSelector.js +7 -5
- package/src/util/resolveConfig.js +41 -1
- package/src/util/toPath.js +23 -1
- package/stubs/defaultConfig.stub.js +27 -11
- package/lib/lib/setupWatchingContext.js +0 -288
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -311
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _plugin = require("./plugin");
|
|
7
|
+
var _default = Object.assign(function(opts) {
|
|
8
|
+
return {
|
|
9
|
+
postcssPlugin: 'tailwindcss/nesting',
|
|
10
|
+
Once (root, { result }) {
|
|
11
|
+
return (0, _plugin).nesting(opts)(root, result);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
postcss: true
|
|
16
|
+
});
|
|
17
|
+
exports.default = _default;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.nesting = nesting;
|
|
6
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
|
+
var _postcssNested = _interopRequireDefault(require("postcss-nested"));
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function nesting(opts = _postcssNested.default) {
|
|
14
|
+
return (root, result)=>{
|
|
15
|
+
root.walkAtRules('screen', (rule)=>{
|
|
16
|
+
rule.name = 'media';
|
|
17
|
+
rule.params = `screen(${rule.params})`;
|
|
18
|
+
});
|
|
19
|
+
root.walkAtRules('apply', (rule)=>{
|
|
20
|
+
rule.before(_postcss.default.decl({
|
|
21
|
+
prop: '__apply',
|
|
22
|
+
value: rule.params,
|
|
23
|
+
source: rule.source
|
|
24
|
+
}));
|
|
25
|
+
rule.remove();
|
|
26
|
+
});
|
|
27
|
+
let plugin = (()=>{
|
|
28
|
+
var ref;
|
|
29
|
+
if (typeof opts === 'function' || typeof opts === 'object' && (opts === null || opts === void 0 ? void 0 : (ref = opts.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(opts, 'postcssPlugin'))) {
|
|
30
|
+
return opts;
|
|
31
|
+
}
|
|
32
|
+
if (typeof opts === 'string') {
|
|
33
|
+
return require(opts);
|
|
34
|
+
}
|
|
35
|
+
if (Object.keys(opts).length <= 0) {
|
|
36
|
+
return _postcssNested.default;
|
|
37
|
+
}
|
|
38
|
+
throw new Error('tailwindcss/nesting should be loaded with a nesting plugin.');
|
|
39
|
+
})();
|
|
40
|
+
(0, _postcss).default([
|
|
41
|
+
plugin
|
|
42
|
+
]).process(root, result.opts).sync();
|
|
43
|
+
root.walkDecls('__apply', (decl)=>{
|
|
44
|
+
decl.before(_postcss.default.atRule({
|
|
45
|
+
name: 'apply',
|
|
46
|
+
params: decl.value,
|
|
47
|
+
source: decl.source
|
|
48
|
+
}));
|
|
49
|
+
decl.remove();
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Use a private PostCSS API to remove the "clean" flag from the entire AST.
|
|
53
|
+
* This is done because running process() on the AST will set the "clean"
|
|
54
|
+
* flag on all nodes, which we don't want.
|
|
55
|
+
*
|
|
56
|
+
* This causes downstream plugins using the visitor API to be skipped.
|
|
57
|
+
*
|
|
58
|
+
* This is guarded because the PostCSS API is not public
|
|
59
|
+
* and may change in future versions of PostCSS.
|
|
60
|
+
*
|
|
61
|
+
* See https://github.com/postcss/postcss/issues/1712 for more details
|
|
62
|
+
*
|
|
63
|
+
* @param {import('postcss').Node} node
|
|
64
|
+
*/ function markDirty(node) {
|
|
65
|
+
if (!('markDirty' in node)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Traverse the tree down to the leaf nodes
|
|
69
|
+
if (node.nodes) {
|
|
70
|
+
node.nodes.forEach((n)=>markDirty(n)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
// If it's a leaf node mark it as dirty
|
|
74
|
+
// We do this here because marking a node as dirty
|
|
75
|
+
// will walk up the tree and mark all parents as dirty
|
|
76
|
+
// resulting in a lot of unnecessary work if we did this
|
|
77
|
+
// for every single node
|
|
78
|
+
if (!node.nodes) {
|
|
79
|
+
node.markDirty();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
markDirty(root);
|
|
83
|
+
return root;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -11,6 +11,7 @@ var _substituteScreenAtRules = _interopRequireDefault(require("./lib/substituteS
|
|
|
11
11
|
var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
12
12
|
var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
13
13
|
var _collapseDuplicateDeclarations = _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
14
|
+
var _partitionApplyAtRules = _interopRequireDefault(require("./lib/partitionApplyAtRules"));
|
|
14
15
|
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
15
16
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
16
17
|
var _featureFlags = require("./featureFlags");
|
|
@@ -21,9 +22,14 @@ function _interopRequireDefault(obj) {
|
|
|
21
22
|
}
|
|
22
23
|
function processTailwindFeatures(setupContext) {
|
|
23
24
|
return function(root, result) {
|
|
24
|
-
let tailwindDirectives = (0, _normalizeTailwindDirectives).default(root);
|
|
25
|
+
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
|
|
26
|
+
(0, _detectNesting).default()(root, result);
|
|
27
|
+
// Partition apply rules that are found in the css
|
|
28
|
+
// itself.
|
|
29
|
+
(0, _partitionApplyAtRules).default()(root, result);
|
|
25
30
|
let context = setupContext({
|
|
26
31
|
tailwindDirectives,
|
|
32
|
+
applyDirectives,
|
|
27
33
|
registerDependency (dependency) {
|
|
28
34
|
result.messages.push({
|
|
29
35
|
plugin: 'tailwindcss',
|
|
@@ -39,8 +45,10 @@ function processTailwindFeatures(setupContext) {
|
|
|
39
45
|
throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
|
|
40
46
|
}
|
|
41
47
|
(0, _featureFlags).issueFlagNotices(context.tailwindConfig);
|
|
42
|
-
(0, _detectNesting).default(context)(root, result);
|
|
43
48
|
(0, _expandTailwindAtRules).default(context)(root, result);
|
|
49
|
+
// Partition apply rules that are generated by
|
|
50
|
+
// addComponents, addUtilities and so on.
|
|
51
|
+
(0, _partitionApplyAtRules).default()(root, result);
|
|
44
52
|
(0, _expandApplyAtRules).default(context)(root, result);
|
|
45
53
|
(0, _evaluateTailwindFunctions).default(context)(root, result);
|
|
46
54
|
(0, _substituteScreenAtRules).default(context)(root, result);
|
|
@@ -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
|
}
|
package/lib/util/cloneNodes.js
CHANGED
|
@@ -3,11 +3,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = cloneNodes;
|
|
6
|
-
function cloneNodes(nodes, source) {
|
|
6
|
+
function cloneNodes(nodes, source = undefined, raws = undefined) {
|
|
7
7
|
return nodes.map((node)=>{
|
|
8
8
|
let cloned = node.clone();
|
|
9
9
|
if (source !== undefined) {
|
|
10
10
|
cloned.source = source;
|
|
11
|
+
if ('walk' in cloned) {
|
|
12
|
+
cloned.walk((child)=>{
|
|
13
|
+
child.source = source;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (raws !== undefined) {
|
|
18
|
+
cloned.raws.tailwind = {
|
|
19
|
+
...cloned.raws.tailwind,
|
|
20
|
+
...raws
|
|
21
|
+
};
|
|
11
22
|
}
|
|
12
23
|
return cloned;
|
|
13
24
|
});
|
package/lib/util/color.js
CHANGED
|
@@ -15,7 +15,8 @@ let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
|
|
|
15
15
|
let VALUE = `(?:\\d+|\\d*\\.\\d+)%?`;
|
|
16
16
|
let SEP = `(?:\\s*,\\s*|\\s+)`;
|
|
17
17
|
let ALPHA_SEP = `\\s*[,/]\\s*`;
|
|
18
|
-
let
|
|
18
|
+
let RGB = new RegExp(`^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
|
|
19
|
+
let HSL = new RegExp(`^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
|
|
19
20
|
function parseColor(value) {
|
|
20
21
|
if (typeof value !== 'string') {
|
|
21
22
|
return null;
|
|
@@ -62,18 +63,32 @@ function parseColor(value) {
|
|
|
62
63
|
alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
66
|
+
let rgbMatch = value.match(RGB);
|
|
67
|
+
if (rgbMatch !== null) {
|
|
67
68
|
var ref, ref1;
|
|
68
69
|
return {
|
|
69
|
-
mode:
|
|
70
|
+
mode: 'rgb',
|
|
71
|
+
color: [
|
|
72
|
+
rgbMatch[1],
|
|
73
|
+
rgbMatch[2],
|
|
74
|
+
rgbMatch[3]
|
|
75
|
+
].map((v)=>v.toString()
|
|
76
|
+
),
|
|
77
|
+
alpha: (ref = rgbMatch[4]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
let hslMatch = value.match(HSL);
|
|
81
|
+
if (hslMatch !== null) {
|
|
82
|
+
var ref2, ref3;
|
|
83
|
+
return {
|
|
84
|
+
mode: 'hsl',
|
|
70
85
|
color: [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
hslMatch[1],
|
|
87
|
+
hslMatch[2],
|
|
88
|
+
hslMatch[3]
|
|
74
89
|
].map((v)=>v.toString()
|
|
75
90
|
),
|
|
76
|
-
alpha: (
|
|
91
|
+
alpha: (ref2 = hslMatch[4]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.toString) === null || ref3 === void 0 ? void 0 : ref3.call(ref2)
|
|
77
92
|
};
|
|
78
93
|
}
|
|
79
94
|
return null;
|
package/lib/util/createPlugin.js
CHANGED
|
@@ -9,8 +9,7 @@ function createPlugin(plugin, config) {
|
|
|
9
9
|
config
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({
|
|
13
|
-
})
|
|
12
|
+
createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})
|
|
14
13
|
) {
|
|
15
14
|
const optionsFunction = function(options) {
|
|
16
15
|
return {
|
|
@@ -16,8 +16,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
16
16
|
themeKey
|
|
17
17
|
]
|
|
18
18
|
]
|
|
19
|
-
], { filterDefault =false , ...options } = {
|
|
20
|
-
}) {
|
|
19
|
+
], { filterDefault =false , ...options } = {}) {
|
|
21
20
|
let transformValue = (0, _transformThemeValue).default(themeKey);
|
|
22
21
|
return function({ matchUtilities , theme }) {
|
|
23
22
|
for (let utilityVariation of utilityVariations){
|
|
@@ -25,8 +24,8 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
25
24
|
utilityVariation
|
|
26
25
|
];
|
|
27
26
|
var ref;
|
|
28
|
-
matchUtilities(group.reduce((
|
|
29
|
-
return Object.assign(
|
|
27
|
+
matchUtilities(group.reduce((obj1, [classPrefix, properties])=>{
|
|
28
|
+
return Object.assign(obj1, {
|
|
30
29
|
[classPrefix]: (value)=>{
|
|
31
30
|
return properties.reduce((obj, name)=>{
|
|
32
31
|
if (Array.isArray(name)) {
|
|
@@ -37,15 +36,12 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
37
36
|
return Object.assign(obj, {
|
|
38
37
|
[name]: transformValue(value)
|
|
39
38
|
});
|
|
40
|
-
}, {
|
|
41
|
-
});
|
|
39
|
+
}, {});
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
|
-
}, {
|
|
45
|
-
}), {
|
|
42
|
+
}, {}), {
|
|
46
43
|
...options,
|
|
47
|
-
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {
|
|
48
|
-
}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
44
|
+
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
49
45
|
)) : theme(themeKey)
|
|
50
46
|
});
|
|
51
47
|
}
|
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
|
}
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = void 0;
|
|
6
|
-
const flattenColorPalette = (colors)=>Object.assign({
|
|
7
|
-
}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {
|
|
8
|
-
}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
|
|
6
|
+
const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
|
|
9
7
|
[color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex
|
|
10
8
|
})
|
|
11
9
|
) : [
|
|
@@ -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,25 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
exports.dim = dim;
|
|
5
6
|
exports.default = void 0;
|
|
6
|
-
var
|
|
7
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
7
8
|
function _interopRequireDefault(obj) {
|
|
8
9
|
return obj && obj.__esModule ? obj : {
|
|
9
10
|
default: obj
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
let alreadyShown = new Set();
|
|
13
|
-
function log(
|
|
14
|
+
function log(type, messages, key) {
|
|
14
15
|
if (process.env.JEST_WORKER_ID !== undefined) return;
|
|
15
16
|
if (key && alreadyShown.has(key)) return;
|
|
16
17
|
if (key) alreadyShown.add(key);
|
|
17
18
|
console.warn('');
|
|
18
|
-
messages.forEach((message)=>console.warn(
|
|
19
|
+
messages.forEach((message)=>console.warn(type, '-', message)
|
|
19
20
|
);
|
|
20
21
|
}
|
|
22
|
+
function dim(input) {
|
|
23
|
+
return _picocolors.default.dim(input);
|
|
24
|
+
}
|
|
21
25
|
var _default = {
|
|
22
26
|
info (key, messages) {
|
|
23
|
-
log(
|
|
27
|
+
log(_picocolors.default.bold(_picocolors.default.cyan('info')), ...Array.isArray(key) ? [
|
|
24
28
|
key
|
|
25
29
|
] : [
|
|
26
30
|
messages,
|
|
@@ -28,7 +32,7 @@ var _default = {
|
|
|
28
32
|
]);
|
|
29
33
|
},
|
|
30
34
|
warn (key, messages) {
|
|
31
|
-
log(
|
|
35
|
+
log(_picocolors.default.bold(_picocolors.default.yellow('warn')), ...Array.isArray(key) ? [
|
|
32
36
|
key
|
|
33
37
|
] : [
|
|
34
38
|
messages,
|
|
@@ -36,7 +40,7 @@ var _default = {
|
|
|
36
40
|
]);
|
|
37
41
|
},
|
|
38
42
|
risk (key, messages) {
|
|
39
|
-
log(
|
|
43
|
+
log(_picocolors.default.bold(_picocolors.default.magenta('risk')), ...Array.isArray(key) ? [
|
|
40
44
|
key
|
|
41
45
|
] : [
|
|
42
46
|
messages,
|
package/lib/util/nameClass.js
CHANGED