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