tailwindcss 0.0.0-insiders.f9fb2ce → 0.0.0-insiders.fa3f45f

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 (185) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +18 -15
  3. package/dist/chunk-4V6TN65S.mjs +35 -0
  4. package/dist/chunk-G32FJCSR.mjs +1 -0
  5. package/dist/chunk-HTB5LLOP.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 +3 -0
  18. package/dist/flatten-color-palette.mjs +1 -0
  19. package/dist/lib.d.mts +351 -0
  20. package/dist/lib.d.ts +3 -0
  21. package/dist/lib.js +35 -0
  22. package/dist/lib.mjs +1 -0
  23. package/dist/plugin.d.mts +11 -0
  24. package/dist/plugin.d.ts +131 -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-WlZgYgM8.d.mts +125 -0
  30. package/index.css +896 -0
  31. package/package.json +76 -100
  32. package/preflight.css +393 -0
  33. package/theme.css +462 -0
  34. package/CHANGELOG.md +0 -1816
  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 -706
  42. package/lib/constants.js +0 -37
  43. package/lib/corePluginList.js +0 -174
  44. package/lib/corePlugins.js +0 -3562
  45. package/lib/css/LICENSE +0 -25
  46. package/lib/css/preflight.css +0 -366
  47. package/lib/featureFlags.js +0 -60
  48. package/lib/index.js +0 -32
  49. package/lib/lib/collapseAdjacentRules.js +0 -41
  50. package/lib/lib/collapseDuplicateDeclarations.js +0 -29
  51. package/lib/lib/detectNesting.js +0 -19
  52. package/lib/lib/evaluateTailwindFunctions.js +0 -167
  53. package/lib/lib/expandApplyAtRules.js +0 -228
  54. package/lib/lib/expandTailwindAtRules.js +0 -245
  55. package/lib/lib/generateRules.js +0 -493
  56. package/lib/lib/getModuleDependencies.js +0 -48
  57. package/lib/lib/normalizeTailwindDirectives.js +0 -76
  58. package/lib/lib/resolveDefaultsAtRules.js +0 -125
  59. package/lib/lib/setupContextUtils.js +0 -860
  60. package/lib/lib/setupTrackingContext.js +0 -170
  61. package/lib/lib/setupWatchingContext.js +0 -288
  62. package/lib/lib/sharedState.js +0 -19
  63. package/lib/lib/substituteScreenAtRules.js +0 -24
  64. package/lib/processTailwindFeatures.js +0 -51
  65. package/lib/public/colors.js +0 -329
  66. package/lib/public/create-plugin.js +0 -13
  67. package/lib/public/default-config.js +0 -14
  68. package/lib/public/default-theme.js +0 -14
  69. package/lib/public/resolve-config.js +0 -19
  70. package/lib/util/bigSign.js +0 -8
  71. package/lib/util/buildMediaQuery.js +0 -31
  72. package/lib/util/cloneDeep.js +0 -19
  73. package/lib/util/cloneNodes.js +0 -14
  74. package/lib/util/color.js +0 -84
  75. package/lib/util/configurePlugins.js +0 -18
  76. package/lib/util/createPlugin.js +0 -30
  77. package/lib/util/createUtilityPlugin.js +0 -53
  78. package/lib/util/dataTypes.js +0 -211
  79. package/lib/util/defaults.js +0 -16
  80. package/lib/util/escapeClassName.js +0 -19
  81. package/lib/util/escapeCommas.js +0 -8
  82. package/lib/util/flattenColorPalette.js +0 -19
  83. package/lib/util/formatVariantSelector.js +0 -102
  84. package/lib/util/getAllConfigs.js +0 -29
  85. package/lib/util/hashConfig.js +0 -16
  86. package/lib/util/isKeyframeRule.js +0 -8
  87. package/lib/util/isPlainObject.js +0 -12
  88. package/lib/util/log.js +0 -47
  89. package/lib/util/nameClass.js +0 -31
  90. package/lib/util/negateValue.js +0 -19
  91. package/lib/util/normalizeConfig.js +0 -208
  92. package/lib/util/parseAnimationValue.js +0 -89
  93. package/lib/util/parseDependency.js +0 -63
  94. package/lib/util/parseObjectStyles.js +0 -31
  95. package/lib/util/pluginUtils.js +0 -185
  96. package/lib/util/prefixSelector.js +0 -21
  97. package/lib/util/resolveConfig.js +0 -234
  98. package/lib/util/resolveConfigPath.js +0 -52
  99. package/lib/util/responsive.js +0 -19
  100. package/lib/util/tap.js +0 -9
  101. package/lib/util/toColorValue.js +0 -9
  102. package/lib/util/toPath.js +0 -9
  103. package/lib/util/transformThemeValue.js +0 -63
  104. package/lib/util/withAlphaVariable.js +0 -67
  105. package/nesting/README.md +0 -42
  106. package/nesting/index.js +0 -12
  107. package/nesting/plugin.js +0 -41
  108. package/peers/index.js +0 -75407
  109. package/plugin.js +0 -1
  110. package/prettier.config.js +0 -19
  111. package/resolveConfig.js +0 -1
  112. package/screens.css +0 -1
  113. package/scripts/create-plugin-list.js +0 -10
  114. package/scripts/install-integrations.js +0 -27
  115. package/scripts/rebuildFixtures.js +0 -68
  116. package/src/cli-peer-dependencies.js +0 -9
  117. package/src/cli.js +0 -768
  118. package/src/constants.js +0 -17
  119. package/src/corePluginList.js +0 -1
  120. package/src/corePlugins.js +0 -2291
  121. package/src/css/LICENSE +0 -25
  122. package/src/css/preflight.css +0 -366
  123. package/src/featureFlags.js +0 -54
  124. package/src/index.js +0 -34
  125. package/src/lib/collapseAdjacentRules.js +0 -39
  126. package/src/lib/collapseDuplicateDeclarations.js +0 -28
  127. package/src/lib/detectNesting.js +0 -20
  128. package/src/lib/evaluateTailwindFunctions.js +0 -195
  129. package/src/lib/expandApplyAtRules.js +0 -251
  130. package/src/lib/expandTailwindAtRules.js +0 -252
  131. package/src/lib/generateRules.js +0 -495
  132. package/src/lib/getModuleDependencies.js +0 -39
  133. package/src/lib/normalizeTailwindDirectives.js +0 -78
  134. package/src/lib/resolveDefaultsAtRules.js +0 -121
  135. package/src/lib/setupContextUtils.js +0 -853
  136. package/src/lib/setupTrackingContext.js +0 -182
  137. package/src/lib/setupWatchingContext.js +0 -311
  138. package/src/lib/sharedState.js +0 -10
  139. package/src/lib/substituteScreenAtRules.js +0 -16
  140. package/src/processTailwindFeatures.js +0 -48
  141. package/src/public/colors.js +0 -300
  142. package/src/public/create-plugin.js +0 -2
  143. package/src/public/default-config.js +0 -4
  144. package/src/public/default-theme.js +0 -4
  145. package/src/public/resolve-config.js +0 -7
  146. package/src/util/bigSign.js +0 -3
  147. package/src/util/buildMediaQuery.js +0 -24
  148. package/src/util/cloneDeep.js +0 -11
  149. package/src/util/cloneNodes.js +0 -11
  150. package/src/util/color.js +0 -56
  151. package/src/util/configurePlugins.js +0 -23
  152. package/src/util/createPlugin.js +0 -27
  153. package/src/util/createUtilityPlugin.js +0 -37
  154. package/src/util/dataTypes.js +0 -230
  155. package/src/util/defaults.js +0 -11
  156. package/src/util/escapeClassName.js +0 -8
  157. package/src/util/escapeCommas.js +0 -3
  158. package/src/util/flattenColorPalette.js +0 -13
  159. package/src/util/formatVariantSelector.js +0 -105
  160. package/src/util/getAllConfigs.js +0 -19
  161. package/src/util/hashConfig.js +0 -5
  162. package/src/util/isKeyframeRule.js +0 -3
  163. package/src/util/isPlainObject.js +0 -8
  164. package/src/util/log.js +0 -25
  165. package/src/util/nameClass.js +0 -26
  166. package/src/util/negateValue.js +0 -16
  167. package/src/util/normalizeConfig.js +0 -249
  168. package/src/util/parseAnimationValue.js +0 -68
  169. package/src/util/parseDependency.js +0 -49
  170. package/src/util/parseObjectStyles.js +0 -19
  171. package/src/util/pluginUtils.js +0 -190
  172. package/src/util/prefixSelector.js +0 -12
  173. package/src/util/resolveConfig.js +0 -229
  174. package/src/util/resolveConfigPath.js +0 -55
  175. package/src/util/responsive.js +0 -10
  176. package/src/util/tap.js +0 -4
  177. package/src/util/toColorValue.js +0 -3
  178. package/src/util/toPath.js +0 -4
  179. package/src/util/transformThemeValue.js +0 -52
  180. package/src/util/withAlphaVariable.js +0 -49
  181. package/stubs/defaultConfig.stub.js +0 -932
  182. package/stubs/defaultPostCssConfig.stub.js +0 -6
  183. package/stubs/simpleConfig.stub.js +0 -7
  184. package/tailwind.css +0 -5
  185. package/variants.css +0 -1
@@ -1,495 +0,0 @@
1
- import postcss from 'postcss'
2
- import selectorParser from 'postcss-selector-parser'
3
- import parseObjectStyles from '../util/parseObjectStyles'
4
- import isPlainObject from '../util/isPlainObject'
5
- import prefixSelector from '../util/prefixSelector'
6
- import { updateAllClasses } from '../util/pluginUtils'
7
- import log from '../util/log'
8
- import { formatVariantSelector, finalizeSelector } from '../util/formatVariantSelector'
9
-
10
- let classNameParser = selectorParser((selectors) => {
11
- return selectors.first.filter(({ type }) => type === 'class').pop().value
12
- })
13
-
14
- function getClassNameFromSelector(selector) {
15
- return classNameParser.transformSync(selector)
16
- }
17
-
18
- // Generate match permutations for a class candidate, like:
19
- // ['ring-offset-blue', '100']
20
- // ['ring-offset', 'blue-100']
21
- // ['ring', 'offset-blue-100']
22
- // Example with dynamic classes:
23
- // ['grid-cols', '[[linename],1fr,auto]']
24
- // ['grid', 'cols-[[linename],1fr,auto]']
25
- function* candidatePermutations(candidate, lastIndex = Infinity) {
26
- if (lastIndex < 0) {
27
- return
28
- }
29
-
30
- let dashIdx
31
-
32
- if (lastIndex === Infinity && candidate.endsWith(']')) {
33
- let bracketIdx = candidate.indexOf('[')
34
-
35
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
36
- // eg. string[]
37
- dashIdx = ['-', '/'].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1
38
- } else {
39
- dashIdx = candidate.lastIndexOf('-', lastIndex)
40
- }
41
-
42
- if (dashIdx < 0) {
43
- return
44
- }
45
-
46
- let prefix = candidate.slice(0, dashIdx)
47
- let modifier = candidate.slice(dashIdx + 1)
48
-
49
- yield [prefix, modifier]
50
-
51
- yield* candidatePermutations(candidate, dashIdx - 1)
52
- }
53
-
54
- function applyPrefix(matches, context) {
55
- if (matches.length === 0 || context.tailwindConfig.prefix === '') {
56
- return matches
57
- }
58
-
59
- for (let match of matches) {
60
- let [meta] = match
61
- if (meta.options.respectPrefix) {
62
- let container = postcss.root({ nodes: [match[1].clone()] })
63
- container.walkRules((r) => {
64
- r.selector = prefixSelector(context.tailwindConfig.prefix, r.selector)
65
- })
66
- match[1] = container.nodes[0]
67
- }
68
- }
69
-
70
- return matches
71
- }
72
-
73
- function applyImportant(matches) {
74
- if (matches.length === 0) {
75
- return matches
76
- }
77
- let result = []
78
-
79
- for (let [meta, rule] of matches) {
80
- let container = postcss.root({ nodes: [rule.clone()] })
81
- container.walkRules((r) => {
82
- r.selector = updateAllClasses(r.selector, (className) => {
83
- return `!${className}`
84
- })
85
- r.walkDecls((d) => (d.important = true))
86
- })
87
- result.push([{ ...meta, important: true }, container.nodes[0]])
88
- }
89
-
90
- return result
91
- }
92
-
93
- // Takes a list of rule tuples and applies a variant like `hover`, sm`,
94
- // whatever to it. We used to do some extra caching here to avoid generating
95
- // a variant of the same rule more than once, but this was never hit because
96
- // we cache at the entire selector level further up the tree.
97
- //
98
- // Technically you can get a cache hit if you have `hover:focus:text-center`
99
- // and `focus:hover:text-center` in the same project, but it doesn't feel
100
- // worth the complexity for that case.
101
-
102
- function applyVariant(variant, matches, context) {
103
- if (matches.length === 0) {
104
- return matches
105
- }
106
-
107
- if (context.variantMap.has(variant)) {
108
- let variantFunctionTuples = context.variantMap.get(variant)
109
- let result = []
110
-
111
- for (let [meta, rule] of matches) {
112
- let container = postcss.root({ nodes: [rule.clone()] })
113
-
114
- for (let [variantSort, variantFunction] of variantFunctionTuples) {
115
- let clone = container.clone()
116
- let collectedFormats = []
117
-
118
- let originals = new Map()
119
-
120
- function prepareBackup() {
121
- if (originals.size > 0) return // Already prepared, chicken out
122
- clone.walkRules((rule) => originals.set(rule, rule.selector))
123
- }
124
-
125
- function modifySelectors(modifierFunction) {
126
- prepareBackup()
127
- clone.each((rule) => {
128
- if (rule.type !== 'rule') {
129
- return
130
- }
131
-
132
- rule.selectors = rule.selectors.map((selector) => {
133
- return modifierFunction({
134
- get className() {
135
- return getClassNameFromSelector(selector)
136
- },
137
- selector,
138
- })
139
- })
140
- })
141
-
142
- return clone
143
- }
144
-
145
- let ruleWithVariant = variantFunction({
146
- // Public API
147
- get container() {
148
- prepareBackup()
149
- return clone
150
- },
151
- separator: context.tailwindConfig.separator,
152
- modifySelectors,
153
-
154
- // Private API for now
155
- wrap(wrapper) {
156
- let nodes = clone.nodes
157
- clone.removeAll()
158
- wrapper.append(nodes)
159
- clone.append(wrapper)
160
- },
161
- format(selectorFormat) {
162
- collectedFormats.push(selectorFormat)
163
- },
164
- })
165
-
166
- if (typeof ruleWithVariant === 'string') {
167
- collectedFormats.push(ruleWithVariant)
168
- }
169
-
170
- if (ruleWithVariant === null) {
171
- continue
172
- }
173
-
174
- // We filled the `originals`, therefore we assume that somebody touched
175
- // `container` or `modifySelectors`. Let's see if they did, so that we
176
- // can restore the selectors, and collect the format strings.
177
- if (originals.size > 0) {
178
- clone.walkRules((rule) => {
179
- if (!originals.has(rule)) return
180
- let before = originals.get(rule)
181
- if (before === rule.selector) return // No mutation happened
182
-
183
- let modified = rule.selector
184
-
185
- // Rebuild the base selector, this is what plugin authors would do
186
- // as well. E.g.: `${variant}${separator}${className}`.
187
- // However, plugin authors probably also prepend or append certain
188
- // classes, pseudos, ids, ...
189
- let rebuiltBase = selectorParser((selectors) => {
190
- selectors.walkClasses((classNode) => {
191
- classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`
192
- })
193
- }).processSync(before)
194
-
195
- // Now that we know the original selector, the new selector, and
196
- // the rebuild part in between, we can replace the part that plugin
197
- // authors need to rebuild with `&`, and eventually store it in the
198
- // collectedFormats. Similar to what `format('...')` would do.
199
- //
200
- // E.g.:
201
- // variant: foo
202
- // selector: .markdown > p
203
- // modified (by plugin): .foo .foo\\:markdown > p
204
- // rebuiltBase (internal): .foo\\:markdown > p
205
- // format: .foo &
206
- collectedFormats.push(modified.replace(rebuiltBase, '&'))
207
- rule.selector = before
208
- })
209
- }
210
-
211
- let withOffset = [
212
- {
213
- ...meta,
214
- sort: variantSort | meta.sort,
215
- collectedFormats: (meta.collectedFormats ?? []).concat(collectedFormats),
216
- },
217
- clone.nodes[0],
218
- ]
219
- result.push(withOffset)
220
- }
221
- }
222
-
223
- return result
224
- }
225
-
226
- return []
227
- }
228
-
229
- function parseRules(rule, cache, options = {}) {
230
- // PostCSS node
231
- if (!isPlainObject(rule) && !Array.isArray(rule)) {
232
- return [[rule], options]
233
- }
234
-
235
- // Tuple
236
- if (Array.isArray(rule)) {
237
- return parseRules(rule[0], cache, rule[1])
238
- }
239
-
240
- // Simple object
241
- if (!cache.has(rule)) {
242
- cache.set(rule, parseObjectStyles(rule))
243
- }
244
-
245
- return [cache.get(rule), options]
246
- }
247
-
248
- function* resolveMatchedPlugins(classCandidate, context) {
249
- if (context.candidateRuleMap.has(classCandidate)) {
250
- yield [context.candidateRuleMap.get(classCandidate), 'DEFAULT']
251
- }
252
-
253
- let candidatePrefix = classCandidate
254
- let negative = false
255
-
256
- const twConfigPrefix = context.tailwindConfig.prefix
257
-
258
- const twConfigPrefixLen = twConfigPrefix.length
259
- if (candidatePrefix[twConfigPrefixLen] === '-') {
260
- negative = true
261
- candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1)
262
- }
263
-
264
- if (negative && context.candidateRuleMap.has(candidatePrefix)) {
265
- yield [context.candidateRuleMap.get(candidatePrefix), '-DEFAULT']
266
- }
267
-
268
- for (let [prefix, modifier] of candidatePermutations(candidatePrefix)) {
269
- if (context.candidateRuleMap.has(prefix)) {
270
- yield [context.candidateRuleMap.get(prefix), negative ? `-${modifier}` : modifier]
271
- return
272
- }
273
- }
274
- }
275
-
276
- function splitWithSeparator(input, separator) {
277
- return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'))
278
- }
279
-
280
- function* resolveMatches(candidate, context) {
281
- let separator = context.tailwindConfig.separator
282
- let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse()
283
- let important = false
284
-
285
- if (classCandidate.startsWith('!')) {
286
- important = true
287
- classCandidate = classCandidate.slice(1)
288
- }
289
-
290
- // TODO: Reintroduce this in ways that doesn't break on false positives
291
- // function sortAgainst(toSort, against) {
292
- // return toSort.slice().sort((a, z) => {
293
- // return bigSign(against.get(a)[0] - against.get(z)[0])
294
- // })
295
- // }
296
- // let sorted = sortAgainst(variants, context.variantMap)
297
- // if (sorted.toString() !== variants.toString()) {
298
- // let corrected = sorted.reverse().concat(classCandidate).join(':')
299
- // throw new Error(`Class ${candidate} should be written as ${corrected}`)
300
- // }
301
-
302
- for (let matchedPlugins of resolveMatchedPlugins(classCandidate, context)) {
303
- let matches = []
304
- let typesByMatches = new Map()
305
-
306
- let [plugins, modifier] = matchedPlugins
307
- let isOnlyPlugin = plugins.length === 1
308
-
309
- for (let [sort, plugin] of plugins) {
310
- let matchesPerPlugin = []
311
-
312
- if (typeof plugin === 'function') {
313
- for (let ruleSet of [].concat(plugin(modifier, { isOnlyPlugin }))) {
314
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache)
315
- for (let rule of rules) {
316
- matchesPerPlugin.push([{ ...sort, options: { ...sort.options, ...options } }, rule])
317
- }
318
- }
319
- }
320
- // Only process static plugins on exact matches
321
- else if (modifier === 'DEFAULT' || modifier === '-DEFAULT') {
322
- let ruleSet = plugin
323
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache)
324
- for (let rule of rules) {
325
- matchesPerPlugin.push([{ ...sort, options: { ...sort.options, ...options } }, rule])
326
- }
327
- }
328
-
329
- if (matchesPerPlugin.length > 0) {
330
- typesByMatches.set(matchesPerPlugin, sort.options?.type)
331
- matches.push(matchesPerPlugin)
332
- }
333
- }
334
-
335
- // Only keep the result of the very first plugin if we are dealing with
336
- // arbitrary values, to protect against ambiguity.
337
- if (isArbitraryValue(modifier) && matches.length > 1) {
338
- let typesPerPlugin = matches.map((match) => new Set([...(typesByMatches.get(match) ?? [])]))
339
-
340
- // Remove duplicates, so that we can detect proper unique types for each plugin.
341
- for (let pluginTypes of typesPerPlugin) {
342
- for (let type of pluginTypes) {
343
- let removeFromOwnGroup = false
344
-
345
- for (let otherGroup of typesPerPlugin) {
346
- if (pluginTypes === otherGroup) continue
347
-
348
- if (otherGroup.has(type)) {
349
- otherGroup.delete(type)
350
- removeFromOwnGroup = true
351
- }
352
- }
353
-
354
- if (removeFromOwnGroup) pluginTypes.delete(type)
355
- }
356
- }
357
-
358
- let messages = []
359
-
360
- for (let [idx, group] of typesPerPlugin.entries()) {
361
- for (let type of group) {
362
- let rules = matches[idx]
363
- .map(([, rule]) => rule)
364
- .flat()
365
- .map((rule) =>
366
- rule
367
- .toString()
368
- .split('\n')
369
- .slice(1, -1) // Remove selector and closing '}'
370
- .map((line) => line.trim())
371
- .map((x) => ` ${x}`) // Re-indent
372
- .join('\n')
373
- )
374
- .join('\n\n')
375
-
376
- messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``)
377
- break
378
- }
379
- }
380
-
381
- log.warn([
382
- `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
383
- ...messages,
384
- `If this is content and not a class, replace it with \`${candidate
385
- .replace('[', '&lsqb;')
386
- .replace(']', '&rsqb;')}\` to silence this warning.`,
387
- ])
388
- continue
389
- }
390
-
391
- matches = applyPrefix(matches.flat(), context)
392
-
393
- if (important) {
394
- matches = applyImportant(matches, context)
395
- }
396
-
397
- for (let variant of variants) {
398
- matches = applyVariant(variant, matches, context)
399
- }
400
-
401
- for (let match of matches) {
402
- // Apply final format selector
403
- if (match[0].collectedFormats) {
404
- let finalFormat = formatVariantSelector('&', ...match[0].collectedFormats)
405
- let container = postcss.root({ nodes: [match[1].clone()] })
406
- container.walkRules((rule) => {
407
- if (inKeyframes(rule)) return
408
-
409
- rule.selector = finalizeSelector(finalFormat, {
410
- selector: rule.selector,
411
- candidate,
412
- context,
413
- })
414
- })
415
- match[1] = container.nodes[0]
416
- }
417
-
418
- yield match
419
- }
420
- }
421
- }
422
-
423
- function inKeyframes(rule) {
424
- return rule.parent && rule.parent.type === 'atrule' && rule.parent.name === 'keyframes'
425
- }
426
-
427
- function generateRules(candidates, context) {
428
- let allRules = []
429
-
430
- for (let candidate of candidates) {
431
- if (context.notClassCache.has(candidate)) {
432
- continue
433
- }
434
-
435
- if (context.classCache.has(candidate)) {
436
- allRules.push(context.classCache.get(candidate))
437
- continue
438
- }
439
-
440
- let matches = Array.from(resolveMatches(candidate, context))
441
-
442
- if (matches.length === 0) {
443
- context.notClassCache.add(candidate)
444
- continue
445
- }
446
-
447
- context.classCache.set(candidate, matches)
448
- allRules.push(matches)
449
- }
450
-
451
- // Strategy based on `tailwindConfig.important`
452
- let strategy = ((important) => {
453
- if (important === true) {
454
- return (rule) => {
455
- rule.walkDecls((d) => {
456
- if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
457
- d.important = true
458
- }
459
- })
460
- }
461
- }
462
-
463
- if (typeof important === 'string') {
464
- return (rule) => {
465
- rule.selectors = rule.selectors.map((selector) => {
466
- return `${important} ${selector}`
467
- })
468
- }
469
- }
470
- })(context.tailwindConfig.important)
471
-
472
- return allRules.flat(1).map(([{ sort, layer, options }, rule]) => {
473
- if (options.respectImportant) {
474
- if (strategy) {
475
- let container = postcss.root({ nodes: [rule.clone()] })
476
- container.walkRules((r) => {
477
- if (inKeyframes(r)) {
478
- return
479
- }
480
-
481
- strategy(r)
482
- })
483
- rule = container.nodes[0]
484
- }
485
- }
486
-
487
- return [sort | context.layerOrder[layer], rule]
488
- })
489
- }
490
-
491
- function isArbitraryValue(input) {
492
- return input.startsWith('[') && input.endsWith(']')
493
- }
494
-
495
- export { resolveMatches, generateRules }
@@ -1,39 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
- import resolve from 'resolve'
4
- import detective from 'detective'
5
-
6
- function createModule(file) {
7
- const source = fs.readFileSync(file, 'utf-8')
8
- const requires = detective(source)
9
-
10
- return { file, requires }
11
- }
12
-
13
- export default function getModuleDependencies(entryFile) {
14
- const rootModule = createModule(entryFile)
15
- const modules = [rootModule]
16
-
17
- // Iterate over the modules, even when new
18
- // ones are being added
19
- for (const mdl of modules) {
20
- mdl.requires
21
- .filter((dep) => {
22
- // Only track local modules, not node_modules
23
- return dep.startsWith('./') || dep.startsWith('../')
24
- })
25
- .forEach((dep) => {
26
- try {
27
- const basedir = path.dirname(mdl.file)
28
- const depPath = resolve.sync(dep, { basedir })
29
- const depModule = createModule(depPath)
30
-
31
- modules.push(depModule)
32
- } catch (_err) {
33
- // eslint-disable-next-line no-empty
34
- }
35
- })
36
- }
37
-
38
- return modules
39
- }
@@ -1,78 +0,0 @@
1
- import log from '../util/log'
2
-
3
- export default function normalizeTailwindDirectives(root) {
4
- let tailwindDirectives = new Set()
5
- let layerDirectives = new Set()
6
-
7
- root.walkAtRules((atRule) => {
8
- if (atRule.name === 'import') {
9
- if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
10
- atRule.name = 'tailwind'
11
- atRule.params = 'base'
12
- } else if (
13
- atRule.params === '"tailwindcss/components"' ||
14
- atRule.params === "'tailwindcss/components'"
15
- ) {
16
- atRule.name = 'tailwind'
17
- atRule.params = 'components'
18
- } else if (
19
- atRule.params === '"tailwindcss/utilities"' ||
20
- atRule.params === "'tailwindcss/utilities'"
21
- ) {
22
- atRule.name = 'tailwind'
23
- atRule.params = 'utilities'
24
- } else if (
25
- atRule.params === '"tailwindcss/screens"' ||
26
- atRule.params === "'tailwindcss/screens'" ||
27
- atRule.params === '"tailwindcss/variants"' ||
28
- atRule.params === "'tailwindcss/variants'"
29
- ) {
30
- atRule.name = 'tailwind'
31
- atRule.params = 'variants'
32
- }
33
- }
34
-
35
- if (atRule.name === 'tailwind') {
36
- if (atRule.params === 'screens') {
37
- atRule.params = 'variants'
38
- }
39
- tailwindDirectives.add(atRule.params)
40
- }
41
-
42
- if (['layer', 'responsive', 'variants'].includes(atRule.name)) {
43
- if (['responsive', 'variants'].includes(atRule.name)) {
44
- log.warn(`${atRule.name}-at-rule-deprecated`, [
45
- `The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
46
- `Use \`@layer utilities\` or \`@layer components\` instead.`,
47
- ])
48
- }
49
- layerDirectives.add(atRule)
50
- }
51
- })
52
-
53
- if (
54
- !tailwindDirectives.has('base') ||
55
- !tailwindDirectives.has('components') ||
56
- !tailwindDirectives.has('utilities')
57
- ) {
58
- for (let rule of layerDirectives) {
59
- if (rule.name === 'layer' && ['base', 'components', 'utilities'].includes(rule.params)) {
60
- if (!tailwindDirectives.has(rule.params)) {
61
- throw rule.error(
62
- `\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`
63
- )
64
- }
65
- } else if (rule.name === 'responsive') {
66
- if (!tailwindDirectives.has('utilities')) {
67
- throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.')
68
- }
69
- } else if (rule.name === 'variants') {
70
- if (!tailwindDirectives.has('utilities')) {
71
- throw rule.error('`@variants` is used but `@tailwind utilities` is missing.')
72
- }
73
- }
74
- }
75
- }
76
-
77
- return tailwindDirectives
78
- }