tailwindcss 0.0.0-insiders.d33b650 → 0.0.0-insiders.d3f2221

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 (191) hide show
  1. package/README.md +1 -1
  2. package/index.css +5 -0
  3. package/lib/cli/build/index.js +32 -19
  4. package/lib/cli/build/plugin.js +228 -148
  5. package/lib/cli/build/utils.js +31 -21
  6. package/lib/cli/build/watching.js +99 -30
  7. package/lib/cli/help/index.js +17 -15
  8. package/lib/cli/index.js +223 -10
  9. package/lib/cli/init/index.js +31 -14
  10. package/lib/cli.js +1 -227
  11. package/lib/corePluginList.js +8 -1
  12. package/lib/corePlugins.js +2128 -1823
  13. package/lib/css/preflight.css +17 -4
  14. package/lib/featureFlags.js +39 -25
  15. package/lib/index.js +1 -47
  16. package/lib/lib/cacheInvalidation.js +10 -8
  17. package/lib/lib/collapseAdjacentRules.js +10 -8
  18. package/lib/lib/collapseDuplicateDeclarations.js +13 -11
  19. package/lib/lib/content.js +65 -28
  20. package/lib/lib/defaultExtractor.js +24 -32
  21. package/lib/lib/detectNesting.js +18 -10
  22. package/lib/lib/evaluateTailwindFunctions.js +45 -41
  23. package/lib/lib/expandApplyAtRules.js +60 -52
  24. package/lib/lib/expandTailwindAtRules.js +115 -47
  25. package/lib/lib/findAtConfigPath.js +14 -12
  26. package/lib/lib/generateRules.js +206 -146
  27. package/lib/lib/getModuleDependencies.js +85 -37
  28. package/lib/lib/handleImportAtRules.js +50 -0
  29. package/lib/lib/load-config.js +42 -0
  30. package/lib/lib/normalizeTailwindDirectives.js +26 -39
  31. package/lib/lib/offsets.js +136 -47
  32. package/lib/lib/partitionApplyAtRules.js +5 -3
  33. package/lib/lib/regex.js +26 -12
  34. package/lib/lib/remap-bitfield.js +89 -0
  35. package/lib/lib/resolveDefaultsAtRules.js +53 -49
  36. package/lib/lib/setupContextUtils.js +337 -250
  37. package/lib/lib/setupTrackingContext.js +54 -29
  38. package/lib/lib/sharedState.js +36 -17
  39. package/lib/lib/substituteScreenAtRules.js +9 -7
  40. package/lib/plugin.js +164 -0
  41. package/lib/postcss-plugins/nesting/index.js +5 -3
  42. package/lib/postcss-plugins/nesting/plugin.js +19 -17
  43. package/lib/processTailwindFeatures.js +19 -17
  44. package/lib/public/colors.js +269 -245
  45. package/lib/public/create-plugin.js +5 -3
  46. package/lib/public/default-config.js +6 -4
  47. package/lib/public/default-theme.js +6 -4
  48. package/lib/public/load-config.js +12 -0
  49. package/lib/public/resolve-config.js +6 -4
  50. package/lib/util/applyImportantSelector.js +36 -0
  51. package/lib/util/bigSign.js +3 -1
  52. package/lib/util/buildMediaQuery.js +5 -3
  53. package/lib/util/cloneDeep.js +4 -2
  54. package/lib/util/cloneNodes.js +6 -4
  55. package/lib/util/color.js +46 -28
  56. package/lib/util/colorNames.js +752 -0
  57. package/lib/util/configurePlugins.js +3 -1
  58. package/lib/util/createPlugin.js +3 -1
  59. package/lib/util/createUtilityPlugin.js +9 -7
  60. package/lib/util/dataTypes.js +215 -96
  61. package/lib/util/defaults.js +9 -7
  62. package/lib/util/escapeClassName.js +10 -8
  63. package/lib/util/escapeCommas.js +4 -2
  64. package/lib/util/flattenColorPalette.js +5 -3
  65. package/lib/util/formatVariantSelector.js +149 -169
  66. package/lib/util/getAllConfigs.js +12 -9
  67. package/lib/util/hashConfig.js +6 -4
  68. package/lib/util/isKeyframeRule.js +4 -2
  69. package/lib/util/isPlainObject.js +4 -2
  70. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +14 -12
  71. package/lib/util/log.js +31 -10
  72. package/lib/util/nameClass.js +16 -10
  73. package/lib/util/negateValue.js +12 -10
  74. package/lib/util/normalizeConfig.js +123 -77
  75. package/lib/util/normalizeScreens.js +30 -22
  76. package/lib/util/parseAnimationValue.js +41 -39
  77. package/lib/util/parseBoxShadowValue.js +24 -20
  78. package/lib/util/parseDependency.js +7 -5
  79. package/lib/util/parseGlob.js +10 -8
  80. package/lib/util/parseObjectStyles.js +10 -8
  81. package/lib/util/pluginUtils.js +92 -96
  82. package/lib/util/prefixSelector.js +27 -11
  83. package/lib/util/pseudoElements.js +209 -0
  84. package/lib/util/removeAlphaVariables.js +4 -2
  85. package/lib/util/resolveConfig.js +28 -24
  86. package/lib/util/resolveConfigPath.js +28 -12
  87. package/lib/util/responsive.js +7 -5
  88. package/lib/util/splitAtTopLevelOnly.js +12 -4
  89. package/lib/util/tap.js +3 -1
  90. package/lib/util/toColorValue.js +4 -2
  91. package/lib/util/toPath.js +5 -3
  92. package/lib/util/transformThemeValue.js +30 -28
  93. package/lib/util/validateConfig.js +31 -7
  94. package/lib/util/validateFormalSyntax.js +8 -6
  95. package/lib/util/withAlphaVariable.js +11 -7
  96. package/lib/value-parser/LICENSE +22 -0
  97. package/lib/value-parser/README.md +3 -0
  98. package/lib/value-parser/index.d.js +2 -0
  99. package/lib/value-parser/index.js +22 -0
  100. package/lib/value-parser/parse.js +259 -0
  101. package/lib/value-parser/stringify.js +38 -0
  102. package/lib/value-parser/unit.js +86 -0
  103. package/lib/value-parser/walk.js +16 -0
  104. package/loadConfig.d.ts +4 -0
  105. package/loadConfig.js +2 -0
  106. package/package.json +49 -50
  107. package/resolveConfig.d.ts +11 -2
  108. package/scripts/release-notes.js +1 -1
  109. package/src/cli/build/index.js +17 -9
  110. package/src/cli/build/plugin.js +129 -77
  111. package/src/cli/build/watching.js +108 -13
  112. package/src/cli/index.js +217 -3
  113. package/src/cli/init/index.js +37 -8
  114. package/src/cli.js +1 -221
  115. package/src/corePluginList.js +1 -1
  116. package/src/corePlugins.js +259 -46
  117. package/src/css/preflight.css +17 -4
  118. package/src/featureFlags.js +7 -7
  119. package/src/index.js +1 -47
  120. package/src/lib/content.js +44 -10
  121. package/src/lib/defaultExtractor.js +10 -14
  122. package/src/lib/detectNesting.js +9 -1
  123. package/src/lib/evaluateTailwindFunctions.js +4 -1
  124. package/src/lib/expandApplyAtRules.js +10 -3
  125. package/src/lib/expandTailwindAtRules.js +78 -13
  126. package/src/lib/generateRules.js +140 -65
  127. package/src/lib/getModuleDependencies.js +70 -30
  128. package/src/lib/handleImportAtRules.js +34 -0
  129. package/src/lib/load-config.ts +31 -0
  130. package/src/lib/normalizeTailwindDirectives.js +0 -27
  131. package/src/lib/offsets.js +105 -2
  132. package/src/lib/remap-bitfield.js +82 -0
  133. package/src/lib/setupContextUtils.js +145 -80
  134. package/src/lib/setupTrackingContext.js +37 -14
  135. package/src/lib/sharedState.js +11 -4
  136. package/src/plugin.js +133 -0
  137. package/src/processTailwindFeatures.js +3 -2
  138. package/src/public/colors.js +22 -0
  139. package/src/public/default-config.js +1 -1
  140. package/src/public/default-theme.js +2 -2
  141. package/src/public/load-config.js +2 -0
  142. package/src/util/applyImportantSelector.js +27 -0
  143. package/src/util/color.js +19 -4
  144. package/src/util/colorNames.js +150 -0
  145. package/src/util/dataTypes.js +97 -9
  146. package/src/util/formatVariantSelector.js +163 -165
  147. package/src/util/getAllConfigs.js +2 -2
  148. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  149. package/src/util/log.js +24 -0
  150. package/src/util/negateValue.js +1 -1
  151. package/src/util/normalizeConfig.js +57 -11
  152. package/src/util/pluginUtils.js +38 -54
  153. package/src/util/prefixSelector.js +29 -10
  154. package/src/util/pseudoElements.js +167 -0
  155. package/src/util/resolveConfig.js +0 -2
  156. package/src/util/resolveConfigPath.js +12 -1
  157. package/src/util/splitAtTopLevelOnly.js +8 -1
  158. package/src/util/validateConfig.js +23 -0
  159. package/src/value-parser/LICENSE +22 -0
  160. package/src/value-parser/README.md +3 -0
  161. package/src/value-parser/index.d.ts +177 -0
  162. package/src/value-parser/index.js +28 -0
  163. package/src/value-parser/parse.js +303 -0
  164. package/src/value-parser/stringify.js +41 -0
  165. package/src/value-parser/unit.js +118 -0
  166. package/src/value-parser/walk.js +18 -0
  167. package/stubs/.gitignore +1 -0
  168. package/stubs/.prettierrc.json +6 -0
  169. package/stubs/{defaultConfig.stub.js → config.full.js} +203 -172
  170. package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
  171. package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
  172. package/stubs/postcss.config.js +5 -0
  173. package/stubs/tailwind.config.cjs +2 -0
  174. package/stubs/tailwind.config.js +2 -0
  175. package/stubs/tailwind.config.ts +3 -0
  176. package/types/config.d.ts +20 -13
  177. package/types/generated/colors.d.ts +22 -0
  178. package/types/generated/corePluginList.d.ts +1 -1
  179. package/types/generated/default-theme.d.ts +116 -80
  180. package/CHANGELOG.md +0 -2300
  181. package/lib/cli/build/deps.js +0 -54
  182. package/lib/cli/shared.js +0 -12
  183. package/lib/cli-peer-dependencies.js +0 -28
  184. package/lib/constants.js +0 -44
  185. package/peers/index.js +0 -79459
  186. package/scripts/install-integrations.js +0 -27
  187. package/scripts/rebuildFixtures.js +0 -68
  188. package/src/cli/build/deps.js +0 -56
  189. package/src/cli/shared.js +0 -5
  190. package/src/cli-peer-dependencies.js +0 -15
  191. package/src/constants.js +0 -17
@@ -9,26 +9,32 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- getClassNameFromSelector: ()=>getClassNameFromSelector,
13
- resolveMatches: ()=>resolveMatches,
14
- generateRules: ()=>generateRules
12
+ getClassNameFromSelector: function() {
13
+ return getClassNameFromSelector;
14
+ },
15
+ resolveMatches: function() {
16
+ return resolveMatches;
17
+ },
18
+ generateRules: function() {
19
+ return generateRules;
20
+ }
15
21
  });
16
- const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
17
- const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
18
- const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
19
- const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isPlainObject"));
20
- const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
22
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
23
+ const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
24
+ const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
25
+ const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
26
+ const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
21
27
  const _pluginUtils = require("../util/pluginUtils");
22
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
23
- const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
28
+ const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
29
+ const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
24
30
  const _formatVariantSelector = require("../util/formatVariantSelector");
25
31
  const _nameClass = require("../util/nameClass");
26
32
  const _dataTypes = require("../util/dataTypes");
27
33
  const _setupContextUtils = require("./setupContextUtils");
28
- const _isValidArbitraryValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isValidArbitraryValue"));
29
- const _splitAtTopLevelOnlyJs = require("../util/splitAtTopLevelOnly.js");
30
- const _featureFlags = require("../featureFlags");
31
- function _interopRequireDefault(obj) {
34
+ const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
35
+ const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
36
+ const _applyImportantSelector = require("../util/applyImportantSelector");
37
+ function _interop_require_default(obj) {
32
38
  return obj && obj.__esModule ? obj : {
33
39
  default: obj
34
40
  };
@@ -41,7 +47,7 @@ function _getRequireWildcardCache(nodeInterop) {
41
47
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
48
  })(nodeInterop);
43
49
  }
44
- function _interopRequireWildcard(obj, nodeInterop) {
50
+ function _interop_require_wildcard(obj, nodeInterop) {
45
51
  if (!nodeInterop && obj && obj.__esModule) {
46
52
  return obj;
47
53
  }
@@ -72,8 +78,8 @@ function _interopRequireWildcard(obj, nodeInterop) {
72
78
  }
73
79
  return newObj;
74
80
  }
75
- let classNameParser = (0, _postcssSelectorParser.default)((selectors)=>{
76
- return selectors.first.filter(({ type })=>type === "class").pop().value;
81
+ let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
82
+ return selectors.first.filter(({ type })=>type === 'class').pop().value;
77
83
  });
78
84
  function getClassNameFromSelector(selector) {
79
85
  return classNameParser.transformSync(selector);
@@ -90,23 +96,23 @@ function* candidatePermutations(candidate) {
90
96
  while(lastIndex >= 0){
91
97
  let dashIdx;
92
98
  let wasSlash = false;
93
- if (lastIndex === Infinity && candidate.endsWith("]")) {
94
- let bracketIdx = candidate.indexOf("[");
99
+ if (lastIndex === Infinity && candidate.endsWith(']')) {
100
+ let bracketIdx = candidate.indexOf('[');
95
101
  // If character before `[` isn't a dash or a slash, this isn't a dynamic class
96
- // eg. string[]
97
- if (candidate[bracketIdx - 1] === "-") {
102
+ // e.g. string[]
103
+ if (candidate[bracketIdx - 1] === '-') {
98
104
  dashIdx = bracketIdx - 1;
99
- } else if (candidate[bracketIdx - 1] === "/") {
105
+ } else if (candidate[bracketIdx - 1] === '/') {
100
106
  dashIdx = bracketIdx - 1;
101
107
  wasSlash = true;
102
108
  } else {
103
109
  dashIdx = -1;
104
110
  }
105
- } else if (lastIndex === Infinity && candidate.includes("/")) {
106
- dashIdx = candidate.lastIndexOf("/");
111
+ } else if (lastIndex === Infinity && candidate.includes('/')) {
112
+ dashIdx = candidate.lastIndexOf('/');
107
113
  wasSlash = true;
108
114
  } else {
109
- dashIdx = candidate.lastIndexOf("-", lastIndex);
115
+ dashIdx = candidate.lastIndexOf('-', lastIndex);
110
116
  }
111
117
  if (dashIdx < 0) {
112
118
  break;
@@ -115,7 +121,7 @@ function* candidatePermutations(candidate) {
115
121
  let modifier = candidate.slice(wasSlash ? dashIdx : dashIdx + 1);
116
122
  lastIndex = dashIdx - 1;
117
123
  // TODO: This feels a bit hacky
118
- if (prefix === "" || modifier === "/") {
124
+ if (prefix === '' || modifier === '/') {
119
125
  continue;
120
126
  }
121
127
  yield [
@@ -125,7 +131,7 @@ function* candidatePermutations(candidate) {
125
131
  }
126
132
  }
127
133
  function applyPrefix(matches, context) {
128
- if (matches.length === 0 || context.tailwindConfig.prefix === "") {
134
+ if (matches.length === 0 || context.tailwindConfig.prefix === '') {
129
135
  return matches;
130
136
  }
131
137
  for (let match of matches){
@@ -142,7 +148,7 @@ function applyPrefix(matches, context) {
142
148
  // have to ensure that the generated selector matches the candidate
143
149
  // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
144
150
  // The disconnect between candidate <-> class can cause @apply to hard crash.
145
- let shouldPrependNegative = classCandidate.startsWith("-");
151
+ let shouldPrependNegative = classCandidate.startsWith('-');
146
152
  r.selector = (0, _prefixSelector.default)(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
147
153
  });
148
154
  match[1] = container.nodes[0];
@@ -162,12 +168,12 @@ function applyImportant(matches, classCandidate) {
162
168
  ]
163
169
  });
164
170
  container.walkRules((r)=>{
165
- r.selector = (0, _pluginUtils.updateAllClasses)((0, _pluginUtils.filterSelectorsForClass)(r.selector, classCandidate), (className)=>{
166
- if (className === classCandidate) {
167
- return `!${className}`;
168
- }
169
- return className;
170
- });
171
+ let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
172
+ // Remove extraneous selectors that do not include the base candidate
173
+ ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
174
+ // Update all instances of the base candidate to include the important marker
175
+ (0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
176
+ r.selector = ast.toString();
171
177
  r.walkDecls((d)=>d.important = true);
172
178
  });
173
179
  result.push([
@@ -198,17 +204,20 @@ function applyVariant(variant, matches, context) {
198
204
  };
199
205
  // Retrieve "modifier"
200
206
  {
201
- let match = /(.*)\/(.*)$/g.exec(variant);
202
- if (match) {
203
- variant = match[1];
204
- args.modifier = match[2];
205
- if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
206
- return [];
207
- }
207
+ let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, '/');
208
+ // This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
209
+ // In this case 1/10 is a value but /20 is a modifier
210
+ if (modifiers.length > 1) {
211
+ baseVariant = baseVariant + '/' + modifiers.slice(0, -1).join('/');
212
+ modifiers = modifiers.slice(-1);
213
+ }
214
+ if (modifiers.length && !context.variantMap.has(variant)) {
215
+ variant = baseVariant;
216
+ args.modifier = modifiers[0];
208
217
  }
209
218
  }
210
219
  // Retrieve "arbitrary value"
211
- if (variant.endsWith("]") && !variant.startsWith("[")) {
220
+ if (variant.endsWith(']') && !variant.startsWith('[')) {
212
221
  // We either have:
213
222
  // @[200px]
214
223
  // group-[:hover]
@@ -216,38 +225,50 @@ function applyVariant(variant, matches, context) {
216
225
  // But we don't want:
217
226
  // @-[200px] (`-` is incorrect)
218
227
  // group[:hover] (`-` is missing)
219
- let match1 = /(.)(-?)\[(.*)\]/g.exec(variant);
220
- if (match1) {
221
- let [, char, seperator, value] = match1;
228
+ let match = /(.)(-?)\[(.*)\]/g.exec(variant);
229
+ if (match) {
230
+ let [, char, separator, value] = match;
222
231
  // @-[200px] case
223
- if (char === "@" && seperator === "-") return [];
232
+ if (char === '@' && separator === '-') return [];
224
233
  // group[:hover] case
225
- if (char !== "@" && seperator === "") return [];
226
- variant = variant.replace(`${seperator}[${value}]`, "");
234
+ if (char !== '@' && separator === '') return [];
235
+ variant = variant.replace(`${separator}[${value}]`, '');
227
236
  args.value = value;
228
237
  }
229
238
  }
230
239
  // Register arbitrary variants
231
240
  if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
241
+ let sort = context.offsets.recordVariant(variant);
232
242
  let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
233
- if (!(0, _setupContextUtils.isValidVariantFormatString)(selector)) {
243
+ let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ',');
244
+ // We do not support multiple selectors for arbitrary variants
245
+ if (selectors.length > 1) {
234
246
  return [];
235
247
  }
236
- let fn = (0, _setupContextUtils.parseVariant)(selector);
237
- let sort = context.offsets.recordVariant(variant);
238
- context.variantMap.set(variant, [
239
- [
240
- sort,
241
- fn
242
- ]
243
- ]);
248
+ if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
249
+ return [];
250
+ }
251
+ let records = selectors.map((sel, idx)=>[
252
+ context.offsets.applyParallelOffset(sort, idx),
253
+ (0, _setupContextUtils.parseVariant)(sel.trim())
254
+ ]);
255
+ context.variantMap.set(variant, records);
244
256
  }
245
257
  if (context.variantMap.has(variant)) {
258
+ var _context_variantOptions_get;
259
+ let isArbitraryVariant = isArbitraryValue(variant);
260
+ var _context_variantOptions_get_INTERNAL_FEATURES;
261
+ let internalFeatures = (_context_variantOptions_get_INTERNAL_FEATURES = (_context_variantOptions_get = context.variantOptions.get(variant)) === null || _context_variantOptions_get === void 0 ? void 0 : _context_variantOptions_get[_setupContextUtils.INTERNAL_FEATURES]) !== null && _context_variantOptions_get_INTERNAL_FEATURES !== void 0 ? _context_variantOptions_get_INTERNAL_FEATURES : {};
246
262
  let variantFunctionTuples = context.variantMap.get(variant).slice();
247
263
  let result = [];
264
+ let respectPrefix = (()=>{
265
+ if (isArbitraryVariant) return false;
266
+ if (internalFeatures.respectPrefix === false) return false;
267
+ return true;
268
+ })();
248
269
  for (let [meta, rule] of matches){
249
270
  // Don't generate variants for user css
250
- if (meta.layer === "user") {
271
+ if (meta.layer === 'user') {
251
272
  continue;
252
273
  }
253
274
  let container = _postcss.default.root({
@@ -269,7 +290,7 @@ function applyVariant(variant, matches, context) {
269
290
  function modifySelectors(modifierFunction) {
270
291
  prepareBackup();
271
292
  clone.each((rule)=>{
272
- if (rule.type !== "rule") {
293
+ if (rule.type !== 'rule') {
273
294
  return;
274
295
  }
275
296
  rule.selectors = rule.selectors.map((selector)=>{
@@ -299,21 +320,24 @@ function applyVariant(variant, matches, context) {
299
320
  clone.append(wrapper);
300
321
  },
301
322
  format (selectorFormat) {
302
- collectedFormats.push(selectorFormat);
323
+ collectedFormats.push({
324
+ format: selectorFormat,
325
+ respectPrefix
326
+ });
303
327
  },
304
328
  args
305
329
  });
306
330
  // It can happen that a list of format strings is returned from within the function. In that
307
331
  // case, we have to process them as well. We can use the existing `variantSort`.
308
332
  if (Array.isArray(ruleWithVariant)) {
309
- for (let [idx, variantFunction1] of ruleWithVariant.entries()){
333
+ for (let [idx, variantFunction] of ruleWithVariant.entries()){
310
334
  // This is a little bit scary since we are pushing to an array of items that we are
311
335
  // currently looping over. However, you can also think of it like a processing queue
312
336
  // where you keep handling jobs until everything is done and each job can queue more
313
337
  // jobs if needed.
314
338
  variantFunctionTuples.push([
315
339
  context.offsets.applyParallelOffset(variantSort, idx),
316
- variantFunction1,
340
+ variantFunction,
317
341
  // If the clone has been modified we have to pass that back
318
342
  // though so each rule can use the modified container
319
343
  clone.clone()
@@ -321,8 +345,11 @@ function applyVariant(variant, matches, context) {
321
345
  }
322
346
  continue;
323
347
  }
324
- if (typeof ruleWithVariant === "string") {
325
- collectedFormats.push(ruleWithVariant);
348
+ if (typeof ruleWithVariant === 'string') {
349
+ collectedFormats.push({
350
+ format: ruleWithVariant,
351
+ respectPrefix
352
+ });
326
353
  }
327
354
  if (ruleWithVariant === null) {
328
355
  continue;
@@ -342,7 +369,7 @@ function applyVariant(variant, matches, context) {
342
369
  // as well. E.g.: `${variant}${separator}${className}`.
343
370
  // However, plugin authors probably also prepend or append certain
344
371
  // classes, pseudos, ids, ...
345
- let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
372
+ let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
346
373
  selectors.walkClasses((classNode)=>{
347
374
  classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
348
375
  });
@@ -358,7 +385,10 @@ function applyVariant(variant, matches, context) {
358
385
  // modified (by plugin): .foo .foo\\:markdown > p
359
386
  // rebuiltBase (internal): .foo\\:markdown > p
360
387
  // format: .foo &
361
- collectedFormats.push(modified.replace(rebuiltBase, "&"));
388
+ collectedFormats.push({
389
+ format: modified.replace(rebuiltBase, '&'),
390
+ respectPrefix
391
+ });
362
392
  rule.selector = before;
363
393
  });
364
394
  }
@@ -370,13 +400,12 @@ function applyVariant(variant, matches, context) {
370
400
  ...clone.nodes[0].raws.tailwind,
371
401
  parentLayer: meta.layer
372
402
  };
373
- var _collectedFormats;
403
+ var _meta_collectedFormats;
374
404
  let withOffset = [
375
405
  {
376
406
  ...meta,
377
407
  sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
378
- collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats),
379
- isArbitraryVariant: isArbitraryValue(variant)
408
+ collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
380
409
  },
381
410
  clone.nodes[0]
382
411
  ];
@@ -420,12 +449,12 @@ function isValidPropName(name) {
420
449
  */ function looksLikeUri(declaration) {
421
450
  // Quick bailout for obvious non-urls
422
451
  // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
423
- if (!declaration.includes("://")) {
452
+ if (!declaration.includes('://')) {
424
453
  return false;
425
454
  }
426
455
  try {
427
456
  const url = new URL(declaration);
428
- return url.scheme !== "" && url.host !== "";
457
+ return url.scheme !== '' && url.host !== '';
429
458
  } catch (err) {
430
459
  // Definitely not a valid url
431
460
  return false;
@@ -434,7 +463,7 @@ function isValidPropName(name) {
434
463
  function isParsableNode(node) {
435
464
  let isParsable = true;
436
465
  node.walkDecls((decl)=>{
437
- if (!isParsableCssValue(decl.name, decl.value)) {
466
+ if (!isParsableCssValue(decl.prop, decl.value)) {
438
467
  isParsable = false;
439
468
  return false;
440
469
  }
@@ -442,9 +471,9 @@ function isParsableNode(node) {
442
471
  return isParsable;
443
472
  }
444
473
  function isParsableCssValue(property, value) {
445
- // We don't want to to treat [https://example.com] as a custom property
474
+ // We don't want to treat [https://example.com] as a custom property
446
475
  // Even though, according to the CSS grammar, it's a totally valid CSS declaration
447
- // So we short-circuit here by checking if the custom property looks like a url
476
+ // So we short-circuit here by checking if the custom property looks like a URL
448
477
  if (looksLikeUri(`${property}:${value}`)) {
449
478
  return false;
450
479
  }
@@ -456,15 +485,15 @@ function isParsableCssValue(property, value) {
456
485
  }
457
486
  }
458
487
  function extractArbitraryProperty(classCandidate, context) {
459
- var ref;
460
- let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
488
+ var _classCandidate_match;
489
+ let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
461
490
  if (value === undefined) {
462
491
  return null;
463
492
  }
464
493
  if (!isValidPropName(property)) {
465
494
  return null;
466
495
  }
467
- if (!(0, _isValidArbitraryValue.default)(value)) {
496
+ if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
468
497
  return null;
469
498
  }
470
499
  let normalized = (0, _dataTypes.normalize)(value);
@@ -476,7 +505,7 @@ function extractArbitraryProperty(classCandidate, context) {
476
505
  [
477
506
  {
478
507
  sort,
479
- layer: "utilities"
508
+ layer: 'utilities'
480
509
  },
481
510
  ()=>({
482
511
  [(0, _nameClass.asClass)(classCandidate)]: {
@@ -490,14 +519,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
490
519
  if (context.candidateRuleMap.has(classCandidate)) {
491
520
  yield [
492
521
  context.candidateRuleMap.get(classCandidate),
493
- "DEFAULT"
522
+ 'DEFAULT'
494
523
  ];
495
524
  }
496
525
  yield* function*(arbitraryPropertyRule) {
497
526
  if (arbitraryPropertyRule !== null) {
498
527
  yield [
499
528
  arbitraryPropertyRule,
500
- "DEFAULT"
529
+ 'DEFAULT'
501
530
  ];
502
531
  }
503
532
  }(extractArbitraryProperty(classCandidate, context));
@@ -506,14 +535,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
506
535
  const twConfigPrefix = context.tailwindConfig.prefix;
507
536
  const twConfigPrefixLen = twConfigPrefix.length;
508
537
  const hasMatchingPrefix = candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`);
509
- if (candidatePrefix[twConfigPrefixLen] === "-" && hasMatchingPrefix) {
538
+ if (candidatePrefix[twConfigPrefixLen] === '-' && hasMatchingPrefix) {
510
539
  negative = true;
511
540
  candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
512
541
  }
513
542
  if (negative && context.candidateRuleMap.has(candidatePrefix)) {
514
543
  yield [
515
544
  context.candidateRuleMap.get(candidatePrefix),
516
- "-DEFAULT"
545
+ '-DEFAULT'
517
546
  ];
518
547
  }
519
548
  for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
@@ -531,36 +560,28 @@ function splitWithSeparator(input, separator) {
531
560
  _sharedState.NOT_ON_DEMAND
532
561
  ];
533
562
  }
534
- return (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(input, separator);
563
+ return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
535
564
  }
536
565
  function* recordCandidates(matches, classCandidate) {
537
566
  for (const match of matches){
538
- var ref;
539
- var ref1;
567
+ var _match__options;
568
+ var _match__options_preserveSource;
540
569
  match[1].raws.tailwind = {
541
570
  ...match[1].raws.tailwind,
542
571
  classCandidate,
543
- preserveSource: (ref1 = (ref = match[0].options) === null || ref === void 0 ? void 0 : ref.preserveSource) !== null && ref1 !== void 0 ? ref1 : false
572
+ preserveSource: (_match__options_preserveSource = (_match__options = match[0].options) === null || _match__options === void 0 ? void 0 : _match__options.preserveSource) !== null && _match__options_preserveSource !== void 0 ? _match__options_preserveSource : false
544
573
  };
545
574
  yield match;
546
575
  }
547
576
  }
548
- function* resolveMatches(candidate, context, original = candidate) {
577
+ function* resolveMatches(candidate, context) {
549
578
  let separator = context.tailwindConfig.separator;
550
579
  let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
551
580
  let important = false;
552
- if (classCandidate.startsWith("!")) {
581
+ if (classCandidate.startsWith('!')) {
553
582
  important = true;
554
583
  classCandidate = classCandidate.slice(1);
555
584
  }
556
- if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
557
- if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
558
- let base = variants.slice().reverse().join(separator);
559
- for (let part of (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
560
- yield* resolveMatches(base + separator + part, context, original);
561
- }
562
- }
563
- }
564
585
  // TODO: Reintroduce this in ways that doesn't break on false positives
565
586
  // function sortAgainst(toSort, against) {
566
587
  // return toSort.slice().sort((a, z) => {
@@ -579,7 +600,7 @@ function* resolveMatches(candidate, context, original = candidate) {
579
600
  let isOnlyPlugin = plugins.length === 1;
580
601
  for (let [sort, plugin] of plugins){
581
602
  let matchesPerPlugin = [];
582
- if (typeof plugin === "function") {
603
+ if (typeof plugin === 'function') {
583
604
  for (let ruleSet of [].concat(plugin(modifier, {
584
605
  isOnlyPlugin
585
606
  }))){
@@ -597,26 +618,26 @@ function* resolveMatches(candidate, context, original = candidate) {
597
618
  ]);
598
619
  }
599
620
  }
600
- } else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
601
- let ruleSet1 = plugin;
602
- let [rules1, options1] = parseRules(ruleSet1, context.postCssNodeCache);
603
- for (let rule1 of rules1){
621
+ } else if (modifier === 'DEFAULT' || modifier === '-DEFAULT') {
622
+ let ruleSet = plugin;
623
+ let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
624
+ for (let rule of rules){
604
625
  matchesPerPlugin.push([
605
626
  {
606
627
  ...sort,
607
628
  options: {
608
629
  ...sort.options,
609
- ...options1
630
+ ...options
610
631
  }
611
632
  },
612
- rule1
633
+ rule
613
634
  ]);
614
635
  }
615
636
  }
616
637
  if (matchesPerPlugin.length > 0) {
617
- var ref;
618
- var ref1, _options;
619
- let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((ref1 = (ref = sort.options) === null || ref === void 0 ? void 0 : ref.types) !== null && ref1 !== void 0 ? ref1 : [], modifier, (_options = sort.options) !== null && _options !== void 0 ? _options : {}, context.tailwindConfig)).map(([_, type])=>type);
638
+ var _sort_options;
639
+ var _sort_options_types, _sort_options1;
640
+ let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((_sort_options_types = (_sort_options = sort.options) === null || _sort_options === void 0 ? void 0 : _sort_options.types) !== null && _sort_options_types !== void 0 ? _sort_options_types : [], modifier, (_sort_options1 = sort.options) !== null && _sort_options1 !== void 0 ? _sort_options1 : {}, context.tailwindConfig)).map(([_, type])=>type);
620
641
  if (matchingTypes.length > 0) {
621
642
  typesByMatches.set(matchesPerPlugin, matchingTypes);
622
643
  }
@@ -628,7 +649,7 @@ function* resolveMatches(candidate, context, original = candidate) {
628
649
  // Partition plugins in 2 categories so that we can start searching in the plugins that
629
650
  // don't have `any` as a type first.
630
651
  let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
631
- let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === "any"));
652
+ let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === 'any'));
632
653
  if (hasAnyType) {
633
654
  group[0].push(plugin);
634
655
  } else {
@@ -648,26 +669,26 @@ function* resolveMatches(candidate, context, original = candidate) {
648
669
  // also has the correct type which preferOnConflicts the plugin in case of clashes.
649
670
  return matches.find((rules)=>{
650
671
  let matchingTypes = typesByMatches.get(rules);
651
- return rules.some(([{ options }, rule])=>{
672
+ return rules.some(([{ options }, rule])=>{
652
673
  if (!isParsableNode(rule)) {
653
674
  return false;
654
675
  }
655
- return options.types.some(({ type , preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
676
+ return options.types.some(({ type, preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
656
677
  });
657
678
  });
658
679
  }
659
- var ref2;
680
+ var _findFallback;
660
681
  // Try to find a fallback plugin, because we already know that multiple plugins matched for
661
682
  // the given arbitrary value.
662
- let fallback = (ref2 = findFallback(withoutAny)) !== null && ref2 !== void 0 ? ref2 : findFallback(withAny);
683
+ let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
663
684
  if (fallback) {
664
685
  matches = [
665
686
  fallback
666
687
  ];
667
688
  } else {
668
- var ref3;
689
+ var _typesByMatches_get;
669
690
  let typesPerPlugin = matches.map((match)=>new Set([
670
- ...(ref3 = typesByMatches.get(match)) !== null && ref3 !== void 0 ? ref3 : []
691
+ ...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
671
692
  ]));
672
693
  // Remove duplicates, so that we can detect proper unique types for each plugin.
673
694
  for (let pluginTypes of typesPerPlugin){
@@ -685,18 +706,18 @@ function* resolveMatches(candidate, context, original = candidate) {
685
706
  }
686
707
  let messages = [];
687
708
  for (let [idx, group] of typesPerPlugin.entries()){
688
- for (let type1 of group){
689
- let rules2 = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
709
+ for (let type of group){
710
+ let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split('\n').slice(1, -1) // Remove selector and closing '}'
690
711
  .map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
691
- .join("\n")).join("\n\n");
692
- messages.push(` Use \`${candidate.replace("[", `[${type1}:`)}\` for \`${rules2.trim()}\``);
712
+ .join('\n')).join('\n\n');
713
+ messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``);
693
714
  break;
694
715
  }
695
716
  }
696
717
  _log.default.warn([
697
718
  `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
698
719
  ...messages,
699
- `If this is content and not a class, replace it with \`${candidate.replace("[", "&lsqb;").replace("]", "&rsqb;")}\` to silence this warning.`
720
+ `If this is content and not a class, replace it with \`${candidate.replace('[', '&lsqb;').replace(']', '&rsqb;')}\` to silence this warning.`
700
721
  ]);
701
722
  continue;
702
723
  }
@@ -718,33 +739,72 @@ function* resolveMatches(candidate, context, original = candidate) {
718
739
  candidate
719
740
  };
720
741
  // Apply final format selector
721
- if (match[0].collectedFormats) {
722
- let finalFormat = (0, _formatVariantSelector.formatVariantSelector)("&", ...match[0].collectedFormats);
723
- let container = _postcss.default.root({
724
- nodes: [
725
- match[1].clone()
726
- ]
727
- });
728
- container.walkRules((rule)=>{
729
- var ref;
730
- if (inKeyframes(rule)) return;
731
- var ref1;
732
- rule.selector = (0, _formatVariantSelector.finalizeSelector)(finalFormat, {
733
- selector: rule.selector,
734
- candidate: original,
735
- base: candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop(),
736
- isArbitraryVariant: match[0].isArbitraryVariant,
737
- context
738
- });
739
- });
740
- match[1] = container.nodes[0];
742
+ match = applyFinalFormat(match, {
743
+ context,
744
+ candidate
745
+ });
746
+ // Skip rules with invalid selectors
747
+ // This will cause the candidate to be added to the "not class"
748
+ // cache skipping it entirely for future builds
749
+ if (match === null) {
750
+ continue;
741
751
  }
742
752
  yield match;
743
753
  }
744
754
  }
745
755
  }
756
+ function applyFinalFormat(match, { context, candidate }) {
757
+ if (!match[0].collectedFormats) {
758
+ return match;
759
+ }
760
+ let isValid = true;
761
+ let finalFormat;
762
+ try {
763
+ finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
764
+ context,
765
+ candidate
766
+ });
767
+ } catch (e) {
768
+ // The format selector we produced is invalid
769
+ // This could be because:
770
+ // - A bug exists
771
+ // - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
772
+ // - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
773
+ // Either way the build will fail because of this
774
+ // We would rather that the build pass "silently" given that this could
775
+ // happen because of picking up invalid things when scanning content
776
+ // So we'll throw out the candidate instead
777
+ return null;
778
+ }
779
+ let container = _postcss.default.root({
780
+ nodes: [
781
+ match[1].clone()
782
+ ]
783
+ });
784
+ container.walkRules((rule)=>{
785
+ if (inKeyframes(rule)) {
786
+ return;
787
+ }
788
+ try {
789
+ rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
790
+ candidate,
791
+ context
792
+ });
793
+ } catch (e) {
794
+ // If this selector is invalid we also want to skip it
795
+ // But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
796
+ isValid = false;
797
+ return false;
798
+ }
799
+ });
800
+ if (!isValid) {
801
+ return null;
802
+ }
803
+ match[1] = container.nodes[0];
804
+ return match;
805
+ }
746
806
  function inKeyframes(rule) {
747
- return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
807
+ return rule.parent && rule.parent.type === 'atrule' && rule.parent.name === 'keyframes';
748
808
  }
749
809
  function getImportantStrategy(important) {
750
810
  if (important === true) {
@@ -753,19 +813,19 @@ function getImportantStrategy(important) {
753
813
  return;
754
814
  }
755
815
  rule.walkDecls((d)=>{
756
- if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
816
+ if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
757
817
  d.important = true;
758
818
  }
759
819
  });
760
820
  };
761
821
  }
762
- if (typeof important === "string") {
822
+ if (typeof important === 'string') {
763
823
  return (rule)=>{
764
824
  if (inKeyframes(rule)) {
765
825
  return;
766
826
  }
767
827
  rule.selectors = rule.selectors.map((selector)=>{
768
- return `${important} ${selector}`;
828
+ return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
769
829
  });
770
830
  };
771
831
  }
@@ -787,11 +847,11 @@ function generateRules(candidates, context) {
787
847
  continue;
788
848
  }
789
849
  context.classCache.set(candidate, matches);
790
- var ref;
791
- let rules = (ref = context.candidateRuleCache.get(candidate)) !== null && ref !== void 0 ? ref : new Set();
850
+ var _context_candidateRuleCache_get;
851
+ let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
792
852
  context.candidateRuleCache.set(candidate, rules);
793
853
  for (const match of matches){
794
- let [{ sort , options }, rule] = match;
854
+ let [{ sort, options }, rule] = match;
795
855
  if (options.respectImportant && strategy) {
796
856
  let container = _postcss.default.root({
797
857
  nodes: [
@@ -813,5 +873,5 @@ function generateRules(candidates, context) {
813
873
  return allRules;
814
874
  }
815
875
  function isArbitraryValue(input) {
816
- return input.startsWith("[") && input.endsWith("]");
876
+ return input.startsWith('[') && input.endsWith(']');
817
877
  }