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,350 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.generateRules = exports.resolveMatches = void 0;
6
- var _postcss = _interopRequireDefault(require("postcss"));
7
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
8
- var _parseObjectStyles = _interopRequireDefault(require("../util/parseObjectStyles"));
9
- var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
10
- var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
11
- var _pluginUtils = require("../util/pluginUtils");
12
- function _interopRequireDefault(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- let classNameParser = (0, _postcssSelectorParser).default((selectors)=>{
18
- return selectors.first.filter(({ type })=>type === 'class'
19
- ).pop().value;
20
- });
21
- function getClassNameFromSelector(selector) {
22
- return classNameParser.transformSync(selector);
23
- }
24
- // Generate match permutations for a class candidate, like:
25
- // ['ring-offset-blue', '100']
26
- // ['ring-offset', 'blue-100']
27
- // ['ring', 'offset-blue-100']
28
- // Example with dynamic classes:
29
- // ['grid-cols', '[[linename],1fr,auto]']
30
- // ['grid', 'cols-[[linename],1fr,auto]']
31
- function* candidatePermutations(candidate, lastIndex = Infinity) {
32
- if (lastIndex < 0) {
33
- return;
34
- }
35
- let dashIdx;
36
- if (lastIndex === Infinity && candidate.endsWith(']')) {
37
- let bracketIdx = candidate.indexOf('[');
38
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
39
- // eg. string[]
40
- dashIdx = [
41
- '-',
42
- '/'
43
- ].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
44
- } else {
45
- dashIdx = candidate.lastIndexOf('-', lastIndex);
46
- }
47
- if (dashIdx < 0) {
48
- return;
49
- }
50
- let prefix = candidate.slice(0, dashIdx);
51
- let modifier = candidate.slice(dashIdx + 1);
52
- yield [
53
- prefix,
54
- modifier
55
- ];
56
- yield* candidatePermutations(candidate, dashIdx - 1);
57
- }
58
- function applyPrefix(matches, context) {
59
- if (matches.length === 0 || context.tailwindConfig.prefix === '') {
60
- return matches;
61
- }
62
- for (let match of matches){
63
- let [meta] = match;
64
- if (meta.options.respectPrefix) {
65
- let container = _postcss.default.root({
66
- nodes: [
67
- match[1].clone()
68
- ]
69
- });
70
- container.walkRules((r)=>{
71
- r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector);
72
- });
73
- match[1] = container.nodes[0];
74
- }
75
- }
76
- return matches;
77
- }
78
- function applyImportant(matches) {
79
- if (matches.length === 0) {
80
- return matches;
81
- }
82
- let result = [];
83
- for (let [meta, rule] of matches){
84
- let container = _postcss.default.root({
85
- nodes: [
86
- rule.clone()
87
- ]
88
- });
89
- container.walkRules((r)=>{
90
- r.selector = (0, _pluginUtils).updateAllClasses(r.selector, (className)=>{
91
- return `!${className}`;
92
- });
93
- r.walkDecls((d)=>d.important = true
94
- );
95
- });
96
- result.push([
97
- {
98
- ...meta,
99
- important: true
100
- },
101
- container.nodes[0]
102
- ]);
103
- }
104
- return result;
105
- }
106
- // Takes a list of rule tuples and applies a variant like `hover`, sm`,
107
- // whatever to it. We used to do some extra caching here to avoid generating
108
- // a variant of the same rule more than once, but this was never hit because
109
- // we cache at the entire selector level further up the tree.
110
- //
111
- // Technically you can get a cache hit if you have `hover:focus:text-center`
112
- // and `focus:hover:text-center` in the same project, but it doesn't feel
113
- // worth the complexity for that case.
114
- function applyVariant(variant, matches, context) {
115
- if (matches.length === 0) {
116
- return matches;
117
- }
118
- if (context.variantMap.has(variant)) {
119
- let variantFunctionTuples = context.variantMap.get(variant);
120
- let result = [];
121
- for (let [meta, rule] of matches){
122
- if (meta.options.respectVariants === false) {
123
- result.push([
124
- meta,
125
- rule
126
- ]);
127
- continue;
128
- }
129
- let container = _postcss.default.root({
130
- nodes: [
131
- rule.clone()
132
- ]
133
- });
134
- for (let [variantSort, variantFunction] of variantFunctionTuples){
135
- let clone = container.clone();
136
- function modifySelectors(modifierFunction) {
137
- clone.each((rule)=>{
138
- if (rule.type !== 'rule') {
139
- return;
140
- }
141
- rule.selectors = rule.selectors.map((selector)=>{
142
- return modifierFunction({
143
- get className () {
144
- return getClassNameFromSelector(selector);
145
- },
146
- selector
147
- });
148
- });
149
- });
150
- return clone;
151
- }
152
- let ruleWithVariant = variantFunction({
153
- container: clone,
154
- separator: context.tailwindConfig.separator,
155
- modifySelectors
156
- });
157
- if (ruleWithVariant === null) {
158
- continue;
159
- }
160
- let withOffset = [
161
- {
162
- ...meta,
163
- sort: variantSort | meta.sort
164
- },
165
- clone.nodes[0]
166
- ];
167
- result.push(withOffset);
168
- }
169
- }
170
- return result;
171
- }
172
- return [];
173
- }
174
- function parseRules(rule, cache, options = {
175
- }) {
176
- // PostCSS node
177
- if (!(0, _isPlainObject).default(rule) && !Array.isArray(rule)) {
178
- return [
179
- [
180
- rule
181
- ],
182
- options
183
- ];
184
- }
185
- // Tuple
186
- if (Array.isArray(rule)) {
187
- return parseRules(rule[0], cache, rule[1]);
188
- }
189
- // Simple object
190
- if (!cache.has(rule)) {
191
- cache.set(rule, (0, _parseObjectStyles).default(rule));
192
- }
193
- return [
194
- cache.get(rule),
195
- options
196
- ];
197
- }
198
- function* resolveMatchedPlugins(classCandidate, context) {
199
- if (context.candidateRuleMap.has(classCandidate)) {
200
- yield [
201
- context.candidateRuleMap.get(classCandidate),
202
- 'DEFAULT'
203
- ];
204
- }
205
- let candidatePrefix = classCandidate;
206
- let negative = false;
207
- const twConfigPrefix = context.tailwindConfig.prefix || '';
208
- const twConfigPrefixLen = twConfigPrefix.length;
209
- if (candidatePrefix[twConfigPrefixLen] === '-') {
210
- negative = true;
211
- candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
212
- }
213
- for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
214
- if (context.candidateRuleMap.has(prefix)) {
215
- yield [
216
- context.candidateRuleMap.get(prefix),
217
- negative ? `-${modifier}` : modifier
218
- ];
219
- return;
220
- }
221
- }
222
- }
223
- function splitWithSeparator(input, separator) {
224
- return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'));
225
- }
226
- function* resolveMatches(candidate, context) {
227
- let separator = context.tailwindConfig.separator;
228
- let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
229
- let important = false;
230
- if (classCandidate.startsWith('!')) {
231
- important = true;
232
- classCandidate = classCandidate.slice(1);
233
- }
234
- // TODO: Reintroduce this in ways that doesn't break on false positives
235
- // function sortAgainst(toSort, against) {
236
- // return toSort.slice().sort((a, z) => {
237
- // return bigSign(against.get(a)[0] - against.get(z)[0])
238
- // })
239
- // }
240
- // let sorted = sortAgainst(variants, context.variantMap)
241
- // if (sorted.toString() !== variants.toString()) {
242
- // let corrected = sorted.reverse().concat(classCandidate).join(':')
243
- // throw new Error(`Class ${candidate} should be written as ${corrected}`)
244
- // }
245
- for (let matchedPlugins of resolveMatchedPlugins(classCandidate, context)){
246
- let matches = [];
247
- let [plugins, modifier] = matchedPlugins;
248
- let isOnlyPlugin = plugins.length === 1;
249
- for (let [sort, plugin] of plugins){
250
- if (typeof plugin === 'function') {
251
- for (let ruleSet of [].concat(plugin(modifier, {
252
- isOnlyPlugin
253
- }))){
254
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
255
- for (let rule of rules){
256
- matches.push([
257
- {
258
- ...sort,
259
- options: {
260
- ...sort.options,
261
- ...options
262
- }
263
- },
264
- rule
265
- ]);
266
- }
267
- }
268
- } else if (modifier === 'DEFAULT') {
269
- let ruleSet = plugin;
270
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
271
- for (let rule of rules){
272
- matches.push([
273
- {
274
- ...sort,
275
- options: {
276
- ...sort.options,
277
- ...options
278
- }
279
- },
280
- rule
281
- ]);
282
- }
283
- }
284
- }
285
- matches = applyPrefix(matches, context);
286
- if (important) {
287
- matches = applyImportant(matches, context);
288
- }
289
- for (let variant of variants){
290
- matches = applyVariant(variant, matches, context);
291
- }
292
- for (let match of matches){
293
- yield match;
294
- }
295
- }
296
- }
297
- function inKeyframes(rule) {
298
- return rule.parent && rule.parent.type === 'atrule' && rule.parent.name === 'keyframes';
299
- }
300
- function generateRules(candidates, context) {
301
- let allRules = [];
302
- for (let candidate of candidates){
303
- if (context.notClassCache.has(candidate)) {
304
- continue;
305
- }
306
- if (context.classCache.has(candidate)) {
307
- allRules.push(context.classCache.get(candidate));
308
- continue;
309
- }
310
- let matches = Array.from(resolveMatches(candidate, context));
311
- if (matches.length === 0) {
312
- context.notClassCache.add(candidate);
313
- continue;
314
- }
315
- context.classCache.set(candidate, matches);
316
- allRules.push(matches);
317
- }
318
- return allRules.flat(1).map(([{ sort , layer , options }, rule])=>{
319
- if (options.respectImportant) {
320
- if (context.tailwindConfig.important === true) {
321
- rule.walkDecls((d)=>{
322
- if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
323
- d.important = true;
324
- }
325
- });
326
- } else if (typeof context.tailwindConfig.important === 'string') {
327
- let container = _postcss.default.root({
328
- nodes: [
329
- rule.clone()
330
- ]
331
- });
332
- container.walkRules((r)=>{
333
- if (inKeyframes(r)) {
334
- return;
335
- }
336
- r.selectors = r.selectors.map((selector)=>{
337
- return `${context.tailwindConfig.important} ${selector}`;
338
- });
339
- });
340
- rule = container.nodes[0];
341
- }
342
- }
343
- return [
344
- sort | context.layerOrder[layer],
345
- rule
346
- ];
347
- });
348
- }
349
- exports.resolveMatches = resolveMatches;
350
- exports.generateRules = generateRules;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = getModuleDependencies;
6
- var _fs = _interopRequireDefault(require("fs"));
7
- var _path = _interopRequireDefault(require("path"));
8
- var _resolve = _interopRequireDefault(require("resolve"));
9
- var _detective = _interopRequireDefault(require("detective"));
10
- function _interopRequireDefault(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- function createModule(file) {
16
- const source = _fs.default.readFileSync(file, 'utf-8');
17
- const requires = (0, _detective).default(source);
18
- return {
19
- file,
20
- requires
21
- };
22
- }
23
- function getModuleDependencies(entryFile) {
24
- const rootModule = createModule(entryFile);
25
- const modules = [
26
- rootModule
27
- ];
28
- // Iterate over the modules, even when new
29
- // ones are being added
30
- for (const mdl of modules){
31
- mdl.requires.filter((dep)=>{
32
- // Only track local modules, not node_modules
33
- return dep.startsWith('./') || dep.startsWith('../');
34
- }).forEach((dep)=>{
35
- try {
36
- const basedir = _path.default.dirname(mdl.file);
37
- const depPath = _resolve.default.sync(dep, {
38
- basedir
39
- });
40
- const depModule = createModule(depPath);
41
- modules.push(depModule);
42
- } catch (_err) {
43
- // eslint-disable-next-line no-empty
44
- }
45
- });
46
- }
47
- return modules;
48
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = normalizeTailwindDirectives;
6
- var _log = _interopRequireDefault(require("../util/log"));
7
- function _interopRequireDefault(obj) {
8
- return obj && obj.__esModule ? obj : {
9
- default: obj
10
- };
11
- }
12
- function normalizeTailwindDirectives(root) {
13
- let tailwindDirectives = new Set();
14
- let layerDirectives = new Set();
15
- root.walkAtRules((atRule)=>{
16
- if (atRule.name === 'import') {
17
- if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
18
- atRule.name = 'tailwind';
19
- atRule.params = 'base';
20
- } else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
21
- atRule.name = 'tailwind';
22
- atRule.params = 'components';
23
- } else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
24
- atRule.name = 'tailwind';
25
- atRule.params = 'utilities';
26
- } else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
27
- atRule.name = 'tailwind';
28
- atRule.params = 'variants';
29
- }
30
- }
31
- if (atRule.name === 'tailwind') {
32
- if (atRule.params === 'screens') {
33
- atRule.params = 'variants';
34
- }
35
- tailwindDirectives.add(atRule.params);
36
- }
37
- if ([
38
- 'layer',
39
- 'responsive',
40
- 'variants'
41
- ].includes(atRule.name)) {
42
- if ([
43
- 'responsive',
44
- 'variants'
45
- ].includes(atRule.name)) {
46
- _log.default.warn([
47
- `'@${atRule.name}' is deprecated, use '@layer utilities' or '@layer components' instead.`,
48
- ]);
49
- }
50
- layerDirectives.add(atRule);
51
- }
52
- });
53
- if (!tailwindDirectives.has('base') || !tailwindDirectives.has('components') || !tailwindDirectives.has('utilities')) {
54
- for (let rule of layerDirectives){
55
- if (rule.name === 'layer' && [
56
- 'base',
57
- 'components',
58
- 'utilities'
59
- ].includes(rule.params)) {
60
- if (!tailwindDirectives.has(rule.params)) {
61
- throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
62
- }
63
- } else if (rule.name === 'responsive') {
64
- if (!tailwindDirectives.has('utilities')) {
65
- throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.');
66
- }
67
- } else if (rule.name === 'variants') {
68
- if (!tailwindDirectives.has('utilities')) {
69
- throw rule.error('`@variants` is used but `@tailwind utilities` is missing.');
70
- }
71
- }
72
- }
73
- }
74
- return tailwindDirectives;
75
- }
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = resolveDefaultsAtRules;
6
- var _postcss = _interopRequireDefault(require("postcss"));
7
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
8
- var _featureFlags = require("../featureFlags");
9
- function _interopRequireDefault(obj) {
10
- return obj && obj.__esModule ? obj : {
11
- default: obj
12
- };
13
- }
14
- function isPseudoElement(n) {
15
- if (n.type !== 'pseudo') {
16
- return false;
17
- }
18
- return n.value.startsWith('::') || [
19
- ':before',
20
- ':after',
21
- ':first-line',
22
- ':first-letter'
23
- ].includes(n.value);
24
- }
25
- function minimumImpactSelector(nodes) {
26
- let rest = nodes// Keep all pseudo & combinator types (:not([hidden]) ~ :not([hidden]))
27
- .filter((n)=>n.type === 'pseudo' || n.type === 'combinator'
28
- )// Remove leading pseudo's (:hover, :focus, ...)
29
- .filter((n, idx, all)=>{
30
- // Keep pseudo elements
31
- if (isPseudoElement(n)) return true;
32
- if (idx === 0 && n.type === 'pseudo') return false;
33
- if (idx > 0 && n.type === 'pseudo' && all[idx - 1].type === 'pseudo') return false;
34
- return true;
35
- });
36
- let [bestNode] = nodes;
37
- for (let [type, getNode = (n)=>n
38
- ] of [
39
- [
40
- 'class'
41
- ],
42
- [
43
- 'id',
44
- (n)=>_postcssSelectorParser.default.attribute({
45
- attribute: 'id',
46
- operator: '=',
47
- value: n.value,
48
- quoteMark: '"'
49
- })
50
- ,
51
- ],
52
- [
53
- 'attribute'
54
- ],
55
- ]){
56
- let match = nodes.find((n)=>n.type === type
57
- );
58
- if (match) {
59
- bestNode = getNode(match);
60
- break;
61
- }
62
- }
63
- return [
64
- bestNode,
65
- ...rest
66
- ].join('').trim();
67
- }
68
- let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
69
- return selectors.map((s)=>{
70
- let nodes = s.split((n)=>n.type === 'combinator' && n.value === ' '
71
- ).pop();
72
- return minimumImpactSelector(nodes);
73
- });
74
- });
75
- let cache = new Map();
76
- function extractElementSelector(selector) {
77
- if (!cache.has(selector)) {
78
- cache.set(selector, elementSelectorParser.transformSync(selector));
79
- }
80
- return cache.get(selector);
81
- }
82
- function resolveDefaultsAtRules({ tailwindConfig }) {
83
- return (root)=>{
84
- let variableNodeMap = new Map();
85
- let universals = new Set();
86
- root.walkAtRules('defaults', (rule)=>{
87
- if (rule.nodes && rule.nodes.length > 0) {
88
- universals.add(rule);
89
- return;
90
- }
91
- let variable = rule.params;
92
- if (!variableNodeMap.has(variable)) {
93
- variableNodeMap.set(variable, new Set());
94
- }
95
- variableNodeMap.get(variable).add(rule.parent);
96
- rule.remove();
97
- });
98
- for (let universal of universals){
99
- let selectors = new Set();
100
- var ref;
101
- let rules = (ref = variableNodeMap.get(universal.params)) !== null && ref !== void 0 ? ref : [];
102
- for (let rule of rules){
103
- for (let selector of extractElementSelector(rule.selector)){
104
- selectors.add(selector);
105
- }
106
- }
107
- if (selectors.size === 0) {
108
- universal.remove();
109
- continue;
110
- }
111
- let universalRule = _postcss.default.rule();
112
- if ((0, _featureFlags).flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
113
- universalRule.selectors = [
114
- ...selectors
115
- ];
116
- } else {
117
- universalRule.selectors = [
118
- '*',
119
- '::before',
120
- '::after'
121
- ];
122
- }
123
- universalRule.append(universal.nodes);
124
- universal.before(universalRule);
125
- universal.remove();
126
- }
127
- };
128
- }