tailwindcss 0.0.0-insiders.ea10bb9 → 0.0.0-insiders.ea4e1cd

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 (184) hide show
  1. package/README.md +1 -1
  2. package/lib/cli/build/deps.js +17 -9
  3. package/lib/cli/build/index.js +20 -10
  4. package/lib/cli/build/plugin.js +86 -70
  5. package/lib/cli/build/utils.js +18 -8
  6. package/lib/cli/build/watching.js +16 -12
  7. package/lib/cli/help/index.js +6 -4
  8. package/lib/cli/index.js +222 -10
  9. package/lib/cli/init/index.js +29 -12
  10. package/lib/cli-peer-dependencies.js +12 -4
  11. package/lib/cli.js +4 -226
  12. package/lib/corePluginList.js +7 -1
  13. package/lib/corePlugins.js +348 -75
  14. package/lib/css/preflight.css +2 -0
  15. package/lib/featureFlags.js +27 -15
  16. package/lib/index.js +1 -47
  17. package/lib/lib/cacheInvalidation.js +7 -5
  18. package/lib/lib/collapseAdjacentRules.js +5 -3
  19. package/lib/lib/collapseDuplicateDeclarations.js +12 -10
  20. package/lib/lib/content.js +34 -30
  21. package/lib/lib/defaultExtractor.js +15 -8
  22. package/lib/lib/detectNesting.js +10 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +22 -20
  24. package/lib/lib/expandApplyAtRules.js +43 -35
  25. package/lib/lib/expandTailwindAtRules.js +46 -19
  26. package/lib/lib/findAtConfigPath.js +9 -7
  27. package/lib/lib/generateRules.js +157 -92
  28. package/lib/lib/getModuleDependencies.js +85 -37
  29. package/lib/lib/load-config.js +42 -0
  30. package/lib/lib/normalizeTailwindDirectives.js +5 -3
  31. package/lib/lib/offsets.js +93 -4
  32. package/lib/lib/partitionApplyAtRules.js +3 -1
  33. package/lib/lib/regex.js +21 -7
  34. package/lib/lib/remap-bitfield.js +89 -0
  35. package/lib/lib/resolveDefaultsAtRules.js +28 -24
  36. package/lib/lib/setupContextUtils.js +190 -131
  37. package/lib/lib/setupTrackingContext.js +49 -26
  38. package/lib/lib/sharedState.js +37 -10
  39. package/lib/lib/substituteScreenAtRules.js +5 -3
  40. package/lib/oxide/cli/build/deps.js +89 -0
  41. package/lib/oxide/cli/build/index.js +53 -0
  42. package/lib/oxide/cli/build/plugin.js +375 -0
  43. package/lib/oxide/cli/build/utils.js +87 -0
  44. package/lib/oxide/cli/build/watching.js +179 -0
  45. package/lib/oxide/cli/help/index.js +72 -0
  46. package/lib/oxide/cli/index.js +214 -0
  47. package/lib/oxide/cli/init/index.js +52 -0
  48. package/lib/oxide/cli.js +5 -0
  49. package/lib/oxide/postcss-plugin.js +2 -0
  50. package/lib/plugin.js +98 -0
  51. package/lib/postcss-plugins/nesting/index.js +3 -1
  52. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  53. package/lib/processTailwindFeatures.js +14 -12
  54. package/lib/public/colors.js +49 -25
  55. package/lib/public/create-plugin.js +5 -3
  56. package/lib/public/default-config.js +6 -4
  57. package/lib/public/default-theme.js +6 -4
  58. package/lib/public/load-config.js +12 -0
  59. package/lib/public/resolve-config.js +6 -4
  60. package/lib/util/applyImportantSelector.js +36 -0
  61. package/lib/util/bigSign.js +3 -1
  62. package/lib/util/buildMediaQuery.js +3 -1
  63. package/lib/util/cloneDeep.js +3 -1
  64. package/lib/util/cloneNodes.js +5 -3
  65. package/lib/util/color.js +30 -12
  66. package/lib/util/colorNames.js +752 -0
  67. package/lib/util/configurePlugins.js +3 -1
  68. package/lib/util/createPlugin.js +3 -1
  69. package/lib/util/createUtilityPlugin.js +7 -5
  70. package/lib/util/dataTypes.js +74 -17
  71. package/lib/util/defaults.js +9 -7
  72. package/lib/util/escapeClassName.js +10 -8
  73. package/lib/util/escapeCommas.js +3 -1
  74. package/lib/util/flattenColorPalette.js +3 -1
  75. package/lib/util/formatVariantSelector.js +138 -160
  76. package/lib/util/getAllConfigs.js +8 -6
  77. package/lib/util/hashConfig.js +6 -4
  78. package/lib/util/isKeyframeRule.js +3 -1
  79. package/lib/util/isPlainObject.js +3 -1
  80. package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
  81. package/lib/util/log.js +8 -4
  82. package/lib/util/nameClass.js +12 -6
  83. package/lib/util/negateValue.js +4 -2
  84. package/lib/util/normalizeConfig.js +28 -27
  85. package/lib/util/normalizeScreens.js +12 -4
  86. package/lib/util/parseAnimationValue.js +3 -1
  87. package/lib/util/parseBoxShadowValue.js +6 -2
  88. package/lib/util/parseDependency.js +3 -1
  89. package/lib/util/parseGlob.js +6 -4
  90. package/lib/util/parseObjectStyles.js +9 -7
  91. package/lib/util/pluginUtils.js +54 -54
  92. package/lib/util/prefixSelector.js +27 -11
  93. package/lib/util/pseudoElements.js +229 -0
  94. package/lib/util/removeAlphaVariables.js +3 -1
  95. package/lib/util/resolveConfig.js +17 -15
  96. package/lib/util/resolveConfigPath.js +26 -10
  97. package/lib/util/responsive.js +6 -4
  98. package/lib/util/splitAtTopLevelOnly.js +10 -2
  99. package/lib/util/tap.js +3 -1
  100. package/lib/util/toColorValue.js +3 -1
  101. package/lib/util/toPath.js +3 -1
  102. package/lib/util/transformThemeValue.js +6 -4
  103. package/lib/util/validateConfig.js +16 -3
  104. package/lib/util/validateFormalSyntax.js +3 -1
  105. package/lib/util/withAlphaVariable.js +6 -2
  106. package/loadConfig.d.ts +4 -0
  107. package/loadConfig.js +2 -0
  108. package/package.json +45 -37
  109. package/peers/index.js +63324 -46417
  110. package/resolveConfig.d.ts +11 -2
  111. package/scripts/swap-engines.js +40 -0
  112. package/src/cli/build/index.js +13 -9
  113. package/src/cli/build/plugin.js +42 -32
  114. package/src/cli/build/watching.js +4 -2
  115. package/src/cli/index.js +216 -3
  116. package/src/cli/init/index.js +37 -8
  117. package/src/cli.js +4 -220
  118. package/src/corePluginList.js +1 -1
  119. package/src/corePlugins.js +207 -32
  120. package/src/css/preflight.css +2 -0
  121. package/src/featureFlags.js +6 -0
  122. package/src/index.js +1 -47
  123. package/src/lib/content.js +12 -17
  124. package/src/lib/defaultExtractor.js +9 -3
  125. package/src/lib/detectNesting.js +9 -1
  126. package/src/lib/expandApplyAtRules.js +8 -1
  127. package/src/lib/expandTailwindAtRules.js +36 -7
  128. package/src/lib/generateRules.js +124 -42
  129. package/src/lib/getModuleDependencies.js +70 -30
  130. package/src/lib/load-config.ts +31 -0
  131. package/src/lib/offsets.js +104 -1
  132. package/src/lib/remap-bitfield.js +82 -0
  133. package/src/lib/setupContextUtils.js +103 -54
  134. package/src/lib/setupTrackingContext.js +36 -11
  135. package/src/lib/sharedState.js +15 -4
  136. package/src/oxide/cli/build/deps.ts +91 -0
  137. package/src/oxide/cli/build/index.ts +47 -0
  138. package/src/oxide/cli/build/plugin.ts +442 -0
  139. package/src/oxide/cli/build/utils.ts +74 -0
  140. package/src/oxide/cli/build/watching.ts +225 -0
  141. package/src/oxide/cli/help/index.ts +69 -0
  142. package/src/oxide/cli/index.ts +204 -0
  143. package/src/oxide/cli/init/index.ts +59 -0
  144. package/src/oxide/cli.ts +1 -0
  145. package/src/oxide/postcss-plugin.ts +1 -0
  146. package/src/plugin.js +107 -0
  147. package/src/public/colors.js +22 -0
  148. package/src/public/default-config.js +1 -1
  149. package/src/public/default-theme.js +2 -2
  150. package/src/public/load-config.js +2 -0
  151. package/src/util/applyImportantSelector.js +27 -0
  152. package/src/util/color.js +18 -3
  153. package/src/util/colorNames.js +150 -0
  154. package/src/util/dataTypes.js +33 -4
  155. package/src/util/formatVariantSelector.js +160 -163
  156. package/src/util/getAllConfigs.js +2 -2
  157. package/src/util/negateValue.js +1 -1
  158. package/src/util/normalizeConfig.js +2 -1
  159. package/src/util/pluginUtils.js +16 -31
  160. package/src/util/prefixSelector.js +28 -10
  161. package/src/util/pseudoElements.js +170 -0
  162. package/src/util/resolveConfigPath.js +12 -1
  163. package/src/util/splitAtTopLevelOnly.js +8 -1
  164. package/src/util/validateConfig.js +13 -0
  165. package/stubs/.gitignore +1 -0
  166. package/stubs/.prettierrc.json +6 -0
  167. package/stubs/{defaultConfig.stub.js → config.full.js} +183 -146
  168. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  169. package/stubs/postcss.config.js +6 -0
  170. package/stubs/tailwind.config.cjs +2 -0
  171. package/stubs/tailwind.config.js +2 -0
  172. package/stubs/tailwind.config.ts +3 -0
  173. package/types/config.d.ts +15 -9
  174. package/types/generated/colors.d.ts +22 -0
  175. package/types/generated/corePluginList.d.ts +1 -1
  176. package/types/generated/default-theme.d.ts +108 -79
  177. package/CHANGELOG.md +0 -2336
  178. package/lib/cli/shared.js +0 -12
  179. package/lib/constants.js +0 -44
  180. package/scripts/install-integrations.js +0 -27
  181. package/scripts/rebuildFixtures.js +0 -68
  182. package/src/cli/shared.js +0 -5
  183. package/src/constants.js +0 -17
  184. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -9,26 +9,33 @@ 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 _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
29
- const _splitAtTopLevelOnlyJs = require("../util/splitAtTopLevelOnly.js");
34
+ const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
35
+ const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
30
36
  const _featureFlags = require("../featureFlags");
31
- function _interopRequireDefault(obj) {
37
+ const _applyImportantSelector = require("../util/applyImportantSelector");
38
+ function _interop_require_default(obj) {
32
39
  return obj && obj.__esModule ? obj : {
33
40
  default: obj
34
41
  };
@@ -41,7 +48,7 @@ function _getRequireWildcardCache(nodeInterop) {
41
48
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
49
  })(nodeInterop);
43
50
  }
44
- function _interopRequireWildcard(obj, nodeInterop) {
51
+ function _interop_require_wildcard(obj, nodeInterop) {
45
52
  if (!nodeInterop && obj && obj.__esModule) {
46
53
  return obj;
47
54
  }
@@ -72,7 +79,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
72
79
  }
73
80
  return newObj;
74
81
  }
75
- let classNameParser = (0, _postcssSelectorParser.default)((selectors)=>{
82
+ let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
76
83
  return selectors.first.filter(({ type })=>type === "class").pop().value;
77
84
  });
78
85
  function getClassNameFromSelector(selector) {
@@ -162,12 +169,12 @@ function applyImportant(matches, classCandidate) {
162
169
  ]
163
170
  });
164
171
  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
- });
172
+ let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
173
+ // Remove extraneous selectors that do not include the base candidate
174
+ ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
175
+ // Update all instances of the base candidate to include the important marker
176
+ (0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
177
+ r.selector = ast.toString();
171
178
  r.walkDecls((d)=>d.important = true);
172
179
  });
173
180
  result.push([
@@ -198,10 +205,16 @@ function applyVariant(variant, matches, context) {
198
205
  };
199
206
  // Retrieve "modifier"
200
207
  {
201
- let match = /(.*)\/(.*)$/g.exec(variant);
202
- if (match) {
203
- variant = match[1];
204
- args.modifier = match[2];
208
+ let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, "/");
209
+ // This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
210
+ // In this case 1/10 is a value but /20 is a modifier
211
+ if (modifiers.length > 1) {
212
+ baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
213
+ modifiers = modifiers.slice(-1);
214
+ }
215
+ if (modifiers.length && !context.variantMap.has(variant)) {
216
+ variant = baseVariant;
217
+ args.modifier = modifiers[0];
205
218
  if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
206
219
  return [];
207
220
  }
@@ -216,9 +229,9 @@ function applyVariant(variant, matches, context) {
216
229
  // But we don't want:
217
230
  // @-[200px] (`-` is incorrect)
218
231
  // group[:hover] (`-` is missing)
219
- let match1 = /(.)(-?)\[(.*)\]/g.exec(variant);
220
- if (match1) {
221
- let [, char, seperator, value] = match1;
232
+ let match = /(.)(-?)\[(.*)\]/g.exec(variant);
233
+ if (match) {
234
+ let [, char, seperator, value] = match;
222
235
  // @-[200px] case
223
236
  if (char === "@" && seperator === "-") return [];
224
237
  // group[:hover] case
@@ -229,20 +242,24 @@ function applyVariant(variant, matches, context) {
229
242
  }
230
243
  // Register arbitrary variants
231
244
  if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
245
+ let sort = context.offsets.recordVariant(variant);
232
246
  let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
233
- if (!(0, _setupContextUtils.isValidVariantFormatString)(selector)) {
247
+ let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ",");
248
+ // We do not support multiple selectors for arbitrary variants
249
+ if (selectors.length > 1) {
234
250
  return [];
235
251
  }
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
- ]);
252
+ if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
253
+ return [];
254
+ }
255
+ let records = selectors.map((sel, idx)=>[
256
+ context.offsets.applyParallelOffset(sort, idx),
257
+ (0, _setupContextUtils.parseVariant)(sel.trim())
258
+ ]);
259
+ context.variantMap.set(variant, records);
244
260
  }
245
261
  if (context.variantMap.has(variant)) {
262
+ let isArbitraryVariant = isArbitraryValue(variant);
246
263
  let variantFunctionTuples = context.variantMap.get(variant).slice();
247
264
  let result = [];
248
265
  for (let [meta, rule] of matches){
@@ -299,21 +316,24 @@ function applyVariant(variant, matches, context) {
299
316
  clone.append(wrapper);
300
317
  },
301
318
  format (selectorFormat) {
302
- collectedFormats.push(selectorFormat);
319
+ collectedFormats.push({
320
+ format: selectorFormat,
321
+ isArbitraryVariant
322
+ });
303
323
  },
304
324
  args
305
325
  });
306
326
  // It can happen that a list of format strings is returned from within the function. In that
307
327
  // case, we have to process them as well. We can use the existing `variantSort`.
308
328
  if (Array.isArray(ruleWithVariant)) {
309
- for (let [idx, variantFunction1] of ruleWithVariant.entries()){
329
+ for (let [idx, variantFunction] of ruleWithVariant.entries()){
310
330
  // This is a little bit scary since we are pushing to an array of items that we are
311
331
  // currently looping over. However, you can also think of it like a processing queue
312
332
  // where you keep handling jobs until everything is done and each job can queue more
313
333
  // jobs if needed.
314
334
  variantFunctionTuples.push([
315
335
  context.offsets.applyParallelOffset(variantSort, idx),
316
- variantFunction1,
336
+ variantFunction,
317
337
  // If the clone has been modified we have to pass that back
318
338
  // though so each rule can use the modified container
319
339
  clone.clone()
@@ -322,7 +342,10 @@ function applyVariant(variant, matches, context) {
322
342
  continue;
323
343
  }
324
344
  if (typeof ruleWithVariant === "string") {
325
- collectedFormats.push(ruleWithVariant);
345
+ collectedFormats.push({
346
+ format: ruleWithVariant,
347
+ isArbitraryVariant
348
+ });
326
349
  }
327
350
  if (ruleWithVariant === null) {
328
351
  continue;
@@ -342,7 +365,7 @@ function applyVariant(variant, matches, context) {
342
365
  // as well. E.g.: `${variant}${separator}${className}`.
343
366
  // However, plugin authors probably also prepend or append certain
344
367
  // classes, pseudos, ids, ...
345
- let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
368
+ let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
346
369
  selectors.walkClasses((classNode)=>{
347
370
  classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
348
371
  });
@@ -358,7 +381,10 @@ function applyVariant(variant, matches, context) {
358
381
  // modified (by plugin): .foo .foo\\:markdown > p
359
382
  // rebuiltBase (internal): .foo\\:markdown > p
360
383
  // format: .foo &
361
- collectedFormats.push(modified.replace(rebuiltBase, "&"));
384
+ collectedFormats.push({
385
+ format: modified.replace(rebuiltBase, "&"),
386
+ isArbitraryVariant
387
+ });
362
388
  rule.selector = before;
363
389
  });
364
390
  }
@@ -370,13 +396,12 @@ function applyVariant(variant, matches, context) {
370
396
  ...clone.nodes[0].raws.tailwind,
371
397
  parentLayer: meta.layer
372
398
  };
373
- var _collectedFormats;
399
+ var _meta_collectedFormats;
374
400
  let withOffset = [
375
401
  {
376
402
  ...meta,
377
403
  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)
404
+ collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
380
405
  },
381
406
  clone.nodes[0]
382
407
  ];
@@ -434,7 +459,7 @@ function isValidPropName(name) {
434
459
  function isParsableNode(node) {
435
460
  let isParsable = true;
436
461
  node.walkDecls((decl)=>{
437
- if (!isParsableCssValue(decl.name, decl.value)) {
462
+ if (!isParsableCssValue(decl.prop, decl.value)) {
438
463
  isParsable = false;
439
464
  return false;
440
465
  }
@@ -456,8 +481,8 @@ function isParsableCssValue(property, value) {
456
481
  }
457
482
  }
458
483
  function extractArbitraryProperty(classCandidate, context) {
459
- var ref;
460
- let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
484
+ var _classCandidate_match;
485
+ let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
461
486
  if (value === undefined) {
462
487
  return null;
463
488
  }
@@ -531,16 +556,16 @@ function splitWithSeparator(input, separator) {
531
556
  _sharedState.NOT_ON_DEMAND
532
557
  ];
533
558
  }
534
- return (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(input, separator);
559
+ return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
535
560
  }
536
561
  function* recordCandidates(matches, classCandidate) {
537
562
  for (const match of matches){
538
- var ref;
539
- var ref1;
563
+ var _match__options;
564
+ var _match__options_preserveSource;
540
565
  match[1].raws.tailwind = {
541
566
  ...match[1].raws.tailwind,
542
567
  classCandidate,
543
- preserveSource: (ref1 = (ref = match[0].options) === null || ref === void 0 ? void 0 : ref.preserveSource) !== null && ref1 !== void 0 ? ref1 : false
568
+ 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
569
  };
545
570
  yield match;
546
571
  }
@@ -556,7 +581,7 @@ function* resolveMatches(candidate, context, original = candidate) {
556
581
  if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
557
582
  if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
558
583
  let base = variants.slice().reverse().join(separator);
559
- for (let part of (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
584
+ for (let part of (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
560
585
  yield* resolveMatches(base + separator + part, context, original);
561
586
  }
562
587
  }
@@ -598,25 +623,25 @@ function* resolveMatches(candidate, context, original = candidate) {
598
623
  }
599
624
  }
600
625
  } else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
601
- let ruleSet1 = plugin;
602
- let [rules1, options1] = parseRules(ruleSet1, context.postCssNodeCache);
603
- for (let rule1 of rules1){
626
+ let ruleSet = plugin;
627
+ let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
628
+ for (let rule of rules){
604
629
  matchesPerPlugin.push([
605
630
  {
606
631
  ...sort,
607
632
  options: {
608
633
  ...sort.options,
609
- ...options1
634
+ ...options
610
635
  }
611
636
  },
612
- rule1
637
+ rule
613
638
  ]);
614
639
  }
615
640
  }
616
641
  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);
642
+ var _sort_options;
643
+ var _sort_options_types, _sort_options1;
644
+ 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
645
  if (matchingTypes.length > 0) {
621
646
  typesByMatches.set(matchesPerPlugin, matchingTypes);
622
647
  }
@@ -656,18 +681,18 @@ function* resolveMatches(candidate, context, original = candidate) {
656
681
  });
657
682
  });
658
683
  }
659
- var ref2;
684
+ var _findFallback;
660
685
  // Try to find a fallback plugin, because we already know that multiple plugins matched for
661
686
  // the given arbitrary value.
662
- let fallback = (ref2 = findFallback(withoutAny)) !== null && ref2 !== void 0 ? ref2 : findFallback(withAny);
687
+ let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
663
688
  if (fallback) {
664
689
  matches = [
665
690
  fallback
666
691
  ];
667
692
  } else {
668
- var ref3;
693
+ var _typesByMatches_get;
669
694
  let typesPerPlugin = matches.map((match)=>new Set([
670
- ...(ref3 = typesByMatches.get(match)) !== null && ref3 !== void 0 ? ref3 : []
695
+ ...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
671
696
  ]));
672
697
  // Remove duplicates, so that we can detect proper unique types for each plugin.
673
698
  for (let pluginTypes of typesPerPlugin){
@@ -685,11 +710,11 @@ function* resolveMatches(candidate, context, original = candidate) {
685
710
  }
686
711
  let messages = [];
687
712
  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 '}'
713
+ for (let type of group){
714
+ let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
690
715
  .map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
691
716
  .join("\n")).join("\n\n");
692
- messages.push(` Use \`${candidate.replace("[", `[${type1}:`)}\` for \`${rules2.trim()}\``);
717
+ messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
693
718
  break;
694
719
  }
695
720
  }
@@ -718,31 +743,71 @@ function* resolveMatches(candidate, context, original = candidate) {
718
743
  candidate
719
744
  };
720
745
  // 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];
746
+ match = applyFinalFormat(match, {
747
+ context,
748
+ candidate,
749
+ original
750
+ });
751
+ // Skip rules with invalid selectors
752
+ // This will cause the candidate to be added to the "not class"
753
+ // cache skipping it entirely for future builds
754
+ if (match === null) {
755
+ continue;
741
756
  }
742
757
  yield match;
743
758
  }
744
759
  }
745
760
  }
761
+ function applyFinalFormat(match, { context , candidate , original }) {
762
+ if (!match[0].collectedFormats) {
763
+ return match;
764
+ }
765
+ let isValid = true;
766
+ let finalFormat;
767
+ try {
768
+ finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
769
+ context,
770
+ candidate
771
+ });
772
+ } catch {
773
+ // The format selector we produced is invalid
774
+ // This could be because:
775
+ // - A bug exists
776
+ // - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
777
+ // - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
778
+ // Either way the build will fail because of this
779
+ // We would rather that the build pass "silently" given that this could
780
+ // happen because of picking up invalid things when scanning content
781
+ // So we'll throw out the candidate instead
782
+ return null;
783
+ }
784
+ let container = _postcss.default.root({
785
+ nodes: [
786
+ match[1].clone()
787
+ ]
788
+ });
789
+ container.walkRules((rule)=>{
790
+ if (inKeyframes(rule)) {
791
+ return;
792
+ }
793
+ try {
794
+ rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
795
+ candidate: original,
796
+ context
797
+ });
798
+ } catch {
799
+ // If this selector is invalid we also want to skip it
800
+ // But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
801
+ isValid = false;
802
+ return false;
803
+ }
804
+ });
805
+ if (!isValid) {
806
+ return null;
807
+ }
808
+ match[1] = container.nodes[0];
809
+ return match;
810
+ }
746
811
  function inKeyframes(rule) {
747
812
  return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
748
813
  }
@@ -765,7 +830,7 @@ function getImportantStrategy(important) {
765
830
  return;
766
831
  }
767
832
  rule.selectors = rule.selectors.map((selector)=>{
768
- return `${important} ${selector}`;
833
+ return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
769
834
  });
770
835
  };
771
836
  }
@@ -787,8 +852,8 @@ function generateRules(candidates, context) {
787
852
  continue;
788
853
  }
789
854
  context.classCache.set(candidate, matches);
790
- var ref;
791
- let rules = (ref = context.candidateRuleCache.get(candidate)) !== null && ref !== void 0 ? ref : new Set();
855
+ var _context_candidateRuleCache_get;
856
+ let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
792
857
  context.candidateRuleCache.set(candidate, rules);
793
858
  for (const match of matches){
794
859
  let [{ sort , options }, rule] = match;
@@ -4,48 +4,96 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
- get: ()=>getModuleDependencies
7
+ get: function() {
8
+ return getModuleDependencies;
9
+ }
8
10
  });
9
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
- const _resolve = /*#__PURE__*/ _interopRequireDefault(require("resolve"));
12
- const _detective = /*#__PURE__*/ _interopRequireDefault(require("detective"));
13
- function _interopRequireDefault(obj) {
11
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ function _interop_require_default(obj) {
14
14
  return obj && obj.__esModule ? obj : {
15
15
  default: obj
16
16
  };
17
17
  }
18
- function createModule(file) {
19
- const source = _fs.default.readFileSync(file, "utf-8");
20
- const requires = (0, _detective.default)(source);
21
- return {
22
- file,
23
- requires
24
- };
18
+ let jsExtensions = [
19
+ ".js",
20
+ ".cjs",
21
+ ".mjs"
22
+ ];
23
+ // Given the current file `a.ts`, we want to make sure that when importing `b` that we resolve
24
+ // `b.ts` before `b.js`
25
+ //
26
+ // E.g.:
27
+ //
28
+ // a.ts
29
+ // b // .ts
30
+ // c // .ts
31
+ // a.js
32
+ // b // .js or .ts
33
+ let jsResolutionOrder = [
34
+ "",
35
+ ".js",
36
+ ".cjs",
37
+ ".mjs",
38
+ ".ts",
39
+ ".cts",
40
+ ".mts",
41
+ ".jsx",
42
+ ".tsx"
43
+ ];
44
+ let tsResolutionOrder = [
45
+ "",
46
+ ".ts",
47
+ ".cts",
48
+ ".mts",
49
+ ".tsx",
50
+ ".js",
51
+ ".cjs",
52
+ ".mjs",
53
+ ".jsx"
54
+ ];
55
+ function resolveWithExtension(file, extensions) {
56
+ // Try to find `./a.ts`, `./a.ts`, ... from `./a`
57
+ for (let ext of extensions){
58
+ let full = `${file}${ext}`;
59
+ if (_fs.default.existsSync(full) && _fs.default.statSync(full).isFile()) {
60
+ return full;
61
+ }
62
+ }
63
+ // Try to find `./a/index.js` from `./a`
64
+ for (let ext of extensions){
65
+ let full = `${file}/index${ext}`;
66
+ if (_fs.default.existsSync(full)) {
67
+ return full;
68
+ }
69
+ }
70
+ return null;
25
71
  }
26
- function getModuleDependencies(entryFile) {
27
- const rootModule = createModule(entryFile);
28
- const modules = [
29
- rootModule
30
- ];
31
- // Iterate over the modules, even when new
32
- // ones are being added
33
- for (const mdl of modules){
34
- mdl.requires.filter((dep)=>{
35
- // Only track local modules, not node_modules
36
- return dep.startsWith("./") || dep.startsWith("../");
37
- }).forEach((dep)=>{
38
- try {
39
- const basedir = _path.default.dirname(mdl.file);
40
- const depPath = _resolve.default.sync(dep, {
41
- basedir
42
- });
43
- const depModule = createModule(depPath);
44
- modules.push(depModule);
45
- } catch (_err) {
46
- // eslint-disable-next-line no-empty
47
- }
48
- });
72
+ function* _getModuleDependencies(filename, base, seen, ext = _path.default.extname(filename)) {
73
+ // Try to find the file
74
+ let absoluteFile = resolveWithExtension(_path.default.resolve(base, filename), jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder);
75
+ if (absoluteFile === null) return; // File doesn't exist
76
+ // Prevent infinite loops when there are circular dependencies
77
+ if (seen.has(absoluteFile)) return; // Already seen
78
+ seen.add(absoluteFile);
79
+ // Mark the file as a dependency
80
+ yield absoluteFile;
81
+ // Resolve new base for new imports/requires
82
+ base = _path.default.dirname(absoluteFile);
83
+ ext = _path.default.extname(absoluteFile);
84
+ let contents = _fs.default.readFileSync(absoluteFile, "utf-8");
85
+ // Find imports/requires
86
+ for (let match of [
87
+ ...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
88
+ ...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
89
+ ...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
90
+ ]){
91
+ // Bail out if it's not a relative file
92
+ if (!match[1].startsWith(".")) continue;
93
+ yield* _getModuleDependencies(match[1], base, seen, ext);
49
94
  }
50
- return modules;
95
+ }
96
+ function getModuleDependencies(absoluteFilePath) {
97
+ if (absoluteFilePath === null) return new Set();
98
+ return new Set(_getModuleDependencies(absoluteFilePath, _path.default.dirname(absoluteFilePath), new Set()));
51
99
  }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "loadConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return loadConfig;
9
+ }
10
+ });
11
+ const _jiti = /*#__PURE__*/ _interop_require_default(require("jiti"));
12
+ const _sucrase = require("sucrase");
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ let jiti = null;
19
+ function lazyJiti() {
20
+ return jiti !== null && jiti !== void 0 ? jiti : jiti = (0, _jiti.default)(__filename, {
21
+ interopDefault: true,
22
+ transform: (opts)=>{
23
+ return (0, _sucrase.transform)(opts.source, {
24
+ transforms: [
25
+ "typescript",
26
+ "imports"
27
+ ]
28
+ });
29
+ }
30
+ });
31
+ }
32
+ function loadConfig(path) {
33
+ let config = function() {
34
+ try {
35
+ return path ? require(path) : {};
36
+ } catch {
37
+ return lazyJiti()(path);
38
+ }
39
+ }();
40
+ var _config_default;
41
+ return (_config_default = config.default) !== null && _config_default !== void 0 ? _config_default : config;
42
+ }
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
- get: ()=>normalizeTailwindDirectives
7
+ get: function() {
8
+ return normalizeTailwindDirectives;
9
+ }
8
10
  });
9
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
10
- function _interopRequireDefault(obj) {
11
+ const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
12
+ function _interop_require_default(obj) {
11
13
  return obj && obj.__esModule ? obj : {
12
14
  default: obj
13
15
  };