tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.6d7c311
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 +384 -3
- package/LICENSE +1 -2
- package/README.md +12 -8
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +239 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +13 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +4 -740
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +2064 -1811
- package/lib/css/preflight.css +5 -5
- package/lib/featureFlags.js +31 -22
- package/lib/index.js +4 -28
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +225 -31
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +118 -55
- package/lib/lib/expandApplyAtRules.js +439 -190
- package/lib/lib/expandTailwindAtRules.js +151 -134
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +454 -187
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +36 -32
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -67
- package/lib/lib/setupContextUtils.js +667 -376
- package/lib/lib/setupTrackingContext.js +38 -67
- package/lib/lib/sharedState.js +27 -14
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/oxide/cli.d.js +1 -0
- package/lib/oxide/cli.js +2 -0
- package/lib/oxide/postcss-plugin.d.js +1 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +48 -0
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +35 -25
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +11 -6
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -110
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +184 -85
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
- package/lib/util/log.js +20 -14
- package/lib/util/nameClass.js +20 -9
- package/lib/util/negateValue.js +23 -8
- package/lib/util/normalizeConfig.js +116 -72
- package/lib/util/normalizeScreens.js +120 -11
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +147 -50
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -85
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +52 -46
- package/peers/index.js +11381 -7950
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +439 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +234 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +4 -810
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +532 -217
- package/src/css/preflight.css +5 -5
- package/src/featureFlags.js +15 -9
- package/src/index.js +4 -27
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/content.js +212 -0
- package/src/lib/defaultExtractor.js +196 -33
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +482 -183
- package/src/lib/expandTailwindAtRules.js +106 -85
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +418 -129
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +51 -30
- package/src/lib/setupContextUtils.js +556 -208
- package/src/lib/setupTrackingContext.js +11 -48
- package/src/lib/sharedState.js +5 -0
- package/src/oxide/cli.d.ts +0 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.d.ts +0 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +47 -0
- 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 +8 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +29 -21
- package/src/util/formatVariantSelector.js +184 -61
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +8 -8
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +44 -6
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -32
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +167 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +362 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/nesting/plugin.js +0 -41
|
@@ -2,24 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
selectorFunctions: ()=>selectorFunctions,
|
|
13
|
+
formatVariantSelector: ()=>formatVariantSelector,
|
|
14
|
+
finalizeSelector: ()=>finalizeSelector
|
|
15
|
+
});
|
|
16
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
17
|
+
const _unesc = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
|
|
18
|
+
const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
|
|
19
|
+
const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
|
|
12
20
|
function _interopRequireDefault(obj) {
|
|
13
21
|
return obj && obj.__esModule ? obj : {
|
|
14
22
|
default: obj
|
|
15
23
|
};
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
let
|
|
25
|
+
var ref;
|
|
26
|
+
let MERGE = ":merge";
|
|
27
|
+
let PARENT = "&";
|
|
19
28
|
let selectorFunctions = new Set([
|
|
20
29
|
MERGE
|
|
21
30
|
]);
|
|
22
|
-
exports.selectorFunctions = selectorFunctions;
|
|
23
31
|
function formatVariantSelector(current, ...others) {
|
|
24
32
|
for (let other of others){
|
|
25
33
|
let incomingValue = resolveFunctionArgument(other, MERGE);
|
|
@@ -28,7 +36,7 @@ function formatVariantSelector(current, ...others) {
|
|
|
28
36
|
if (existingValue !== null) {
|
|
29
37
|
let existingTarget = `${MERGE}(${incomingValue})`;
|
|
30
38
|
let splitIdx = other.indexOf(existingTarget);
|
|
31
|
-
let addition = other.slice(splitIdx + existingTarget.length).split(
|
|
39
|
+
let addition = other.slice(splitIdx + existingTarget.length).split(" ")[0];
|
|
32
40
|
current = current.replace(existingTarget, existingTarget + addition);
|
|
33
41
|
continue;
|
|
34
42
|
}
|
|
@@ -37,23 +45,88 @@ function formatVariantSelector(current, ...others) {
|
|
|
37
45
|
}
|
|
38
46
|
return current;
|
|
39
47
|
}
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Given any node in a selector this gets the "simple" selector it's a part of
|
|
50
|
+
* A simple selector is just a list of nodes without any combinators
|
|
51
|
+
* Technically :is(), :not(), :has(), etc… can have combinators but those are nested
|
|
52
|
+
* inside the relevant node and won't be picked up so they're fine to ignore
|
|
53
|
+
*
|
|
54
|
+
* @param {import('postcss-selector-parser').Node} node
|
|
55
|
+
* @returns {import('postcss-selector-parser').Node[]}
|
|
56
|
+
**/ function simpleSelectorForNode(node) {
|
|
57
|
+
/** @type {import('postcss-selector-parser').Node[]} */ let nodes = [];
|
|
58
|
+
// Walk backwards until we hit a combinator node (or the start)
|
|
59
|
+
while(node.prev() && node.prev().type !== "combinator"){
|
|
60
|
+
node = node.prev();
|
|
61
|
+
}
|
|
62
|
+
// Now record all non-combinator nodes until we hit one (or the end)
|
|
63
|
+
while(node && node.type !== "combinator"){
|
|
64
|
+
nodes.push(node);
|
|
65
|
+
node = node.next();
|
|
66
|
+
}
|
|
67
|
+
return nodes;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resorts the nodes in a selector to ensure they're in the correct order
|
|
71
|
+
* Tags go before classes, and pseudo classes go after classes
|
|
72
|
+
*
|
|
73
|
+
* @param {import('postcss-selector-parser').Selector} sel
|
|
74
|
+
* @returns {import('postcss-selector-parser').Selector}
|
|
75
|
+
**/ function resortSelector(sel) {
|
|
76
|
+
sel.sort((a, b)=>{
|
|
77
|
+
if (a.type === "tag" && b.type === "class") {
|
|
78
|
+
return -1;
|
|
79
|
+
} else if (a.type === "class" && b.type === "tag") {
|
|
80
|
+
return 1;
|
|
81
|
+
} else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
|
|
82
|
+
return -1;
|
|
83
|
+
} else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
return sel.index(a) - sel.index(b);
|
|
87
|
+
});
|
|
88
|
+
return sel;
|
|
89
|
+
}
|
|
90
|
+
function eliminateIrrelevantSelectors(sel, base) {
|
|
91
|
+
let hasClassesMatchingCandidate = false;
|
|
92
|
+
sel.walk((child)=>{
|
|
93
|
+
if (child.type === "class" && child.value === base) {
|
|
94
|
+
hasClassesMatchingCandidate = true;
|
|
95
|
+
return false // Stop walking
|
|
96
|
+
;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (!hasClassesMatchingCandidate) {
|
|
100
|
+
sel.remove();
|
|
101
|
+
}
|
|
102
|
+
// We do NOT recursively eliminate sub selectors that don't have the base class
|
|
103
|
+
// as this is NOT a safe operation. For example, if we have:
|
|
104
|
+
// `.space-x-2 > :not([hidden]) ~ :not([hidden])`
|
|
105
|
+
// We cannot remove the [hidden] from the :not() because it would change the
|
|
106
|
+
// meaning of the selector.
|
|
107
|
+
// TODO: Can we do this for :matches, :is, and :where?
|
|
108
|
+
}
|
|
109
|
+
var ref1;
|
|
110
|
+
function finalizeSelector(format, { selector , candidate , context , isArbitraryVariant , // Split by the separator, but ignore the separator inside square brackets:
|
|
111
|
+
//
|
|
112
|
+
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
113
|
+
// ┬ ┬ ┬ ┬
|
|
114
|
+
// │ │ │ ╰── We will not split here
|
|
115
|
+
// ╰──┴─────┴─────────────── We will split here
|
|
116
|
+
//
|
|
117
|
+
base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop() }) {
|
|
42
118
|
var ref2;
|
|
43
|
-
let
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
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);
|
|
119
|
+
let ast = (0, _postcssSelectorParser.default)().astSync(selector);
|
|
120
|
+
// We explicitly DO NOT prefix classes in arbitrary variants
|
|
121
|
+
if ((context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) && !isArbitraryVariant) {
|
|
122
|
+
format = (0, _prefixSelector.default)(context.tailwindConfig.prefix, format);
|
|
55
123
|
}
|
|
56
|
-
format = format.replace(PARENT, `.${(0, _escapeClassName
|
|
124
|
+
format = format.replace(PARENT, `.${(0, _escapeClassName.default)(candidate)}`);
|
|
125
|
+
let formatAst = (0, _postcssSelectorParser.default)().astSync(format);
|
|
126
|
+
// Remove extraneous selectors that do not include the base class/candidate being matched against
|
|
127
|
+
// For example if we have a utility defined `.a, .b { color: red}`
|
|
128
|
+
// And the formatted variant is sm:b then we want the final selector to be `.sm\:b` and not `.a, .sm\:b`
|
|
129
|
+
ast.each((sel)=>eliminateIrrelevantSelectors(sel, base));
|
|
57
130
|
// Normalize escaped classes, e.g.:
|
|
58
131
|
//
|
|
59
132
|
// The idea would be to replace the escaped `base` in the selector with the
|
|
@@ -65,69 +138,95 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
|
|
|
65
138
|
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
66
139
|
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
67
140
|
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
141
|
+
ast.walkClasses((node)=>{
|
|
142
|
+
if (node.raws && node.value.includes(base)) {
|
|
143
|
+
node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
let simpleStart = _postcssSelectorParser.default.comment({
|
|
147
|
+
value: "/*__simple__*/"
|
|
148
|
+
});
|
|
149
|
+
let simpleEnd = _postcssSelectorParser.default.comment({
|
|
150
|
+
value: "/*__simple__*/"
|
|
151
|
+
});
|
|
76
152
|
// We can safely replace the escaped base now, since the `base` section is
|
|
77
153
|
// now in a normalized escaped value.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
154
|
+
ast.walkClasses((node)=>{
|
|
155
|
+
if (node.value !== base) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
let parent = node.parent;
|
|
159
|
+
let formatNodes = formatAst.nodes[0].nodes;
|
|
160
|
+
// Perf optimization: if the parent is a single class we can just replace it and be done
|
|
161
|
+
if (parent.nodes.length === 1) {
|
|
162
|
+
node.replaceWith(...formatNodes);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
let simpleSelector = simpleSelectorForNode(node);
|
|
166
|
+
parent.insertBefore(simpleSelector[0], simpleStart);
|
|
167
|
+
parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
|
|
168
|
+
for (let child of formatNodes){
|
|
169
|
+
parent.insertBefore(simpleSelector[0], child);
|
|
170
|
+
}
|
|
171
|
+
node.remove();
|
|
172
|
+
// Re-sort the simple selector to ensure it's in the correct order
|
|
173
|
+
simpleSelector = simpleSelectorForNode(simpleStart);
|
|
174
|
+
let firstNode = parent.index(simpleStart);
|
|
175
|
+
parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssSelectorParser.default.selector({
|
|
176
|
+
nodes: simpleSelector
|
|
177
|
+
})).nodes);
|
|
178
|
+
simpleStart.remove();
|
|
179
|
+
simpleEnd.remove();
|
|
180
|
+
});
|
|
181
|
+
// This will make sure to move pseudo's to the correct spot (the end for
|
|
182
|
+
// pseudo elements) because otherwise the selector will never work
|
|
183
|
+
// anyway.
|
|
184
|
+
//
|
|
185
|
+
// E.g.:
|
|
186
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
187
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
188
|
+
//
|
|
189
|
+
// `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
190
|
+
function collectPseudoElements(selector) {
|
|
191
|
+
let nodes = [];
|
|
192
|
+
for (let node of selector.nodes){
|
|
193
|
+
if (isPseudoElement(node)) {
|
|
194
|
+
nodes.push(node);
|
|
195
|
+
selector.removeChild(node);
|
|
109
196
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
197
|
+
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
198
|
+
nodes.push(...collectPseudoElements(node));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return nodes;
|
|
202
|
+
}
|
|
203
|
+
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
204
|
+
ast.each((selector)=>{
|
|
205
|
+
selector.walkPseudos((p)=>{
|
|
206
|
+
if (selectorFunctions.has(p.value)) {
|
|
207
|
+
p.replaceWith(p.nodes);
|
|
113
208
|
}
|
|
114
|
-
return selector2;
|
|
115
209
|
});
|
|
116
|
-
|
|
210
|
+
let pseudoElements = collectPseudoElements(selector);
|
|
211
|
+
if (pseudoElements.length > 0) {
|
|
212
|
+
selector.nodes.push(pseudoElements.sort(sortSelector));
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
return ast.toString();
|
|
117
216
|
}
|
|
118
217
|
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
119
218
|
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
120
219
|
// this distinction was not present in older versions of the W3C spec, most
|
|
121
220
|
// browsers support both syntaxes for the original pseudo-elements.
|
|
122
221
|
let pseudoElementsBC = [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
222
|
+
":before",
|
|
223
|
+
":after",
|
|
224
|
+
":first-line",
|
|
225
|
+
":first-letter"
|
|
127
226
|
];
|
|
128
227
|
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
129
228
|
let pseudoElementExceptions = [
|
|
130
|
-
|
|
229
|
+
"::file-selector-button"
|
|
131
230
|
];
|
|
132
231
|
// This will make sure to move pseudo's to the correct spot (the end for
|
|
133
232
|
// pseudo elements) because otherwise the selector will never work
|
|
@@ -142,42 +241,42 @@ let pseudoElementExceptions = [
|
|
|
142
241
|
function sortSelector(a, z) {
|
|
143
242
|
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
144
243
|
// them in the same order.
|
|
145
|
-
if (a.type !==
|
|
244
|
+
if (a.type !== "pseudo" && z.type !== "pseudo") {
|
|
146
245
|
return 0;
|
|
147
246
|
}
|
|
148
247
|
// If one of them is a combinator, we need to keep it in the same order
|
|
149
248
|
// because that means it will start a new "section" in the selector.
|
|
150
|
-
if (a.type ===
|
|
249
|
+
if (a.type === "combinator" ^ z.type === "combinator") {
|
|
151
250
|
return 0;
|
|
152
251
|
}
|
|
153
252
|
// One of the items is a pseudo and the other one isn't. Let's move
|
|
154
253
|
// the pseudo to the right.
|
|
155
|
-
if (a.type ===
|
|
156
|
-
return (a.type ===
|
|
254
|
+
if (a.type === "pseudo" ^ z.type === "pseudo") {
|
|
255
|
+
return (a.type === "pseudo") - (z.type === "pseudo");
|
|
157
256
|
}
|
|
158
257
|
// Both are pseudo's, move the pseudo elements (except for
|
|
159
258
|
// ::file-selector-button) to the right.
|
|
160
259
|
return isPseudoElement(a) - isPseudoElement(z);
|
|
161
260
|
}
|
|
162
261
|
function isPseudoElement(node) {
|
|
163
|
-
if (node.type !==
|
|
262
|
+
if (node.type !== "pseudo") return false;
|
|
164
263
|
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
165
|
-
return node.value.startsWith(
|
|
264
|
+
return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
|
|
166
265
|
}
|
|
167
266
|
function resolveFunctionArgument(haystack, needle, arg) {
|
|
168
267
|
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
169
268
|
if (startIdx === -1) return null;
|
|
170
269
|
// Start inside the `(`
|
|
171
270
|
startIdx += needle.length + 1;
|
|
172
|
-
let target =
|
|
271
|
+
let target = "";
|
|
173
272
|
let count = 0;
|
|
174
273
|
for (let char of haystack.slice(startIdx)){
|
|
175
|
-
if (char !==
|
|
274
|
+
if (char !== "(" && char !== ")") {
|
|
176
275
|
target += char;
|
|
177
|
-
} else if (char ===
|
|
276
|
+
} else if (char === "(") {
|
|
178
277
|
target += char;
|
|
179
278
|
count++;
|
|
180
|
-
} else if (char ===
|
|
279
|
+
} else if (char === ")") {
|
|
181
280
|
if (--count < 0) break; // unbalanced
|
|
182
281
|
target += char;
|
|
183
282
|
}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>getAllConfigs
|
|
8
|
+
});
|
|
9
|
+
const _defaultConfigStubJs = /*#__PURE__*/ _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
|
|
10
|
+
const _featureFlags = require("../featureFlags");
|
|
8
11
|
function _interopRequireDefault(obj) {
|
|
9
12
|
return obj && obj.__esModule ? obj : {
|
|
10
13
|
default: obj
|
|
@@ -14,13 +17,29 @@ function getAllConfigs(config) {
|
|
|
14
17
|
var ref;
|
|
15
18
|
const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
|
|
16
19
|
_defaultConfigStubJs.default
|
|
17
|
-
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
|
|
18
|
-
);
|
|
20
|
+
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
19
21
|
const features = {
|
|
22
|
+
// Add experimental configs here...
|
|
23
|
+
respectDefaultRingColorOpacity: {
|
|
24
|
+
theme: {
|
|
25
|
+
ringColor: ({ theme })=>({
|
|
26
|
+
DEFAULT: "#3b82f67f",
|
|
27
|
+
...theme("colors")
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
disableColorOpacityUtilitiesByDefault: {
|
|
32
|
+
corePlugins: {
|
|
33
|
+
backgroundOpacity: false,
|
|
34
|
+
borderOpacity: false,
|
|
35
|
+
divideOpacity: false,
|
|
36
|
+
placeholderOpacity: false,
|
|
37
|
+
ringOpacity: false,
|
|
38
|
+
textOpacity: false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
20
41
|
};
|
|
21
|
-
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags
|
|
22
|
-
).map((feature)=>features[feature]
|
|
23
|
-
);
|
|
42
|
+
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags.flagEnabled)(config, feature)).map((feature)=>features[feature]);
|
|
24
43
|
return [
|
|
25
44
|
config,
|
|
26
45
|
...experimentals,
|
package/lib/util/hashConfig.js
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>hashConfig
|
|
8
|
+
});
|
|
9
|
+
const _objectHash = /*#__PURE__*/ _interopRequireDefault(require("object-hash"));
|
|
7
10
|
function _interopRequireDefault(obj) {
|
|
8
11
|
return obj && obj.__esModule ? obj : {
|
|
9
12
|
default: obj
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
function hashConfig(config) {
|
|
13
|
-
return (0, _objectHash
|
|
16
|
+
return (0, _objectHash.default)(config, {
|
|
14
17
|
ignoreUnknown: true
|
|
15
18
|
});
|
|
16
19
|
}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>isKeyframeRule
|
|
8
|
+
});
|
|
6
9
|
function isKeyframeRule(rule) {
|
|
7
|
-
return rule.parent && rule.parent.type ===
|
|
10
|
+
return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
|
|
8
11
|
}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>isPlainObject
|
|
8
|
+
});
|
|
6
9
|
function isPlainObject(value) {
|
|
7
|
-
if (Object.prototype.toString.call(value) !==
|
|
10
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
8
11
|
return false;
|
|
9
12
|
}
|
|
10
13
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -2,45 +2,53 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
5
|
+
Object.defineProperty(exports, // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
6
|
+
// values don't count, and brackets inside quotes also don't count.
|
|
7
|
+
//
|
|
8
|
+
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
9
|
+
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
10
|
+
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
11
|
+
"default", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: ()=>isSyntacticallyValidPropertyValue
|
|
14
|
+
});
|
|
6
15
|
let matchingBrackets = new Map([
|
|
7
16
|
[
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
"{",
|
|
18
|
+
"}"
|
|
10
19
|
],
|
|
11
20
|
[
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
"[",
|
|
22
|
+
"]"
|
|
14
23
|
],
|
|
15
24
|
[
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
25
|
+
"(",
|
|
26
|
+
")"
|
|
27
|
+
]
|
|
19
28
|
]);
|
|
20
29
|
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
21
30
|
v,
|
|
22
31
|
k
|
|
23
|
-
]
|
|
24
|
-
));
|
|
32
|
+
]));
|
|
25
33
|
let quotes = new Set([
|
|
26
34
|
'"',
|
|
27
35
|
"'",
|
|
28
|
-
|
|
36
|
+
"`"
|
|
29
37
|
]);
|
|
30
|
-
function
|
|
38
|
+
function isSyntacticallyValidPropertyValue(value) {
|
|
31
39
|
let stack = [];
|
|
32
40
|
let inQuotes = false;
|
|
33
41
|
for(let i = 0; i < value.length; i++){
|
|
34
42
|
let char = value[i];
|
|
35
|
-
if (char ===
|
|
43
|
+
if (char === ":" && !inQuotes && stack.length === 0) {
|
|
36
44
|
return false;
|
|
37
45
|
}
|
|
38
46
|
// Non-escaped quotes allow us to "allow" anything in between
|
|
39
|
-
if (quotes.has(char) && value[i - 1] !==
|
|
47
|
+
if (quotes.has(char) && value[i - 1] !== "\\") {
|
|
40
48
|
inQuotes = !inQuotes;
|
|
41
49
|
}
|
|
42
50
|
if (inQuotes) continue;
|
|
43
|
-
if (value[i - 1] ===
|
|
51
|
+
if (value[i - 1] === "\\") continue; // Escaped
|
|
44
52
|
if (matchingBrackets.has(char)) {
|
|
45
53
|
stack.push(char);
|
|
46
54
|
} else if (inverseMatchingBrackets.has(char)) {
|
package/lib/util/log.js
CHANGED
|
@@ -2,29 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
dim: ()=>dim,
|
|
13
|
+
default: ()=>_default
|
|
14
|
+
});
|
|
15
|
+
const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
|
|
8
16
|
function _interopRequireDefault(obj) {
|
|
9
17
|
return obj && obj.__esModule ? obj : {
|
|
10
18
|
default: obj
|
|
11
19
|
};
|
|
12
20
|
}
|
|
13
21
|
let alreadyShown = new Set();
|
|
14
|
-
function log(
|
|
15
|
-
if (process.env.JEST_WORKER_ID
|
|
22
|
+
function log(type, messages, key) {
|
|
23
|
+
if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) return;
|
|
16
24
|
if (key && alreadyShown.has(key)) return;
|
|
17
25
|
if (key) alreadyShown.add(key);
|
|
18
|
-
console.warn(
|
|
19
|
-
messages.forEach((message)=>console.warn(
|
|
20
|
-
);
|
|
26
|
+
console.warn("");
|
|
27
|
+
messages.forEach((message)=>console.warn(type, "-", message));
|
|
21
28
|
}
|
|
22
29
|
function dim(input) {
|
|
23
|
-
return
|
|
30
|
+
return _picocolors.default.dim(input);
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
const _default = {
|
|
26
33
|
info (key, messages) {
|
|
27
|
-
log(
|
|
34
|
+
log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
|
|
28
35
|
key
|
|
29
36
|
] : [
|
|
30
37
|
messages,
|
|
@@ -32,7 +39,7 @@ var _default = {
|
|
|
32
39
|
]);
|
|
33
40
|
},
|
|
34
41
|
warn (key, messages) {
|
|
35
|
-
log(
|
|
42
|
+
log(_picocolors.default.bold(_picocolors.default.yellow("warn")), ...Array.isArray(key) ? [
|
|
36
43
|
key
|
|
37
44
|
] : [
|
|
38
45
|
messages,
|
|
@@ -40,7 +47,7 @@ var _default = {
|
|
|
40
47
|
]);
|
|
41
48
|
},
|
|
42
49
|
risk (key, messages) {
|
|
43
|
-
log(
|
|
50
|
+
log(_picocolors.default.bold(_picocolors.default.magenta("risk")), ...Array.isArray(key) ? [
|
|
44
51
|
key
|
|
45
52
|
] : [
|
|
46
53
|
messages,
|
|
@@ -48,4 +55,3 @@ var _default = {
|
|
|
48
55
|
]);
|
|
49
56
|
}
|
|
50
57
|
};
|
|
51
|
-
exports.default = _default;
|
package/lib/util/nameClass.js
CHANGED
|
@@ -2,31 +2,42 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
asClass: ()=>asClass,
|
|
13
|
+
default: ()=>nameClass,
|
|
14
|
+
formatClass: ()=>formatClass
|
|
15
|
+
});
|
|
16
|
+
const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("./escapeClassName"));
|
|
17
|
+
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
10
18
|
function _interopRequireDefault(obj) {
|
|
11
19
|
return obj && obj.__esModule ? obj : {
|
|
12
20
|
default: obj
|
|
13
21
|
};
|
|
14
22
|
}
|
|
15
23
|
function asClass(name) {
|
|
16
|
-
return (0, _escapeCommas
|
|
24
|
+
return (0, _escapeCommas.default)(`.${(0, _escapeClassName.default)(name)}`);
|
|
17
25
|
}
|
|
18
26
|
function nameClass(classPrefix, key) {
|
|
19
27
|
return asClass(formatClass(classPrefix, key));
|
|
20
28
|
}
|
|
21
29
|
function formatClass(classPrefix, key) {
|
|
22
|
-
if (key ===
|
|
30
|
+
if (key === "DEFAULT") {
|
|
23
31
|
return classPrefix;
|
|
24
32
|
}
|
|
25
|
-
if (key ===
|
|
33
|
+
if (key === "-" || key === "-DEFAULT") {
|
|
26
34
|
return `-${classPrefix}`;
|
|
27
35
|
}
|
|
28
|
-
if (key.startsWith(
|
|
36
|
+
if (key.startsWith("-")) {
|
|
29
37
|
return `-${classPrefix}${key}`;
|
|
30
38
|
}
|
|
39
|
+
if (key.startsWith("/")) {
|
|
40
|
+
return `${classPrefix}${key}`;
|
|
41
|
+
}
|
|
31
42
|
return `${classPrefix}-${key}`;
|
|
32
43
|
}
|