tailwindcss 0.0.0-insiders.ba2fd32 → 0.0.0-insiders.bbafc8e

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 (106) hide show
  1. package/CHANGELOG.md +292 -3
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.js +2 -1
  5. package/defaultConfig.js +2 -1
  6. package/defaultTheme.js +2 -1
  7. package/lib/cli.js +96 -61
  8. package/lib/constants.js +1 -1
  9. package/lib/corePluginList.js +4 -0
  10. package/lib/corePlugins.js +399 -374
  11. package/lib/css/preflight.css +6 -5
  12. package/lib/featureFlags.js +7 -8
  13. package/lib/index.js +12 -3
  14. package/lib/lib/cacheInvalidation.js +69 -0
  15. package/lib/lib/collapseAdjacentRules.js +14 -1
  16. package/lib/lib/collapseDuplicateDeclarations.js +54 -3
  17. package/lib/lib/defaultExtractor.js +44 -0
  18. package/lib/lib/detectNesting.js +17 -2
  19. package/lib/lib/evaluateTailwindFunctions.js +10 -6
  20. package/lib/lib/expandApplyAtRules.js +264 -59
  21. package/lib/lib/expandTailwindAtRules.js +63 -46
  22. package/lib/lib/generateRules.js +181 -43
  23. package/lib/lib/normalizeTailwindDirectives.js +10 -2
  24. package/lib/lib/partitionApplyAtRules.js +53 -0
  25. package/lib/lib/resolveDefaultsAtRules.js +32 -14
  26. package/lib/lib/setupContextUtils.js +152 -153
  27. package/lib/lib/setupTrackingContext.js +8 -7
  28. package/lib/lib/sharedState.js +38 -5
  29. package/lib/lib/substituteScreenAtRules.js +7 -4
  30. package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
  31. package/lib/postcss-plugins/nesting/index.js +17 -0
  32. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  33. package/lib/processTailwindFeatures.js +10 -2
  34. package/lib/util/buildMediaQuery.js +13 -24
  35. package/lib/util/cloneNodes.js +12 -1
  36. package/lib/util/color.js +23 -8
  37. package/lib/util/createPlugin.js +1 -2
  38. package/lib/util/createUtilityPlugin.js +6 -10
  39. package/lib/util/dataTypes.js +25 -3
  40. package/lib/util/defaults.js +6 -0
  41. package/lib/util/flattenColorPalette.js +1 -3
  42. package/lib/util/formatVariantSelector.js +93 -9
  43. package/lib/util/isValidArbitraryValue.js +64 -0
  44. package/lib/util/log.js +10 -6
  45. package/lib/util/nameClass.js +1 -0
  46. package/lib/util/normalizeConfig.js +54 -22
  47. package/lib/util/normalizeScreens.js +59 -0
  48. package/lib/util/parseBoxShadowValue.js +117 -0
  49. package/lib/util/pluginUtils.js +18 -24
  50. package/lib/util/prefixSelector.js +4 -5
  51. package/lib/util/resolveConfig.js +52 -31
  52. package/lib/util/resolveConfigPath.js +1 -2
  53. package/lib/util/toColorValue.js +1 -2
  54. package/lib/util/toPath.js +6 -1
  55. package/lib/util/transformThemeValue.js +4 -8
  56. package/nesting/index.js +2 -12
  57. package/package.json +28 -33
  58. package/peers/index.js +6970 -7268
  59. package/plugin.js +2 -1
  60. package/resolveConfig.js +2 -1
  61. package/src/cli.js +62 -15
  62. package/src/corePluginList.js +1 -1
  63. package/src/corePlugins.js +329 -255
  64. package/src/css/preflight.css +6 -5
  65. package/src/featureFlags.js +3 -3
  66. package/src/index.js +14 -6
  67. package/src/lib/cacheInvalidation.js +52 -0
  68. package/src/lib/collapseAdjacentRules.js +16 -1
  69. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  70. package/src/lib/defaultExtractor.js +50 -0
  71. package/src/lib/detectNesting.js +22 -3
  72. package/src/lib/evaluateTailwindFunctions.js +6 -3
  73. package/src/lib/expandApplyAtRules.js +285 -56
  74. package/src/lib/expandTailwindAtRules.js +75 -35
  75. package/src/lib/generateRules.js +154 -26
  76. package/src/lib/normalizeTailwindDirectives.js +7 -1
  77. package/src/lib/partitionApplyAtRules.js +52 -0
  78. package/src/lib/resolveDefaultsAtRules.js +35 -10
  79. package/src/lib/setupContextUtils.js +133 -103
  80. package/src/lib/setupTrackingContext.js +8 -7
  81. package/src/lib/sharedState.js +42 -4
  82. package/src/lib/substituteScreenAtRules.js +6 -3
  83. package/src/postcss-plugins/nesting/README.md +42 -0
  84. package/src/postcss-plugins/nesting/index.js +13 -0
  85. package/src/postcss-plugins/nesting/plugin.js +80 -0
  86. package/src/processTailwindFeatures.js +12 -2
  87. package/src/util/buildMediaQuery.js +14 -18
  88. package/src/util/cloneNodes.js +14 -1
  89. package/src/util/color.js +20 -7
  90. package/src/util/dataTypes.js +24 -6
  91. package/src/util/defaults.js +6 -0
  92. package/src/util/formatVariantSelector.js +92 -1
  93. package/src/util/isValidArbitraryValue.js +61 -0
  94. package/src/util/log.js +10 -6
  95. package/src/util/nameClass.js +1 -1
  96. package/src/util/normalizeConfig.js +24 -3
  97. package/src/util/normalizeScreens.js +45 -0
  98. package/src/util/parseBoxShadowValue.js +119 -0
  99. package/src/util/pluginUtils.js +3 -1
  100. package/src/util/prefixSelector.js +7 -5
  101. package/src/util/resolveConfig.js +41 -1
  102. package/src/util/toPath.js +23 -1
  103. package/stubs/defaultConfig.stub.js +27 -11
  104. package/lib/lib/setupWatchingContext.js +0 -288
  105. package/nesting/plugin.js +0 -41
  106. package/src/lib/setupWatchingContext.js +0 -311
@@ -23,6 +23,9 @@ var sharedState = _interopRequireWildcard(require("./sharedState"));
23
23
  var _toPath = require("../util/toPath");
24
24
  var _log = _interopRequireDefault(require("../util/log"));
25
25
  var _negateValue = _interopRequireDefault(require("../util/negateValue"));
26
+ var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
27
+ var _generateRules = require("./generateRules");
28
+ var _cacheInvalidationJs = require("./cacheInvalidation.js");
26
29
  function _interopRequireDefault(obj) {
27
30
  return obj && obj.__esModule ? obj : {
28
31
  default: obj
@@ -32,13 +35,11 @@ function _interopRequireWildcard(obj) {
32
35
  if (obj && obj.__esModule) {
33
36
  return obj;
34
37
  } else {
35
- var newObj = {
36
- };
38
+ var newObj = {};
37
39
  if (obj != null) {
38
40
  for(var key in obj){
39
41
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
40
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
41
- };
42
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
42
43
  if (desc.get || desc.set) {
43
44
  Object.defineProperty(newObj, key, desc);
44
45
  } else {
@@ -51,6 +52,10 @@ function _interopRequireWildcard(obj) {
51
52
  return newObj;
52
53
  }
53
54
  }
55
+ function prefix(context, selector) {
56
+ let prefix1 = context.tailwindConfig.prefix;
57
+ return typeof prefix1 === 'function' ? prefix1(selector) : prefix1 + selector;
58
+ }
54
59
  function parseVariantFormatString(input) {
55
60
  if (input.includes('{')) {
56
61
  if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
@@ -75,8 +80,7 @@ function isBalanced(input) {
75
80
  }
76
81
  return count === 0;
77
82
  }
78
- function insertInto(list, value, { before =[] } = {
79
- }) {
83
+ function insertInto(list, value, { before =[] } = {}) {
80
84
  before = [].concat(before);
81
85
  if (before.length <= 0) {
82
86
  list.push(value);
@@ -111,44 +115,49 @@ function getClasses(selector) {
111
115
  });
112
116
  return parser.transformSync(selector);
113
117
  }
114
- function extractCandidates(node) {
118
+ function extractCandidates(node, state = {
119
+ containsNonOnDemandable: false
120
+ }, depth = 0) {
115
121
  let classes = [];
122
+ // Handle normal rules
116
123
  if (node.type === 'rule') {
117
124
  for (let selector of node.selectors){
118
125
  let classCandidates = getClasses(selector);
119
126
  // At least one of the selectors contains non-"on-demandable" candidates.
120
- if (classCandidates.length === 0) return [];
121
- classes = [
122
- ...classes,
123
- ...classCandidates
124
- ];
127
+ if (classCandidates.length === 0) {
128
+ state.containsNonOnDemandable = true;
129
+ }
130
+ for (let classCandidate of classCandidates){
131
+ classes.push(classCandidate);
132
+ }
125
133
  }
126
- return classes;
127
- }
128
- if (node.type === 'atrule') {
134
+ } else if (node.type === 'atrule') {
129
135
  node.walkRules((rule)=>{
130
- classes = [
131
- ...classes,
132
- ...rule.selectors.flatMap((selector)=>getClasses(selector)
133
- )
134
- ];
136
+ for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector, state, depth + 1)
137
+ )){
138
+ classes.push(classCandidate);
139
+ }
135
140
  });
136
141
  }
142
+ if (depth === 0) {
143
+ return [
144
+ state.containsNonOnDemandable || classes.length === 0,
145
+ classes
146
+ ];
147
+ }
137
148
  return classes;
138
149
  }
139
150
  function withIdentifiers(styles) {
140
151
  return parseStyles(styles).flatMap((node)=>{
141
152
  let nodeMap = new Map();
142
- let candidates = extractCandidates(node);
143
- // If this isn't "on-demandable", assign it a universal candidate.
144
- if (candidates.length === 0) {
145
- return [
146
- [
147
- '*',
148
- node
149
- ]
150
- ];
153
+ let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
154
+ // If this isn't "on-demandable", assign it a universal candidate to always include it.
155
+ if (containsNonOnDemandableSelectors) {
156
+ candidates.unshift(sharedState.NOT_ON_DEMAND);
151
157
  }
158
+ // However, it could be that it also contains "on-demandable" candidates.
159
+ // E.g.: `span, .foo {}`, in that case it should still be possible to use
160
+ // `@apply foo` for example.
152
161
  return candidates.map((c)=>{
153
162
  if (!nodeMap.has(node)) {
154
163
  nodeMap.set(node, node);
@@ -160,68 +169,6 @@ function withIdentifiers(styles) {
160
169
  });
161
170
  });
162
171
  }
163
- let matchingBrackets = new Map([
164
- [
165
- '{',
166
- '}'
167
- ],
168
- [
169
- '[',
170
- ']'
171
- ],
172
- [
173
- '(',
174
- ')'
175
- ],
176
- ]);
177
- let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
178
- v,
179
- k
180
- ]
181
- ));
182
- let quotes = new Set([
183
- '"',
184
- "'",
185
- '`'
186
- ]);
187
- // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
188
- // values don't count, and brackets inside quotes also don't count.
189
- //
190
- // E.g.: w-[this-is]w-[weird-and-invalid]
191
- // E.g.: w-[this-is\\]w-\\[weird-but-valid]
192
- // E.g.: content-['this-is-also-valid]-weirdly-enough']
193
- function isValidArbitraryValue(value) {
194
- let stack = [];
195
- let inQuotes = false;
196
- for(let i = 0; i < value.length; i++){
197
- let char = value[i];
198
- // Non-escaped quotes allow us to "allow" anything in between
199
- if (quotes.has(char) && value[i - 1] !== '\\') {
200
- inQuotes = !inQuotes;
201
- }
202
- if (inQuotes) continue;
203
- if (value[i - 1] === '\\') continue; // Escaped
204
- if (matchingBrackets.has(char)) {
205
- stack.push(char);
206
- } else if (inverseMatchingBrackets.has(char)) {
207
- let inverse = inverseMatchingBrackets.get(char);
208
- // Nothing to pop from, therefore it is unbalanced
209
- if (stack.length <= 0) {
210
- return false;
211
- }
212
- // Popped value must match the inverse value, otherwise it is unbalanced
213
- if (stack.pop() !== inverse) {
214
- return false;
215
- }
216
- }
217
- }
218
- // If there is still something on the stack, it is also unbalanced
219
- if (stack.length > 0) {
220
- return false;
221
- }
222
- // All good, totally balanced!
223
- return true;
224
- }
225
172
  function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
226
173
  function getConfigValue(path, defaultValue) {
227
174
  return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
@@ -230,8 +177,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
230
177
  return (0, _prefixSelector).default(tailwindConfig.prefix, selector);
231
178
  }
232
179
  function prefixIdentifier(identifier, options) {
233
- if (identifier === '*') {
234
- return '*';
180
+ if (identifier === sharedState.NOT_ON_DEMAND) {
181
+ return sharedState.NOT_ON_DEMAND;
235
182
  }
236
183
  if (!options.respectPrefix) {
237
184
  return identifier;
@@ -239,8 +186,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
239
186
  return context.tailwindConfig.prefix + identifier;
240
187
  }
241
188
  return {
242
- addVariant (variantName, variantFunctions, options = {
243
- }) {
189
+ addVariant (variantName, variantFunctions, options = {}) {
244
190
  variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
245
191
  if (typeof variantFunction !== 'string') {
246
192
  // Safelist public API functions
@@ -300,33 +246,38 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
300
246
  // Preserved for backwards compatibility but not used in v3.0+
301
247
  return [];
302
248
  },
303
- addUserCss (userCss) {
304
- for (let [identifier, rule] of withIdentifiers(userCss)){
305
- let offset = offsets.user++;
306
- if (!context.candidateRuleMap.has(identifier)) {
307
- context.candidateRuleMap.set(identifier, []);
249
+ addBase (base) {
250
+ for (let [identifier, rule] of withIdentifiers(base)){
251
+ let prefixedIdentifier = prefixIdentifier(identifier, {});
252
+ let offset = offsets.base++;
253
+ if (!context.candidateRuleMap.has(prefixedIdentifier)) {
254
+ context.candidateRuleMap.set(prefixedIdentifier, []);
308
255
  }
309
- context.candidateRuleMap.get(identifier).push([
256
+ context.candidateRuleMap.get(prefixedIdentifier).push([
310
257
  {
311
258
  sort: offset,
312
- layer: 'user'
259
+ layer: 'base'
313
260
  },
314
261
  rule
315
262
  ]);
316
263
  }
317
264
  },
318
- addBase (base) {
319
- for (let [identifier, rule] of withIdentifiers(base)){
320
- let prefixedIdentifier = prefixIdentifier(identifier, {
321
- });
322
- let offset = offsets.base++;
265
+ /**
266
+ * @param {string} group
267
+ * @param {Record<string, string | string[]>} declarations
268
+ */ addDefaults (group, declarations) {
269
+ const groups = {
270
+ [`@defaults ${group}`]: declarations
271
+ };
272
+ for (let [identifier, rule] of withIdentifiers(groups)){
273
+ let prefixedIdentifier = prefixIdentifier(identifier, {});
323
274
  if (!context.candidateRuleMap.has(prefixedIdentifier)) {
324
275
  context.candidateRuleMap.set(prefixedIdentifier, []);
325
276
  }
326
277
  context.candidateRuleMap.get(prefixedIdentifier).push([
327
278
  {
328
- sort: offset,
329
- layer: 'base'
279
+ sort: offsets.base++,
280
+ layer: 'defaults'
330
281
  },
331
282
  rule
332
283
  ]);
@@ -337,19 +288,16 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
337
288
  respectPrefix: true,
338
289
  respectImportant: false
339
290
  };
340
- options = Object.assign({
341
- }, defaultOptions, Array.isArray(options) ? {
342
- } : options);
291
+ options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
343
292
  for (let [identifier, rule] of withIdentifiers(components)){
344
293
  let prefixedIdentifier = prefixIdentifier(identifier, options);
345
- let offset = offsets.components++;
346
294
  classList.add(prefixedIdentifier);
347
295
  if (!context.candidateRuleMap.has(prefixedIdentifier)) {
348
296
  context.candidateRuleMap.set(prefixedIdentifier, []);
349
297
  }
350
298
  context.candidateRuleMap.get(prefixedIdentifier).push([
351
299
  {
352
- sort: offset,
300
+ sort: offsets.components++,
353
301
  layer: 'components',
354
302
  options
355
303
  },
@@ -362,19 +310,16 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
362
310
  respectPrefix: true,
363
311
  respectImportant: true
364
312
  };
365
- options = Object.assign({
366
- }, defaultOptions, Array.isArray(options) ? {
367
- } : options);
313
+ options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
368
314
  for (let [identifier, rule] of withIdentifiers(utilities)){
369
315
  let prefixedIdentifier = prefixIdentifier(identifier, options);
370
- let offset = offsets.utilities++;
371
316
  classList.add(prefixedIdentifier);
372
317
  if (!context.candidateRuleMap.has(prefixedIdentifier)) {
373
318
  context.candidateRuleMap.set(prefixedIdentifier, []);
374
319
  }
375
320
  context.candidateRuleMap.get(prefixedIdentifier).push([
376
321
  {
377
- sort: offset,
322
+ sort: offsets.utilities++,
378
323
  layer: 'utilities',
379
324
  options
380
325
  },
@@ -409,7 +354,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
409
354
  if (!type.includes(coercedType) && !isOnlyPlugin) {
410
355
  return [];
411
356
  }
412
- if (!isValidArbitraryValue(value)) {
357
+ if (!(0, _isValidArbitraryValue).default(value)) {
413
358
  return [];
414
359
  }
415
360
  let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
@@ -466,7 +411,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
466
411
  return [];
467
412
  }
468
413
  }
469
- if (!isValidArbitraryValue(value)) {
414
+ if (!(0, _isValidArbitraryValue).default(value)) {
470
415
  return [];
471
416
  }
472
417
  let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
@@ -501,11 +446,17 @@ function getFileModifiedMap(context) {
501
446
  function trackModified(files, fileModifiedMap) {
502
447
  let changed = false;
503
448
  for (let file of files){
449
+ var ref;
504
450
  if (!file) continue;
505
451
  let parsed = _url.default.parse(file);
506
452
  let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href;
507
453
  pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname;
508
- let newModified = _fs.default.statSync(decodeURIComponent(pathname)).mtimeMs;
454
+ let newModified = (ref = _fs.default.statSync(decodeURIComponent(pathname), {
455
+ throwIfNoEntry: false
456
+ })) === null || ref === void 0 ? void 0 : ref.mtimeMs;
457
+ if (!newModified) {
458
+ continue;
459
+ }
509
460
  if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
510
461
  changed = true;
511
462
  }
@@ -568,16 +519,6 @@ function collectLayerPlugins(root) {
568
519
  layerRule.remove();
569
520
  }
570
521
  });
571
- root.walkRules((rule)=>{
572
- // At this point it is safe to include all the left-over css from the
573
- // user's css file. This is because the `@tailwind` and `@layer` directives
574
- // will already be handled and will be removed from the css tree.
575
- layerPlugins.push(function({ addUserCss }) {
576
- addUserCss(rule, {
577
- respectPrefix: false
578
- });
579
- });
580
- });
581
522
  return layerPlugins;
582
523
  }
583
524
  function resolvePlugins(context, root) {
@@ -608,7 +549,8 @@ function resolvePlugins(context, root) {
608
549
  _corePlugins.variantPlugins['reducedMotionVariants'],
609
550
  _corePlugins.variantPlugins['darkVariants'],
610
551
  _corePlugins.variantPlugins['printVariant'],
611
- _corePlugins.variantPlugins['screenVariants'],
552
+ _corePlugins.variantPlugins['screenVariants'],
553
+ _corePlugins.variantPlugins['orientationVariants'],
612
554
  ];
613
555
  return [
614
556
  ...corePluginList,
@@ -622,6 +564,7 @@ function registerPlugins(plugins, context) {
622
564
  let variantList = [];
623
565
  let variantMap = new Map();
624
566
  let offsets = {
567
+ defaults: 0n,
625
568
  base: 0n,
626
569
  components: 0n,
627
570
  utilities: 0n,
@@ -647,18 +590,23 @@ function registerPlugins(plugins, context) {
647
590
  )
648
591
  )([
649
592
  offsets.base,
593
+ offsets.defaults,
650
594
  offsets.components,
651
595
  offsets.utilities,
652
596
  offsets.user,
653
597
  ]);
654
598
  let reservedBits = BigInt(highestOffset.toString(2).length);
599
+ // A number one less than the top range of the highest offset area
600
+ // so arbitrary properties are always sorted at the end.
601
+ context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
655
602
  context.layerOrder = {
656
- base: 1n << reservedBits << 0n,
657
- components: 1n << reservedBits << 1n,
658
- utilities: 1n << reservedBits << 2n,
659
- user: 1n << reservedBits << 3n
603
+ defaults: 1n << reservedBits << 0n,
604
+ base: 1n << reservedBits << 1n,
605
+ components: 1n << reservedBits << 2n,
606
+ utilities: 1n << reservedBits << 3n,
607
+ user: 1n << reservedBits << 4n
660
608
  };
661
- reservedBits += 4n;
609
+ reservedBits += 5n;
662
610
  let offset = 0;
663
611
  context.variantOrder = new Map(variantList.map((variant, i)=>{
664
612
  let variantFunctions = variantMap.get(variant).length;
@@ -674,9 +622,9 @@ function registerPlugins(plugins, context) {
674
622
  ...context.variantOrder.values()
675
623
  ].shift();
676
624
  // Build variantMap
677
- for (let [variantName, variantFunctions] of variantMap.entries()){
625
+ for (let [variantName, variantFunctions1] of variantMap.entries()){
678
626
  let sort = context.variantOrder.get(variantName);
679
- context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
627
+ context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
680
628
  sort << BigInt(idx),
681
629
  variantFunction
682
630
  ]
@@ -686,32 +634,53 @@ function registerPlugins(plugins, context) {
686
634
  let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
687
635
  if (safelist.length > 0) {
688
636
  let checks = [];
689
- for (let value of safelist){
690
- if (typeof value === 'string') {
637
+ for (let value1 of safelist){
638
+ if (typeof value1 === 'string') {
691
639
  context.changedContent.push({
692
- content: value,
640
+ content: value1,
693
641
  extension: 'html'
694
642
  });
695
643
  continue;
696
644
  }
697
- if (value instanceof RegExp) {
645
+ if (value1 instanceof RegExp) {
698
646
  _log.default.warn('root-regex', [
699
647
  'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
700
- 'Update your `safelist` configuration to eliminate this warning.'
648
+ 'Update your `safelist` configuration to eliminate this warning.',
649
+ 'https://tailwindcss.com/docs/content-configuration#safelisting-classes',
701
650
  ]);
702
651
  continue;
703
652
  }
704
- checks.push(value);
653
+ checks.push(value1);
705
654
  }
706
655
  if (checks.length > 0) {
707
656
  let patternMatchingCount = new Map();
657
+ let prefixLength = context.tailwindConfig.prefix.length;
708
658
  for (let util of classList){
709
659
  let utils = Array.isArray(util) ? (()=>{
710
660
  let [utilName, options] = util;
711
661
  var ref;
712
- return Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
713
- }).map((value)=>(0, _nameClass).formatClass(utilName, value)
662
+ let values = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {});
663
+ let classes = values.map((value)=>(0, _nameClass).formatClass(utilName, value)
714
664
  );
665
+ if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
666
+ // This is the normal negated version
667
+ // e.g. `-inset-1` or `-tw-inset-1`
668
+ classes = [
669
+ ...classes,
670
+ ...classes.map((cls)=>'-' + cls
671
+ )
672
+ ];
673
+ // This is the negated version *after* the prefix
674
+ // e.g. `tw--inset-1`
675
+ // The prefix is already attached to util name
676
+ // So we add the negative after the prefix
677
+ classes = [
678
+ ...classes,
679
+ ...classes.map((cls)=>cls.slice(0, prefixLength) + '-' + cls.slice(prefixLength)
680
+ ),
681
+ ];
682
+ }
683
+ return classes;
715
684
  })() : [
716
685
  util
717
686
  ];
@@ -742,22 +711,51 @@ function registerPlugins(plugins, context) {
742
711
  if (count !== 0) continue;
743
712
  _log.default.warn([
744
713
  `The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
745
- 'Fix this pattern or remove it from your `safelist` configuration.',
714
+ 'Fix this pattern or remove it from your `safelist` configuration.',
715
+ 'https://tailwindcss.com/docs/content-configuration#safelisting-classes',
746
716
  ]);
747
717
  }
748
718
  }
749
719
  }
720
+ // A list of utilities that are used by certain Tailwind CSS utilities but
721
+ // that don't exist on their own. This will result in them "not existing" and
722
+ // sorting could be weird since you still require them in order to make the
723
+ // host utitlies work properly. (Thanks Biology)
724
+ let parasiteUtilities = new Set([
725
+ prefix(context, 'group'),
726
+ prefix(context, 'peer')
727
+ ]);
728
+ context.getClassOrder = function getClassOrder(classes) {
729
+ let sortedClassNames = new Map();
730
+ for (let [sort, rule] of (0, _generateRules).generateRules(new Set(classes), context)){
731
+ if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue;
732
+ sortedClassNames.set(rule.raws.tailwind.candidate, sort);
733
+ }
734
+ return classes.map((className)=>{
735
+ var ref;
736
+ let order = (ref = sortedClassNames.get(className)) !== null && ref !== void 0 ? ref : null;
737
+ if (order === null && parasiteUtilities.has(className)) {
738
+ // This will make sure that it is at the very beginning of the
739
+ // `components` layer which technically means 'before any
740
+ // components'.
741
+ order = context.layerOrder.components;
742
+ }
743
+ return [
744
+ className,
745
+ order
746
+ ];
747
+ });
748
+ };
750
749
  // Generate a list of strings for autocompletion purposes, e.g.
751
750
  // ['uppercase', 'lowercase', ...]
752
- context.getClassList = function() {
751
+ context.getClassList = function getClassList() {
753
752
  let output = [];
754
753
  for (let util of classList){
755
754
  if (Array.isArray(util)) {
756
755
  let [utilName, options] = util;
757
756
  let negativeClasses = [];
758
757
  var ref;
759
- for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
760
- })){
758
+ for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
761
759
  output.push((0, _nameClass).formatClass(utilName, key));
762
760
  if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
763
761
  negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
@@ -805,13 +803,14 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
805
803
  contextMap.set(sourcePath, context);
806
804
  existingContext = context;
807
805
  }
806
+ let cssDidChange = (0, _cacheInvalidationJs).hasContentChanged(sourcePath, root);
808
807
  // If there's already a context in the cache and we don't need to
809
808
  // reset the context, return the cached context.
810
809
  if (existingContext) {
811
810
  let contextDependenciesChanged = trackModified([
812
811
  ...contextDependencies
813
812
  ], getFileModifiedMap(existingContext));
814
- if (!contextDependenciesChanged) {
813
+ if (!contextDependenciesChanged && !cssDidChange) {
815
814
  return [
816
815
  existingContext,
817
816
  false
@@ -123,11 +123,12 @@ function setupTrackingContext(configOrPath) {
123
123
  return (root, result)=>{
124
124
  let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
125
125
  let contextDependencies = new Set(configDependencies);
126
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
127
- // to be dependencies of the context. Can reuse the context even if they change.
128
- // We may want to think about `@layer` being part of this trigger too, but it's tough
129
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
130
- // in another file since independent sources are effectively isolated.
126
+ // If there are no @tailwind or @apply rules, we don't consider this CSS
127
+ // file or its dependencies to be dependencies of the context. Can reuse
128
+ // the context even if they change. We may want to think about `@layer`
129
+ // being part of this trigger too, but it's tough because it's impossible
130
+ // for a layer in one file to end up in the actual @tailwind rule in
131
+ // another file since independent sources are effectively isolated.
131
132
  if (tailwindDirectives.size > 0) {
132
133
  // Add current css file as a context dependencies.
133
134
  contextDependencies.add(result.opts.from);
@@ -140,8 +141,8 @@ function setupTrackingContext(configOrPath) {
140
141
  }
141
142
  let [context] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
142
143
  let candidateFiles = getCandidateFiles(context, tailwindConfig);
143
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
144
- // to be dependencies of the context. Can reuse the context even if they change.
144
+ // If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
145
+ // dependencies to be dependencies of the context. Can reuse the context even if they change.
145
146
  // We may want to think about `@layer` being part of this trigger too, but it's tough
146
147
  // because it's impossible for a layer in one file to end up in the actual @tailwind rule
147
148
  // in another file since independent sources are effectively isolated.
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.contextSourcesMap = exports.configContextMap = exports.env = exports.contextMap = void 0;
5
+ exports.resolveDebug = resolveDebug;
6
+ exports.NOT_ON_DEMAND = exports.sourceHashMap = exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
6
7
  const env = {
7
- TAILWIND_MODE: process.env.TAILWIND_MODE,
8
8
  NODE_ENV: process.env.NODE_ENV,
9
- DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
10
- TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
11
- TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
9
+ DEBUG: resolveDebug(process.env.DEBUG)
12
10
  };
13
11
  exports.env = env;
14
12
  const contextMap = new Map();
@@ -17,3 +15,38 @@ const configContextMap = new Map();
17
15
  exports.configContextMap = configContextMap;
18
16
  const contextSourcesMap = new Map();
19
17
  exports.contextSourcesMap = contextSourcesMap;
18
+ const sourceHashMap = new Map();
19
+ exports.sourceHashMap = sourceHashMap;
20
+ const NOT_ON_DEMAND = new String('*');
21
+ exports.NOT_ON_DEMAND = NOT_ON_DEMAND;
22
+ function resolveDebug(debug) {
23
+ if (debug === undefined) {
24
+ return false;
25
+ }
26
+ // Environment variables are strings, so convert to boolean
27
+ if (debug === 'true' || debug === '1') {
28
+ return true;
29
+ }
30
+ if (debug === 'false' || debug === '0') {
31
+ return false;
32
+ }
33
+ // Keep the debug convention into account:
34
+ // DEBUG=* -> This enables all debug modes
35
+ // DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
36
+ // DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
37
+ // DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
38
+ if (debug === '*') {
39
+ return true;
40
+ }
41
+ let debuggers = debug.split(',').map((d)=>d.split(':')[0]
42
+ );
43
+ // Ignoring tailwindcss
44
+ if (debuggers.includes('-tailwindcss')) {
45
+ return false;
46
+ }
47
+ // Including tailwindcss
48
+ if (debuggers.includes('tailwindcss')) {
49
+ return true;
50
+ }
51
+ return false;
52
+ }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = _default;
6
+ var _normalizeScreens = require("../util/normalizeScreens");
6
7
  var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
7
8
  function _interopRequireDefault(obj) {
8
9
  return obj && obj.__esModule ? obj : {
@@ -12,13 +13,15 @@ function _interopRequireDefault(obj) {
12
13
  function _default({ tailwindConfig: { theme } }) {
13
14
  return function(css) {
14
15
  css.walkAtRules('screen', (atRule)=>{
15
- var ref, ref1;
16
- const screen = atRule.params;
17
- if (!((ref = theme.screens) === null || ref === void 0 ? void 0 : (ref1 = ref.hasOwnProperty) === null || ref1 === void 0 ? void 0 : ref1.call(ref, screen))) {
16
+ let screen = atRule.params;
17
+ let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
18
+ let screenDefinition = screens.find(({ name })=>name === screen
19
+ );
20
+ if (!screenDefinition) {
18
21
  throw atRule.error(`No \`${screen}\` screen found.`);
19
22
  }
20
23
  atRule.name = 'media';
21
- atRule.params = (0, _buildMediaQuery).default(theme.screens[screen]);
24
+ atRule.params = (0, _buildMediaQuery).default(screenDefinition);
22
25
  });
23
26
  };
24
27
  }