tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.ca7b10e

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 (179) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +18 -11
  3. package/dist/chunk-7MHEDNEU.mjs +1 -0
  4. package/dist/chunk-AZANAYY2.mjs +1 -0
  5. package/dist/chunk-YTVGJJD3.mjs +12 -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 +264 -0
  20. package/dist/lib.d.ts +3 -0
  21. package/dist/lib.js +33 -0
  22. package/dist/lib.mjs +22 -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 +866 -0
  31. package/package.json +73 -100
  32. package/preflight.css +375 -0
  33. package/theme.css +453 -0
  34. package/CHANGELOG.md +0 -1758
  35. package/base.css +0 -1
  36. package/colors.js +0 -1
  37. package/components.css +0 -1
  38. package/defaultConfig.js +0 -1
  39. package/defaultTheme.js +0 -1
  40. package/lib/cli-peer-dependencies.js +0 -15
  41. package/lib/cli.js +0 -707
  42. package/lib/constants.js +0 -37
  43. package/lib/corePluginList.js +0 -169
  44. package/lib/corePlugins.js +0 -3525
  45. package/lib/css/LICENSE +0 -25
  46. package/lib/css/preflight.css +0 -354
  47. package/lib/featureFlags.js +0 -57
  48. package/lib/index.js +0 -32
  49. package/lib/lib/collapseAdjacentRules.js +0 -41
  50. package/lib/lib/detectNesting.js +0 -19
  51. package/lib/lib/evaluateTailwindFunctions.js +0 -167
  52. package/lib/lib/expandApplyAtRules.js +0 -228
  53. package/lib/lib/expandTailwindAtRules.js +0 -257
  54. package/lib/lib/generateRules.js +0 -350
  55. package/lib/lib/getModuleDependencies.js +0 -48
  56. package/lib/lib/normalizeTailwindDirectives.js +0 -75
  57. package/lib/lib/resolveDefaultsAtRules.js +0 -128
  58. package/lib/lib/setupContextUtils.js +0 -791
  59. package/lib/lib/setupTrackingContext.js +0 -170
  60. package/lib/lib/setupWatchingContext.js +0 -284
  61. package/lib/lib/sharedState.js +0 -29
  62. package/lib/lib/substituteScreenAtRules.js +0 -24
  63. package/lib/processTailwindFeatures.js +0 -47
  64. package/lib/public/colors.js +0 -333
  65. package/lib/public/create-plugin.js +0 -13
  66. package/lib/public/default-config.js +0 -14
  67. package/lib/public/default-theme.js +0 -14
  68. package/lib/public/resolve-config.js +0 -19
  69. package/lib/util/bigSign.js +0 -8
  70. package/lib/util/buildMediaQuery.js +0 -31
  71. package/lib/util/cloneDeep.js +0 -19
  72. package/lib/util/cloneNodes.js +0 -14
  73. package/lib/util/color.js +0 -84
  74. package/lib/util/configurePlugins.js +0 -18
  75. package/lib/util/createPlugin.js +0 -30
  76. package/lib/util/createUtilityPlugin.js +0 -53
  77. package/lib/util/dataTypes.js +0 -202
  78. package/lib/util/defaults.js +0 -16
  79. package/lib/util/escapeClassName.js +0 -19
  80. package/lib/util/escapeCommas.js +0 -8
  81. package/lib/util/flattenColorPalette.js +0 -19
  82. package/lib/util/getAllConfigs.js +0 -29
  83. package/lib/util/hashConfig.js +0 -16
  84. package/lib/util/isKeyframeRule.js +0 -8
  85. package/lib/util/isPlainObject.js +0 -12
  86. package/lib/util/log.js +0 -35
  87. package/lib/util/nameClass.js +0 -31
  88. package/lib/util/negateValue.js +0 -17
  89. package/lib/util/parseAnimationValue.js +0 -89
  90. package/lib/util/parseDependency.js +0 -63
  91. package/lib/util/parseObjectStyles.js +0 -31
  92. package/lib/util/pluginUtils.js +0 -282
  93. package/lib/util/prefixSelector.js +0 -23
  94. package/lib/util/resolveConfig.js +0 -293
  95. package/lib/util/resolveConfigPath.js +0 -52
  96. package/lib/util/responsive.js +0 -19
  97. package/lib/util/tap.js +0 -9
  98. package/lib/util/toColorValue.js +0 -9
  99. package/lib/util/toPath.js +0 -9
  100. package/lib/util/transformThemeValue.js +0 -53
  101. package/lib/util/withAlphaVariable.js +0 -67
  102. package/nesting/README.md +0 -42
  103. package/nesting/index.js +0 -12
  104. package/nesting/plugin.js +0 -41
  105. package/peers/index.js +0 -77111
  106. package/plugin.js +0 -1
  107. package/prettier.config.js +0 -19
  108. package/resolveConfig.js +0 -1
  109. package/screens.css +0 -1
  110. package/scripts/create-plugin-list.js +0 -10
  111. package/scripts/install-integrations.js +0 -27
  112. package/scripts/rebuildFixtures.js +0 -68
  113. package/src/cli-peer-dependencies.js +0 -9
  114. package/src/cli.js +0 -762
  115. package/src/constants.js +0 -17
  116. package/src/corePluginList.js +0 -1
  117. package/src/corePlugins.js +0 -2382
  118. package/src/css/LICENSE +0 -25
  119. package/src/css/preflight.css +0 -354
  120. package/src/featureFlags.js +0 -48
  121. package/src/index.js +0 -34
  122. package/src/lib/collapseAdjacentRules.js +0 -39
  123. package/src/lib/detectNesting.js +0 -20
  124. package/src/lib/evaluateTailwindFunctions.js +0 -195
  125. package/src/lib/expandApplyAtRules.js +0 -251
  126. package/src/lib/expandTailwindAtRules.js +0 -266
  127. package/src/lib/generateRules.js +0 -320
  128. package/src/lib/getModuleDependencies.js +0 -39
  129. package/src/lib/normalizeTailwindDirectives.js +0 -77
  130. package/src/lib/resolveDefaultsAtRules.js +0 -125
  131. package/src/lib/setupContextUtils.js +0 -775
  132. package/src/lib/setupTrackingContext.js +0 -184
  133. package/src/lib/setupWatchingContext.js +0 -306
  134. package/src/lib/sharedState.js +0 -13
  135. package/src/lib/substituteScreenAtRules.js +0 -16
  136. package/src/processTailwindFeatures.js +0 -43
  137. package/src/public/colors.js +0 -305
  138. package/src/public/create-plugin.js +0 -2
  139. package/src/public/default-config.js +0 -4
  140. package/src/public/default-theme.js +0 -4
  141. package/src/public/resolve-config.js +0 -7
  142. package/src/util/bigSign.js +0 -3
  143. package/src/util/buildMediaQuery.js +0 -24
  144. package/src/util/cloneDeep.js +0 -11
  145. package/src/util/cloneNodes.js +0 -11
  146. package/src/util/color.js +0 -56
  147. package/src/util/configurePlugins.js +0 -23
  148. package/src/util/createPlugin.js +0 -27
  149. package/src/util/createUtilityPlugin.js +0 -37
  150. package/src/util/dataTypes.js +0 -216
  151. package/src/util/defaults.js +0 -11
  152. package/src/util/escapeClassName.js +0 -8
  153. package/src/util/escapeCommas.js +0 -3
  154. package/src/util/flattenColorPalette.js +0 -13
  155. package/src/util/getAllConfigs.js +0 -19
  156. package/src/util/hashConfig.js +0 -5
  157. package/src/util/isKeyframeRule.js +0 -3
  158. package/src/util/isPlainObject.js +0 -8
  159. package/src/util/log.js +0 -28
  160. package/src/util/nameClass.js +0 -26
  161. package/src/util/negateValue.js +0 -14
  162. package/src/util/parseAnimationValue.js +0 -68
  163. package/src/util/parseDependency.js +0 -49
  164. package/src/util/parseObjectStyles.js +0 -19
  165. package/src/util/pluginUtils.js +0 -288
  166. package/src/util/prefixSelector.js +0 -15
  167. package/src/util/resolveConfig.js +0 -282
  168. package/src/util/resolveConfigPath.js +0 -55
  169. package/src/util/responsive.js +0 -10
  170. package/src/util/tap.js +0 -4
  171. package/src/util/toColorValue.js +0 -3
  172. package/src/util/toPath.js +0 -4
  173. package/src/util/transformThemeValue.js +0 -37
  174. package/src/util/withAlphaVariable.js +0 -49
  175. package/stubs/defaultConfig.stub.js +0 -890
  176. package/stubs/defaultPostCssConfig.stub.js +0 -6
  177. package/stubs/simpleConfig.stub.js +0 -8
  178. package/tailwind.css +0 -5
  179. package/variants.css +0 -1
@@ -1,228 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = expandApplyAtRules;
6
- var _postcss = _interopRequireDefault(require("postcss"));
7
- var _generateRules = require("./generateRules");
8
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
9
- var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
10
- function _interopRequireDefault(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- function prefix(context, selector) {
16
- let prefix = context.tailwindConfig.prefix;
17
- return typeof prefix === 'function' ? prefix(selector) : prefix + selector;
18
- }
19
- function buildApplyCache(applyCandidates, context) {
20
- for (let candidate of applyCandidates){
21
- if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
22
- continue;
23
- }
24
- if (context.classCache.has(candidate)) {
25
- context.applyClassCache.set(candidate, context.classCache.get(candidate).map(([meta, rule])=>[
26
- meta,
27
- rule.clone()
28
- ]
29
- ));
30
- continue;
31
- }
32
- let matches = Array.from((0, _generateRules).resolveMatches(candidate, context));
33
- if (matches.length === 0) {
34
- context.notClassCache.add(candidate);
35
- continue;
36
- }
37
- context.applyClassCache.set(candidate, matches);
38
- }
39
- return context.applyClassCache;
40
- }
41
- function extractApplyCandidates(params) {
42
- let candidates = params.split(/[\s\t\n]+/g);
43
- if (candidates[candidates.length - 1] === '!important') {
44
- return [
45
- candidates.slice(0, -1),
46
- true
47
- ];
48
- }
49
- return [
50
- candidates,
51
- false
52
- ];
53
- }
54
- function partitionApplyParents(root) {
55
- let applyParents = new Set();
56
- root.walkAtRules('apply', (rule)=>{
57
- applyParents.add(rule.parent);
58
- });
59
- for (let rule of applyParents){
60
- let nodeGroups = [];
61
- let lastGroup = [];
62
- for (let node of rule.nodes){
63
- if (node.type === 'atrule' && node.name === 'apply') {
64
- if (lastGroup.length > 0) {
65
- nodeGroups.push(lastGroup);
66
- lastGroup = [];
67
- }
68
- nodeGroups.push([
69
- node
70
- ]);
71
- } else {
72
- lastGroup.push(node);
73
- }
74
- }
75
- if (lastGroup.length > 0) {
76
- nodeGroups.push(lastGroup);
77
- }
78
- if (nodeGroups.length === 1) {
79
- continue;
80
- }
81
- for (let group of [
82
- ...nodeGroups
83
- ].reverse()){
84
- let newParent = rule.clone({
85
- nodes: []
86
- });
87
- newParent.append(group);
88
- rule.after(newParent);
89
- }
90
- rule.remove();
91
- }
92
- }
93
- function processApply(root, context) {
94
- let applyCandidates = new Set();
95
- // Collect all @apply rules and candidates
96
- let applies = [];
97
- root.walkAtRules('apply', (rule)=>{
98
- let [candidates] = extractApplyCandidates(rule.params);
99
- for (let util of candidates){
100
- applyCandidates.add(util);
101
- }
102
- applies.push(rule);
103
- });
104
- // Start the @apply process if we have rules with @apply in them
105
- if (applies.length > 0) {
106
- // Fill up some caches!
107
- let applyClassCache = buildApplyCache(applyCandidates, context);
108
- /**
109
- * When we have an apply like this:
110
- *
111
- * .abc {
112
- * @apply hover:font-bold;
113
- * }
114
- *
115
- * What we essentially will do is resolve to this:
116
- *
117
- * .abc {
118
- * @apply .hover\:font-bold:hover {
119
- * font-weight: 500;
120
- * }
121
- * }
122
- *
123
- * Notice that the to-be-applied class is `.hover\:font-bold:hover` and that the utility candidate was `hover:font-bold`.
124
- * What happens in this function is that we prepend a `.` and escape the candidate.
125
- * This will result in `.hover\:font-bold`
126
- * Which means that we can replace `.hover\:font-bold` with `.abc` in `.hover\:font-bold:hover` resulting in `.abc:hover`
127
- */ // TODO: Should we use postcss-selector-parser for this instead?
128
- function replaceSelector(selector, utilitySelectors, candidate) {
129
- let needle = `.${(0, _escapeClassName).default(candidate)}`;
130
- let utilitySelectorsList = utilitySelectors.split(/\s*,\s*/g);
131
- return selector.split(/\s*,\s*/g).map((s)=>{
132
- let replaced = [];
133
- for (let utilitySelector of utilitySelectorsList){
134
- let replacedSelector = utilitySelector.replace(needle, s);
135
- if (replacedSelector === utilitySelector) {
136
- continue;
137
- }
138
- replaced.push(replacedSelector);
139
- }
140
- return replaced.join(', ');
141
- }).join(', ');
142
- }
143
- let perParentApplies = new Map();
144
- // Collect all apply candidates and their rules
145
- for (let apply of applies){
146
- let candidates = perParentApplies.get(apply.parent) || [];
147
- perParentApplies.set(apply.parent, candidates);
148
- let [applyCandidates, important] = extractApplyCandidates(apply.params);
149
- if (apply.parent.type === 'atrule') {
150
- if (apply.parent.name === 'screen') {
151
- const screenType = apply.parent.params;
152
- 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}`
153
- ).join(' ')} instead.`);
154
- }
155
- 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}.`);
156
- }
157
- for (let applyCandidate of applyCandidates){
158
- if (!applyClassCache.has(applyCandidate)) {
159
- if (applyCandidate === prefix(context, 'group')) {
160
- // TODO: Link to specific documentation page with error code.
161
- throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
162
- }
163
- throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
164
- }
165
- let rules = applyClassCache.get(applyCandidate);
166
- candidates.push([
167
- applyCandidate,
168
- important,
169
- rules
170
- ]);
171
- }
172
- }
173
- for (const [parent, candidates] of perParentApplies){
174
- let siblings = [];
175
- for (let [applyCandidate, important, rules] of candidates){
176
- for (let [meta, node] of rules){
177
- let root = _postcss.default.root({
178
- nodes: [
179
- node.clone()
180
- ]
181
- });
182
- let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
183
- if (canRewriteSelector) {
184
- root.walkRules((rule)=>{
185
- rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
186
- rule.walkDecls((d)=>{
187
- d.important = meta.important || important;
188
- });
189
- });
190
- }
191
- // Insert it
192
- siblings.push([
193
- // Ensure that when we are sorting, that we take the layer order into account
194
- {
195
- ...meta,
196
- sort: meta.sort | context.layerOrder[meta.layer]
197
- },
198
- root.nodes[0],
199
- ]);
200
- }
201
- }
202
- // Inject the rules, sorted, correctly
203
- let nodes = siblings.sort(([a], [z])=>(0, _bigSign).default(a.sort - z.sort)
204
- ).map((s)=>s[1]
205
- );
206
- // console.log(parent)
207
- // `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
208
- parent.after(nodes);
209
- }
210
- for (let apply1 of applies){
211
- // If there are left-over declarations, just remove the @apply
212
- if (apply1.parent.nodes.length > 1) {
213
- apply1.remove();
214
- } else {
215
- // The node is empty, drop the full node
216
- apply1.parent.remove();
217
- }
218
- }
219
- // Do it again, in case we have other `@apply` rules
220
- processApply(root, context);
221
- }
222
- }
223
- function expandApplyAtRules(context) {
224
- return (root)=>{
225
- partitionApplyParents(root);
226
- processApply(root, context);
227
- };
228
- }
@@ -1,257 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = expandTailwindAtRules;
6
- var sharedState = _interopRequireWildcard(require("./sharedState"));
7
- var _generateRules = require("./generateRules");
8
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
9
- var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
10
- function _interopRequireDefault(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- function _interopRequireWildcard(obj) {
16
- if (obj && obj.__esModule) {
17
- return obj;
18
- } else {
19
- var newObj = {
20
- };
21
- if (obj != null) {
22
- for(var key in obj){
23
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
24
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
25
- };
26
- if (desc.get || desc.set) {
27
- Object.defineProperty(newObj, key, desc);
28
- } else {
29
- newObj[key] = obj[key];
30
- }
31
- }
32
- }
33
- }
34
- newObj.default = obj;
35
- return newObj;
36
- }
37
- }
38
- let env = sharedState.env;
39
- let contentMatchCache = sharedState.contentMatchCache;
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]*\['[^"'`\s]*'\])/.source,
46
- /([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
47
- /([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
48
- /([^<>"'`\s]*[^"'`\s:])/.source
49
- ].join('|');
50
- const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
51
- const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
52
- const builtInExtractors = {
53
- DEFAULT: (content)=>{
54
- let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
55
- let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
56
- return [
57
- ...broadMatches,
58
- ...innerMatches
59
- ];
60
- }
61
- };
62
- const builtInTransformers = {
63
- DEFAULT: (content)=>content
64
- ,
65
- svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
66
- };
67
- function getExtractor(tailwindConfig, fileExtension) {
68
- let extractors = tailwindConfig.content.extract;
69
- let contentOptions = tailwindConfig.content.options;
70
- if (typeof extractors === 'function') {
71
- extractors = {
72
- DEFAULT: extractors
73
- };
74
- }
75
- if (contentOptions.defaultExtractor) {
76
- extractors.DEFAULT = contentOptions.defaultExtractor;
77
- }
78
- for (let { extensions , extractor } of contentOptions.extractors || []){
79
- for (let extension of extensions){
80
- extractors[extension] = extractor;
81
- }
82
- }
83
- return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
84
- }
85
- function getTransformer(tailwindConfig, fileExtension) {
86
- let transformers = tailwindConfig.content.transform;
87
- if (typeof transformers === 'function') {
88
- transformers = {
89
- DEFAULT: transformers
90
- };
91
- }
92
- return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
93
- }
94
- // Scans template contents for possible classes. This is a hot path on initial build but
95
- // not too important for subsequent builds. The faster the better though — if we can speed
96
- // up these regexes by 50% that could cut initial build time by like 20%.
97
- function getClassCandidates(content, extractor, contentMatchCache, candidates, seen) {
98
- for (let line of content.split('\n')){
99
- line = line.trim();
100
- if (seen.has(line)) {
101
- continue;
102
- }
103
- seen.add(line);
104
- if (contentMatchCache.has(line)) {
105
- for (let match of contentMatchCache.get(line)){
106
- candidates.add(match);
107
- }
108
- } else {
109
- let extractorMatches = extractor(line).filter((s)=>s !== '!*'
110
- );
111
- let lineMatchesSet = new Set(extractorMatches);
112
- for (let match of lineMatchesSet){
113
- candidates.add(match);
114
- }
115
- contentMatchCache.set(line, lineMatchesSet);
116
- }
117
- }
118
- }
119
- function buildStylesheet(rules, context) {
120
- let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
121
- );
122
- let returnValue = {
123
- base: new Set(),
124
- components: new Set(),
125
- utilities: new Set(),
126
- variants: new Set(),
127
- // All the CSS that is not Tailwind related can be put in this bucket. This
128
- // will make it easier to later use this information when we want to
129
- // `@apply` for example. The main reason we do this here is because we
130
- // still need to make sure the order is correct. Last but not least, we
131
- // will make sure to always re-inject this section into the css, even if
132
- // certain rules were not used. This means that it will look like a no-op
133
- // from the user's perspective, but we gathered all the useful information
134
- // we need.
135
- user: new Set()
136
- };
137
- for (let [sort, rule] of sortedRules){
138
- if (sort >= context.minimumScreen) {
139
- returnValue.variants.add(rule);
140
- continue;
141
- }
142
- if (sort & context.layerOrder.base) {
143
- returnValue.base.add(rule);
144
- continue;
145
- }
146
- if (sort & context.layerOrder.components) {
147
- returnValue.components.add(rule);
148
- continue;
149
- }
150
- if (sort & context.layerOrder.utilities) {
151
- returnValue.utilities.add(rule);
152
- continue;
153
- }
154
- if (sort & context.layerOrder.user) {
155
- returnValue.user.add(rule);
156
- continue;
157
- }
158
- }
159
- return returnValue;
160
- }
161
- function expandTailwindAtRules(context) {
162
- return (root)=>{
163
- let layerNodes = {
164
- base: null,
165
- components: null,
166
- utilities: null,
167
- variants: null
168
- };
169
- // Make sure this file contains Tailwind directives. If not, we can save
170
- // a lot of work and bail early. Also we don't have to register our touch
171
- // file as a dependency since the output of this CSS does not depend on
172
- // the source of any templates. Think Vue <style> blocks for example.
173
- root.walkAtRules('tailwind', (rule)=>{
174
- if (Object.keys(layerNodes).includes(rule.params)) {
175
- layerNodes[rule.params] = rule;
176
- }
177
- });
178
- if (Object.values(layerNodes).every((n)=>n === null
179
- )) {
180
- return root;
181
- }
182
- // ---
183
- // Find potential rules in changed files
184
- let candidates = new Set([
185
- '*'
186
- ]);
187
- let seen = new Set();
188
- env.DEBUG && console.time('Reading changed files');
189
- for (let { content , extension } of context.changedContent){
190
- let transformer = getTransformer(context.tailwindConfig, extension);
191
- let extractor = getExtractor(context.tailwindConfig, extension);
192
- getClassCandidates(transformer(content), extractor, contentMatchCache, candidates, seen);
193
- }
194
- // ---
195
- // Generate the actual CSS
196
- let classCacheCount = context.classCache.size;
197
- env.DEBUG && console.time('Generate rules');
198
- let rules = (0, _generateRules).generateRules(candidates, context);
199
- env.DEBUG && console.timeEnd('Generate rules');
200
- // We only ever add to the classCache, so if it didn't grow, there is nothing new.
201
- env.DEBUG && console.time('Build stylesheet');
202
- if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
203
- for (let rule of rules){
204
- context.ruleCache.add(rule);
205
- }
206
- context.stylesheetCache = buildStylesheet([
207
- ...context.ruleCache
208
- ], context);
209
- }
210
- env.DEBUG && console.timeEnd('Build stylesheet');
211
- let { base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
212
- // ---
213
- // Replace any Tailwind directives with generated CSS
214
- if (layerNodes.base) {
215
- layerNodes.base.before((0, _cloneNodes).default([
216
- ...baseNodes
217
- ], layerNodes.base.source));
218
- layerNodes.base.remove();
219
- }
220
- if (layerNodes.components) {
221
- layerNodes.components.before((0, _cloneNodes).default([
222
- ...componentNodes
223
- ], layerNodes.components.source));
224
- layerNodes.components.remove();
225
- }
226
- if (layerNodes.utilities) {
227
- layerNodes.utilities.before((0, _cloneNodes).default([
228
- ...utilityNodes
229
- ], layerNodes.utilities.source));
230
- layerNodes.utilities.remove();
231
- }
232
- if (layerNodes.variants) {
233
- layerNodes.variants.before((0, _cloneNodes).default([
234
- ...screenNodes
235
- ], layerNodes.variants.source));
236
- layerNodes.variants.remove();
237
- } else {
238
- root.append((0, _cloneNodes).default([
239
- ...screenNodes
240
- ], root.source));
241
- }
242
- // ---
243
- if (env.DEBUG) {
244
- console.log('Potential classes: ', candidates.size);
245
- console.log('Active contexts: ', sharedState.contextSourcesMap.size);
246
- console.log('Content match entries', contentMatchCache.size);
247
- }
248
- // Clear the cache for the changed files
249
- context.changedContent = [];
250
- // Cleanup any leftover @layer atrules
251
- root.walkAtRules('layer', (rule)=>{
252
- if (Object.keys(layerNodes).includes(rule.params)) {
253
- rule.remove();
254
- }
255
- });
256
- };
257
- }