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,251 +0,0 @@
1
- import postcss from 'postcss'
2
- import { resolveMatches } from './generateRules'
3
- import bigSign from '../util/bigSign'
4
- import escapeClassName from '../util/escapeClassName'
5
-
6
- function prefix(context, selector) {
7
- let prefix = context.tailwindConfig.prefix
8
- return typeof prefix === 'function' ? prefix(selector) : prefix + selector
9
- }
10
-
11
- function buildApplyCache(applyCandidates, context) {
12
- for (let candidate of applyCandidates) {
13
- if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
14
- continue
15
- }
16
-
17
- if (context.classCache.has(candidate)) {
18
- context.applyClassCache.set(
19
- candidate,
20
- context.classCache.get(candidate).map(([meta, rule]) => [meta, rule.clone()])
21
- )
22
- continue
23
- }
24
-
25
- let matches = Array.from(resolveMatches(candidate, context))
26
-
27
- if (matches.length === 0) {
28
- context.notClassCache.add(candidate)
29
- continue
30
- }
31
-
32
- context.applyClassCache.set(candidate, matches)
33
- }
34
-
35
- return context.applyClassCache
36
- }
37
-
38
- function extractApplyCandidates(params) {
39
- let candidates = params.split(/[\s\t\n]+/g)
40
-
41
- if (candidates[candidates.length - 1] === '!important') {
42
- return [candidates.slice(0, -1), true]
43
- }
44
-
45
- return [candidates, false]
46
- }
47
-
48
- function partitionApplyParents(root) {
49
- let applyParents = new Set()
50
-
51
- root.walkAtRules('apply', (rule) => {
52
- applyParents.add(rule.parent)
53
- })
54
-
55
- for (let rule of applyParents) {
56
- let nodeGroups = []
57
- let lastGroup = []
58
-
59
- for (let node of rule.nodes) {
60
- if (node.type === 'atrule' && node.name === 'apply') {
61
- if (lastGroup.length > 0) {
62
- nodeGroups.push(lastGroup)
63
- lastGroup = []
64
- }
65
- nodeGroups.push([node])
66
- } else {
67
- lastGroup.push(node)
68
- }
69
- }
70
-
71
- if (lastGroup.length > 0) {
72
- nodeGroups.push(lastGroup)
73
- }
74
-
75
- if (nodeGroups.length === 1) {
76
- continue
77
- }
78
-
79
- for (let group of [...nodeGroups].reverse()) {
80
- let newParent = rule.clone({ nodes: [] })
81
- newParent.append(group)
82
- rule.after(newParent)
83
- }
84
-
85
- rule.remove()
86
- }
87
- }
88
-
89
- function processApply(root, context) {
90
- let applyCandidates = new Set()
91
-
92
- // Collect all @apply rules and candidates
93
- let applies = []
94
- root.walkAtRules('apply', (rule) => {
95
- let [candidates] = extractApplyCandidates(rule.params)
96
-
97
- for (let util of candidates) {
98
- applyCandidates.add(util)
99
- }
100
-
101
- applies.push(rule)
102
- })
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
- /**
110
- * When we have an apply like this:
111
- *
112
- * .abc {
113
- * @apply hover:font-bold;
114
- * }
115
- *
116
- * What we essentially will do is resolve to this:
117
- *
118
- * .abc {
119
- * @apply .hover\:font-bold:hover {
120
- * font-weight: 500;
121
- * }
122
- * }
123
- *
124
- * Notice that the to-be-applied class is `.hover\:font-bold:hover` and that the utility candidate was `hover:font-bold`.
125
- * What happens in this function is that we prepend a `.` and escape the candidate.
126
- * This will result in `.hover\:font-bold`
127
- * Which means that we can replace `.hover\:font-bold` with `.abc` in `.hover\:font-bold:hover` resulting in `.abc:hover`
128
- */
129
- // TODO: Should we use postcss-selector-parser for this instead?
130
- function replaceSelector(selector, utilitySelectors, candidate) {
131
- let needle = `.${escapeClassName(candidate)}`
132
- let utilitySelectorsList = utilitySelectors.split(/\s*,\s*/g)
133
-
134
- return selector
135
- .split(/\s*,\s*/g)
136
- .map((s) => {
137
- let replaced = []
138
-
139
- for (let utilitySelector of utilitySelectorsList) {
140
- let replacedSelector = utilitySelector.replace(needle, s)
141
- if (replacedSelector === utilitySelector) {
142
- continue
143
- }
144
- replaced.push(replacedSelector)
145
- }
146
- return replaced.join(', ')
147
- })
148
- .join(', ')
149
- }
150
-
151
- let perParentApplies = new Map()
152
-
153
- // Collect all apply candidates and their rules
154
- for (let apply of applies) {
155
- let candidates = perParentApplies.get(apply.parent) || []
156
-
157
- perParentApplies.set(apply.parent, candidates)
158
-
159
- let [applyCandidates, important] = extractApplyCandidates(apply.params)
160
-
161
- if (apply.parent.type === 'atrule') {
162
- if (apply.parent.name === 'screen') {
163
- const screenType = apply.parent.params
164
-
165
- throw apply.error(
166
- `@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates
167
- .map((c) => `${screenType}:${c}`)
168
- .join(' ')} instead.`
169
- )
170
- }
171
-
172
- throw apply.error(
173
- `@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`
174
- )
175
- }
176
-
177
- for (let applyCandidate of applyCandidates) {
178
- if (!applyClassCache.has(applyCandidate)) {
179
- if (applyCandidate === prefix(context, 'group')) {
180
- // TODO: Link to specific documentation page with error code.
181
- throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`)
182
- }
183
-
184
- throw apply.error(
185
- `The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`
186
- )
187
- }
188
-
189
- let rules = applyClassCache.get(applyCandidate)
190
-
191
- candidates.push([applyCandidate, important, rules])
192
- }
193
- }
194
-
195
- for (const [parent, candidates] of perParentApplies) {
196
- let siblings = []
197
-
198
- for (let [applyCandidate, important, rules] of candidates) {
199
- for (let [meta, node] of rules) {
200
- let root = postcss.root({ nodes: [node.clone()] })
201
- let canRewriteSelector =
202
- node.type !== 'atrule' || (node.type === 'atrule' && node.name !== 'keyframes')
203
-
204
- if (canRewriteSelector) {
205
- root.walkRules((rule) => {
206
- rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate)
207
-
208
- rule.walkDecls((d) => {
209
- d.important = meta.important || important
210
- })
211
- })
212
- }
213
-
214
- // Insert it
215
- siblings.push([
216
- // Ensure that when we are sorting, that we take the layer order into account
217
- { ...meta, sort: meta.sort | context.layerOrder[meta.layer] },
218
- root.nodes[0],
219
- ])
220
- }
221
- }
222
-
223
- // Inject the rules, sorted, correctly
224
- let nodes = siblings.sort(([a], [z]) => bigSign(a.sort - z.sort)).map((s) => s[1])
225
-
226
- // console.log(parent)
227
- // `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
228
- parent.after(nodes)
229
- }
230
-
231
- for (let apply of applies) {
232
- // If there are left-over declarations, just remove the @apply
233
- if (apply.parent.nodes.length > 1) {
234
- apply.remove()
235
- } else {
236
- // The node is empty, drop the full node
237
- apply.parent.remove()
238
- }
239
- }
240
-
241
- // Do it again, in case we have other `@apply` rules
242
- processApply(root, context)
243
- }
244
- }
245
-
246
- export default function expandApplyAtRules(context) {
247
- return (root) => {
248
- partitionApplyParents(root)
249
- processApply(root, context)
250
- }
251
- }
@@ -1,262 +0,0 @@
1
- import * as sharedState from './sharedState'
2
- import { generateRules } from './generateRules'
3
- import bigSign from '../util/bigSign'
4
- import cloneNodes from '../util/cloneNodes'
5
-
6
- let env = sharedState.env
7
- let contentMatchCache = sharedState.contentMatchCache
8
-
9
- const PATTERNS = [
10
- "([^<>\"'`\\s]*\\['[^<>\"'`\\s]*'\\])", // `content-['hello']` but not `content-['hello']']`
11
- '([^<>"\'`\\s]*\\["[^<>"\'`\\s]*"\\])', // `content-["hello"]` but not `content-["hello"]"]`
12
- '([^<>"\'`\\s]*\\[[^<>"\'`\\s]+\\])', // `fill-[#bada55]`
13
- '([^<>"\'`\\s]*[^<>"\'`\\s:])', // `px-1.5`, `uppercase` but not `uppercase:`
14
- ].join('|')
15
- const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g')
16
- const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g
17
-
18
- const builtInExtractors = {
19
- DEFAULT: (content) => {
20
- let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || []
21
- let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || []
22
-
23
- return [...broadMatches, ...innerMatches]
24
- },
25
- }
26
-
27
- const builtInTransformers = {
28
- DEFAULT: (content) => content,
29
- svelte: (content) => content.replace(/(?:^|\s)class:/g, ' '),
30
- }
31
-
32
- function getExtractor(tailwindConfig, fileExtension) {
33
- let extractors = tailwindConfig.content.extract
34
- let contentOptions = tailwindConfig.content.options
35
-
36
- if (typeof extractors === 'function') {
37
- extractors = {
38
- DEFAULT: extractors,
39
- }
40
- }
41
- if (contentOptions.defaultExtractor) {
42
- extractors.DEFAULT = contentOptions.defaultExtractor
43
- }
44
- for (let { extensions, extractor } of contentOptions.extractors || []) {
45
- for (let extension of extensions) {
46
- extractors[extension] = extractor
47
- }
48
- }
49
-
50
- return (
51
- extractors[fileExtension] ||
52
- extractors.DEFAULT ||
53
- builtInExtractors[fileExtension] ||
54
- builtInExtractors.DEFAULT
55
- )
56
- }
57
-
58
- function getTransformer(tailwindConfig, fileExtension) {
59
- let transformers = tailwindConfig.content.transform
60
-
61
- if (typeof transformers === 'function') {
62
- transformers = {
63
- DEFAULT: transformers,
64
- }
65
- }
66
-
67
- return (
68
- transformers[fileExtension] ||
69
- transformers.DEFAULT ||
70
- builtInTransformers[fileExtension] ||
71
- builtInTransformers.DEFAULT
72
- )
73
- }
74
-
75
- // Scans template contents for possible classes. This is a hot path on initial build but
76
- // not too important for subsequent builds. The faster the better though — if we can speed
77
- // up these regexes by 50% that could cut initial build time by like 20%.
78
- function getClassCandidates(content, extractor, contentMatchCache, candidates, seen) {
79
- for (let line of content.split('\n')) {
80
- line = line.trim()
81
-
82
- if (seen.has(line)) {
83
- continue
84
- }
85
- seen.add(line)
86
-
87
- if (contentMatchCache.has(line)) {
88
- for (let match of contentMatchCache.get(line)) {
89
- candidates.add(match)
90
- }
91
- } else {
92
- let extractorMatches = extractor(line).filter((s) => s !== '!*')
93
- let lineMatchesSet = new Set(extractorMatches)
94
-
95
- for (let match of lineMatchesSet) {
96
- candidates.add(match)
97
- }
98
-
99
- contentMatchCache.set(line, lineMatchesSet)
100
- }
101
- }
102
- }
103
-
104
- function buildStylesheet(rules, context) {
105
- let sortedRules = rules.sort(([a], [z]) => bigSign(a - z))
106
-
107
- let returnValue = {
108
- base: new Set(),
109
- components: new Set(),
110
- utilities: new Set(),
111
- variants: new Set(),
112
-
113
- // All the CSS that is not Tailwind related can be put in this bucket. This
114
- // will make it easier to later use this information when we want to
115
- // `@apply` for example. The main reason we do this here is because we
116
- // still need to make sure the order is correct. Last but not least, we
117
- // will make sure to always re-inject this section into the css, even if
118
- // certain rules were not used. This means that it will look like a no-op
119
- // from the user's perspective, but we gathered all the useful information
120
- // we need.
121
- user: new Set(),
122
- }
123
-
124
- for (let [sort, rule] of sortedRules) {
125
- if (sort >= context.minimumScreen) {
126
- returnValue.variants.add(rule)
127
- continue
128
- }
129
-
130
- if (sort & context.layerOrder.base) {
131
- returnValue.base.add(rule)
132
- continue
133
- }
134
-
135
- if (sort & context.layerOrder.components) {
136
- returnValue.components.add(rule)
137
- continue
138
- }
139
-
140
- if (sort & context.layerOrder.utilities) {
141
- returnValue.utilities.add(rule)
142
- continue
143
- }
144
-
145
- if (sort & context.layerOrder.user) {
146
- returnValue.user.add(rule)
147
- continue
148
- }
149
- }
150
-
151
- return returnValue
152
- }
153
-
154
- export default function expandTailwindAtRules(context) {
155
- return (root) => {
156
- let layerNodes = {
157
- base: null,
158
- components: null,
159
- utilities: null,
160
- variants: null,
161
- }
162
-
163
- // Make sure this file contains Tailwind directives. If not, we can save
164
- // a lot of work and bail early. Also we don't have to register our touch
165
- // file as a dependency since the output of this CSS does not depend on
166
- // the source of any templates. Think Vue <style> blocks for example.
167
- root.walkAtRules('tailwind', (rule) => {
168
- if (Object.keys(layerNodes).includes(rule.params)) {
169
- layerNodes[rule.params] = rule
170
- }
171
- })
172
-
173
- if (Object.values(layerNodes).every((n) => n === null)) {
174
- return root
175
- }
176
-
177
- // ---
178
-
179
- // Find potential rules in changed files
180
- let candidates = new Set(['*'])
181
- let seen = new Set()
182
-
183
- env.DEBUG && console.time('Reading changed files')
184
-
185
- for (let { content, extension } of context.changedContent) {
186
- let transformer = getTransformer(context.tailwindConfig, extension)
187
- let extractor = getExtractor(context.tailwindConfig, extension)
188
- getClassCandidates(transformer(content), extractor, contentMatchCache, candidates, seen)
189
- }
190
-
191
- // ---
192
-
193
- // Generate the actual CSS
194
- let classCacheCount = context.classCache.size
195
-
196
- env.DEBUG && console.time('Generate rules')
197
- let rules = generateRules(candidates, context)
198
- env.DEBUG && console.timeEnd('Generate rules')
199
-
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
-
207
- context.stylesheetCache = buildStylesheet([...context.ruleCache], context)
208
- }
209
- env.DEBUG && console.timeEnd('Build stylesheet')
210
-
211
- let {
212
- base: baseNodes,
213
- components: componentNodes,
214
- utilities: utilityNodes,
215
- variants: screenNodes,
216
- } = context.stylesheetCache
217
-
218
- // ---
219
-
220
- // Replace any Tailwind directives with generated CSS
221
-
222
- if (layerNodes.base) {
223
- layerNodes.base.before(cloneNodes([...baseNodes], layerNodes.base.source))
224
- layerNodes.base.remove()
225
- }
226
-
227
- if (layerNodes.components) {
228
- layerNodes.components.before(cloneNodes([...componentNodes], layerNodes.components.source))
229
- layerNodes.components.remove()
230
- }
231
-
232
- if (layerNodes.utilities) {
233
- layerNodes.utilities.before(cloneNodes([...utilityNodes], layerNodes.utilities.source))
234
- layerNodes.utilities.remove()
235
- }
236
-
237
- if (layerNodes.variants) {
238
- layerNodes.variants.before(cloneNodes([...screenNodes], layerNodes.variants.source))
239
- layerNodes.variants.remove()
240
- } else {
241
- root.append(cloneNodes([...screenNodes], root.source))
242
- }
243
-
244
- // ---
245
-
246
- if (env.DEBUG) {
247
- console.log('Potential classes: ', candidates.size)
248
- console.log('Active contexts: ', sharedState.contextSourcesMap.size)
249
- console.log('Content match entries', contentMatchCache.size)
250
- }
251
-
252
- // Clear the cache for the changed files
253
- context.changedContent = []
254
-
255
- // Cleanup any leftover @layer atrules
256
- root.walkAtRules('layer', (rule) => {
257
- if (Object.keys(layerNodes).includes(rule.params)) {
258
- rule.remove()
259
- }
260
- })
261
- }
262
- }