tailwindcss 0.0.0-insiders.ebc1c7a → 0.0.0-insiders.ec0049a

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 (165) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +18 -11
  3. package/dist/chunk-AZANAYY2.mjs +1 -0
  4. package/dist/chunk-CH45MXZF.mjs +10 -0
  5. package/dist/chunk-V2K3XTS4.mjs +1 -0
  6. package/dist/colors-b_6i0Oi7.d.ts +295 -0
  7. package/dist/colors.d.mts +295 -0
  8. package/dist/colors.d.ts +5 -0
  9. package/dist/colors.js +1 -0
  10. package/dist/colors.mjs +1 -0
  11. package/dist/default-theme.d.mts +1147 -0
  12. package/dist/default-theme.d.ts +1147 -0
  13. package/dist/default-theme.js +1 -0
  14. package/dist/default-theme.mjs +1 -0
  15. package/dist/flatten-color-palette.d.mts +6 -0
  16. package/dist/flatten-color-palette.d.ts +6 -0
  17. package/dist/flatten-color-palette.js +1 -0
  18. package/dist/flatten-color-palette.mjs +1 -0
  19. package/dist/lib.d.mts +260 -0
  20. package/dist/lib.d.ts +3 -0
  21. package/dist/lib.js +33 -0
  22. package/dist/lib.mjs +24 -0
  23. package/dist/plugin.d.mts +11 -0
  24. package/dist/plugin.d.ts +104 -0
  25. package/dist/plugin.js +1 -0
  26. package/dist/plugin.mjs +1 -0
  27. package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
  28. package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
  29. package/dist/types-B254mqw1.d.mts +98 -0
  30. package/index.css +865 -0
  31. package/package.json +73 -110
  32. package/preflight.css +383 -0
  33. package/theme.css +453 -0
  34. package/CHANGELOG.md +0 -1742
  35. package/base.css +0 -1
  36. package/colors.js +0 -304
  37. package/components.css +0 -1
  38. package/defaultConfig.js +0 -4
  39. package/defaultTheme.js +0 -4
  40. package/lib/cli-peer-dependencies.js +0 -20
  41. package/lib/cli.js +0 -765
  42. package/lib/constants.js +0 -37
  43. package/lib/corePluginList.js +0 -8
  44. package/lib/corePlugins.js +0 -2977
  45. package/lib/css/LICENSE +0 -25
  46. package/lib/css/preflight.css +0 -354
  47. package/lib/featureFlags.js +0 -60
  48. package/lib/index.js +0 -31
  49. package/lib/lib/collapseAdjacentRules.js +0 -43
  50. package/lib/lib/evaluateTailwindFunctions.js +0 -192
  51. package/lib/lib/expandApplyAtRules.js +0 -245
  52. package/lib/lib/expandTailwindAtRules.js +0 -260
  53. package/lib/lib/generateRules.js +0 -362
  54. package/lib/lib/getModuleDependencies.js +0 -53
  55. package/lib/lib/normalizeTailwindDirectives.js +0 -68
  56. package/lib/lib/resolveDefaultsAtRules.js +0 -105
  57. package/lib/lib/setupContextUtils.js +0 -643
  58. package/lib/lib/setupTrackingContext.js +0 -190
  59. package/lib/lib/setupWatchingContext.js +0 -331
  60. package/lib/lib/sharedState.js +0 -29
  61. package/lib/lib/substituteScreenAtRules.js +0 -31
  62. package/lib/processTailwindFeatures.js +0 -57
  63. package/lib/util/bigSign.js +0 -10
  64. package/lib/util/buildMediaQuery.js +0 -36
  65. package/lib/util/cloneDeep.js +0 -18
  66. package/lib/util/cloneNodes.js +0 -18
  67. package/lib/util/color.js +0 -74
  68. package/lib/util/configurePlugins.js +0 -19
  69. package/lib/util/createPlugin.js +0 -33
  70. package/lib/util/createUtilityPlugin.js +0 -51
  71. package/lib/util/defaults.js +0 -20
  72. package/lib/util/escapeClassName.js +0 -21
  73. package/lib/util/escapeCommas.js +0 -10
  74. package/lib/util/flattenColorPalette.js +0 -15
  75. package/lib/util/getAllConfigs.js +0 -22
  76. package/lib/util/hashConfig.js +0 -16
  77. package/lib/util/isKeyframeRule.js +0 -10
  78. package/lib/util/isPlainObject.js +0 -15
  79. package/lib/util/log.js +0 -38
  80. package/lib/util/nameClass.js +0 -32
  81. package/lib/util/negateValue.js +0 -20
  82. package/lib/util/parseAnimationValue.js +0 -60
  83. package/lib/util/parseDependency.js +0 -74
  84. package/lib/util/parseObjectStyles.js +0 -28
  85. package/lib/util/pluginUtils.js +0 -318
  86. package/lib/util/prefixSelector.js +0 -23
  87. package/lib/util/resolveConfig.js +0 -289
  88. package/lib/util/resolveConfigPath.js +0 -59
  89. package/lib/util/responsive.js +0 -18
  90. package/lib/util/tap.js +0 -11
  91. package/lib/util/toColorValue.js +0 -10
  92. package/lib/util/toPath.js +0 -11
  93. package/lib/util/transformThemeValue.js +0 -32
  94. package/lib/util/withAlphaVariable.js +0 -65
  95. package/nesting/README.md +0 -42
  96. package/nesting/index.js +0 -12
  97. package/nesting/plugin.js +0 -41
  98. package/peers/index.js +0 -87302
  99. package/plugin.js +0 -3
  100. package/prettier.config.js +0 -19
  101. package/resolveConfig.js +0 -7
  102. package/screens.css +0 -1
  103. package/scripts/create-plugin-list.js +0 -10
  104. package/scripts/install-integrations.js +0 -27
  105. package/scripts/rebuildFixtures.js +0 -68
  106. package/src/cli-peer-dependencies.js +0 -9
  107. package/src/cli.js +0 -759
  108. package/src/constants.js +0 -17
  109. package/src/corePluginList.js +0 -1
  110. package/src/corePlugins.js +0 -2228
  111. package/src/css/LICENSE +0 -25
  112. package/src/css/preflight.css +0 -354
  113. package/src/featureFlags.js +0 -48
  114. package/src/index.js +0 -34
  115. package/src/lib/collapseAdjacentRules.js +0 -39
  116. package/src/lib/evaluateTailwindFunctions.js +0 -195
  117. package/src/lib/expandApplyAtRules.js +0 -251
  118. package/src/lib/expandTailwindAtRules.js +0 -262
  119. package/src/lib/generateRules.js +0 -319
  120. package/src/lib/getModuleDependencies.js +0 -39
  121. package/src/lib/normalizeTailwindDirectives.js +0 -77
  122. package/src/lib/resolveDefaultsAtRules.js +0 -105
  123. package/src/lib/setupContextUtils.js +0 -639
  124. package/src/lib/setupTrackingContext.js +0 -181
  125. package/src/lib/setupWatchingContext.js +0 -306
  126. package/src/lib/sharedState.js +0 -13
  127. package/src/lib/substituteScreenAtRules.js +0 -16
  128. package/src/processTailwindFeatures.js +0 -41
  129. package/src/util/bigSign.js +0 -3
  130. package/src/util/buildMediaQuery.js +0 -24
  131. package/src/util/cloneDeep.js +0 -11
  132. package/src/util/cloneNodes.js +0 -11
  133. package/src/util/color.js +0 -56
  134. package/src/util/configurePlugins.js +0 -23
  135. package/src/util/createPlugin.js +0 -27
  136. package/src/util/createUtilityPlugin.js +0 -46
  137. package/src/util/defaults.js +0 -11
  138. package/src/util/escapeClassName.js +0 -8
  139. package/src/util/escapeCommas.js +0 -3
  140. package/src/util/flattenColorPalette.js +0 -13
  141. package/src/util/getAllConfigs.js +0 -19
  142. package/src/util/hashConfig.js +0 -5
  143. package/src/util/isKeyframeRule.js +0 -3
  144. package/src/util/isPlainObject.js +0 -8
  145. package/src/util/log.js +0 -28
  146. package/src/util/nameClass.js +0 -22
  147. package/src/util/negateValue.js +0 -14
  148. package/src/util/parseAnimationValue.js +0 -62
  149. package/src/util/parseDependency.js +0 -45
  150. package/src/util/parseObjectStyles.js +0 -19
  151. package/src/util/pluginUtils.js +0 -295
  152. package/src/util/prefixSelector.js +0 -15
  153. package/src/util/resolveConfig.js +0 -282
  154. package/src/util/resolveConfigPath.js +0 -55
  155. package/src/util/responsive.js +0 -10
  156. package/src/util/tap.js +0 -4
  157. package/src/util/toColorValue.js +0 -3
  158. package/src/util/toPath.js +0 -4
  159. package/src/util/transformThemeValue.js +0 -37
  160. package/src/util/withAlphaVariable.js +0 -44
  161. package/stubs/defaultConfig.stub.js +0 -884
  162. package/stubs/defaultPostCssConfig.stub.js +0 -6
  163. package/stubs/simpleConfig.stub.js +0 -8
  164. package/tailwind.css +0 -5
  165. package/variants.css +0 -1
@@ -1,245 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = expandApplyAtRules;
7
-
8
- var _postcss = _interopRequireDefault(require("postcss"));
9
-
10
- var _generateRules = require("./generateRules");
11
-
12
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
13
-
14
- var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function prefix(context, selector) {
19
- let prefix = context.tailwindConfig.prefix;
20
- return typeof prefix === 'function' ? prefix(selector) : prefix + selector;
21
- }
22
-
23
- function buildApplyCache(applyCandidates, context) {
24
- for (let candidate of applyCandidates) {
25
- if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
26
- continue;
27
- }
28
-
29
- if (context.classCache.has(candidate)) {
30
- context.applyClassCache.set(candidate, context.classCache.get(candidate).map(([meta, rule]) => [meta, rule.clone()]));
31
- continue;
32
- }
33
-
34
- let matches = Array.from((0, _generateRules.resolveMatches)(candidate, context));
35
-
36
- if (matches.length === 0) {
37
- context.notClassCache.add(candidate);
38
- continue;
39
- }
40
-
41
- context.applyClassCache.set(candidate, matches);
42
- }
43
-
44
- return context.applyClassCache;
45
- }
46
-
47
- function extractApplyCandidates(params) {
48
- let candidates = params.split(/[\s\t\n]+/g);
49
-
50
- if (candidates[candidates.length - 1] === '!important') {
51
- return [candidates.slice(0, -1), true];
52
- }
53
-
54
- return [candidates, false];
55
- }
56
-
57
- function partitionApplyParents(root) {
58
- let applyParents = new Set();
59
- root.walkAtRules('apply', rule => {
60
- applyParents.add(rule.parent);
61
- });
62
-
63
- for (let rule of applyParents) {
64
- let nodeGroups = [];
65
- let lastGroup = [];
66
-
67
- for (let node of rule.nodes) {
68
- if (node.type === 'atrule' && node.name === 'apply') {
69
- if (lastGroup.length > 0) {
70
- nodeGroups.push(lastGroup);
71
- lastGroup = [];
72
- }
73
-
74
- nodeGroups.push([node]);
75
- } else {
76
- lastGroup.push(node);
77
- }
78
- }
79
-
80
- if (lastGroup.length > 0) {
81
- nodeGroups.push(lastGroup);
82
- }
83
-
84
- if (nodeGroups.length === 1) {
85
- continue;
86
- }
87
-
88
- for (let group of [...nodeGroups].reverse()) {
89
- let newParent = rule.clone({
90
- nodes: []
91
- });
92
- newParent.append(group);
93
- rule.after(newParent);
94
- }
95
-
96
- rule.remove();
97
- }
98
- }
99
-
100
- function processApply(root, context) {
101
- let applyCandidates = new Set(); // Collect all @apply rules and candidates
102
-
103
- let applies = [];
104
- root.walkAtRules('apply', rule => {
105
- let [candidates] = extractApplyCandidates(rule.params);
106
-
107
- for (let util of candidates) {
108
- applyCandidates.add(util);
109
- }
110
-
111
- applies.push(rule);
112
- }); // Start the @apply process if we have rules with @apply in them
113
-
114
- if (applies.length > 0) {
115
- // Fill up some caches!
116
- let applyClassCache = buildApplyCache(applyCandidates, context);
117
- /**
118
- * When we have an apply like this:
119
- *
120
- * .abc {
121
- * @apply hover:font-bold;
122
- * }
123
- *
124
- * What we essentially will do is resolve to this:
125
- *
126
- * .abc {
127
- * @apply .hover\:font-bold:hover {
128
- * font-weight: 500;
129
- * }
130
- * }
131
- *
132
- * Notice that the to-be-applied class is `.hover\:font-bold:hover` and that the utility candidate was `hover:font-bold`.
133
- * What happens in this function is that we prepend a `.` and escape the candidate.
134
- * This will result in `.hover\:font-bold`
135
- * Which means that we can replace `.hover\:font-bold` with `.abc` in `.hover\:font-bold:hover` resulting in `.abc:hover`
136
- */
137
- // TODO: Should we use postcss-selector-parser for this instead?
138
-
139
- function replaceSelector(selector, utilitySelectors, candidate) {
140
- let needle = `.${(0, _escapeClassName.default)(candidate)}`;
141
- let utilitySelectorsList = utilitySelectors.split(/\s*,\s*/g);
142
- return selector.split(/\s*,\s*/g).map(s => {
143
- let replaced = [];
144
-
145
- for (let utilitySelector of utilitySelectorsList) {
146
- let replacedSelector = utilitySelector.replace(needle, s);
147
-
148
- if (replacedSelector === utilitySelector) {
149
- continue;
150
- }
151
-
152
- replaced.push(replacedSelector);
153
- }
154
-
155
- return replaced.join(', ');
156
- }).join(', ');
157
- }
158
-
159
- let perParentApplies = new Map(); // Collect all apply candidates and their rules
160
-
161
- for (let apply of applies) {
162
- let candidates = perParentApplies.get(apply.parent) || [];
163
- perParentApplies.set(apply.parent, candidates);
164
- let [applyCandidates, important] = extractApplyCandidates(apply.params);
165
-
166
- if (apply.parent.type === 'atrule') {
167
- if (apply.parent.name === 'screen') {
168
- const screenType = apply.parent.params;
169
- throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map(c => `${screenType}:${c}`).join(' ')} instead.`);
170
- }
171
-
172
- throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
173
- }
174
-
175
- for (let applyCandidate of applyCandidates) {
176
- if (!applyClassCache.has(applyCandidate)) {
177
- if (applyCandidate === prefix(context, 'group')) {
178
- // TODO: Link to specific documentation page with error code.
179
- throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
180
- }
181
-
182
- throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
183
- }
184
-
185
- let rules = applyClassCache.get(applyCandidate);
186
- candidates.push([applyCandidate, important, rules]);
187
- }
188
- }
189
-
190
- for (const [parent, candidates] of perParentApplies) {
191
- let siblings = [];
192
-
193
- for (let [applyCandidate, important, rules] of candidates) {
194
- for (let [meta, node] of rules) {
195
- let root = _postcss.default.root({
196
- nodes: [node.clone()]
197
- });
198
-
199
- let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
200
-
201
- if (canRewriteSelector) {
202
- root.walkRules(rule => {
203
- rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
204
- rule.walkDecls(d => {
205
- d.important = meta.important || important;
206
- });
207
- });
208
- } // Insert it
209
-
210
-
211
- siblings.push([// Ensure that when we are sorting, that we take the layer order into account
212
- { ...meta,
213
- sort: meta.sort | context.layerOrder[meta.layer]
214
- }, root.nodes[0]]);
215
- }
216
- } // Inject the rules, sorted, correctly
217
-
218
-
219
- let nodes = siblings.sort(([a], [z]) => (0, _bigSign.default)(a.sort - z.sort)).map(s => s[1]); // console.log(parent)
220
- // `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
221
-
222
- parent.after(nodes);
223
- }
224
-
225
- for (let apply of applies) {
226
- // If there are left-over declarations, just remove the @apply
227
- if (apply.parent.nodes.length > 1) {
228
- apply.remove();
229
- } else {
230
- // The node is empty, drop the full node
231
- apply.parent.remove();
232
- }
233
- } // Do it again, in case we have other `@apply` rules
234
-
235
-
236
- processApply(root, context);
237
- }
238
- }
239
-
240
- function expandApplyAtRules(context) {
241
- return root => {
242
- partitionApplyParents(root);
243
- processApply(root, context);
244
- };
245
- }
@@ -1,260 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = expandTailwindAtRules;
7
-
8
- var sharedState = _interopRequireWildcard(require("./sharedState"));
9
-
10
- var _generateRules = require("./generateRules");
11
-
12
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
13
-
14
- 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
-
22
- 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:`
28
- ].join('|');
29
- const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
30
- const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
31
- 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
- }
37
- };
38
- const builtInTransformers = {
39
- DEFAULT: content => content,
40
- svelte: content => content.replace(/(?:^|\s)class:/g, ' ')
41
- };
42
-
43
- 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;
67
- }
68
-
69
- 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
80
- // not too important for subsequent builds. The faster the better though — if we can speed
81
- // 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;
90
- }
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);
107
- }
108
- }
109
- }
110
-
111
- 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;
153
- }
154
- }
155
-
156
- return returnValue;
157
- }
158
-
159
- 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
- }