tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21

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 (120) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/README.md +1 -1
  3. package/colors.js +1 -304
  4. package/defaultConfig.js +1 -4
  5. package/defaultTheme.js +1 -4
  6. package/lib/cli-peer-dependencies.js +4 -9
  7. package/lib/cli.js +646 -705
  8. package/lib/constants.js +15 -15
  9. package/lib/corePluginList.js +174 -4
  10. package/lib/corePlugins.js +3637 -2934
  11. package/lib/css/preflight.css +14 -1
  12. package/lib/featureFlags.js +44 -44
  13. package/lib/index.js +25 -24
  14. package/lib/lib/collapseAdjacentRules.js +33 -35
  15. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  16. package/lib/lib/detectNesting.js +34 -0
  17. package/lib/lib/evaluateTailwindFunctions.js +134 -155
  18. package/lib/lib/expandApplyAtRules.js +183 -200
  19. package/lib/lib/expandTailwindAtRules.js +219 -232
  20. package/lib/lib/generateRules.js +478 -311
  21. package/lib/lib/getModuleDependencies.js +36 -41
  22. package/lib/lib/normalizeTailwindDirectives.js +66 -58
  23. package/lib/lib/resolveDefaultsAtRules.js +110 -90
  24. package/lib/lib/setupContextUtils.js +740 -580
  25. package/lib/lib/setupTrackingContext.js +142 -162
  26. package/lib/lib/setupWatchingContext.js +235 -278
  27. package/lib/lib/sharedState.js +7 -17
  28. package/lib/lib/substituteScreenAtRules.js +22 -26
  29. package/lib/processTailwindFeatures.js +38 -44
  30. package/lib/public/colors.js +329 -0
  31. package/lib/public/create-plugin.js +13 -0
  32. package/lib/public/default-config.js +14 -0
  33. package/lib/public/default-theme.js +14 -0
  34. package/lib/public/resolve-config.js +19 -0
  35. package/lib/util/bigSign.js +3 -5
  36. package/lib/util/buildMediaQuery.js +15 -31
  37. package/lib/util/cloneDeep.js +14 -13
  38. package/lib/util/cloneNodes.js +9 -13
  39. package/lib/util/color.js +69 -59
  40. package/lib/util/configurePlugins.js +13 -14
  41. package/lib/util/createPlugin.js +21 -24
  42. package/lib/util/createUtilityPlugin.js +47 -45
  43. package/lib/util/dataTypes.js +231 -0
  44. package/lib/util/defaults.js +10 -14
  45. package/lib/util/escapeClassName.js +12 -14
  46. package/lib/util/escapeCommas.js +3 -5
  47. package/lib/util/flattenColorPalette.js +14 -10
  48. package/lib/util/formatVariantSelector.js +186 -0
  49. package/lib/util/getAllConfigs.js +23 -16
  50. package/lib/util/hashConfig.js +10 -10
  51. package/lib/util/isKeyframeRule.js +3 -5
  52. package/lib/util/isPlainObject.js +7 -10
  53. package/lib/util/isValidArbitraryValue.js +64 -0
  54. package/lib/util/log.js +39 -30
  55. package/lib/util/nameClass.js +23 -23
  56. package/lib/util/negateValue.js +14 -15
  57. package/lib/util/normalizeConfig.js +208 -0
  58. package/lib/util/normalizeScreens.js +58 -0
  59. package/lib/util/parseAnimationValue.js +82 -53
  60. package/lib/util/parseBoxShadowValue.js +77 -0
  61. package/lib/util/parseDependency.js +49 -60
  62. package/lib/util/parseObjectStyles.js +23 -20
  63. package/lib/util/pluginUtils.js +153 -285
  64. package/lib/util/prefixSelector.js +14 -16
  65. package/lib/util/resolveConfig.js +194 -249
  66. package/lib/util/resolveConfigPath.js +38 -45
  67. package/lib/util/responsive.js +12 -11
  68. package/lib/util/tap.js +4 -6
  69. package/lib/util/toColorValue.js +4 -5
  70. package/lib/util/toPath.js +4 -6
  71. package/lib/util/transformThemeValue.js +57 -26
  72. package/lib/util/withAlphaVariable.js +56 -54
  73. package/package.json +27 -37
  74. package/peers/index.js +73099 -84294
  75. package/plugin.js +1 -3
  76. package/resolveConfig.js +1 -7
  77. package/scripts/create-plugin-list.js +2 -2
  78. package/src/cli.js +27 -18
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +2124 -1968
  81. package/src/css/preflight.css +14 -1
  82. package/src/featureFlags.js +12 -6
  83. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  84. package/src/lib/detectNesting.js +39 -0
  85. package/src/lib/evaluateTailwindFunctions.js +5 -2
  86. package/src/lib/expandTailwindAtRules.js +24 -32
  87. package/src/lib/generateRules.js +230 -20
  88. package/src/lib/normalizeTailwindDirectives.js +3 -2
  89. package/src/lib/resolveDefaultsAtRules.js +46 -30
  90. package/src/lib/setupContextUtils.js +275 -113
  91. package/src/lib/setupTrackingContext.js +9 -8
  92. package/src/lib/setupWatchingContext.js +12 -7
  93. package/src/lib/sharedState.js +1 -4
  94. package/src/lib/substituteScreenAtRules.js +6 -3
  95. package/src/processTailwindFeatures.js +8 -1
  96. package/src/public/colors.js +300 -0
  97. package/src/public/create-plugin.js +2 -0
  98. package/src/public/default-config.js +4 -0
  99. package/src/public/default-theme.js +4 -0
  100. package/src/public/resolve-config.js +7 -0
  101. package/src/util/buildMediaQuery.js +14 -18
  102. package/src/util/createUtilityPlugin.js +2 -11
  103. package/src/util/dataTypes.js +246 -0
  104. package/src/util/formatVariantSelector.js +196 -0
  105. package/src/util/isValidArbitraryValue.js +61 -0
  106. package/src/util/log.js +18 -21
  107. package/src/util/nameClass.js +10 -6
  108. package/src/util/negateValue.js +4 -2
  109. package/src/util/normalizeConfig.js +249 -0
  110. package/src/util/normalizeScreens.js +42 -0
  111. package/src/util/parseAnimationValue.js +7 -1
  112. package/src/util/parseBoxShadowValue.js +71 -0
  113. package/src/util/parseDependency.js +4 -0
  114. package/src/util/pluginUtils.js +101 -204
  115. package/src/util/prefixSelector.js +1 -4
  116. package/src/util/resolveConfig.js +12 -65
  117. package/src/util/transformThemeValue.js +22 -7
  118. package/src/util/withAlphaVariable.js +13 -8
  119. package/stubs/defaultConfig.stub.js +163 -97
  120. package/stubs/simpleConfig.stub.js +0 -1
@@ -1,260 +1,247 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = expandTailwindAtRules;
7
-
6
+ var _quickLru = _interopRequireDefault(require("quick-lru"));
8
7
  var sharedState = _interopRequireWildcard(require("./sharedState"));
9
-
10
8
  var _generateRules = require("./generateRules");
11
-
12
9
  var _bigSign = _interopRequireDefault(require("../util/bigSign"));
13
-
14
10
  var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function _interopRequireWildcard(obj) {
17
+ if (obj && obj.__esModule) {
18
+ return obj;
19
+ } else {
20
+ var newObj = {
21
+ };
22
+ if (obj != null) {
23
+ for(var key in obj){
24
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
25
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
26
+ };
27
+ if (desc.get || desc.set) {
28
+ Object.defineProperty(newObj, key, desc);
29
+ } else {
30
+ newObj[key] = obj[key];
31
+ }
32
+ }
33
+ }
34
+ }
35
+ newObj.default = obj;
36
+ return newObj;
37
+ }
38
+ }
22
39
  let env = sharedState.env;
23
- let contentMatchCache = sharedState.contentMatchCache;
24
- const PATTERNS = ["([^<>\"'`\\s]*\\['[^<>\"'`\\s]*'\\])", // `content-['hello']` but not `content-['hello']']`
25
- '([^<>"\'`\\s]*\\["[^<>"\'`\\s]*"\\])', // `content-["hello"]` but not `content-["hello"]"]`
26
- '([^<>"\'`\\s]*\\[[^<>"\'`\\s]+\\])', // `fill-[#bada55]`
27
- '([^<>"\'`\\s]*[^<>"\'`\\s:])' // `px-1.5`, `uppercase` but not `uppercase:`
40
+ const PATTERNS = [
41
+ /([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
42
+ /([^<>"'`\s]*\[\w*"[^"`\s]*"?\])/.source,
43
+ /([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
44
+ /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
45
+ /([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
46
+ /([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
47
+ /([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
48
+ /([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
49
+ /([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
50
+ /([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
51
+ /([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
52
+ /([^<>"'`\s]*[^"'`\s:])/.source
28
53
  ].join('|');
29
54
  const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
30
55
  const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
31
56
  const builtInExtractors = {
32
- DEFAULT: content => {
33
- let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
34
- let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
35
- return [...broadMatches, ...innerMatches];
36
- }
57
+ DEFAULT: (content)=>{
58
+ let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
59
+ let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
60
+ return [
61
+ ...broadMatches,
62
+ ...innerMatches
63
+ ];
64
+ }
37
65
  };
38
66
  const builtInTransformers = {
39
- DEFAULT: content => content,
40
- svelte: content => content.replace(/(?:^|\s)class:/g, ' ')
67
+ DEFAULT: (content)=>content
68
+ ,
69
+ svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
41
70
  };
42
-
43
71
  function getExtractor(tailwindConfig, fileExtension) {
44
- let extractors = tailwindConfig.content.extract;
45
- let contentOptions = tailwindConfig.content.options;
46
-
47
- if (typeof extractors === 'function') {
48
- extractors = {
49
- DEFAULT: extractors
50
- };
51
- }
52
-
53
- if (contentOptions.defaultExtractor) {
54
- extractors.DEFAULT = contentOptions.defaultExtractor;
55
- }
56
-
57
- for (let {
58
- extensions,
59
- extractor
60
- } of contentOptions.extractors || []) {
61
- for (let extension of extensions) {
62
- extractors[extension] = extractor;
63
- }
64
- }
65
-
66
- return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
72
+ let extractors = tailwindConfig.content.extract;
73
+ return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
67
74
  }
68
-
69
75
  function getTransformer(tailwindConfig, fileExtension) {
70
- let transformers = tailwindConfig.content.transform;
71
-
72
- if (typeof transformers === 'function') {
73
- transformers = {
74
- DEFAULT: transformers
75
- };
76
- }
77
-
78
- return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
79
- } // Scans template contents for possible classes. This is a hot path on initial build but
76
+ let transformers = tailwindConfig.content.transform;
77
+ return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
78
+ }
79
+ let extractorCache = new WeakMap();
80
+ // Scans template contents for possible classes. This is a hot path on initial build but
80
81
  // not too important for subsequent builds. The faster the better though — if we can speed
81
82
  // up these regexes by 50% that could cut initial build time by like 20%.
82
-
83
-
84
- function getClassCandidates(content, extractor, contentMatchCache, candidates, seen) {
85
- for (let line of content.split('\n')) {
86
- line = line.trim();
87
-
88
- if (seen.has(line)) {
89
- continue;
83
+ function getClassCandidates(content, extractor, candidates, seen) {
84
+ if (!extractorCache.has(extractor)) {
85
+ extractorCache.set(extractor, new _quickLru.default({
86
+ maxSize: 25000
87
+ }));
90
88
  }
91
-
92
- seen.add(line);
93
-
94
- if (contentMatchCache.has(line)) {
95
- for (let match of contentMatchCache.get(line)) {
96
- candidates.add(match);
97
- }
98
- } else {
99
- let extractorMatches = extractor(line).filter(s => s !== '!*');
100
- let lineMatchesSet = new Set(extractorMatches);
101
-
102
- for (let match of lineMatchesSet) {
103
- candidates.add(match);
104
- }
105
-
106
- contentMatchCache.set(line, lineMatchesSet);
89
+ for (let line of content.split('\n')){
90
+ line = line.trim();
91
+ if (seen.has(line)) {
92
+ continue;
93
+ }
94
+ seen.add(line);
95
+ if (extractorCache.get(extractor).has(line)) {
96
+ for (let match of extractorCache.get(extractor).get(line)){
97
+ candidates.add(match);
98
+ }
99
+ } else {
100
+ let extractorMatches = extractor(line).filter((s)=>s !== '!*'
101
+ );
102
+ let lineMatchesSet = new Set(extractorMatches);
103
+ for (let match of lineMatchesSet){
104
+ candidates.add(match);
105
+ }
106
+ extractorCache.get(extractor).set(line, lineMatchesSet);
107
+ }
107
108
  }
108
- }
109
109
  }
110
-
111
110
  function buildStylesheet(rules, context) {
112
- let sortedRules = rules.sort(([a], [z]) => (0, _bigSign.default)(a - z));
113
- let returnValue = {
114
- base: new Set(),
115
- components: new Set(),
116
- utilities: new Set(),
117
- variants: new Set(),
118
- // All the CSS that is not Tailwind related can be put in this bucket. This
119
- // will make it easier to later use this information when we want to
120
- // `@apply` for example. The main reason we do this here is because we
121
- // still need to make sure the order is correct. Last but not least, we
122
- // will make sure to always re-inject this section into the css, even if
123
- // certain rules were not used. This means that it will look like a no-op
124
- // from the user's perspective, but we gathered all the useful information
125
- // we need.
126
- user: new Set()
127
- };
128
-
129
- for (let [sort, rule] of sortedRules) {
130
- if (sort >= context.minimumScreen) {
131
- returnValue.variants.add(rule);
132
- continue;
133
- }
134
-
135
- if (sort & context.layerOrder.base) {
136
- returnValue.base.add(rule);
137
- continue;
138
- }
139
-
140
- if (sort & context.layerOrder.components) {
141
- returnValue.components.add(rule);
142
- continue;
143
- }
144
-
145
- if (sort & context.layerOrder.utilities) {
146
- returnValue.utilities.add(rule);
147
- continue;
148
- }
149
-
150
- if (sort & context.layerOrder.user) {
151
- returnValue.user.add(rule);
152
- continue;
111
+ let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
112
+ );
113
+ let returnValue = {
114
+ base: new Set(),
115
+ components: new Set(),
116
+ utilities: new Set(),
117
+ variants: new Set(),
118
+ // All the CSS that is not Tailwind related can be put in this bucket. This
119
+ // will make it easier to later use this information when we want to
120
+ // `@apply` for example. The main reason we do this here is because we
121
+ // still need to make sure the order is correct. Last but not least, we
122
+ // will make sure to always re-inject this section into the css, even if
123
+ // certain rules were not used. This means that it will look like a no-op
124
+ // from the user's perspective, but we gathered all the useful information
125
+ // we need.
126
+ user: new Set()
127
+ };
128
+ for (let [sort, rule] of sortedRules){
129
+ if (sort >= context.minimumScreen) {
130
+ returnValue.variants.add(rule);
131
+ continue;
132
+ }
133
+ if (sort & context.layerOrder.base) {
134
+ returnValue.base.add(rule);
135
+ continue;
136
+ }
137
+ if (sort & context.layerOrder.components) {
138
+ returnValue.components.add(rule);
139
+ continue;
140
+ }
141
+ if (sort & context.layerOrder.utilities) {
142
+ returnValue.utilities.add(rule);
143
+ continue;
144
+ }
145
+ if (sort & context.layerOrder.user) {
146
+ returnValue.user.add(rule);
147
+ continue;
148
+ }
153
149
  }
154
- }
155
-
156
- return returnValue;
150
+ return returnValue;
157
151
  }
158
-
159
152
  function expandTailwindAtRules(context) {
160
- return root => {
161
- let layerNodes = {
162
- base: null,
163
- components: null,
164
- utilities: null,
165
- variants: null
166
- }; // Make sure this file contains Tailwind directives. If not, we can save
167
- // a lot of work and bail early. Also we don't have to register our touch
168
- // file as a dependency since the output of this CSS does not depend on
169
- // the source of any templates. Think Vue <style> blocks for example.
170
-
171
- root.walkAtRules('tailwind', rule => {
172
- if (Object.keys(layerNodes).includes(rule.params)) {
173
- layerNodes[rule.params] = rule;
174
- }
175
- });
176
-
177
- if (Object.values(layerNodes).every(n => n === null)) {
178
- return root;
179
- } // ---
180
- // Find potential rules in changed files
181
-
182
-
183
- let candidates = new Set(['*']);
184
- let seen = new Set();
185
- env.DEBUG && console.time('Reading changed files');
186
-
187
- for (let {
188
- content,
189
- extension
190
- } of context.changedContent) {
191
- let transformer = getTransformer(context.tailwindConfig, extension);
192
- let extractor = getExtractor(context.tailwindConfig, extension);
193
- getClassCandidates(transformer(content), extractor, contentMatchCache, candidates, seen);
194
- } // ---
195
- // Generate the actual CSS
196
-
197
-
198
- let classCacheCount = context.classCache.size;
199
- env.DEBUG && console.time('Generate rules');
200
- let rules = (0, _generateRules.generateRules)(candidates, context);
201
- env.DEBUG && console.timeEnd('Generate rules'); // We only ever add to the classCache, so if it didn't grow, there is nothing new.
202
-
203
- env.DEBUG && console.time('Build stylesheet');
204
-
205
- if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
206
- for (let rule of rules) {
207
- context.ruleCache.add(rule);
208
- }
209
-
210
- context.stylesheetCache = buildStylesheet([...context.ruleCache], context);
211
- }
212
-
213
- env.DEBUG && console.timeEnd('Build stylesheet');
214
- let {
215
- base: baseNodes,
216
- components: componentNodes,
217
- utilities: utilityNodes,
218
- variants: screenNodes
219
- } = context.stylesheetCache; // ---
220
- // Replace any Tailwind directives with generated CSS
221
-
222
- if (layerNodes.base) {
223
- layerNodes.base.before((0, _cloneNodes.default)([...baseNodes], layerNodes.base.source));
224
- layerNodes.base.remove();
225
- }
226
-
227
- if (layerNodes.components) {
228
- layerNodes.components.before((0, _cloneNodes.default)([...componentNodes], layerNodes.components.source));
229
- layerNodes.components.remove();
230
- }
231
-
232
- if (layerNodes.utilities) {
233
- layerNodes.utilities.before((0, _cloneNodes.default)([...utilityNodes], layerNodes.utilities.source));
234
- layerNodes.utilities.remove();
235
- }
236
-
237
- if (layerNodes.variants) {
238
- layerNodes.variants.before((0, _cloneNodes.default)([...screenNodes], layerNodes.variants.source));
239
- layerNodes.variants.remove();
240
- } else {
241
- root.append((0, _cloneNodes.default)([...screenNodes], root.source));
242
- } // ---
243
-
244
-
245
- if (env.DEBUG) {
246
- console.log('Potential classes: ', candidates.size);
247
- console.log('Active contexts: ', sharedState.contextSourcesMap.size);
248
- console.log('Content match entries', contentMatchCache.size);
249
- } // Clear the cache for the changed files
250
-
251
-
252
- context.changedContent = []; // Cleanup any leftover @layer atrules
253
-
254
- root.walkAtRules('layer', rule => {
255
- if (Object.keys(layerNodes).includes(rule.params)) {
256
- rule.remove();
257
- }
258
- });
259
- };
260
- }
153
+ return (root)=>{
154
+ let layerNodes = {
155
+ base: null,
156
+ components: null,
157
+ utilities: null,
158
+ variants: null
159
+ };
160
+ // Make sure this file contains Tailwind directives. If not, we can save
161
+ // a lot of work and bail early. Also we don't have to register our touch
162
+ // file as a dependency since the output of this CSS does not depend on
163
+ // the source of any templates. Think Vue <style> blocks for example.
164
+ root.walkAtRules('tailwind', (rule)=>{
165
+ if (Object.keys(layerNodes).includes(rule.params)) {
166
+ layerNodes[rule.params] = rule;
167
+ }
168
+ });
169
+ if (Object.values(layerNodes).every((n)=>n === null
170
+ )) {
171
+ return root;
172
+ }
173
+ // ---
174
+ // Find potential rules in changed files
175
+ let candidates = new Set([
176
+ '*'
177
+ ]);
178
+ let seen = new Set();
179
+ env.DEBUG && console.time('Reading changed files');
180
+ for (let { content , extension } of context.changedContent){
181
+ let transformer = getTransformer(context.tailwindConfig, extension);
182
+ let extractor = getExtractor(context.tailwindConfig, extension);
183
+ getClassCandidates(transformer(content), extractor, candidates, seen);
184
+ }
185
+ // ---
186
+ // Generate the actual CSS
187
+ let classCacheCount = context.classCache.size;
188
+ env.DEBUG && console.time('Generate rules');
189
+ let rules = (0, _generateRules).generateRules(candidates, context);
190
+ env.DEBUG && console.timeEnd('Generate rules');
191
+ // We only ever add to the classCache, so if it didn't grow, there is nothing new.
192
+ env.DEBUG && console.time('Build stylesheet');
193
+ if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
194
+ for (let rule of rules){
195
+ context.ruleCache.add(rule);
196
+ }
197
+ context.stylesheetCache = buildStylesheet([
198
+ ...context.ruleCache
199
+ ], context);
200
+ }
201
+ env.DEBUG && console.timeEnd('Build stylesheet');
202
+ let { base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
203
+ // ---
204
+ // Replace any Tailwind directives with generated CSS
205
+ if (layerNodes.base) {
206
+ layerNodes.base.before((0, _cloneNodes).default([
207
+ ...baseNodes
208
+ ], layerNodes.base.source));
209
+ layerNodes.base.remove();
210
+ }
211
+ if (layerNodes.components) {
212
+ layerNodes.components.before((0, _cloneNodes).default([
213
+ ...componentNodes
214
+ ], layerNodes.components.source));
215
+ layerNodes.components.remove();
216
+ }
217
+ if (layerNodes.utilities) {
218
+ layerNodes.utilities.before((0, _cloneNodes).default([
219
+ ...utilityNodes
220
+ ], layerNodes.utilities.source));
221
+ layerNodes.utilities.remove();
222
+ }
223
+ if (layerNodes.variants) {
224
+ layerNodes.variants.before((0, _cloneNodes).default([
225
+ ...screenNodes
226
+ ], layerNodes.variants.source));
227
+ layerNodes.variants.remove();
228
+ } else {
229
+ root.append((0, _cloneNodes).default([
230
+ ...screenNodes
231
+ ], root.source));
232
+ }
233
+ // ---
234
+ if (env.DEBUG) {
235
+ console.log('Potential classes: ', candidates.size);
236
+ console.log('Active contexts: ', sharedState.contextSourcesMap.size);
237
+ }
238
+ // Clear the cache for the changed files
239
+ context.changedContent = [];
240
+ // Cleanup any leftover @layer atrules
241
+ root.walkAtRules('layer', (rule)=>{
242
+ if (Object.keys(layerNodes).includes(rule.params)) {
243
+ rule.remove();
244
+ }
245
+ });
246
+ };
247
+ }