tailwindcss 0.0.0-insiders.ff2c25f → 0.0.0-internal.b2586d4e
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/README.md +5 -6
- package/dist/lib.d.mts +339 -0
- package/dist/lib.d.ts +339 -0
- package/dist/lib.js +17 -0
- package/dist/lib.mjs +17 -0
- package/index.css +5 -0
- package/package.json +36 -107
- package/preflight.css +334 -0
- package/theme.css +463 -0
- package/base.css +0 -1
- package/colors.d.ts +0 -3
- package/colors.js +0 -2
- package/components.css +0 -1
- package/defaultConfig.d.ts +0 -3
- package/defaultConfig.js +0 -2
- package/defaultTheme.d.ts +0 -4
- package/defaultTheme.js +0 -2
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli/build/index.js +0 -48
- package/lib/cli/build/plugin.js +0 -367
- package/lib/cli/build/utils.js +0 -78
- package/lib/cli/build/watching.js +0 -178
- package/lib/cli/help/index.js +0 -71
- package/lib/cli/index.js +0 -239
- package/lib/cli/init/index.js +0 -46
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/cli.js +0 -7
- package/lib/constants.js +0 -44
- package/lib/corePluginList.js +0 -181
- package/lib/corePlugins.js +0 -4062
- package/lib/css/LICENSE +0 -25
- package/lib/css/preflight.css +0 -367
- package/lib/featureFlags.js +0 -71
- package/lib/index.js +0 -6
- package/lib/lib/cacheInvalidation.js +0 -90
- package/lib/lib/collapseAdjacentRules.js +0 -59
- package/lib/lib/collapseDuplicateDeclarations.js +0 -83
- package/lib/lib/content.js +0 -177
- package/lib/lib/defaultExtractor.js +0 -241
- package/lib/lib/detectNesting.js +0 -43
- package/lib/lib/evaluateTailwindFunctions.js +0 -234
- package/lib/lib/expandApplyAtRules.js +0 -526
- package/lib/lib/expandTailwindAtRules.js +0 -273
- package/lib/lib/findAtConfigPath.js +0 -44
- package/lib/lib/generateRules.js +0 -866
- package/lib/lib/getModuleDependencies.js +0 -51
- package/lib/lib/normalizeTailwindDirectives.js +0 -87
- package/lib/lib/offsets.js +0 -299
- package/lib/lib/partitionApplyAtRules.js +0 -56
- package/lib/lib/regex.js +0 -60
- package/lib/lib/remap-bitfield.js +0 -87
- package/lib/lib/resolveDefaultsAtRules.js +0 -161
- package/lib/lib/setupContextUtils.js +0 -1218
- package/lib/lib/setupTrackingContext.js +0 -163
- package/lib/lib/sharedState.js +0 -78
- package/lib/lib/substituteScreenAtRules.js +0 -29
- package/lib/oxide/cli/build/deps.js +0 -81
- package/lib/oxide/cli/build/index.js +0 -47
- package/lib/oxide/cli/build/plugin.js +0 -364
- package/lib/oxide/cli/build/utils.js +0 -77
- package/lib/oxide/cli/build/watching.js +0 -177
- package/lib/oxide/cli/help/index.js +0 -70
- package/lib/oxide/cli/index.js +0 -220
- package/lib/oxide/cli/init/index.js +0 -35
- package/lib/oxide/cli.js +0 -5
- package/lib/oxide/postcss-plugin.js +0 -2
- package/lib/plugin.js +0 -48
- package/lib/postcss-plugins/nesting/README.md +0 -42
- package/lib/postcss-plugins/nesting/index.js +0 -19
- package/lib/postcss-plugins/nesting/plugin.js +0 -87
- package/lib/processTailwindFeatures.js +0 -62
- package/lib/public/colors.js +0 -331
- package/lib/public/create-plugin.js +0 -15
- package/lib/public/default-config.js +0 -16
- package/lib/public/default-theme.js +0 -16
- package/lib/public/resolve-config.js +0 -22
- package/lib/util/bigSign.js +0 -11
- package/lib/util/buildMediaQuery.js +0 -25
- package/lib/util/cloneDeep.js +0 -20
- package/lib/util/cloneNodes.js +0 -32
- package/lib/util/color.js +0 -98
- package/lib/util/configurePlugins.js +0 -21
- package/lib/util/createPlugin.js +0 -30
- package/lib/util/createUtilityPlugin.js +0 -51
- package/lib/util/dataTypes.js +0 -266
- package/lib/util/defaults.js +0 -25
- package/lib/util/escapeClassName.js +0 -22
- package/lib/util/escapeCommas.js +0 -11
- package/lib/util/flattenColorPalette.js +0 -16
- package/lib/util/formatVariantSelector.js +0 -351
- package/lib/util/getAllConfigs.js +0 -48
- package/lib/util/hashConfig.js +0 -19
- package/lib/util/isKeyframeRule.js +0 -11
- package/lib/util/isPlainObject.js +0 -15
- package/lib/util/isSyntacticallyValidPropertyValue.js +0 -72
- package/lib/util/log.js +0 -57
- package/lib/util/nameClass.js +0 -43
- package/lib/util/negateValue.js +0 -34
- package/lib/util/normalizeConfig.js +0 -281
- package/lib/util/normalizeScreens.js +0 -170
- package/lib/util/parseAnimationValue.js +0 -91
- package/lib/util/parseBoxShadowValue.js +0 -84
- package/lib/util/parseDependency.js +0 -45
- package/lib/util/parseGlob.js +0 -34
- package/lib/util/parseObjectStyles.js +0 -34
- package/lib/util/pluginUtils.js +0 -283
- package/lib/util/prefixSelector.js +0 -37
- package/lib/util/removeAlphaVariables.js +0 -29
- package/lib/util/resolveConfig.js +0 -254
- package/lib/util/resolveConfigPath.js +0 -54
- package/lib/util/responsive.js +0 -22
- package/lib/util/splitAtTopLevelOnly.js +0 -43
- package/lib/util/tap.js +0 -12
- package/lib/util/toColorValue.js +0 -11
- package/lib/util/toPath.js +0 -30
- package/lib/util/transformThemeValue.js +0 -71
- package/lib/util/validateConfig.js +0 -24
- package/lib/util/validateFormalSyntax.js +0 -24
- package/lib/util/withAlphaVariable.js +0 -75
- package/nesting/index.js +0 -2
- package/oxide-node-api-shim/index.js +0 -21
- package/oxide-node-api-shim/package.json +0 -5
- package/peers/index.js +0 -79461
- package/plugin.d.ts +0 -11
- package/plugin.js +0 -2
- package/prettier.config.js +0 -19
- package/resolveConfig.d.ts +0 -12
- package/resolveConfig.js +0 -2
- package/screens.css +0 -1
- package/scripts/create-plugin-list.js +0 -10
- package/scripts/generate-types.js +0 -105
- package/scripts/release-channel.js +0 -18
- package/scripts/release-notes.js +0 -21
- package/scripts/swap-engines.js +0 -40
- package/scripts/type-utils.js +0 -27
- package/src/cli/build/deps.js +0 -56
- package/src/cli/build/index.js +0 -49
- package/src/cli/build/plugin.js +0 -439
- package/src/cli/build/utils.js +0 -76
- package/src/cli/build/watching.js +0 -227
- package/src/cli/help/index.js +0 -70
- package/src/cli/index.js +0 -234
- package/src/cli/init/index.js +0 -50
- package/src/cli-peer-dependencies.js +0 -15
- package/src/cli.js +0 -7
- package/src/constants.js +0 -17
- package/src/corePluginList.js +0 -1
- package/src/corePlugins.js +0 -2744
- package/src/css/LICENSE +0 -25
- package/src/css/preflight.css +0 -367
- package/src/featureFlags.js +0 -64
- package/src/index.js +0 -5
- package/src/lib/cacheInvalidation.js +0 -52
- package/src/lib/collapseAdjacentRules.js +0 -58
- package/src/lib/collapseDuplicateDeclarations.js +0 -93
- package/src/lib/content.js +0 -208
- package/src/lib/defaultExtractor.js +0 -217
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/evaluateTailwindFunctions.js +0 -269
- package/src/lib/expandApplyAtRules.js +0 -606
- package/src/lib/expandTailwindAtRules.js +0 -285
- package/src/lib/findAtConfigPath.js +0 -48
- package/src/lib/generateRules.js +0 -899
- package/src/lib/getModuleDependencies.js +0 -39
- package/src/lib/normalizeTailwindDirectives.js +0 -84
- package/src/lib/offsets.js +0 -367
- package/src/lib/partitionApplyAtRules.js +0 -52
- package/src/lib/regex.js +0 -74
- package/src/lib/remap-bitfield.js +0 -82
- package/src/lib/resolveDefaultsAtRules.js +0 -163
- package/src/lib/setupContextUtils.js +0 -1308
- package/src/lib/setupTrackingContext.js +0 -171
- package/src/lib/sharedState.js +0 -67
- package/src/lib/substituteScreenAtRules.js +0 -19
- package/src/oxide/cli/build/deps.ts +0 -91
- package/src/oxide/cli/build/index.ts +0 -47
- package/src/oxide/cli/build/plugin.ts +0 -436
- package/src/oxide/cli/build/utils.ts +0 -74
- package/src/oxide/cli/build/watching.ts +0 -225
- package/src/oxide/cli/help/index.ts +0 -69
- package/src/oxide/cli/index.ts +0 -212
- package/src/oxide/cli/init/index.ts +0 -32
- package/src/oxide/cli.ts +0 -1
- package/src/oxide/postcss-plugin.ts +0 -1
- package/src/plugin.js +0 -47
- package/src/postcss-plugins/nesting/README.md +0 -42
- package/src/postcss-plugins/nesting/index.js +0 -13
- package/src/postcss-plugins/nesting/plugin.js +0 -80
- package/src/processTailwindFeatures.js +0 -58
- package/src/public/colors.js +0 -300
- package/src/public/create-plugin.js +0 -2
- package/src/public/default-config.js +0 -4
- package/src/public/default-theme.js +0 -4
- package/src/public/resolve-config.js +0 -7
- package/src/util/bigSign.js +0 -3
- package/src/util/buildMediaQuery.js +0 -22
- package/src/util/cloneDeep.js +0 -11
- package/src/util/cloneNodes.js +0 -28
- package/src/util/color.js +0 -73
- package/src/util/configurePlugins.js +0 -23
- package/src/util/createPlugin.js +0 -27
- package/src/util/createUtilityPlugin.js +0 -37
- package/src/util/dataTypes.js +0 -281
- package/src/util/defaults.js +0 -17
- package/src/util/escapeClassName.js +0 -8
- package/src/util/escapeCommas.js +0 -3
- package/src/util/flattenColorPalette.js +0 -13
- package/src/util/formatVariantSelector.js +0 -412
- package/src/util/getAllConfigs.js +0 -38
- package/src/util/hashConfig.js +0 -5
- package/src/util/isKeyframeRule.js +0 -3
- package/src/util/isPlainObject.js +0 -8
- package/src/util/isSyntacticallyValidPropertyValue.js +0 -61
- package/src/util/log.js +0 -29
- package/src/util/nameClass.js +0 -30
- package/src/util/negateValue.js +0 -24
- package/src/util/normalizeConfig.js +0 -300
- package/src/util/normalizeScreens.js +0 -140
- package/src/util/parseAnimationValue.js +0 -68
- package/src/util/parseBoxShadowValue.js +0 -72
- package/src/util/parseDependency.js +0 -44
- package/src/util/parseGlob.js +0 -24
- package/src/util/parseObjectStyles.js +0 -19
- package/src/util/pluginUtils.js +0 -314
- package/src/util/prefixSelector.js +0 -32
- package/src/util/removeAlphaVariables.js +0 -24
- package/src/util/resolveConfig.js +0 -277
- package/src/util/resolveConfigPath.js +0 -55
- package/src/util/responsive.js +0 -10
- package/src/util/splitAtTopLevelOnly.js +0 -45
- package/src/util/tap.js +0 -4
- package/src/util/toColorValue.js +0 -3
- package/src/util/toPath.js +0 -26
- package/src/util/transformThemeValue.js +0 -62
- package/src/util/validateConfig.js +0 -13
- package/src/util/validateFormalSyntax.js +0 -34
- package/src/util/withAlphaVariable.js +0 -49
- package/stubs/defaultConfig.stub.js +0 -956
- package/stubs/defaultPostCssConfig.stub.js +0 -6
- package/stubs/simpleConfig.stub.js +0 -8
- package/tailwind.css +0 -5
- package/types/config.d.ts +0 -367
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +0 -276
- package/types/generated/corePluginList.d.ts +0 -1
- package/types/generated/default-theme.d.ts +0 -345
- package/types/index.d.ts +0 -7
- package/variants.css +0 -1
package/lib/util/dataTypes.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
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
|
-
normalize: ()=>normalize,
|
|
13
|
-
url: ()=>url,
|
|
14
|
-
number: ()=>number,
|
|
15
|
-
percentage: ()=>percentage,
|
|
16
|
-
length: ()=>length,
|
|
17
|
-
lineWidth: ()=>lineWidth,
|
|
18
|
-
shadow: ()=>shadow,
|
|
19
|
-
color: ()=>color,
|
|
20
|
-
image: ()=>image,
|
|
21
|
-
gradient: ()=>gradient,
|
|
22
|
-
position: ()=>position,
|
|
23
|
-
familyName: ()=>familyName,
|
|
24
|
-
genericName: ()=>genericName,
|
|
25
|
-
absoluteSize: ()=>absoluteSize,
|
|
26
|
-
relativeSize: ()=>relativeSize
|
|
27
|
-
});
|
|
28
|
-
const _color = require("./color");
|
|
29
|
-
const _parseBoxShadowValue = require("./parseBoxShadowValue");
|
|
30
|
-
const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
|
|
31
|
-
let cssFunctions = [
|
|
32
|
-
"min",
|
|
33
|
-
"max",
|
|
34
|
-
"clamp",
|
|
35
|
-
"calc"
|
|
36
|
-
];
|
|
37
|
-
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
38
|
-
function isCSSFunction(value) {
|
|
39
|
-
return cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.*\\)`).test(value));
|
|
40
|
-
}
|
|
41
|
-
const placeholder = "--tw-placeholder";
|
|
42
|
-
const placeholderRe = new RegExp(placeholder, "g");
|
|
43
|
-
function normalize(value, isRoot = true) {
|
|
44
|
-
if (value.startsWith("--")) {
|
|
45
|
-
return `var(${value})`;
|
|
46
|
-
}
|
|
47
|
-
// Keep raw strings if it starts with `url(`
|
|
48
|
-
if (value.includes("url(")) {
|
|
49
|
-
return value.split(/(url\(.*?\))/g).filter(Boolean).map((part)=>{
|
|
50
|
-
if (/^url\(.*?\)$/.test(part)) {
|
|
51
|
-
return part;
|
|
52
|
-
}
|
|
53
|
-
return normalize(part, false);
|
|
54
|
-
}).join("");
|
|
55
|
-
}
|
|
56
|
-
// Convert `_` to ` `, except for escaped underscores `\_`
|
|
57
|
-
value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + " ".repeat(fullMatch.length - 1)).replace(/^_/g, " ").replace(/\\_/g, "_");
|
|
58
|
-
// Remove leftover whitespace
|
|
59
|
-
if (isRoot) {
|
|
60
|
-
value = value.trim();
|
|
61
|
-
}
|
|
62
|
-
// Add spaces around operators inside math functions like calc() that do not follow an operator
|
|
63
|
-
// or '('.
|
|
64
|
-
value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
|
|
65
|
-
let vars = [];
|
|
66
|
-
return match.replace(/var\((--.+?)[,)]/g, (match, g1)=>{
|
|
67
|
-
vars.push(g1);
|
|
68
|
-
return match.replace(g1, placeholder);
|
|
69
|
-
}).replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(placeholderRe, ()=>vars.shift());
|
|
70
|
-
});
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
function url(value) {
|
|
74
|
-
return value.startsWith("url(");
|
|
75
|
-
}
|
|
76
|
-
function number(value) {
|
|
77
|
-
return !isNaN(Number(value)) || isCSSFunction(value);
|
|
78
|
-
}
|
|
79
|
-
function percentage(value) {
|
|
80
|
-
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
|
|
81
|
-
}
|
|
82
|
-
// Please refer to MDN when updating this list:
|
|
83
|
-
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
|
|
84
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
|
|
85
|
-
let lengthUnits = [
|
|
86
|
-
"cm",
|
|
87
|
-
"mm",
|
|
88
|
-
"Q",
|
|
89
|
-
"in",
|
|
90
|
-
"pc",
|
|
91
|
-
"pt",
|
|
92
|
-
"px",
|
|
93
|
-
"em",
|
|
94
|
-
"ex",
|
|
95
|
-
"ch",
|
|
96
|
-
"rem",
|
|
97
|
-
"lh",
|
|
98
|
-
"rlh",
|
|
99
|
-
"vw",
|
|
100
|
-
"vh",
|
|
101
|
-
"vmin",
|
|
102
|
-
"vmax",
|
|
103
|
-
"vb",
|
|
104
|
-
"vi",
|
|
105
|
-
"svw",
|
|
106
|
-
"svh",
|
|
107
|
-
"lvw",
|
|
108
|
-
"lvh",
|
|
109
|
-
"dvw",
|
|
110
|
-
"dvh",
|
|
111
|
-
"cqw",
|
|
112
|
-
"cqh",
|
|
113
|
-
"cqi",
|
|
114
|
-
"cqb",
|
|
115
|
-
"cqmin",
|
|
116
|
-
"cqmax"
|
|
117
|
-
];
|
|
118
|
-
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
|
|
119
|
-
function length(value) {
|
|
120
|
-
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
|
|
121
|
-
}
|
|
122
|
-
let lineWidths = new Set([
|
|
123
|
-
"thin",
|
|
124
|
-
"medium",
|
|
125
|
-
"thick"
|
|
126
|
-
]);
|
|
127
|
-
function lineWidth(value) {
|
|
128
|
-
return lineWidths.has(value);
|
|
129
|
-
}
|
|
130
|
-
function shadow(value) {
|
|
131
|
-
let parsedShadows = (0, _parseBoxShadowValue.parseBoxShadowValue)(normalize(value));
|
|
132
|
-
for (let parsedShadow of parsedShadows){
|
|
133
|
-
if (!parsedShadow.valid) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
function color(value) {
|
|
140
|
-
let colors = 0;
|
|
141
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, "_").every((part)=>{
|
|
142
|
-
part = normalize(part);
|
|
143
|
-
if (part.startsWith("var(")) return true;
|
|
144
|
-
if ((0, _color.parseColor)(part, {
|
|
145
|
-
loose: true
|
|
146
|
-
}) !== null) return colors++, true;
|
|
147
|
-
return false;
|
|
148
|
-
});
|
|
149
|
-
if (!result) return false;
|
|
150
|
-
return colors > 0;
|
|
151
|
-
}
|
|
152
|
-
function image(value) {
|
|
153
|
-
let images = 0;
|
|
154
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, ",").every((part)=>{
|
|
155
|
-
part = normalize(part);
|
|
156
|
-
if (part.startsWith("var(")) return true;
|
|
157
|
-
if (url(part) || gradient(part) || [
|
|
158
|
-
"element(",
|
|
159
|
-
"image(",
|
|
160
|
-
"cross-fade(",
|
|
161
|
-
"image-set("
|
|
162
|
-
].some((fn)=>part.startsWith(fn))) {
|
|
163
|
-
images++;
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
return false;
|
|
167
|
-
});
|
|
168
|
-
if (!result) return false;
|
|
169
|
-
return images > 0;
|
|
170
|
-
}
|
|
171
|
-
let gradientTypes = new Set([
|
|
172
|
-
"linear-gradient",
|
|
173
|
-
"radial-gradient",
|
|
174
|
-
"repeating-linear-gradient",
|
|
175
|
-
"repeating-radial-gradient",
|
|
176
|
-
"conic-gradient"
|
|
177
|
-
]);
|
|
178
|
-
function gradient(value) {
|
|
179
|
-
value = normalize(value);
|
|
180
|
-
for (let type of gradientTypes){
|
|
181
|
-
if (value.startsWith(`${type}(`)) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
let validPositions = new Set([
|
|
188
|
-
"center",
|
|
189
|
-
"top",
|
|
190
|
-
"right",
|
|
191
|
-
"bottom",
|
|
192
|
-
"left"
|
|
193
|
-
]);
|
|
194
|
-
function position(value) {
|
|
195
|
-
let positions = 0;
|
|
196
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, "_").every((part)=>{
|
|
197
|
-
part = normalize(part);
|
|
198
|
-
if (part.startsWith("var(")) return true;
|
|
199
|
-
if (validPositions.has(part) || length(part) || percentage(part)) {
|
|
200
|
-
positions++;
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
return false;
|
|
204
|
-
});
|
|
205
|
-
if (!result) return false;
|
|
206
|
-
return positions > 0;
|
|
207
|
-
}
|
|
208
|
-
function familyName(value) {
|
|
209
|
-
let fonts = 0;
|
|
210
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, ",").every((part)=>{
|
|
211
|
-
part = normalize(part);
|
|
212
|
-
if (part.startsWith("var(")) return true;
|
|
213
|
-
// If it contains spaces, then it should be quoted
|
|
214
|
-
if (part.includes(" ")) {
|
|
215
|
-
if (!/(['"])([^"']+)\1/g.test(part)) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// If it starts with a number, it's invalid
|
|
220
|
-
if (/^\d/g.test(part)) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
fonts++;
|
|
224
|
-
return true;
|
|
225
|
-
});
|
|
226
|
-
if (!result) return false;
|
|
227
|
-
return fonts > 0;
|
|
228
|
-
}
|
|
229
|
-
let genericNames = new Set([
|
|
230
|
-
"serif",
|
|
231
|
-
"sans-serif",
|
|
232
|
-
"monospace",
|
|
233
|
-
"cursive",
|
|
234
|
-
"fantasy",
|
|
235
|
-
"system-ui",
|
|
236
|
-
"ui-serif",
|
|
237
|
-
"ui-sans-serif",
|
|
238
|
-
"ui-monospace",
|
|
239
|
-
"ui-rounded",
|
|
240
|
-
"math",
|
|
241
|
-
"emoji",
|
|
242
|
-
"fangsong"
|
|
243
|
-
]);
|
|
244
|
-
function genericName(value) {
|
|
245
|
-
return genericNames.has(value);
|
|
246
|
-
}
|
|
247
|
-
let absoluteSizes = new Set([
|
|
248
|
-
"xx-small",
|
|
249
|
-
"x-small",
|
|
250
|
-
"small",
|
|
251
|
-
"medium",
|
|
252
|
-
"large",
|
|
253
|
-
"x-large",
|
|
254
|
-
"x-large",
|
|
255
|
-
"xxx-large"
|
|
256
|
-
]);
|
|
257
|
-
function absoluteSize(value) {
|
|
258
|
-
return absoluteSizes.has(value);
|
|
259
|
-
}
|
|
260
|
-
let relativeSizes = new Set([
|
|
261
|
-
"larger",
|
|
262
|
-
"smaller"
|
|
263
|
-
]);
|
|
264
|
-
function relativeSize(value) {
|
|
265
|
-
return relativeSizes.has(value);
|
|
266
|
-
}
|
package/lib/util/defaults.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "defaults", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>defaults
|
|
8
|
-
});
|
|
9
|
-
function defaults(target, ...sources) {
|
|
10
|
-
for (let source of sources){
|
|
11
|
-
for(let k in source){
|
|
12
|
-
var _target_hasOwnProperty;
|
|
13
|
-
if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty = target.hasOwnProperty) === null || _target_hasOwnProperty === void 0 ? void 0 : _target_hasOwnProperty.call(target, k))) {
|
|
14
|
-
target[k] = source[k];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
for (let k1 of Object.getOwnPropertySymbols(source)){
|
|
18
|
-
var _target_hasOwnProperty1;
|
|
19
|
-
if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty1 = target.hasOwnProperty) === null || _target_hasOwnProperty1 === void 0 ? void 0 : _target_hasOwnProperty1.call(target, k1))) {
|
|
20
|
-
target[k1] = source[k1];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return target;
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>escapeClassName
|
|
8
|
-
});
|
|
9
|
-
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
10
|
-
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
11
|
-
function _interopRequireDefault(obj) {
|
|
12
|
-
return obj && obj.__esModule ? obj : {
|
|
13
|
-
default: obj
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function escapeClassName(className) {
|
|
17
|
-
var _node_raws;
|
|
18
|
-
let node = _postcssSelectorParser.default.className();
|
|
19
|
-
node.value = className;
|
|
20
|
-
var _node_raws_value;
|
|
21
|
-
return (0, _escapeCommas.default)((_node_raws_value = node === null || node === void 0 ? void 0 : (_node_raws = node.raws) === null || _node_raws === void 0 ? void 0 : _node_raws.value) !== null && _node_raws_value !== void 0 ? _node_raws_value : node.value);
|
|
22
|
-
}
|
package/lib/util/escapeCommas.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>escapeCommas
|
|
8
|
-
});
|
|
9
|
-
function escapeCommas(className) {
|
|
10
|
-
return className.replace(/\\,/g, "\\2c ");
|
|
11
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>_default
|
|
8
|
-
});
|
|
9
|
-
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])=>({
|
|
10
|
-
[color + (number === "DEFAULT" ? "" : `-${number}`)]: hex
|
|
11
|
-
})) : [
|
|
12
|
-
{
|
|
13
|
-
[`${color}`]: values
|
|
14
|
-
}
|
|
15
|
-
]));
|
|
16
|
-
const _default = flattenColorPalette;
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
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
|
-
formatVariantSelector: ()=>formatVariantSelector,
|
|
13
|
-
finalizeSelector: ()=>finalizeSelector,
|
|
14
|
-
handleMergePseudo: ()=>handleMergePseudo
|
|
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"));
|
|
20
|
-
function _interopRequireDefault(obj) {
|
|
21
|
-
return obj && obj.__esModule ? obj : {
|
|
22
|
-
default: obj
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, isArbitraryVariant: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
|
|
26
|
-
function formatVariantSelector(formats, { context , candidate }) {
|
|
27
|
-
var _context_tailwindConfig_prefix;
|
|
28
|
-
let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
|
|
29
|
-
// Parse the format selector into an AST
|
|
30
|
-
let parsedFormats = formats.map((format)=>{
|
|
31
|
-
let ast = (0, _postcssSelectorParser.default)().astSync(format.format);
|
|
32
|
-
return {
|
|
33
|
-
...format,
|
|
34
|
-
ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
// We start with the candidate selector
|
|
38
|
-
let formatAst = _postcssSelectorParser.default.root({
|
|
39
|
-
nodes: [
|
|
40
|
-
_postcssSelectorParser.default.selector({
|
|
41
|
-
nodes: [
|
|
42
|
-
_postcssSelectorParser.default.className({
|
|
43
|
-
value: (0, _escapeClassName.default)(candidate)
|
|
44
|
-
})
|
|
45
|
-
]
|
|
46
|
-
})
|
|
47
|
-
]
|
|
48
|
-
});
|
|
49
|
-
// And iteratively merge each format selector into the candidate selector
|
|
50
|
-
for (let { ast } of parsedFormats){
|
|
51
|
-
[formatAst, ast] = handleMergePseudo(formatAst, ast);
|
|
52
|
-
// 2. Merge the format selector into the current selector AST
|
|
53
|
-
ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
|
|
54
|
-
// 3. Keep going!
|
|
55
|
-
formatAst = ast;
|
|
56
|
-
}
|
|
57
|
-
return formatAst;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Given any node in a selector this gets the "simple" selector it's a part of
|
|
61
|
-
* A simple selector is just a list of nodes without any combinators
|
|
62
|
-
* Technically :is(), :not(), :has(), etc… can have combinators but those are nested
|
|
63
|
-
* inside the relevant node and won't be picked up so they're fine to ignore
|
|
64
|
-
*
|
|
65
|
-
* @param {Node} node
|
|
66
|
-
* @returns {Node[]}
|
|
67
|
-
**/ function simpleSelectorForNode(node) {
|
|
68
|
-
/** @type {Node[]} */ let nodes = [];
|
|
69
|
-
// Walk backwards until we hit a combinator node (or the start)
|
|
70
|
-
while(node.prev() && node.prev().type !== "combinator"){
|
|
71
|
-
node = node.prev();
|
|
72
|
-
}
|
|
73
|
-
// Now record all non-combinator nodes until we hit one (or the end)
|
|
74
|
-
while(node && node.type !== "combinator"){
|
|
75
|
-
nodes.push(node);
|
|
76
|
-
node = node.next();
|
|
77
|
-
}
|
|
78
|
-
return nodes;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Resorts the nodes in a selector to ensure they're in the correct order
|
|
82
|
-
* Tags go before classes, and pseudo classes go after classes
|
|
83
|
-
*
|
|
84
|
-
* @param {Selector} sel
|
|
85
|
-
* @returns {Selector}
|
|
86
|
-
**/ function resortSelector(sel) {
|
|
87
|
-
sel.sort((a, b)=>{
|
|
88
|
-
if (a.type === "tag" && b.type === "class") {
|
|
89
|
-
return -1;
|
|
90
|
-
} else if (a.type === "class" && b.type === "tag") {
|
|
91
|
-
return 1;
|
|
92
|
-
} else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
|
|
93
|
-
return -1;
|
|
94
|
-
} else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
|
|
95
|
-
return 1;
|
|
96
|
-
}
|
|
97
|
-
return sel.index(a) - sel.index(b);
|
|
98
|
-
});
|
|
99
|
-
return sel;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Remove extraneous selectors that do not include the base class/candidate
|
|
103
|
-
*
|
|
104
|
-
* Example:
|
|
105
|
-
* Given the utility `.a, .b { color: red}`
|
|
106
|
-
* Given the candidate `sm:b`
|
|
107
|
-
*
|
|
108
|
-
* The final selector should be `.sm\:b` and not `.a, .sm\:b`
|
|
109
|
-
*
|
|
110
|
-
* @param {Selector} ast
|
|
111
|
-
* @param {string} base
|
|
112
|
-
*/ function eliminateIrrelevantSelectors(sel, base) {
|
|
113
|
-
let hasClassesMatchingCandidate = false;
|
|
114
|
-
sel.walk((child)=>{
|
|
115
|
-
if (child.type === "class" && child.value === base) {
|
|
116
|
-
hasClassesMatchingCandidate = true;
|
|
117
|
-
return false // Stop walking
|
|
118
|
-
;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
if (!hasClassesMatchingCandidate) {
|
|
122
|
-
sel.remove();
|
|
123
|
-
}
|
|
124
|
-
// We do NOT recursively eliminate sub selectors that don't have the base class
|
|
125
|
-
// as this is NOT a safe operation. For example, if we have:
|
|
126
|
-
// `.space-x-2 > :not([hidden]) ~ :not([hidden])`
|
|
127
|
-
// We cannot remove the [hidden] from the :not() because it would change the
|
|
128
|
-
// meaning of the selector.
|
|
129
|
-
// TODO: Can we do this for :matches, :is, and :where?
|
|
130
|
-
}
|
|
131
|
-
function finalizeSelector(current, formats, { context , candidate , base }) {
|
|
132
|
-
var _context_tailwindConfig;
|
|
133
|
-
var _context_tailwindConfig_separator;
|
|
134
|
-
let separator = (_context_tailwindConfig_separator = context === null || context === void 0 ? void 0 : (_context_tailwindConfig = context.tailwindConfig) === null || _context_tailwindConfig === void 0 ? void 0 : _context_tailwindConfig.separator) !== null && _context_tailwindConfig_separator !== void 0 ? _context_tailwindConfig_separator : ":";
|
|
135
|
-
// Split by the separator, but ignore the separator inside square brackets:
|
|
136
|
-
//
|
|
137
|
-
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
138
|
-
// ┬ ┬ ┬ ┬
|
|
139
|
-
// │ │ │ ╰── We will not split here
|
|
140
|
-
// ╰──┴─────┴─────────────── We will split here
|
|
141
|
-
//
|
|
142
|
-
base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
|
|
143
|
-
// Parse the selector into an AST
|
|
144
|
-
let selector = (0, _postcssSelectorParser.default)().astSync(current);
|
|
145
|
-
// Normalize escaped classes, e.g.:
|
|
146
|
-
//
|
|
147
|
-
// The idea would be to replace the escaped `base` in the selector with the
|
|
148
|
-
// `format`. However, in css you can escape the same selector in a few
|
|
149
|
-
// different ways. This would result in different strings and therefore we
|
|
150
|
-
// can't replace it properly.
|
|
151
|
-
//
|
|
152
|
-
// base: bg-[rgb(255,0,0)]
|
|
153
|
-
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
154
|
-
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
155
|
-
//
|
|
156
|
-
selector.walkClasses((node)=>{
|
|
157
|
-
if (node.raws && node.value.includes(base)) {
|
|
158
|
-
node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
// Remove extraneous selectors that do not include the base candidate
|
|
162
|
-
selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
|
|
163
|
-
// If there are no formats that means there were no variants added to the candidate
|
|
164
|
-
// so we can just return the selector as-is
|
|
165
|
-
let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
|
|
166
|
-
context,
|
|
167
|
-
candidate
|
|
168
|
-
}) : formats;
|
|
169
|
-
if (formatAst === null) {
|
|
170
|
-
return selector.toString();
|
|
171
|
-
}
|
|
172
|
-
let simpleStart = _postcssSelectorParser.default.comment({
|
|
173
|
-
value: "/*__simple__*/"
|
|
174
|
-
});
|
|
175
|
-
let simpleEnd = _postcssSelectorParser.default.comment({
|
|
176
|
-
value: "/*__simple__*/"
|
|
177
|
-
});
|
|
178
|
-
// We can safely replace the escaped base now, since the `base` section is
|
|
179
|
-
// now in a normalized escaped value.
|
|
180
|
-
selector.walkClasses((node)=>{
|
|
181
|
-
if (node.value !== base) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
let parent = node.parent;
|
|
185
|
-
let formatNodes = formatAst.nodes[0].nodes;
|
|
186
|
-
// Perf optimization: if the parent is a single class we can just replace it and be done
|
|
187
|
-
if (parent.nodes.length === 1) {
|
|
188
|
-
node.replaceWith(...formatNodes);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
let simpleSelector = simpleSelectorForNode(node);
|
|
192
|
-
parent.insertBefore(simpleSelector[0], simpleStart);
|
|
193
|
-
parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
|
|
194
|
-
for (let child of formatNodes){
|
|
195
|
-
parent.insertBefore(simpleSelector[0], child);
|
|
196
|
-
}
|
|
197
|
-
node.remove();
|
|
198
|
-
// Re-sort the simple selector to ensure it's in the correct order
|
|
199
|
-
simpleSelector = simpleSelectorForNode(simpleStart);
|
|
200
|
-
let firstNode = parent.index(simpleStart);
|
|
201
|
-
parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssSelectorParser.default.selector({
|
|
202
|
-
nodes: simpleSelector
|
|
203
|
-
})).nodes);
|
|
204
|
-
simpleStart.remove();
|
|
205
|
-
simpleEnd.remove();
|
|
206
|
-
});
|
|
207
|
-
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
208
|
-
selector.walkPseudos((p)=>{
|
|
209
|
-
if (p.value === MERGE) {
|
|
210
|
-
p.replaceWith(p.nodes);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
// Move pseudo elements to the end of the selector (if necessary)
|
|
214
|
-
selector.each((sel)=>{
|
|
215
|
-
let pseudoElements = collectPseudoElements(sel);
|
|
216
|
-
if (pseudoElements.length > 0) {
|
|
217
|
-
sel.nodes.push(pseudoElements.sort(sortSelector));
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
return selector.toString();
|
|
221
|
-
}
|
|
222
|
-
function handleMergePseudo(selector, format) {
|
|
223
|
-
/** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
|
|
224
|
-
// Find all :merge() pseudo-classes in `selector`
|
|
225
|
-
selector.walkPseudos((pseudo)=>{
|
|
226
|
-
if (pseudo.value === MERGE) {
|
|
227
|
-
merges.push({
|
|
228
|
-
pseudo,
|
|
229
|
-
value: pseudo.nodes[0].toString()
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
// Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
|
|
234
|
-
format.walkPseudos((pseudo)=>{
|
|
235
|
-
if (pseudo.value !== MERGE) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
let value = pseudo.nodes[0].toString();
|
|
239
|
-
// Does `selector` contain a :merge() pseudo-class with the same value?
|
|
240
|
-
let existing = merges.find((merge)=>merge.value === value);
|
|
241
|
-
// Nope so there's nothing to do
|
|
242
|
-
if (!existing) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
// Everything after `:merge()` up to the next combinator is what is attached to the merged selector
|
|
246
|
-
let attachments = [];
|
|
247
|
-
let next = pseudo.next();
|
|
248
|
-
while(next && next.type !== "combinator"){
|
|
249
|
-
attachments.push(next);
|
|
250
|
-
next = next.next();
|
|
251
|
-
}
|
|
252
|
-
let combinator = next;
|
|
253
|
-
existing.pseudo.parent.insertAfter(existing.pseudo, _postcssSelectorParser.default.selector({
|
|
254
|
-
nodes: attachments.map((node)=>node.clone())
|
|
255
|
-
}));
|
|
256
|
-
pseudo.remove();
|
|
257
|
-
attachments.forEach((node)=>node.remove());
|
|
258
|
-
// What about this case:
|
|
259
|
-
// :merge(.group):focus > &
|
|
260
|
-
// :merge(.group):hover &
|
|
261
|
-
if (combinator && combinator.type === "combinator") {
|
|
262
|
-
combinator.remove();
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
return [
|
|
266
|
-
selector,
|
|
267
|
-
format
|
|
268
|
-
];
|
|
269
|
-
}
|
|
270
|
-
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
271
|
-
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
272
|
-
// this distinction was not present in older versions of the W3C spec, most
|
|
273
|
-
// browsers support both syntaxes for the original pseudo-elements.
|
|
274
|
-
let pseudoElementsBC = [
|
|
275
|
-
":before",
|
|
276
|
-
":after",
|
|
277
|
-
":first-line",
|
|
278
|
-
":first-letter"
|
|
279
|
-
];
|
|
280
|
-
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
281
|
-
let pseudoElementExceptions = [
|
|
282
|
-
"::file-selector-button",
|
|
283
|
-
// Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
|
|
284
|
-
"::-webkit-scrollbar",
|
|
285
|
-
"::-webkit-scrollbar-button",
|
|
286
|
-
"::-webkit-scrollbar-thumb",
|
|
287
|
-
"::-webkit-scrollbar-track",
|
|
288
|
-
"::-webkit-scrollbar-track-piece",
|
|
289
|
-
"::-webkit-scrollbar-corner",
|
|
290
|
-
"::-webkit-resizer"
|
|
291
|
-
];
|
|
292
|
-
/**
|
|
293
|
-
* This will make sure to move pseudo's to the correct spot (the end for
|
|
294
|
-
* pseudo elements) because otherwise the selector will never work
|
|
295
|
-
* anyway.
|
|
296
|
-
*
|
|
297
|
-
* E.g.:
|
|
298
|
-
* - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
299
|
-
* - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
300
|
-
*
|
|
301
|
-
* `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
302
|
-
*
|
|
303
|
-
* @param {Selector} selector
|
|
304
|
-
**/ function collectPseudoElements(selector) {
|
|
305
|
-
/** @type {Node[]} */ let nodes = [];
|
|
306
|
-
for (let node of selector.nodes){
|
|
307
|
-
if (isPseudoElement(node)) {
|
|
308
|
-
nodes.push(node);
|
|
309
|
-
selector.removeChild(node);
|
|
310
|
-
}
|
|
311
|
-
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
312
|
-
nodes.push(...collectPseudoElements(node));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return nodes;
|
|
316
|
-
}
|
|
317
|
-
// This will make sure to move pseudo's to the correct spot (the end for
|
|
318
|
-
// pseudo elements) because otherwise the selector will never work
|
|
319
|
-
// anyway.
|
|
320
|
-
//
|
|
321
|
-
// E.g.:
|
|
322
|
-
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
323
|
-
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
324
|
-
//
|
|
325
|
-
// `::before:hover` doesn't work, which means that we can make it work
|
|
326
|
-
// for you by flipping the order.
|
|
327
|
-
function sortSelector(a, z) {
|
|
328
|
-
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
329
|
-
// them in the same order.
|
|
330
|
-
if (a.type !== "pseudo" && z.type !== "pseudo") {
|
|
331
|
-
return 0;
|
|
332
|
-
}
|
|
333
|
-
// If one of them is a combinator, we need to keep it in the same order
|
|
334
|
-
// because that means it will start a new "section" in the selector.
|
|
335
|
-
if (a.type === "combinator" ^ z.type === "combinator") {
|
|
336
|
-
return 0;
|
|
337
|
-
}
|
|
338
|
-
// One of the items is a pseudo and the other one isn't. Let's move
|
|
339
|
-
// the pseudo to the right.
|
|
340
|
-
if (a.type === "pseudo" ^ z.type === "pseudo") {
|
|
341
|
-
return (a.type === "pseudo") - (z.type === "pseudo");
|
|
342
|
-
}
|
|
343
|
-
// Both are pseudo's, move the pseudo elements (except for
|
|
344
|
-
// ::file-selector-button) to the right.
|
|
345
|
-
return isPseudoElement(a) - isPseudoElement(z);
|
|
346
|
-
}
|
|
347
|
-
function isPseudoElement(node) {
|
|
348
|
-
if (node.type !== "pseudo") return false;
|
|
349
|
-
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
350
|
-
return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
|
|
351
|
-
}
|