tailwindcss 0.0.0-insiders.df011dc → 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 +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.formatVariantSelector = formatVariantSelector;
|
|
6
|
+
exports.finalizeSelector = finalizeSelector;
|
|
7
|
+
exports.selectorFunctions = void 0;
|
|
8
|
+
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
9
|
+
var _unesc = _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
|
|
10
|
+
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
11
|
+
var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
let MERGE = ':merge';
|
|
18
|
+
let PARENT = '&';
|
|
19
|
+
let selectorFunctions = new Set([
|
|
20
|
+
MERGE
|
|
21
|
+
]);
|
|
22
|
+
exports.selectorFunctions = selectorFunctions;
|
|
23
|
+
function formatVariantSelector(current, ...others) {
|
|
24
|
+
for (let other of others){
|
|
25
|
+
let incomingValue = resolveFunctionArgument(other, MERGE);
|
|
26
|
+
if (incomingValue !== null) {
|
|
27
|
+
let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
|
|
28
|
+
if (existingValue !== null) {
|
|
29
|
+
let existingTarget = `${MERGE}(${incomingValue})`;
|
|
30
|
+
let splitIdx = other.indexOf(existingTarget);
|
|
31
|
+
let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0];
|
|
32
|
+
current = current.replace(existingTarget, existingTarget + addition);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
current = other.replace(PARENT, current);
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
function finalizeSelector(format, { selector: selector1 , candidate , context }) {
|
|
41
|
+
var ref, ref1;
|
|
42
|
+
var ref2;
|
|
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();
|
|
53
|
+
if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
|
|
54
|
+
format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
|
|
55
|
+
}
|
|
56
|
+
format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
|
|
57
|
+
// Normalize escaped classes, e.g.:
|
|
58
|
+
//
|
|
59
|
+
// The idea would be to replace the escaped `base` in the selector with the
|
|
60
|
+
// `format`. However, in css you can escape the same selector in a few
|
|
61
|
+
// different ways. This would result in different strings and therefore we
|
|
62
|
+
// can't replace it properly.
|
|
63
|
+
//
|
|
64
|
+
// base: bg-[rgb(255,0,0)]
|
|
65
|
+
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
66
|
+
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
67
|
+
//
|
|
68
|
+
selector1 = (0, _postcssSelectorParser).default((selectors)=>{
|
|
69
|
+
return selectors.walkClasses((node)=>{
|
|
70
|
+
if (node.raws && node.value.includes(base)) {
|
|
71
|
+
node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
|
|
72
|
+
}
|
|
73
|
+
return node;
|
|
74
|
+
});
|
|
75
|
+
}).processSync(selector1);
|
|
76
|
+
// We can safely replace the escaped base now, since the `base` section is
|
|
77
|
+
// now in a normalized escaped value.
|
|
78
|
+
selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
|
|
79
|
+
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
80
|
+
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
81
|
+
return selectors.map((selector2)=>{
|
|
82
|
+
selector2.walkPseudos((p)=>{
|
|
83
|
+
if (selectorFunctions.has(p.value)) {
|
|
84
|
+
p.replaceWith(p.nodes);
|
|
85
|
+
}
|
|
86
|
+
return p;
|
|
87
|
+
});
|
|
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;
|
|
115
|
+
});
|
|
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);
|
|
166
|
+
}
|
|
167
|
+
function resolveFunctionArgument(haystack, needle, arg) {
|
|
168
|
+
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
169
|
+
if (startIdx === -1) return null;
|
|
170
|
+
// Start inside the `(`
|
|
171
|
+
startIdx += needle.length + 1;
|
|
172
|
+
let target = '';
|
|
173
|
+
let count = 0;
|
|
174
|
+
for (let char of haystack.slice(startIdx)){
|
|
175
|
+
if (char !== '(' && char !== ')') {
|
|
176
|
+
target += char;
|
|
177
|
+
} else if (char === '(') {
|
|
178
|
+
target += char;
|
|
179
|
+
count++;
|
|
180
|
+
} else if (char === ')') {
|
|
181
|
+
if (--count < 0) break; // unbalanced
|
|
182
|
+
target += char;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return target;
|
|
186
|
+
}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = getAllConfigs;
|
|
7
|
-
|
|
8
|
-
var _defaultConfigStub = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
|
|
9
|
-
|
|
6
|
+
var _defaultConfigStubJs = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
|
|
10
7
|
var _featureFlags = require("../featureFlags");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
14
13
|
function getAllConfigs(config) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
var ref;
|
|
15
|
+
const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
|
|
16
|
+
_defaultConfigStubJs.default
|
|
17
|
+
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
|
|
18
|
+
);
|
|
19
|
+
const features = {
|
|
20
|
+
};
|
|
21
|
+
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags).flagEnabled(config, feature)
|
|
22
|
+
).map((feature)=>features[feature]
|
|
23
|
+
);
|
|
24
|
+
return [
|
|
25
|
+
config,
|
|
26
|
+
...experimentals,
|
|
27
|
+
...configs
|
|
28
|
+
];
|
|
29
|
+
}
|
package/lib/util/hashConfig.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = hashConfig;
|
|
7
|
-
|
|
8
6
|
var _objectHash = _interopRequireDefault(require("object-hash"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
12
|
function hashConfig(config) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
return (0, _objectHash).default(config, {
|
|
14
|
+
ignoreUnknown: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = isKeyframeRule;
|
|
7
|
-
|
|
8
6
|
function isKeyframeRule(rule) {
|
|
9
|
-
|
|
10
|
-
}
|
|
7
|
+
return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name);
|
|
8
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = isPlainObject;
|
|
7
|
-
|
|
8
6
|
function isPlainObject(value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
7
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const prototype = Object.getPrototypeOf(value);
|
|
11
|
+
return prototype === null || prototype === Object.prototype;
|
|
12
|
+
}
|
|
@@ -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
|
@@ -1,38 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = void 0;
|
|
7
|
-
|
|
8
6
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
messages.forEach(message => {
|
|
17
|
-
console.warn(_chalk.default.bold.cyan('info'), '-', message);
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
warn(messages) {
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
let alreadyShown = new Set();
|
|
13
|
+
function log(chalk, messages, key) {
|
|
22
14
|
if (process.env.JEST_WORKER_ID !== undefined) return;
|
|
15
|
+
if (key && alreadyShown.has(key)) return;
|
|
16
|
+
if (key) alreadyShown.add(key);
|
|
23
17
|
console.warn('');
|
|
24
|
-
messages.forEach(message
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
messages.forEach((message)=>console.warn(chalk, '-', message)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
var _default = {
|
|
22
|
+
info (key, messages) {
|
|
23
|
+
log(_chalk.default.bold.cyan('info'), ...Array.isArray(key) ? [
|
|
24
|
+
key
|
|
25
|
+
] : [
|
|
26
|
+
messages,
|
|
27
|
+
key
|
|
28
|
+
]);
|
|
29
|
+
},
|
|
30
|
+
warn (key, messages) {
|
|
31
|
+
log(_chalk.default.bold.yellow('warn'), ...Array.isArray(key) ? [
|
|
32
|
+
key
|
|
33
|
+
] : [
|
|
34
|
+
messages,
|
|
35
|
+
key
|
|
36
|
+
]);
|
|
37
|
+
},
|
|
38
|
+
risk (key, messages) {
|
|
39
|
+
log(_chalk.default.bold.magenta('risk'), ...Array.isArray(key) ? [
|
|
40
|
+
key
|
|
41
|
+
] : [
|
|
42
|
+
messages,
|
|
43
|
+
key
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
37
46
|
};
|
|
38
|
-
exports.default = _default;
|
|
47
|
+
exports.default = _default;
|
package/lib/util/nameClass.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
5
|
+
exports.asClass = asClass;
|
|
6
6
|
exports.default = nameClass;
|
|
7
|
-
|
|
7
|
+
exports.formatClass = formatClass;
|
|
8
8
|
var _escapeClassName = _interopRequireDefault(require("./escapeClassName"));
|
|
9
|
-
|
|
10
9
|
var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
14
15
|
function asClass(name) {
|
|
15
|
-
|
|
16
|
+
return (0, _escapeCommas).default(`.${(0, _escapeClassName).default(name)}`);
|
|
16
17
|
}
|
|
17
|
-
|
|
18
18
|
function nameClass(classPrefix, key) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
19
|
+
return asClass(formatClass(classPrefix, key));
|
|
20
|
+
}
|
|
21
|
+
function formatClass(classPrefix, key) {
|
|
22
|
+
if (key === 'DEFAULT') {
|
|
23
|
+
return classPrefix;
|
|
24
|
+
}
|
|
25
|
+
if (key === '-' || key === '-DEFAULT') {
|
|
26
|
+
return `-${classPrefix}`;
|
|
27
|
+
}
|
|
28
|
+
if (key.startsWith('-')) {
|
|
29
|
+
return `-${classPrefix}${key}`;
|
|
30
|
+
}
|
|
31
|
+
return `${classPrefix}-${key}`;
|
|
32
|
+
}
|
package/lib/util/negateValue.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = _default;
|
|
7
|
-
|
|
8
6
|
function _default(value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
7
|
+
value = `${value}`;
|
|
8
|
+
if (value === '0') {
|
|
9
|
+
return '0';
|
|
10
|
+
}
|
|
11
|
+
// Flip sign of numbers
|
|
12
|
+
if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
|
|
13
|
+
return value.replace(/^[+-]?/, (sign)=>sign === '-' ? '' : '-'
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (value.includes('var(') || value.includes('calc(')) {
|
|
17
|
+
return `calc(${value} * -1)`;
|
|
18
|
+
}
|
|
19
|
+
}
|