tailwindcss 0.0.0-insiders.deefbf5 → 0.0.0-insiders.df96ea5
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 +16 -17
- package/dist/chunk-GFBUASX3.mjs +1 -0
- package/dist/chunk-HTB5LLOP.mjs +1 -0
- package/dist/chunk-KV2PFGBW.mjs +38 -0
- package/dist/colors-b_6i0Oi7.d.ts +295 -0
- package/dist/colors.d.mts +295 -0
- package/dist/colors.d.ts +5 -0
- package/dist/colors.js +1 -0
- package/dist/colors.mjs +1 -0
- package/dist/default-theme.d.mts +1147 -0
- package/dist/default-theme.d.ts +1147 -0
- package/dist/default-theme.js +1 -0
- package/dist/default-theme.mjs +1 -0
- package/dist/flatten-color-palette.d.mts +6 -0
- package/dist/flatten-color-palette.d.ts +6 -0
- package/dist/flatten-color-palette.js +3 -0
- package/dist/flatten-color-palette.mjs +1 -0
- package/dist/lib.d.mts +378 -0
- package/dist/lib.d.ts +3 -0
- package/dist/lib.js +38 -0
- package/dist/lib.mjs +1 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.d.ts +134 -0
- package/dist/plugin.js +1 -0
- package/dist/plugin.mjs +1 -0
- package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
- package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
- package/dist/types-CJYAW1ql.d.mts +128 -0
- package/index.css +896 -0
- package/package.json +76 -100
- package/preflight.css +393 -0
- package/theme.css +462 -0
- package/CHANGELOG.md +0 -2206
- 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-peer-dependencies.js +0 -20
- package/lib/cli.js +0 -805
- package/lib/constants.js +0 -37
- package/lib/corePluginList.js +0 -179
- package/lib/corePlugins.js +0 -3662
- package/lib/css/LICENSE +0 -25
- package/lib/css/preflight.css +0 -360
- package/lib/featureFlags.js +0 -61
- package/lib/index.js +0 -40
- package/lib/lib/cacheInvalidation.js +0 -87
- package/lib/lib/collapseAdjacentRules.js +0 -56
- package/lib/lib/collapseDuplicateDeclarations.js +0 -80
- package/lib/lib/defaultExtractor.js +0 -228
- package/lib/lib/detectNesting.js +0 -34
- package/lib/lib/evaluateTailwindFunctions.js +0 -215
- package/lib/lib/expandApplyAtRules.js +0 -470
- package/lib/lib/expandTailwindAtRules.js +0 -276
- package/lib/lib/generateRules.js +0 -722
- package/lib/lib/getModuleDependencies.js +0 -48
- package/lib/lib/normalizeTailwindDirectives.js +0 -84
- package/lib/lib/partitionApplyAtRules.js +0 -53
- package/lib/lib/regex.js +0 -52
- package/lib/lib/resolveDefaultsAtRules.js +0 -154
- package/lib/lib/setupContextUtils.js +0 -932
- package/lib/lib/setupTrackingContext.js +0 -169
- package/lib/lib/sharedState.js +0 -51
- package/lib/lib/substituteScreenAtRules.js +0 -26
- package/lib/postcss-plugins/nesting/README.md +0 -42
- package/lib/postcss-plugins/nesting/index.js +0 -17
- package/lib/postcss-plugins/nesting/plugin.js +0 -84
- package/lib/processTailwindFeatures.js +0 -59
- package/lib/public/colors.js +0 -329
- package/lib/public/create-plugin.js +0 -13
- package/lib/public/default-config.js +0 -14
- package/lib/public/default-theme.js +0 -14
- package/lib/public/resolve-config.js +0 -19
- package/lib/util/bigSign.js +0 -8
- package/lib/util/buildMediaQuery.js +0 -19
- package/lib/util/cloneDeep.js +0 -17
- package/lib/util/cloneNodes.js +0 -25
- package/lib/util/color.js +0 -90
- package/lib/util/configurePlugins.js +0 -18
- package/lib/util/createPlugin.js +0 -28
- package/lib/util/createUtilityPlugin.js +0 -48
- package/lib/util/dataTypes.js +0 -235
- package/lib/util/defaults.js +0 -22
- package/lib/util/escapeClassName.js +0 -19
- package/lib/util/escapeCommas.js +0 -8
- package/lib/util/flattenColorPalette.js +0 -14
- package/lib/util/formatVariantSelector.js +0 -194
- package/lib/util/getAllConfigs.js +0 -34
- package/lib/util/hashConfig.js +0 -16
- package/lib/util/isKeyframeRule.js +0 -8
- package/lib/util/isPlainObject.js +0 -12
- package/lib/util/isValidArbitraryValue.js +0 -63
- package/lib/util/log.js +0 -50
- package/lib/util/nameClass.js +0 -32
- package/lib/util/negateValue.js +0 -18
- package/lib/util/normalizeConfig.js +0 -250
- package/lib/util/normalizeScreens.js +0 -58
- package/lib/util/parseAnimationValue.js +0 -88
- package/lib/util/parseBoxShadowValue.js +0 -76
- package/lib/util/parseDependency.js +0 -63
- package/lib/util/parseObjectStyles.js +0 -31
- package/lib/util/pluginUtils.js +0 -187
- package/lib/util/prefixSelector.js +0 -20
- package/lib/util/removeAlphaVariables.js +0 -18
- package/lib/util/resolveConfig.js +0 -256
- package/lib/util/resolveConfigPath.js +0 -51
- package/lib/util/responsive.js +0 -19
- package/lib/util/splitAtTopLevelOnly.js +0 -90
- package/lib/util/tap.js +0 -9
- package/lib/util/toColorValue.js +0 -8
- package/lib/util/toPath.js +0 -14
- package/lib/util/transformThemeValue.js +0 -61
- package/lib/util/validateConfig.js +0 -21
- package/lib/util/withAlphaVariable.js +0 -67
- package/nesting/index.js +0 -2
- package/peers/index.js +0 -77956
- package/plugin.d.ts +0 -11
- package/plugin.js +0 -2
- package/prettier.config.js +0 -19
- 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/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/scripts/type-utils.js +0 -27
- package/src/cli-peer-dependencies.js +0 -15
- package/src/cli.js +0 -915
- package/src/constants.js +0 -17
- package/src/corePluginList.js +0 -1
- package/src/corePlugins.js +0 -2442
- package/src/css/LICENSE +0 -25
- package/src/css/preflight.css +0 -360
- package/src/featureFlags.js +0 -54
- package/src/index.js +0 -42
- package/src/lib/cacheInvalidation.js +0 -52
- package/src/lib/collapseAdjacentRules.js +0 -58
- package/src/lib/collapseDuplicateDeclarations.js +0 -93
- package/src/lib/defaultExtractor.js +0 -208
- package/src/lib/detectNesting.js +0 -39
- package/src/lib/evaluateTailwindFunctions.js +0 -248
- package/src/lib/expandApplyAtRules.js +0 -539
- package/src/lib/expandTailwindAtRules.js +0 -292
- package/src/lib/generateRules.js +0 -719
- package/src/lib/getModuleDependencies.js +0 -39
- package/src/lib/normalizeTailwindDirectives.js +0 -84
- package/src/lib/partitionApplyAtRules.js +0 -52
- package/src/lib/regex.js +0 -74
- package/src/lib/resolveDefaultsAtRules.js +0 -163
- package/src/lib/setupContextUtils.js +0 -977
- package/src/lib/setupTrackingContext.js +0 -187
- package/src/lib/sharedState.js +0 -48
- package/src/lib/substituteScreenAtRules.js +0 -19
- 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 -20
- package/src/util/cloneDeep.js +0 -11
- package/src/util/cloneNodes.js +0 -24
- 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 -254
- 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 -215
- package/src/util/getAllConfigs.js +0 -26
- package/src/util/hashConfig.js +0 -5
- package/src/util/isKeyframeRule.js +0 -3
- package/src/util/isPlainObject.js +0 -8
- package/src/util/isValidArbitraryValue.js +0 -61
- package/src/util/log.js +0 -29
- package/src/util/nameClass.js +0 -26
- package/src/util/negateValue.js +0 -16
- package/src/util/normalizeConfig.js +0 -262
- package/src/util/normalizeScreens.js +0 -45
- package/src/util/parseAnimationValue.js +0 -68
- package/src/util/parseBoxShadowValue.js +0 -72
- package/src/util/parseDependency.js +0 -49
- package/src/util/parseObjectStyles.js +0 -19
- package/src/util/pluginUtils.js +0 -204
- package/src/util/prefixSelector.js +0 -14
- package/src/util/removeAlphaVariables.js +0 -24
- package/src/util/resolveConfig.js +0 -283
- package/src/util/resolveConfigPath.js +0 -55
- package/src/util/responsive.js +0 -10
- package/src/util/splitAtTopLevelOnly.js +0 -71
- 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 -54
- package/src/util/validateConfig.js +0 -13
- package/src/util/withAlphaVariable.js +0 -49
- package/stubs/defaultConfig.stub.js +0 -954
- 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 -327
- 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 -331
- package/types/index.d.ts +0 -7
- package/variants.css +0 -1
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.default = getModuleDependencies;
|
|
6
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var _resolve = _interopRequireDefault(require("resolve"));
|
|
9
|
-
var _detective = _interopRequireDefault(require("detective"));
|
|
10
|
-
function getModuleDependencies(entryFile) {
|
|
11
|
-
const rootModule = createModule(entryFile);
|
|
12
|
-
const modules = [
|
|
13
|
-
rootModule
|
|
14
|
-
];
|
|
15
|
-
// Iterate over the modules, even when new
|
|
16
|
-
// ones are being added
|
|
17
|
-
for (const mdl of modules){
|
|
18
|
-
mdl.requires.filter((dep)=>{
|
|
19
|
-
// Only track local modules, not node_modules
|
|
20
|
-
return dep.startsWith("./") || dep.startsWith("../");
|
|
21
|
-
}).forEach((dep)=>{
|
|
22
|
-
try {
|
|
23
|
-
const basedir = _path.default.dirname(mdl.file);
|
|
24
|
-
const depPath = _resolve.default.sync(dep, {
|
|
25
|
-
basedir
|
|
26
|
-
});
|
|
27
|
-
const depModule = createModule(depPath);
|
|
28
|
-
modules.push(depModule);
|
|
29
|
-
} catch (_err) {
|
|
30
|
-
// eslint-disable-next-line no-empty
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return modules;
|
|
35
|
-
}
|
|
36
|
-
function _interopRequireDefault(obj) {
|
|
37
|
-
return obj && obj.__esModule ? obj : {
|
|
38
|
-
default: obj
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function createModule(file) {
|
|
42
|
-
const source = _fs.default.readFileSync(file, "utf-8");
|
|
43
|
-
const requires = (0, _detective).default(source);
|
|
44
|
-
return {
|
|
45
|
-
file,
|
|
46
|
-
requires
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.default = normalizeTailwindDirectives;
|
|
6
|
-
var _log = _interopRequireDefault(require("../util/log"));
|
|
7
|
-
function normalizeTailwindDirectives(root) {
|
|
8
|
-
let tailwindDirectives = new Set();
|
|
9
|
-
let layerDirectives = new Set();
|
|
10
|
-
let applyDirectives = new Set();
|
|
11
|
-
root.walkAtRules((atRule)=>{
|
|
12
|
-
if (atRule.name === "apply") {
|
|
13
|
-
applyDirectives.add(atRule);
|
|
14
|
-
}
|
|
15
|
-
if (atRule.name === "import") {
|
|
16
|
-
if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
|
|
17
|
-
atRule.name = "tailwind";
|
|
18
|
-
atRule.params = "base";
|
|
19
|
-
} else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
|
|
20
|
-
atRule.name = "tailwind";
|
|
21
|
-
atRule.params = "components";
|
|
22
|
-
} else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
|
|
23
|
-
atRule.name = "tailwind";
|
|
24
|
-
atRule.params = "utilities";
|
|
25
|
-
} else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
|
|
26
|
-
atRule.name = "tailwind";
|
|
27
|
-
atRule.params = "variants";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (atRule.name === "tailwind") {
|
|
31
|
-
if (atRule.params === "screens") {
|
|
32
|
-
atRule.params = "variants";
|
|
33
|
-
}
|
|
34
|
-
tailwindDirectives.add(atRule.params);
|
|
35
|
-
}
|
|
36
|
-
if ([
|
|
37
|
-
"layer",
|
|
38
|
-
"responsive",
|
|
39
|
-
"variants"
|
|
40
|
-
].includes(atRule.name)) {
|
|
41
|
-
if ([
|
|
42
|
-
"responsive",
|
|
43
|
-
"variants"
|
|
44
|
-
].includes(atRule.name)) {
|
|
45
|
-
_log.default.warn(`${atRule.name}-at-rule-deprecated`, [
|
|
46
|
-
`The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
|
|
47
|
-
`Use \`@layer utilities\` or \`@layer components\` instead.`,
|
|
48
|
-
"https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer",
|
|
49
|
-
]);
|
|
50
|
-
}
|
|
51
|
-
layerDirectives.add(atRule);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
if (!tailwindDirectives.has("base") || !tailwindDirectives.has("components") || !tailwindDirectives.has("utilities")) {
|
|
55
|
-
for (let rule of layerDirectives){
|
|
56
|
-
if (rule.name === "layer" && [
|
|
57
|
-
"base",
|
|
58
|
-
"components",
|
|
59
|
-
"utilities"
|
|
60
|
-
].includes(rule.params)) {
|
|
61
|
-
if (!tailwindDirectives.has(rule.params)) {
|
|
62
|
-
throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
|
|
63
|
-
}
|
|
64
|
-
} else if (rule.name === "responsive") {
|
|
65
|
-
if (!tailwindDirectives.has("utilities")) {
|
|
66
|
-
throw rule.error("`@responsive` is used but `@tailwind utilities` is missing.");
|
|
67
|
-
}
|
|
68
|
-
} else if (rule.name === "variants") {
|
|
69
|
-
if (!tailwindDirectives.has("utilities")) {
|
|
70
|
-
throw rule.error("`@variants` is used but `@tailwind utilities` is missing.");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
tailwindDirectives,
|
|
77
|
-
applyDirectives
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function _interopRequireDefault(obj) {
|
|
81
|
-
return obj && obj.__esModule ? obj : {
|
|
82
|
-
default: obj
|
|
83
|
-
};
|
|
84
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.default = expandApplyAtRules;
|
|
6
|
-
function expandApplyAtRules() {
|
|
7
|
-
return (root)=>{
|
|
8
|
-
partitionRules(root);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function partitionRules(root) {
|
|
12
|
-
if (!root.walkAtRules) return;
|
|
13
|
-
let applyParents = new Set();
|
|
14
|
-
root.walkAtRules("apply", (rule)=>{
|
|
15
|
-
applyParents.add(rule.parent);
|
|
16
|
-
});
|
|
17
|
-
if (applyParents.size === 0) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
for (let rule1 of applyParents){
|
|
21
|
-
let nodeGroups = [];
|
|
22
|
-
let lastGroup = [];
|
|
23
|
-
for (let node of rule1.nodes){
|
|
24
|
-
if (node.type === "atrule" && node.name === "apply") {
|
|
25
|
-
if (lastGroup.length > 0) {
|
|
26
|
-
nodeGroups.push(lastGroup);
|
|
27
|
-
lastGroup = [];
|
|
28
|
-
}
|
|
29
|
-
nodeGroups.push([
|
|
30
|
-
node
|
|
31
|
-
]);
|
|
32
|
-
} else {
|
|
33
|
-
lastGroup.push(node);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (lastGroup.length > 0) {
|
|
37
|
-
nodeGroups.push(lastGroup);
|
|
38
|
-
}
|
|
39
|
-
if (nodeGroups.length === 1) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
for (let group of [
|
|
43
|
-
...nodeGroups
|
|
44
|
-
].reverse()){
|
|
45
|
-
let clone = rule1.clone({
|
|
46
|
-
nodes: []
|
|
47
|
-
});
|
|
48
|
-
clone.append(group);
|
|
49
|
-
rule1.after(clone);
|
|
50
|
-
}
|
|
51
|
-
rule1.remove();
|
|
52
|
-
}
|
|
53
|
-
}
|
package/lib/lib/regex.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.pattern = pattern;
|
|
6
|
-
exports.withoutCapturing = withoutCapturing;
|
|
7
|
-
exports.any = any;
|
|
8
|
-
exports.optional = optional;
|
|
9
|
-
exports.zeroOrMore = zeroOrMore;
|
|
10
|
-
exports.nestedBrackets = nestedBrackets;
|
|
11
|
-
exports.escape = escape;
|
|
12
|
-
const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
|
|
13
|
-
const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
|
|
14
|
-
/**
|
|
15
|
-
* @param {string|RegExp|Array<string|RegExp>} source
|
|
16
|
-
*/ function toSource(source) {
|
|
17
|
-
source = Array.isArray(source) ? source : [
|
|
18
|
-
source
|
|
19
|
-
];
|
|
20
|
-
source = source.map((item)=>item instanceof RegExp ? item.source : item);
|
|
21
|
-
return source.join("");
|
|
22
|
-
}
|
|
23
|
-
function pattern(source) {
|
|
24
|
-
return new RegExp(toSource(source), "g");
|
|
25
|
-
}
|
|
26
|
-
function withoutCapturing(source) {
|
|
27
|
-
return new RegExp(`(?:${toSource(source)})`, "g");
|
|
28
|
-
}
|
|
29
|
-
function any(sources) {
|
|
30
|
-
return `(?:${sources.map(toSource).join("|")})`;
|
|
31
|
-
}
|
|
32
|
-
function optional(source) {
|
|
33
|
-
return `(?:${toSource(source)})?`;
|
|
34
|
-
}
|
|
35
|
-
function zeroOrMore(source) {
|
|
36
|
-
return `(?:${toSource(source)})*`;
|
|
37
|
-
}
|
|
38
|
-
function nestedBrackets(open, close, depth = 1) {
|
|
39
|
-
return withoutCapturing([
|
|
40
|
-
escape(open),
|
|
41
|
-
/[^\s]*/,
|
|
42
|
-
depth === 1 ? `[^${escape(open)}${escape(close)}\s]*` : any([
|
|
43
|
-
`[^${escape(open)}${escape(close)}\s]*`,
|
|
44
|
-
nestedBrackets(open, close, depth - 1)
|
|
45
|
-
]),
|
|
46
|
-
/[^\s]*/,
|
|
47
|
-
escape(close),
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
function escape(string) {
|
|
51
|
-
return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
|
|
52
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.default = resolveDefaultsAtRules;
|
|
6
|
-
exports.elementSelectorParser = void 0;
|
|
7
|
-
var _postcss = _interopRequireDefault(require("postcss"));
|
|
8
|
-
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
9
|
-
var _featureFlags = require("../featureFlags");
|
|
10
|
-
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
11
|
-
return (root)=>{
|
|
12
|
-
let variableNodeMap = new Map();
|
|
13
|
-
/** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
|
|
14
|
-
root.walkAtRules("defaults", (rule)=>{
|
|
15
|
-
if (rule.nodes && rule.nodes.length > 0) {
|
|
16
|
-
universals.add(rule);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let variable = rule.params;
|
|
20
|
-
if (!variableNodeMap.has(variable)) {
|
|
21
|
-
variableNodeMap.set(variable, new Set());
|
|
22
|
-
}
|
|
23
|
-
variableNodeMap.get(variable).add(rule.parent);
|
|
24
|
-
rule.remove();
|
|
25
|
-
});
|
|
26
|
-
if ((0, _featureFlags).flagEnabled(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
27
|
-
for (let universal of universals){
|
|
28
|
-
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
29
|
-
var ref;
|
|
30
|
-
let rules = (ref = variableNodeMap.get(universal.params)) !== null && ref !== void 0 ? ref : [];
|
|
31
|
-
for (let rule of rules){
|
|
32
|
-
for (let selector of extractElementSelector(rule.selector)){
|
|
33
|
-
// If selector contains a vendor prefix after a pseudo element or class,
|
|
34
|
-
// we consider them separately because merging the declarations into
|
|
35
|
-
// a single rule will cause browsers that do not understand the
|
|
36
|
-
// vendor prefix to throw out the whole rule
|
|
37
|
-
let selectorGroupName = selector.includes(":-") || selector.includes("::-") ? selector : "__DEFAULT__";
|
|
38
|
-
var ref1;
|
|
39
|
-
let selectors = (ref1 = selectorGroups.get(selectorGroupName)) !== null && ref1 !== void 0 ? ref1 : new Set();
|
|
40
|
-
selectorGroups.set(selectorGroupName, selectors);
|
|
41
|
-
selectors.add(selector);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if ((0, _featureFlags).flagEnabled(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
45
|
-
if (selectorGroups.size === 0) {
|
|
46
|
-
universal.remove();
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
for (let [, selectors] of selectorGroups){
|
|
50
|
-
let universalRule = _postcss.default.rule({
|
|
51
|
-
source: universal.source
|
|
52
|
-
});
|
|
53
|
-
universalRule.selectors = [
|
|
54
|
-
...selectors
|
|
55
|
-
];
|
|
56
|
-
universalRule.append(universal.nodes.map((node)=>node.clone()));
|
|
57
|
-
universal.before(universalRule);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
universal.remove();
|
|
61
|
-
}
|
|
62
|
-
} else if (universals.size) {
|
|
63
|
-
let universalRule = _postcss.default.rule({
|
|
64
|
-
selectors: [
|
|
65
|
-
"*",
|
|
66
|
-
"::before",
|
|
67
|
-
"::after"
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
for (let universal of universals){
|
|
71
|
-
universalRule.append(universal.nodes);
|
|
72
|
-
if (!universalRule.parent) {
|
|
73
|
-
universal.before(universalRule);
|
|
74
|
-
}
|
|
75
|
-
if (!universalRule.source) {
|
|
76
|
-
universalRule.source = universal.source;
|
|
77
|
-
}
|
|
78
|
-
universal.remove();
|
|
79
|
-
}
|
|
80
|
-
let backdropRule = universalRule.clone({
|
|
81
|
-
selectors: [
|
|
82
|
-
"::backdrop"
|
|
83
|
-
]
|
|
84
|
-
});
|
|
85
|
-
universalRule.after(backdropRule);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function _interopRequireDefault(obj) {
|
|
90
|
-
return obj && obj.__esModule ? obj : {
|
|
91
|
-
default: obj
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
let getNode = {
|
|
95
|
-
id (node) {
|
|
96
|
-
return _postcssSelectorParser.default.attribute({
|
|
97
|
-
attribute: "id",
|
|
98
|
-
operator: "=",
|
|
99
|
-
value: node.value,
|
|
100
|
-
quoteMark: '"'
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
function minimumImpactSelector(nodes) {
|
|
105
|
-
let rest = nodes.filter((node)=>{
|
|
106
|
-
// Keep non-pseudo nodes
|
|
107
|
-
if (node.type !== "pseudo") return true;
|
|
108
|
-
// Keep pseudo nodes that have subnodes
|
|
109
|
-
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
110
|
-
if (node.nodes.length > 0) return true;
|
|
111
|
-
// Keep pseudo `elements`
|
|
112
|
-
// This implicitly means that we ignore pseudo `classes`
|
|
113
|
-
return node.value.startsWith("::") || [
|
|
114
|
-
":before",
|
|
115
|
-
":after",
|
|
116
|
-
":first-line",
|
|
117
|
-
":first-letter"
|
|
118
|
-
].includes(node.value);
|
|
119
|
-
}).reverse();
|
|
120
|
-
let searchFor = new Set([
|
|
121
|
-
"tag",
|
|
122
|
-
"class",
|
|
123
|
-
"id",
|
|
124
|
-
"attribute"
|
|
125
|
-
]);
|
|
126
|
-
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
|
|
127
|
-
if (splitPointIdx === -1) return rest.reverse().join("").trim();
|
|
128
|
-
let node1 = rest[splitPointIdx];
|
|
129
|
-
let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
|
|
130
|
-
rest = rest.slice(0, splitPointIdx);
|
|
131
|
-
let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
|
|
132
|
-
if (combinatorIdx !== -1) {
|
|
133
|
-
rest.splice(0, combinatorIdx);
|
|
134
|
-
rest.unshift(_postcssSelectorParser.default.universal());
|
|
135
|
-
}
|
|
136
|
-
return [
|
|
137
|
-
bestNode,
|
|
138
|
-
...rest.reverse()
|
|
139
|
-
].join("").trim();
|
|
140
|
-
}
|
|
141
|
-
let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
142
|
-
return selectors.map((s)=>{
|
|
143
|
-
let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
|
|
144
|
-
return minimumImpactSelector(nodes);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
exports.elementSelectorParser = elementSelectorParser;
|
|
148
|
-
let cache = new Map();
|
|
149
|
-
function extractElementSelector(selector) {
|
|
150
|
-
if (!cache.has(selector)) {
|
|
151
|
-
cache.set(selector, elementSelectorParser.transformSync(selector));
|
|
152
|
-
}
|
|
153
|
-
return cache.get(selector);
|
|
154
|
-
}
|