tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21

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 (161) hide show
  1. package/CHANGELOG.md +246 -6
  2. package/README.md +13 -9
  3. package/defaultTheme.d.ts +2 -1
  4. package/lib/cli/build/deps.js +54 -0
  5. package/lib/cli/build/index.js +48 -0
  6. package/lib/cli/build/plugin.js +362 -0
  7. package/lib/cli/build/utils.js +78 -0
  8. package/lib/cli/build/watching.js +178 -0
  9. package/lib/cli/help/index.js +71 -0
  10. package/lib/cli/index.js +18 -0
  11. package/lib/cli/init/index.js +46 -0
  12. package/lib/cli/shared.js +12 -0
  13. package/lib/cli-peer-dependencies.js +18 -5
  14. package/lib/cli.js +62 -592
  15. package/lib/constants.js +19 -12
  16. package/lib/corePluginList.js +5 -3
  17. package/lib/corePlugins.js +619 -347
  18. package/lib/css/preflight.css +7 -0
  19. package/lib/featureFlags.js +34 -22
  20. package/lib/index.js +16 -9
  21. package/lib/lib/cacheInvalidation.js +42 -21
  22. package/lib/lib/collapseAdjacentRules.js +16 -14
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -10
  24. package/lib/lib/content.js +177 -0
  25. package/lib/lib/defaultExtractor.js +230 -33
  26. package/lib/lib/detectNesting.js +13 -4
  27. package/lib/lib/evaluateTailwindFunctions.js +105 -42
  28. package/lib/lib/expandApplyAtRules.js +151 -92
  29. package/lib/lib/expandTailwindAtRules.js +134 -149
  30. package/lib/lib/findAtConfigPath.js +44 -0
  31. package/lib/lib/generateRules.js +404 -185
  32. package/lib/lib/getModuleDependencies.js +21 -18
  33. package/lib/lib/normalizeTailwindDirectives.js +11 -8
  34. package/lib/lib/offsets.js +285 -0
  35. package/lib/lib/partitionApplyAtRules.js +14 -11
  36. package/lib/lib/regex.js +60 -0
  37. package/lib/lib/remap-bitfield.js +87 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -79
  39. package/lib/lib/setupContextUtils.js +567 -242
  40. package/lib/lib/setupTrackingContext.js +77 -106
  41. package/lib/lib/sharedState.js +18 -10
  42. package/lib/lib/substituteScreenAtRules.js +9 -7
  43. package/lib/postcss-plugins/nesting/index.js +7 -5
  44. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  45. package/lib/processTailwindFeatures.js +34 -31
  46. package/lib/public/colors.js +7 -5
  47. package/lib/public/create-plugin.js +6 -4
  48. package/lib/public/default-config.js +7 -5
  49. package/lib/public/default-theme.js +7 -5
  50. package/lib/public/resolve-config.js +13 -10
  51. package/lib/util/bigSign.js +4 -1
  52. package/lib/util/buildMediaQuery.js +10 -5
  53. package/lib/util/cloneDeep.js +6 -5
  54. package/lib/util/cloneNodes.js +9 -2
  55. package/lib/util/color.js +20 -17
  56. package/lib/util/configurePlugins.js +5 -2
  57. package/lib/util/createPlugin.js +6 -5
  58. package/lib/util/createUtilityPlugin.js +15 -13
  59. package/lib/util/dataTypes.js +75 -51
  60. package/lib/util/defaults.js +8 -5
  61. package/lib/util/escapeClassName.js +13 -10
  62. package/lib/util/escapeCommas.js +4 -1
  63. package/lib/util/flattenColorPalette.js +7 -8
  64. package/lib/util/formatVariantSelector.js +270 -103
  65. package/lib/util/getAllConfigs.js +34 -15
  66. package/lib/util/hashConfig.js +10 -7
  67. package/lib/util/isKeyframeRule.js +4 -1
  68. package/lib/util/isPlainObject.js +4 -1
  69. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
  70. package/lib/util/log.js +14 -8
  71. package/lib/util/nameClass.js +19 -8
  72. package/lib/util/negateValue.js +20 -5
  73. package/lib/util/normalizeConfig.js +94 -53
  74. package/lib/util/normalizeScreens.js +115 -4
  75. package/lib/util/parseAnimationValue.js +43 -41
  76. package/lib/util/parseBoxShadowValue.js +12 -45
  77. package/lib/util/parseDependency.js +37 -55
  78. package/lib/util/parseGlob.js +34 -0
  79. package/lib/util/parseObjectStyles.js +15 -12
  80. package/lib/util/pluginUtils.js +146 -42
  81. package/lib/util/prefixSelector.js +26 -9
  82. package/lib/util/removeAlphaVariables.js +29 -0
  83. package/lib/util/resolveConfig.js +104 -105
  84. package/lib/util/resolveConfigPath.js +20 -17
  85. package/lib/util/responsive.js +12 -9
  86. package/lib/util/splitAtTopLevelOnly.js +43 -0
  87. package/lib/util/tap.js +4 -1
  88. package/lib/util/toColorValue.js +4 -1
  89. package/lib/util/toPath.js +18 -2
  90. package/lib/util/transformThemeValue.js +23 -11
  91. package/lib/util/validateConfig.js +24 -0
  92. package/lib/util/validateFormalSyntax.js +24 -0
  93. package/lib/util/withAlphaVariable.js +32 -24
  94. package/package.json +32 -29
  95. package/peers/index.js +6693 -3036
  96. package/plugin.d.ts +10 -5
  97. package/resolveConfig.d.ts +12 -0
  98. package/scripts/generate-types.js +53 -0
  99. package/scripts/release-channel.js +18 -0
  100. package/scripts/release-notes.js +21 -0
  101. package/scripts/type-utils.js +27 -0
  102. package/src/cli/build/deps.js +56 -0
  103. package/src/cli/build/index.js +49 -0
  104. package/src/cli/build/plugin.js +434 -0
  105. package/src/cli/build/utils.js +76 -0
  106. package/src/cli/build/watching.js +227 -0
  107. package/src/cli/help/index.js +70 -0
  108. package/src/cli/index.js +3 -0
  109. package/src/cli/init/index.js +50 -0
  110. package/src/cli/shared.js +5 -0
  111. package/src/cli-peer-dependencies.js +7 -1
  112. package/src/cli.js +46 -659
  113. package/src/corePlugins.js +346 -79
  114. package/src/css/preflight.css +7 -0
  115. package/src/featureFlags.js +12 -2
  116. package/src/index.js +5 -0
  117. package/src/lib/content.js +213 -0
  118. package/src/lib/defaultExtractor.js +202 -35
  119. package/src/lib/detectNesting.js +9 -1
  120. package/src/lib/evaluateTailwindFunctions.js +78 -7
  121. package/src/lib/expandApplyAtRules.js +129 -34
  122. package/src/lib/expandTailwindAtRules.js +12 -50
  123. package/src/lib/findAtConfigPath.js +48 -0
  124. package/src/lib/generateRules.js +379 -126
  125. package/src/lib/offsets.js +351 -0
  126. package/src/lib/regex.js +74 -0
  127. package/src/lib/remap-bitfield.js +82 -0
  128. package/src/lib/resolveDefaultsAtRules.js +53 -36
  129. package/src/lib/setupContextUtils.js +510 -120
  130. package/src/lib/setupTrackingContext.js +8 -45
  131. package/src/lib/sharedState.js +2 -0
  132. package/src/util/buildMediaQuery.js +5 -3
  133. package/src/util/cloneNodes.js +5 -1
  134. package/src/util/dataTypes.js +51 -26
  135. package/src/util/formatVariantSelector.js +317 -101
  136. package/src/util/getAllConfigs.js +19 -0
  137. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  138. package/src/util/log.js +1 -1
  139. package/src/util/nameClass.js +4 -0
  140. package/src/util/negateValue.js +10 -2
  141. package/src/util/normalizeConfig.js +40 -10
  142. package/src/util/normalizeScreens.js +99 -4
  143. package/src/util/parseBoxShadowValue.js +3 -50
  144. package/src/util/parseDependency.js +37 -42
  145. package/src/util/parseGlob.js +24 -0
  146. package/src/util/pluginUtils.js +132 -10
  147. package/src/util/prefixSelector.js +28 -10
  148. package/src/util/removeAlphaVariables.js +24 -0
  149. package/src/util/resolveConfig.js +70 -62
  150. package/src/util/splitAtTopLevelOnly.js +45 -0
  151. package/src/util/toPath.js +1 -1
  152. package/src/util/transformThemeValue.js +13 -3
  153. package/src/util/validateConfig.js +13 -0
  154. package/src/util/validateFormalSyntax.js +34 -0
  155. package/src/util/withAlphaVariable.js +1 -1
  156. package/stubs/defaultConfig.stub.js +165 -164
  157. package/stubs/simpleConfig.stub.js +1 -0
  158. package/types/config.d.ts +77 -37
  159. package/types/generated/default-theme.d.ts +342 -0
  160. package/types/index.d.ts +7 -1
  161. package/types.d.ts +0 -1
@@ -2,45 +2,138 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.formatVariantSelector = formatVariantSelector;
6
- exports.finalizeSelector = finalizeSelector;
7
- exports.selectorFunctions = void 0;
8
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
9
- var _unesc = _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
10
- var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
11
- var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
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"));
12
20
  function _interopRequireDefault(obj) {
13
21
  return obj && obj.__esModule ? obj : {
14
22
  default: obj
15
23
  };
16
24
  }
17
- let MERGE = ":merge";
18
- let PARENT = "&";
19
- let selectorFunctions = new Set([
20
- MERGE
21
- ]);
22
- exports.selectorFunctions = selectorFunctions;
23
- function formatVariantSelector(current, ...others) {
24
- for (let other of others){
25
- let incomingValue = resolveFunctionArgument(other, MERGE);
26
- if (incomingValue !== null) {
27
- let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
28
- if (existingValue !== null) {
29
- let existingTarget = `${MERGE}(${incomingValue})`;
30
- let splitIdx = other.indexOf(existingTarget);
31
- let addition = other.slice(splitIdx + existingTarget.length).split(" ")[0];
32
- current = current.replace(existingTarget, existingTarget + addition);
33
- continue;
34
- }
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
+ // 1. Handle :merge() special pseudo-class
52
+ ;
53
+ [formatAst, ast] = handleMergePseudo(formatAst, ast);
54
+ // 2. Merge the format selector into the current selector AST
55
+ ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
56
+ // 3. Keep going!
57
+ formatAst = ast;
58
+ }
59
+ return formatAst;
60
+ }
61
+ /**
62
+ * Given any node in a selector this gets the "simple" selector it's a part of
63
+ * A simple selector is just a list of nodes without any combinators
64
+ * Technically :is(), :not(), :has(), etc… can have combinators but those are nested
65
+ * inside the relevant node and won't be picked up so they're fine to ignore
66
+ *
67
+ * @param {Node} node
68
+ * @returns {Node[]}
69
+ **/ function simpleSelectorForNode(node) {
70
+ /** @type {Node[]} */ let nodes = [];
71
+ // Walk backwards until we hit a combinator node (or the start)
72
+ while(node.prev() && node.prev().type !== "combinator"){
73
+ node = node.prev();
74
+ }
75
+ // Now record all non-combinator nodes until we hit one (or the end)
76
+ while(node && node.type !== "combinator"){
77
+ nodes.push(node);
78
+ node = node.next();
79
+ }
80
+ return nodes;
81
+ }
82
+ /**
83
+ * Resorts the nodes in a selector to ensure they're in the correct order
84
+ * Tags go before classes, and pseudo classes go after classes
85
+ *
86
+ * @param {Selector} sel
87
+ * @returns {Selector}
88
+ **/ function resortSelector(sel) {
89
+ sel.sort((a, b)=>{
90
+ if (a.type === "tag" && b.type === "class") {
91
+ return -1;
92
+ } else if (a.type === "class" && b.type === "tag") {
93
+ return 1;
94
+ } else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
95
+ return -1;
96
+ } else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
97
+ return 1;
35
98
  }
36
- current = other.replace(PARENT, current);
99
+ return sel.index(a) - sel.index(b);
100
+ });
101
+ return sel;
102
+ }
103
+ /**
104
+ * Remove extraneous selectors that do not include the base class/candidate
105
+ *
106
+ * Example:
107
+ * Given the utility `.a, .b { color: red}`
108
+ * Given the candidate `sm:b`
109
+ *
110
+ * The final selector should be `.sm\:b` and not `.a, .sm\:b`
111
+ *
112
+ * @param {Selector} ast
113
+ * @param {string} base
114
+ */ function eliminateIrrelevantSelectors(sel, base) {
115
+ let hasClassesMatchingCandidate = false;
116
+ sel.walk((child)=>{
117
+ if (child.type === "class" && child.value === base) {
118
+ hasClassesMatchingCandidate = true;
119
+ return false // Stop walking
120
+ ;
121
+ }
122
+ });
123
+ if (!hasClassesMatchingCandidate) {
124
+ sel.remove();
37
125
  }
38
- return current;
126
+ // We do NOT recursively eliminate sub selectors that don't have the base class
127
+ // as this is NOT a safe operation. For example, if we have:
128
+ // `.space-x-2 > :not([hidden]) ~ :not([hidden])`
129
+ // We cannot remove the [hidden] from the :not() because it would change the
130
+ // meaning of the selector.
131
+ // TODO: Can we do this for :matches, :is, and :where?
39
132
  }
40
- function finalizeSelector(format, { selector: selector1 , candidate , context }) {
41
- var ref, ref1;
42
- var ref2;
43
- let separator = (ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ":";
133
+ function finalizeSelector(current, formats, { context , candidate , base }) {
134
+ var _context_tailwindConfig;
135
+ var _context_tailwindConfig_separator;
136
+ 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 : ":";
44
137
  // Split by the separator, but ignore the separator inside square brackets:
45
138
  //
46
139
  // E.g.: dark:lg:hover:[paint-order:markers]
@@ -48,12 +141,9 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
48
141
  // │ │ │ ╰── We will not split here
49
142
  // ╰──┴─────┴─────────────── We will split here
50
143
  //
51
- let splitter = new RegExp(`\\${separator}(?![^[]*\\])`);
52
- let base = candidate.split(splitter).pop();
53
- if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
54
- format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
55
- }
56
- format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
144
+ base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
145
+ // Parse the selector into an AST
146
+ let selector = (0, _postcssSelectorParser.default)().astSync(current);
57
147
  // Normalize escaped classes, e.g.:
58
148
  //
59
149
  // The idea would be to replace the escaped `base` in the selector with the
@@ -65,55 +155,119 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
65
155
  // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
66
156
  // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
67
157
  //
68
- selector1 = (0, _postcssSelectorParser).default((selectors)=>{
69
- return selectors.walkClasses((node)=>{
70
- if (node.raws && node.value.includes(base)) {
71
- node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
72
- }
73
- return node;
74
- });
75
- }).processSync(selector1);
158
+ selector.walkClasses((node)=>{
159
+ if (node.raws && node.value.includes(base)) {
160
+ node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
161
+ }
162
+ });
163
+ // Remove extraneous selectors that do not include the base candidate
164
+ selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
165
+ // If there are no formats that means there were no variants added to the candidate
166
+ // so we can just return the selector as-is
167
+ let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
168
+ context,
169
+ candidate
170
+ }) : formats;
171
+ if (formatAst === null) {
172
+ return selector.toString();
173
+ }
174
+ let simpleStart = _postcssSelectorParser.default.comment({
175
+ value: "/*__simple__*/"
176
+ });
177
+ let simpleEnd = _postcssSelectorParser.default.comment({
178
+ value: "/*__simple__*/"
179
+ });
76
180
  // We can safely replace the escaped base now, since the `base` section is
77
181
  // now in a normalized escaped value.
78
- selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
182
+ selector.walkClasses((node)=>{
183
+ if (node.value !== base) {
184
+ return;
185
+ }
186
+ let parent = node.parent;
187
+ let formatNodes = formatAst.nodes[0].nodes;
188
+ // Perf optimization: if the parent is a single class we can just replace it and be done
189
+ if (parent.nodes.length === 1) {
190
+ node.replaceWith(...formatNodes);
191
+ return;
192
+ }
193
+ let simpleSelector = simpleSelectorForNode(node);
194
+ parent.insertBefore(simpleSelector[0], simpleStart);
195
+ parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
196
+ for (let child of formatNodes){
197
+ parent.insertBefore(simpleSelector[0], child);
198
+ }
199
+ node.remove();
200
+ // Re-sort the simple selector to ensure it's in the correct order
201
+ simpleSelector = simpleSelectorForNode(simpleStart);
202
+ let firstNode = parent.index(simpleStart);
203
+ parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssSelectorParser.default.selector({
204
+ nodes: simpleSelector
205
+ })).nodes);
206
+ simpleStart.remove();
207
+ simpleEnd.remove();
208
+ });
79
209
  // Remove unnecessary pseudo selectors that we used as placeholders
80
- return (0, _postcssSelectorParser).default((selectors)=>{
81
- return selectors.map((selector2)=>{
82
- selector2.walkPseudos((p)=>{
83
- if (selectorFunctions.has(p.value)) {
84
- p.replaceWith(p.nodes);
85
- }
86
- return p;
210
+ selector.walkPseudos((p)=>{
211
+ if (p.value === MERGE) {
212
+ p.replaceWith(p.nodes);
213
+ }
214
+ });
215
+ // Move pseudo elements to the end of the selector (if necessary)
216
+ selector.each((sel)=>{
217
+ let pseudoElements = collectPseudoElements(sel);
218
+ if (pseudoElements.length > 0) {
219
+ sel.nodes.push(pseudoElements.sort(sortSelector));
220
+ }
221
+ });
222
+ return selector.toString();
223
+ }
224
+ function handleMergePseudo(selector, format) {
225
+ /** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
226
+ // Find all :merge() pseudo-classes in `selector`
227
+ selector.walkPseudos((pseudo)=>{
228
+ if (pseudo.value === MERGE) {
229
+ merges.push({
230
+ pseudo,
231
+ value: pseudo.nodes[0].toString()
87
232
  });
88
- // This will make sure to move pseudo's to the correct spot (the end for
89
- // pseudo elements) because otherwise the selector will never work
90
- // anyway.
91
- //
92
- // E.g.:
93
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
94
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
95
- //
96
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
97
- function collectPseudoElements(selector) {
98
- let nodes = [];
99
- for (let node of selector.nodes){
100
- if (isPseudoElement(node)) {
101
- nodes.push(node);
102
- selector.removeChild(node);
103
- }
104
- if (node === null || node === void 0 ? void 0 : node.nodes) {
105
- nodes.push(...collectPseudoElements(node));
106
- }
107
- }
108
- return nodes;
109
- }
110
- let pseudoElements = collectPseudoElements(selector2);
111
- if (pseudoElements.length > 0) {
112
- selector2.nodes.push(pseudoElements.sort(sortSelector));
113
- }
114
- return selector2;
115
- });
116
- }).processSync(selector1);
233
+ }
234
+ });
235
+ // Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
236
+ format.walkPseudos((pseudo)=>{
237
+ if (pseudo.value !== MERGE) {
238
+ return;
239
+ }
240
+ let value = pseudo.nodes[0].toString();
241
+ // Does `selector` contain a :merge() pseudo-class with the same value?
242
+ let existing = merges.find((merge)=>merge.value === value);
243
+ // Nope so there's nothing to do
244
+ if (!existing) {
245
+ return;
246
+ }
247
+ // Everything after `:merge()` up to the next combinator is what is attached to the merged selector
248
+ let attachments = [];
249
+ let next = pseudo.next();
250
+ while(next && next.type !== "combinator"){
251
+ attachments.push(next);
252
+ next = next.next();
253
+ }
254
+ let combinator = next;
255
+ existing.pseudo.parent.insertAfter(existing.pseudo, _postcssSelectorParser.default.selector({
256
+ nodes: attachments.map((node)=>node.clone())
257
+ }));
258
+ pseudo.remove();
259
+ attachments.forEach((node)=>node.remove());
260
+ // What about this case:
261
+ // :merge(.group):focus > &
262
+ // :merge(.group):hover &
263
+ if (combinator && combinator.type === "combinator") {
264
+ combinator.remove();
265
+ }
266
+ });
267
+ return [
268
+ selector,
269
+ format
270
+ ];
117
271
  }
118
272
  // Note: As a rule, double colons (::) should be used instead of a single colon
119
273
  // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
@@ -127,8 +281,41 @@ let pseudoElementsBC = [
127
281
  ];
128
282
  // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
129
283
  let pseudoElementExceptions = [
130
- "::file-selector-button"
284
+ "::file-selector-button",
285
+ // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
286
+ "::-webkit-scrollbar",
287
+ "::-webkit-scrollbar-button",
288
+ "::-webkit-scrollbar-thumb",
289
+ "::-webkit-scrollbar-track",
290
+ "::-webkit-scrollbar-track-piece",
291
+ "::-webkit-scrollbar-corner",
292
+ "::-webkit-resizer"
131
293
  ];
294
+ /**
295
+ * This will make sure to move pseudo's to the correct spot (the end for
296
+ * pseudo elements) because otherwise the selector will never work
297
+ * anyway.
298
+ *
299
+ * E.g.:
300
+ * - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
301
+ * - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
302
+ *
303
+ * `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
304
+ *
305
+ * @param {Selector} selector
306
+ **/ function collectPseudoElements(selector) {
307
+ /** @type {Node[]} */ let nodes = [];
308
+ for (let node of selector.nodes){
309
+ if (isPseudoElement(node)) {
310
+ nodes.push(node);
311
+ selector.removeChild(node);
312
+ }
313
+ if (node === null || node === void 0 ? void 0 : node.nodes) {
314
+ nodes.push(...collectPseudoElements(node));
315
+ }
316
+ }
317
+ return nodes;
318
+ }
132
319
  // This will make sure to move pseudo's to the correct spot (the end for
133
320
  // pseudo elements) because otherwise the selector will never work
134
321
  // anyway.
@@ -164,23 +351,3 @@ function isPseudoElement(node) {
164
351
  if (pseudoElementExceptions.includes(node.value)) return false;
165
352
  return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
166
353
  }
167
- function resolveFunctionArgument(haystack, needle, arg) {
168
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
169
- if (startIdx === -1) return null;
170
- // Start inside the `(`
171
- startIdx += needle.length + 1;
172
- let target = "";
173
- let count = 0;
174
- for (let char of haystack.slice(startIdx)){
175
- if (char !== "(" && char !== ")") {
176
- target += char;
177
- } else if (char === "(") {
178
- target += char;
179
- count++;
180
- } else if (char === ")") {
181
- if (--count < 0) break; // unbalanced
182
- target += char;
183
- }
184
- }
185
- return target;
186
- }
@@ -2,28 +2,47 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = getAllConfigs;
6
- var _defaultConfigStubJs = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
7
- var _featureFlags = require("../featureFlags");
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");
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
8
16
  function getAllConfigs(config) {
9
- var ref;
10
- const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
17
+ var _config_presets;
18
+ const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
11
19
  _defaultConfigStubJs.default
12
- ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
13
- );
20
+ ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
14
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
+ }
15
41
  };
16
- const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags).flagEnabled(config, feature)
17
- ).map((feature)=>features[feature]
18
- );
42
+ const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags.flagEnabled)(config, feature)).map((feature)=>features[feature]);
19
43
  return [
20
44
  config,
21
45
  ...experimentals,
22
46
  ...configs
23
47
  ];
24
48
  }
25
- function _interopRequireDefault(obj) {
26
- return obj && obj.__esModule ? obj : {
27
- default: obj
28
- };
29
- }
@@ -2,15 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = hashConfig;
6
- var _objectHash = _interopRequireDefault(require("object-hash"));
7
- function hashConfig(config) {
8
- return (0, _objectHash).default(config, {
9
- ignoreUnknown: true
10
- });
11
- }
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>hashConfig
8
+ });
9
+ const _objectHash = /*#__PURE__*/ _interopRequireDefault(require("object-hash"));
12
10
  function _interopRequireDefault(obj) {
13
11
  return obj && obj.__esModule ? obj : {
14
12
  default: obj
15
13
  };
16
14
  }
15
+ function hashConfig(config) {
16
+ return (0, _objectHash.default)(config, {
17
+ ignoreUnknown: true
18
+ });
19
+ }
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isKeyframeRule;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>isKeyframeRule
8
+ });
6
9
  function isKeyframeRule(rule) {
7
10
  return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
8
11
  }
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isPlainObject;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>isPlainObject
8
+ });
6
9
  function isPlainObject(value) {
7
10
  if (Object.prototype.toString.call(value) !== "[object Object]") {
8
11
  return false;
@@ -2,8 +2,40 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isValidArbitraryValue;
6
- function isValidArbitraryValue(value) {
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
+ });
15
+ let matchingBrackets = new Map([
16
+ [
17
+ "{",
18
+ "}"
19
+ ],
20
+ [
21
+ "[",
22
+ "]"
23
+ ],
24
+ [
25
+ "(",
26
+ ")"
27
+ ]
28
+ ]);
29
+ let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
30
+ v,
31
+ k
32
+ ]));
33
+ let quotes = new Set([
34
+ '"',
35
+ "'",
36
+ "`"
37
+ ]);
38
+ function isSyntacticallyValidPropertyValue(value) {
7
39
  let stack = [];
8
40
  let inQuotes = false;
9
41
  for(let i = 0; i < value.length; i++){
@@ -38,27 +70,3 @@ function isValidArbitraryValue(value) {
38
70
  // All good, totally balanced!
39
71
  return true;
40
72
  }
41
- let matchingBrackets = new Map([
42
- [
43
- "{",
44
- "}"
45
- ],
46
- [
47
- "[",
48
- "]"
49
- ],
50
- [
51
- "(",
52
- ")"
53
- ],
54
- ]);
55
- let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
56
- v,
57
- k
58
- ]
59
- ));
60
- let quotes = new Set([
61
- '"',
62
- "'",
63
- "`"
64
- ]);
package/lib/util/log.js CHANGED
@@ -2,9 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.dim = dim;
6
- exports.default = void 0;
7
- var _picocolors = _interopRequireDefault(require("picocolors"));
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
@@ -12,17 +20,16 @@ function _interopRequireDefault(obj) {
12
20
  }
13
21
  let alreadyShown = new Set();
14
22
  function log(type, messages, key) {
15
- if (process.env.JEST_WORKER_ID !== undefined) return;
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
26
  console.warn("");
19
- messages.forEach((message)=>console.warn(type, "-", message)
20
- );
27
+ messages.forEach((message)=>console.warn(type, "-", message));
21
28
  }
22
29
  function dim(input) {
23
30
  return _picocolors.default.dim(input);
24
31
  }
25
- var _default = {
32
+ const _default = {
26
33
  info (key, messages) {
27
34
  log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
28
35
  key
@@ -48,4 +55,3 @@ var _default = {
48
55
  ]);
49
56
  }
50
57
  };
51
- exports.default = _default;