tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4

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.
Files changed (108) hide show
  1. package/lib/cli/build/deps.js +34 -18
  2. package/lib/cli/build/index.js +45 -12
  3. package/lib/cli/build/plugin.js +273 -90
  4. package/lib/cli/build/utils.js +56 -24
  5. package/lib/cli/build/watching.js +156 -38
  6. package/lib/cli/help/index.js +61 -16
  7. package/lib/cli/index.js +121 -62
  8. package/lib/cli/init/index.js +47 -23
  9. package/lib/cli-peer-dependencies.js +23 -13
  10. package/lib/cli.js +5 -1
  11. package/lib/corePluginList.js +7 -4
  12. package/lib/corePlugins.js +855 -386
  13. package/lib/featureFlags.js +43 -18
  14. package/lib/lib/cacheInvalidation.js +78 -30
  15. package/lib/lib/collapseAdjacentRules.js +46 -23
  16. package/lib/lib/collapseDuplicateDeclarations.js +70 -27
  17. package/lib/lib/content.js +134 -41
  18. package/lib/lib/defaultExtractor.js +201 -96
  19. package/lib/lib/detectNesting.js +38 -12
  20. package/lib/lib/evaluateTailwindFunctions.js +192 -103
  21. package/lib/lib/expandApplyAtRules.js +488 -181
  22. package/lib/lib/expandTailwindAtRules.js +240 -70
  23. package/lib/lib/findAtConfigPath.js +34 -15
  24. package/lib/lib/generateRules.js +775 -353
  25. package/lib/lib/getModuleDependencies.js +67 -29
  26. package/lib/lib/load-config.js +27 -17
  27. package/lib/lib/normalizeTailwindDirectives.js +73 -27
  28. package/lib/lib/offsets.js +227 -62
  29. package/lib/lib/partitionApplyAtRules.js +53 -29
  30. package/lib/lib/regex.js +50 -28
  31. package/lib/lib/remap-bitfield.js +86 -9
  32. package/lib/lib/resolveDefaultsAtRules.js +123 -53
  33. package/lib/lib/setupContextUtils.js +1117 -584
  34. package/lib/lib/setupTrackingContext.js +149 -58
  35. package/lib/lib/sharedState.js +71 -23
  36. package/lib/lib/substituteScreenAtRules.js +19 -9
  37. package/lib/oxide/cli/build/deps.js +46 -23
  38. package/lib/oxide/cli/build/index.js +44 -12
  39. package/lib/oxide/cli/build/plugin.js +271 -89
  40. package/lib/oxide/cli/build/utils.js +55 -24
  41. package/lib/oxide/cli/build/watching.js +153 -36
  42. package/lib/oxide/cli/help/index.js +60 -16
  43. package/lib/oxide/cli/index.js +128 -67
  44. package/lib/oxide/cli/init/index.js +40 -19
  45. package/lib/oxide/cli.js +3 -2
  46. package/lib/plugin.js +58 -31
  47. package/lib/postcss-plugins/nesting/index.js +13 -7
  48. package/lib/postcss-plugins/nesting/plugin.js +65 -20
  49. package/lib/processTailwindFeatures.js +41 -10
  50. package/lib/public/colors.js +25 -16
  51. package/lib/public/create-plugin.js +11 -6
  52. package/lib/public/default-config.js +12 -6
  53. package/lib/public/default-theme.js +12 -6
  54. package/lib/public/load-config.js +9 -5
  55. package/lib/public/resolve-config.js +10 -6
  56. package/lib/util/applyImportantSelector.js +28 -17
  57. package/lib/util/bigSign.js +9 -6
  58. package/lib/util/buildMediaQuery.js +19 -10
  59. package/lib/util/cloneDeep.js +19 -9
  60. package/lib/util/cloneNodes.js +29 -14
  61. package/lib/util/color.js +87 -47
  62. package/lib/util/colorNames.js +752 -0
  63. package/lib/util/configurePlugins.js +18 -9
  64. package/lib/util/createPlugin.js +17 -8
  65. package/lib/util/createUtilityPlugin.js +30 -16
  66. package/lib/util/dataTypes.js +189 -38
  67. package/lib/util/defaults.js +21 -9
  68. package/lib/util/escapeClassName.js +15 -9
  69. package/lib/util/escapeCommas.js +9 -6
  70. package/lib/util/flattenColorPalette.js +11 -7
  71. package/lib/util/formatVariantSelector.js +209 -60
  72. package/lib/util/getAllConfigs.js +44 -35
  73. package/lib/util/hashConfig.js +12 -8
  74. package/lib/util/isKeyframeRule.js +10 -7
  75. package/lib/util/isPlainObject.js +14 -9
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
  77. package/lib/util/log.js +20 -9
  78. package/lib/util/nameClass.js +31 -10
  79. package/lib/util/negateValue.js +28 -10
  80. package/lib/util/normalizeConfig.js +242 -63
  81. package/lib/util/normalizeScreens.js +145 -70
  82. package/lib/util/parseAnimationValue.js +64 -14
  83. package/lib/util/parseBoxShadowValue.js +63 -14
  84. package/lib/util/parseDependency.js +39 -13
  85. package/lib/util/parseGlob.js +25 -8
  86. package/lib/util/parseObjectStyles.js +29 -18
  87. package/lib/util/pluginUtils.js +196 -77
  88. package/lib/util/prefixSelector.js +31 -12
  89. package/lib/util/pseudoElements.js +116 -34
  90. package/lib/util/removeAlphaVariables.js +23 -8
  91. package/lib/util/resolveConfig.js +224 -105
  92. package/lib/util/resolveConfigPath.js +45 -15
  93. package/lib/util/responsive.js +10 -6
  94. package/lib/util/splitAtTopLevelOnly.js +46 -10
  95. package/lib/util/tap.js +11 -7
  96. package/lib/util/toColorValue.js +10 -7
  97. package/lib/util/toPath.js +28 -8
  98. package/lib/util/transformThemeValue.js +49 -14
  99. package/lib/util/validateConfig.js +25 -15
  100. package/lib/util/validateFormalSyntax.js +14 -6
  101. package/lib/util/withAlphaVariable.js +54 -30
  102. package/package.json +18 -22
  103. package/peers/index.js +57849 -43101
  104. package/src/lib/expandTailwindAtRules.js +1 -1
  105. package/src/lib/setupTrackingContext.js +1 -1
  106. package/src/util/color.js +1 -1
  107. package/src/util/colorNames.js +150 -0
  108. package/src/util/pseudoElements.js +4 -4
@@ -1,34 +1,58 @@
1
1
  "use strict";
2
- function expandApplyAtRules() {
3
- return (root)=>{
4
- !function(root) {
5
- if (!root.walkAtRules) return;
6
- let applyParents = new Set();
7
- if (root.walkAtRules("apply", (rule)=>{
8
- applyParents.add(rule.parent);
9
- }), 0 !== applyParents.size) for (let rule of applyParents){
10
- let nodeGroups = [], lastGroup = [];
11
- for (let node of rule.nodes)"atrule" === node.type && "apply" === node.name ? (lastGroup.length > 0 && (nodeGroups.push(lastGroup), lastGroup = []), nodeGroups.push([
12
- node
13
- ])) : lastGroup.push(node);
14
- if (lastGroup.length > 0 && nodeGroups.push(lastGroup), 1 !== nodeGroups.length) {
15
- for (let group of [
16
- ...nodeGroups
17
- ].reverse()){
18
- let clone = rule.clone({
19
- nodes: []
20
- });
21
- clone.append(group), rule.after(clone);
22
- }
23
- rule.remove();
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return expandApplyAtRules;
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 rule of applyParents){
21
+ let nodeGroups = [];
22
+ let lastGroup = [];
23
+ for (let node of rule.nodes){
24
+ if (node.type === "atrule" && node.name === "apply") {
25
+ if (lastGroup.length > 0) {
26
+ nodeGroups.push(lastGroup);
27
+ lastGroup = [];
24
28
  }
29
+ nodeGroups.push([
30
+ node
31
+ ]);
32
+ } else {
33
+ lastGroup.push(node);
25
34
  }
26
- }(root);
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 = rule.clone({
46
+ nodes: []
47
+ });
48
+ clone.append(group);
49
+ rule.after(clone);
50
+ }
51
+ rule.remove();
52
+ }
53
+ }
54
+ function expandApplyAtRules() {
55
+ return (root)=>{
56
+ partitionRules(root);
27
57
  };
28
58
  }
29
- Object.defineProperty(exports, "__esModule", {
30
- value: !0
31
- }), Object.defineProperty(exports, "default", {
32
- enumerable: !0,
33
- get: ()=>expandApplyAtRules
34
- });
package/lib/lib/regex.js CHANGED
@@ -1,42 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), function(target, all) {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
5
6
  for(var name in all)Object.defineProperty(target, name, {
6
- enumerable: !0,
7
+ enumerable: true,
7
8
  get: all[name]
8
9
  });
9
- }(exports, {
10
- pattern: ()=>pattern,
11
- withoutCapturing: ()=>withoutCapturing,
12
- any: ()=>any,
13
- optional: ()=>optional,
14
- zeroOrMore: ()=>zeroOrMore,
15
- nestedBrackets: ()=>function nestedBrackets(open, close, depth = 1) {
16
- return withoutCapturing([
17
- escape(open),
18
- /[^\s]*/,
19
- 1 === depth ? `[^${escape(open)}${escape(close)}\s]*` : any([
20
- `[^${escape(open)}${escape(close)}\s]*`,
21
- nestedBrackets(open, close, depth - 1)
22
- ]),
23
- /[^\s]*/,
24
- escape(close)
25
- ]);
26
- },
27
- escape: ()=>escape
10
+ }
11
+ _export(exports, {
12
+ pattern: function() {
13
+ return pattern;
14
+ },
15
+ withoutCapturing: function() {
16
+ return withoutCapturing;
17
+ },
18
+ any: function() {
19
+ return any;
20
+ },
21
+ optional: function() {
22
+ return optional;
23
+ },
24
+ zeroOrMore: function() {
25
+ return zeroOrMore;
26
+ },
27
+ nestedBrackets: function() {
28
+ return nestedBrackets;
29
+ },
30
+ escape: function() {
31
+ return escape;
32
+ }
28
33
  });
29
- const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g, REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
30
- function toSource(source) {
31
- return (source = (source = Array.isArray(source) ? source : [
34
+ const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
35
+ const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
36
+ /**
37
+ * @param {string|RegExp|Array<string|RegExp>} source
38
+ */ function toSource(source) {
39
+ source = Array.isArray(source) ? source : [
32
40
  source
33
- ]).map((item)=>item instanceof RegExp ? item.source : item)).join("");
41
+ ];
42
+ source = source.map((item)=>item instanceof RegExp ? item.source : item);
43
+ return source.join("");
34
44
  }
35
45
  function pattern(source) {
36
- return RegExp(toSource(source), "g");
46
+ return new RegExp(toSource(source), "g");
37
47
  }
38
48
  function withoutCapturing(source) {
39
- return RegExp(`(?:${toSource(source)})`, "g");
49
+ return new RegExp(`(?:${toSource(source)})`, "g");
40
50
  }
41
51
  function any(sources) {
42
52
  return `(?:${sources.map(toSource).join("|")})`;
@@ -47,6 +57,18 @@ function optional(source) {
47
57
  function zeroOrMore(source) {
48
58
  return `(?:${toSource(source)})*`;
49
59
  }
60
+ function nestedBrackets(open, close, depth = 1) {
61
+ return withoutCapturing([
62
+ escape(open),
63
+ /[^\s]*/,
64
+ depth === 1 ? `[^${escape(open)}${escape(close)}\s]*` : any([
65
+ `[^${escape(open)}${escape(close)}\s]*`,
66
+ nestedBrackets(open, close, depth - 1)
67
+ ]),
68
+ /[^\s]*/,
69
+ escape(close)
70
+ ]);
71
+ }
50
72
  function escape(string) {
51
73
  return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
52
74
  }
@@ -1,12 +1,89 @@
1
- "use strict";
1
+ // @ts-check
2
+ /**
3
+ * We must remap all the old bits to new bits for each set variant
4
+ * Only arbitrary variants are considered as those are the only
5
+ * ones that need to be re-sorted at this time
6
+ *
7
+ * An iterated process that removes and sets individual bits simultaneously
8
+ * will not work because we may have a new bit that is also a later old bit
9
+ * This means that we would be removing a previously set bit which we don't
10
+ * want to do
11
+ *
12
+ * For example (assume `bN` = `1<<N`)
13
+ * Given the "total" mapping `[[b1, b3], [b2, b4], [b3, b1], [b4, b2]]`
14
+ * The mapping is "total" because:
15
+ * 1. Every input and output is accounted for
16
+ * 2. All combinations are unique
17
+ * 3. No one input maps to multiple outputs and vice versa
18
+ * And, given an offset with all bits set:
19
+ * V = b1 | b2 | b3 | b4
20
+ *
21
+ * Let's explore the issue with removing and setting bits simultaneously:
22
+ * V & ~b1 | b3 = b2 | b3 | b4
23
+ * V & ~b2 | b4 = b3 | b4
24
+ * V & ~b3 | b1 = b1 | b4
25
+ * V & ~b4 | b2 = b1 | b2
26
+ *
27
+ * As you can see, we end up with the wrong result.
28
+ * This is because we're removing a bit that was previously set.
29
+ * And, thus the final result is missing b3 and b4.
30
+ *
31
+ * Now, let's explore the issue with removing the bits first:
32
+ * V & ~b1 = b2 | b3 | b4
33
+ * V & ~b2 = b3 | b4
34
+ * V & ~b3 = b4
35
+ * V & ~b4 = 0
36
+ *
37
+ * And then setting the bits:
38
+ * V | b3 = b3
39
+ * V | b4 = b3 | b4
40
+ * V | b1 = b1 | b3 | b4
41
+ * V | b2 = b1 | b2 | b3 | b4
42
+ *
43
+ * We get the correct result because we're not removing any bits that were
44
+ * previously set thus properly remapping the bits to the new order
45
+ *
46
+ * To collect this into a single operation that can be done simultaneously
47
+ * we must first create a mask for the old bits that are set and a mask for
48
+ * the new bits that are set. Then we can remove the old bits and set the new
49
+ * bits simultaneously in a "single" operation like so:
50
+ * OldMask = b1 | b2 | b3 | b4
51
+ * NewMask = b3 | b4 | b1 | b2
52
+ *
53
+ * So this:
54
+ * V & ~oldMask | newMask
55
+ *
56
+ * Expands to this:
57
+ * V & ~b1 & ~b2 & ~b3 & ~b4 | b3 | b4 | b1 | b2
58
+ *
59
+ * Which becomes this:
60
+ * b1 | b2 | b3 | b4
61
+ *
62
+ * Which is the correct result!
63
+ *
64
+ * @param {bigint} num
65
+ * @param {[bigint, bigint][]} mapping
66
+ */ "use strict";
67
+ Object.defineProperty(exports, "__esModule", {
68
+ value: true
69
+ });
70
+ Object.defineProperty(exports, "remapBitfield", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return remapBitfield;
74
+ }
75
+ });
2
76
  function remapBitfield(num, mapping) {
3
- let oldMask = 0n, newMask = 0n;
4
- for (let [oldBit, newBit] of mapping)num & oldBit && (oldMask |= oldBit, newMask |= newBit);
77
+ // Create masks for the old and new bits that are set
78
+ let oldMask = 0n;
79
+ let newMask = 0n;
80
+ for (let [oldBit, newBit] of mapping){
81
+ if (num & oldBit) {
82
+ oldMask = oldMask | oldBit;
83
+ newMask = newMask | newBit;
84
+ }
85
+ }
86
+ // Remove all old bits
87
+ // Set all new bits
5
88
  return num & ~oldMask | newMask;
6
89
  }
7
- Object.defineProperty(exports, "__esModule", {
8
- value: !0
9
- }), Object.defineProperty(exports, "remapBitfield", {
10
- enumerable: !0,
11
- get: ()=>remapBitfield
12
- });
@@ -1,81 +1,142 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), function(target, all) {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
5
6
  for(var name in all)Object.defineProperty(target, name, {
6
- enumerable: !0,
7
+ enumerable: true,
7
8
  get: all[name]
8
9
  });
9
- }(exports, {
10
- elementSelectorParser: ()=>elementSelectorParser,
11
- default: ()=>resolveDefaultsAtRules
10
+ }
11
+ _export(exports, {
12
+ elementSelectorParser: function() {
13
+ return elementSelectorParser;
14
+ },
15
+ default: function() {
16
+ return resolveDefaultsAtRules;
17
+ }
12
18
  });
13
- const _postcss = _interopRequireDefault(require("postcss")), _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser")), _featureFlags = require("../featureFlags");
14
- function _interopRequireDefault(obj) {
19
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
20
+ const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
21
+ const _featureFlags = require("../featureFlags");
22
+ function _interop_require_default(obj) {
15
23
  return obj && obj.__esModule ? obj : {
16
24
  default: obj
17
25
  };
18
26
  }
19
27
  let getNode = {
20
- id: (node)=>_postcssSelectorParser.default.attribute({
28
+ id (node) {
29
+ return _postcssselectorparser.default.attribute({
21
30
  attribute: "id",
22
31
  operator: "=",
23
32
  value: node.value,
24
33
  quoteMark: '"'
25
- })
26
- }, elementSelectorParser = (0, _postcssSelectorParser.default)((selectors)=>selectors.map((s)=>(function(nodes) {
27
- let rest = nodes.filter((node)=>"pseudo" !== node.type || node.nodes.length > 0 || node.value.startsWith("::") || [
28
- ":before",
29
- ":after",
30
- ":first-line",
31
- ":first-letter"
32
- ].includes(node.value)).reverse(), searchFor = new Set([
33
- "tag",
34
- "class",
35
- "id",
36
- "attribute"
37
- ]), splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
38
- if (-1 === splitPointIdx) return rest.reverse().join("").trim();
39
- let node = rest[splitPointIdx], bestNode = getNode[node.type] ? getNode[node.type](node) : node, combinatorIdx = (rest = rest.slice(0, splitPointIdx)).findIndex((n)=>"combinator" === n.type && ">" === n.value);
40
- return -1 !== combinatorIdx && (rest.splice(0, combinatorIdx), rest.unshift(_postcssSelectorParser.default.universal())), [
41
- bestNode,
42
- ...rest.reverse()
43
- ].join("").trim();
44
- })(s.split((n)=>"combinator" === n.type && " " === n.value).pop()))), cache = new Map();
34
+ });
35
+ }
36
+ };
37
+ function minimumImpactSelector(nodes) {
38
+ let rest = nodes.filter((node)=>{
39
+ // Keep non-pseudo nodes
40
+ if (node.type !== "pseudo") return true;
41
+ // Keep pseudo nodes that have subnodes
42
+ // E.g.: `:not()` contains subnodes inside the parentheses
43
+ if (node.nodes.length > 0) return true;
44
+ // Keep pseudo `elements`
45
+ // This implicitly means that we ignore pseudo `classes`
46
+ return node.value.startsWith("::") || [
47
+ ":before",
48
+ ":after",
49
+ ":first-line",
50
+ ":first-letter"
51
+ ].includes(node.value);
52
+ }).reverse();
53
+ let searchFor = new Set([
54
+ "tag",
55
+ "class",
56
+ "id",
57
+ "attribute"
58
+ ]);
59
+ let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type));
60
+ if (splitPointIdx === -1) return rest.reverse().join("").trim();
61
+ let node = rest[splitPointIdx];
62
+ let bestNode = getNode[node.type] ? getNode[node.type](node) : node;
63
+ rest = rest.slice(0, splitPointIdx);
64
+ let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
65
+ if (combinatorIdx !== -1) {
66
+ rest.splice(0, combinatorIdx);
67
+ rest.unshift(_postcssselectorparser.default.universal());
68
+ }
69
+ return [
70
+ bestNode,
71
+ ...rest.reverse()
72
+ ].join("").trim();
73
+ }
74
+ let elementSelectorParser = (0, _postcssselectorparser.default)((selectors)=>{
75
+ return selectors.map((s)=>{
76
+ let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
77
+ return minimumImpactSelector(nodes);
78
+ });
79
+ });
80
+ let cache = new Map();
81
+ function extractElementSelector(selector) {
82
+ if (!cache.has(selector)) {
83
+ cache.set(selector, elementSelectorParser.transformSync(selector));
84
+ }
85
+ return cache.get(selector);
86
+ }
45
87
  function resolveDefaultsAtRules({ tailwindConfig }) {
46
88
  return (root)=>{
47
- let variableNodeMap = new Map(), universals = new Set();
48
- if (root.walkAtRules("defaults", (rule)=>{
89
+ let variableNodeMap = new Map();
90
+ /** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
91
+ root.walkAtRules("defaults", (rule)=>{
49
92
  if (rule.nodes && rule.nodes.length > 0) {
50
93
  universals.add(rule);
51
94
  return;
52
95
  }
53
96
  let variable = rule.params;
54
- variableNodeMap.has(variable) || variableNodeMap.set(variable, new Set()), variableNodeMap.get(variable).add(rule.parent), rule.remove();
55
- }), (0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) for (let universal of universals){
56
- var _variableNodeMap_get, _selectorGroups_get, selector;
57
- let selectorGroups = new Map();
58
- for (let rule of null !== (_variableNodeMap_get = variableNodeMap.get(universal.params)) && void 0 !== _variableNodeMap_get ? _variableNodeMap_get : [])for (let selector1 of (selector = rule.selector, cache.has(selector) || cache.set(selector, elementSelectorParser.transformSync(selector)), cache.get(selector))){
59
- let selectorGroupName = selector1.includes(":-") || selector1.includes("::-") ? selector1 : "__DEFAULT__", selectors = null !== (_selectorGroups_get = selectorGroups.get(selectorGroupName)) && void 0 !== _selectorGroups_get ? _selectorGroups_get : new Set();
60
- selectorGroups.set(selectorGroupName, selectors), selectors.add(selector1);
97
+ if (!variableNodeMap.has(variable)) {
98
+ variableNodeMap.set(variable, new Set());
61
99
  }
62
- if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
63
- if (0 === selectorGroups.size) {
64
- universal.remove();
65
- continue;
100
+ variableNodeMap.get(variable).add(rule.parent);
101
+ rule.remove();
102
+ });
103
+ if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
104
+ for (let universal of universals){
105
+ /** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
106
+ var _variableNodeMap_get;
107
+ let rules = (_variableNodeMap_get = variableNodeMap.get(universal.params)) !== null && _variableNodeMap_get !== void 0 ? _variableNodeMap_get : [];
108
+ for (let rule of rules){
109
+ for (let selector of extractElementSelector(rule.selector)){
110
+ // If selector contains a vendor prefix after a pseudo element or class,
111
+ // we consider them separately because merging the declarations into
112
+ // a single rule will cause browsers that do not understand the
113
+ // vendor prefix to throw out the whole rule
114
+ let selectorGroupName = selector.includes(":-") || selector.includes("::-") ? selector : "__DEFAULT__";
115
+ var _selectorGroups_get;
116
+ let selectors = (_selectorGroups_get = selectorGroups.get(selectorGroupName)) !== null && _selectorGroups_get !== void 0 ? _selectorGroups_get : new Set();
117
+ selectorGroups.set(selectorGroupName, selectors);
118
+ selectors.add(selector);
119
+ }
66
120
  }
67
- for (let [, selectors] of selectorGroups){
68
- let universalRule = _postcss.default.rule({
69
- source: universal.source
70
- });
71
- universalRule.selectors = [
72
- ...selectors
73
- ], universalRule.append(universal.nodes.map((node)=>node.clone())), universal.before(universalRule);
121
+ if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
122
+ if (selectorGroups.size === 0) {
123
+ universal.remove();
124
+ continue;
125
+ }
126
+ for (let [, selectors] of selectorGroups){
127
+ let universalRule = _postcss.default.rule({
128
+ source: universal.source
129
+ });
130
+ universalRule.selectors = [
131
+ ...selectors
132
+ ];
133
+ universalRule.append(universal.nodes.map((node)=>node.clone()));
134
+ universal.before(universalRule);
135
+ }
74
136
  }
137
+ universal.remove();
75
138
  }
76
- universal.remove();
77
- }
78
- else if (universals.size) {
139
+ } else if (universals.size) {
79
140
  let universalRule = _postcss.default.rule({
80
141
  selectors: [
81
142
  "*",
@@ -83,7 +144,16 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
83
144
  "::after"
84
145
  ]
85
146
  });
86
- for (let universal of universals)universalRule.append(universal.nodes), universalRule.parent || universal.before(universalRule), universalRule.source || (universalRule.source = universal.source), universal.remove();
147
+ for (let universal of universals){
148
+ universalRule.append(universal.nodes);
149
+ if (!universalRule.parent) {
150
+ universal.before(universalRule);
151
+ }
152
+ if (!universalRule.source) {
153
+ universalRule.source = universal.source;
154
+ }
155
+ universal.remove();
156
+ }
87
157
  let backdropRule = universalRule.clone({
88
158
  selectors: [
89
159
  "::backdrop"