tailwindcss 0.0.0-insiders.bbafc8e → 0.0.0-insiders.bbc2f3f

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 (198) hide show
  1. package/README.md +16 -13
  2. package/dist/chunk-5C7JPVMO.mjs +10 -0
  3. package/dist/chunk-AZANAYY2.mjs +1 -0
  4. package/dist/chunk-V2K3XTS4.mjs +1 -0
  5. package/dist/colors-b_6i0Oi7.d.ts +295 -0
  6. package/dist/colors.d.mts +295 -0
  7. package/dist/colors.d.ts +5 -0
  8. package/dist/colors.js +1 -0
  9. package/dist/colors.mjs +1 -0
  10. package/dist/default-theme.d.mts +1147 -0
  11. package/dist/default-theme.d.ts +1147 -0
  12. package/dist/default-theme.js +1 -0
  13. package/dist/default-theme.mjs +1 -0
  14. package/dist/flatten-color-palette.d.mts +6 -0
  15. package/dist/flatten-color-palette.d.ts +6 -0
  16. package/dist/flatten-color-palette.js +1 -0
  17. package/dist/flatten-color-palette.mjs +1 -0
  18. package/dist/lib.d.mts +260 -0
  19. package/dist/lib.d.ts +3 -0
  20. package/dist/lib.js +33 -0
  21. package/dist/lib.mjs +24 -0
  22. package/dist/plugin.d.mts +11 -0
  23. package/dist/plugin.d.ts +104 -0
  24. package/dist/plugin.js +1 -0
  25. package/dist/plugin.mjs +1 -0
  26. package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
  27. package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
  28. package/dist/types-B254mqw1.d.mts +98 -0
  29. package/index.css +865 -0
  30. package/package.json +73 -95
  31. package/preflight.css +383 -0
  32. package/theme.css +453 -0
  33. package/CHANGELOG.md +0 -2084
  34. package/base.css +0 -1
  35. package/colors.js +0 -2
  36. package/components.css +0 -1
  37. package/defaultConfig.js +0 -2
  38. package/defaultTheme.js +0 -2
  39. package/lib/cli-peer-dependencies.js +0 -15
  40. package/lib/cli.js +0 -741
  41. package/lib/constants.js +0 -37
  42. package/lib/corePluginList.js +0 -178
  43. package/lib/corePlugins.js +0 -3587
  44. package/lib/css/LICENSE +0 -25
  45. package/lib/css/preflight.css +0 -367
  46. package/lib/featureFlags.js +0 -59
  47. package/lib/index.js +0 -41
  48. package/lib/lib/cacheInvalidation.js +0 -69
  49. package/lib/lib/collapseAdjacentRules.js +0 -54
  50. package/lib/lib/collapseDuplicateDeclarations.js +0 -80
  51. package/lib/lib/defaultExtractor.js +0 -44
  52. package/lib/lib/detectNesting.js +0 -34
  53. package/lib/lib/evaluateTailwindFunctions.js +0 -171
  54. package/lib/lib/expandApplyAtRules.js +0 -433
  55. package/lib/lib/expandTailwindAtRules.js +0 -262
  56. package/lib/lib/generateRules.js +0 -631
  57. package/lib/lib/getModuleDependencies.js +0 -48
  58. package/lib/lib/normalizeTailwindDirectives.js +0 -84
  59. package/lib/lib/partitionApplyAtRules.js +0 -53
  60. package/lib/lib/resolveDefaultsAtRules.js +0 -143
  61. package/lib/lib/setupContextUtils.js +0 -859
  62. package/lib/lib/setupTrackingContext.js +0 -171
  63. package/lib/lib/sharedState.js +0 -52
  64. package/lib/lib/substituteScreenAtRules.js +0 -27
  65. package/lib/postcss-plugins/nesting/README.md +0 -42
  66. package/lib/postcss-plugins/nesting/index.js +0 -17
  67. package/lib/postcss-plugins/nesting/plugin.js +0 -85
  68. package/lib/processTailwindFeatures.js +0 -59
  69. package/lib/public/colors.js +0 -329
  70. package/lib/public/create-plugin.js +0 -13
  71. package/lib/public/default-config.js +0 -14
  72. package/lib/public/default-theme.js +0 -14
  73. package/lib/public/resolve-config.js +0 -19
  74. package/lib/util/bigSign.js +0 -8
  75. package/lib/util/buildMediaQuery.js +0 -20
  76. package/lib/util/cloneDeep.js +0 -19
  77. package/lib/util/cloneNodes.js +0 -25
  78. package/lib/util/color.js +0 -99
  79. package/lib/util/configurePlugins.js +0 -18
  80. package/lib/util/createPlugin.js +0 -29
  81. package/lib/util/createUtilityPlugin.js +0 -49
  82. package/lib/util/dataTypes.js +0 -233
  83. package/lib/util/defaults.js +0 -22
  84. package/lib/util/escapeClassName.js +0 -19
  85. package/lib/util/escapeCommas.js +0 -8
  86. package/lib/util/flattenColorPalette.js +0 -17
  87. package/lib/util/formatVariantSelector.js +0 -186
  88. package/lib/util/getAllConfigs.js +0 -29
  89. package/lib/util/hashConfig.js +0 -16
  90. package/lib/util/isKeyframeRule.js +0 -8
  91. package/lib/util/isPlainObject.js +0 -12
  92. package/lib/util/isValidArbitraryValue.js +0 -64
  93. package/lib/util/log.js +0 -51
  94. package/lib/util/nameClass.js +0 -32
  95. package/lib/util/negateValue.js +0 -19
  96. package/lib/util/normalizeConfig.js +0 -240
  97. package/lib/util/normalizeScreens.js +0 -59
  98. package/lib/util/parseAnimationValue.js +0 -89
  99. package/lib/util/parseBoxShadowValue.js +0 -117
  100. package/lib/util/parseDependency.js +0 -63
  101. package/lib/util/parseObjectStyles.js +0 -31
  102. package/lib/util/pluginUtils.js +0 -179
  103. package/lib/util/prefixSelector.js +0 -20
  104. package/lib/util/resolveConfig.js +0 -255
  105. package/lib/util/resolveConfigPath.js +0 -51
  106. package/lib/util/responsive.js +0 -19
  107. package/lib/util/tap.js +0 -9
  108. package/lib/util/toColorValue.js +0 -8
  109. package/lib/util/toPath.js +0 -14
  110. package/lib/util/transformThemeValue.js +0 -59
  111. package/lib/util/withAlphaVariable.js +0 -67
  112. package/nesting/index.js +0 -2
  113. package/peers/index.js +0 -75077
  114. package/plugin.js +0 -2
  115. package/prettier.config.js +0 -19
  116. package/resolveConfig.js +0 -2
  117. package/screens.css +0 -1
  118. package/scripts/create-plugin-list.js +0 -10
  119. package/scripts/install-integrations.js +0 -27
  120. package/scripts/rebuildFixtures.js +0 -68
  121. package/src/cli-peer-dependencies.js +0 -9
  122. package/src/cli.js +0 -815
  123. package/src/constants.js +0 -17
  124. package/src/corePluginList.js +0 -1
  125. package/src/corePlugins.js +0 -2365
  126. package/src/css/LICENSE +0 -25
  127. package/src/css/preflight.css +0 -367
  128. package/src/featureFlags.js +0 -54
  129. package/src/index.js +0 -42
  130. package/src/lib/cacheInvalidation.js +0 -52
  131. package/src/lib/collapseAdjacentRules.js +0 -54
  132. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  133. package/src/lib/defaultExtractor.js +0 -50
  134. package/src/lib/detectNesting.js +0 -39
  135. package/src/lib/evaluateTailwindFunctions.js +0 -198
  136. package/src/lib/expandApplyAtRules.js +0 -480
  137. package/src/lib/expandTailwindAtRules.js +0 -292
  138. package/src/lib/generateRules.js +0 -623
  139. package/src/lib/getModuleDependencies.js +0 -39
  140. package/src/lib/normalizeTailwindDirectives.js +0 -84
  141. package/src/lib/partitionApplyAtRules.js +0 -52
  142. package/src/lib/resolveDefaultsAtRules.js +0 -146
  143. package/src/lib/setupContextUtils.js +0 -883
  144. package/src/lib/setupTrackingContext.js +0 -183
  145. package/src/lib/sharedState.js +0 -48
  146. package/src/lib/substituteScreenAtRules.js +0 -19
  147. package/src/postcss-plugins/nesting/README.md +0 -42
  148. package/src/postcss-plugins/nesting/index.js +0 -13
  149. package/src/postcss-plugins/nesting/plugin.js +0 -80
  150. package/src/processTailwindFeatures.js +0 -58
  151. package/src/public/colors.js +0 -300
  152. package/src/public/create-plugin.js +0 -2
  153. package/src/public/default-config.js +0 -4
  154. package/src/public/default-theme.js +0 -4
  155. package/src/public/resolve-config.js +0 -7
  156. package/src/util/bigSign.js +0 -3
  157. package/src/util/buildMediaQuery.js +0 -20
  158. package/src/util/cloneDeep.js +0 -11
  159. package/src/util/cloneNodes.js +0 -24
  160. package/src/util/color.js +0 -69
  161. package/src/util/configurePlugins.js +0 -23
  162. package/src/util/createPlugin.js +0 -27
  163. package/src/util/createUtilityPlugin.js +0 -37
  164. package/src/util/dataTypes.js +0 -248
  165. package/src/util/defaults.js +0 -17
  166. package/src/util/escapeClassName.js +0 -8
  167. package/src/util/escapeCommas.js +0 -3
  168. package/src/util/flattenColorPalette.js +0 -13
  169. package/src/util/formatVariantSelector.js +0 -196
  170. package/src/util/getAllConfigs.js +0 -19
  171. package/src/util/hashConfig.js +0 -5
  172. package/src/util/isKeyframeRule.js +0 -3
  173. package/src/util/isPlainObject.js +0 -8
  174. package/src/util/isValidArbitraryValue.js +0 -61
  175. package/src/util/log.js +0 -29
  176. package/src/util/nameClass.js +0 -26
  177. package/src/util/negateValue.js +0 -16
  178. package/src/util/normalizeConfig.js +0 -270
  179. package/src/util/normalizeScreens.js +0 -45
  180. package/src/util/parseAnimationValue.js +0 -68
  181. package/src/util/parseBoxShadowValue.js +0 -119
  182. package/src/util/parseDependency.js +0 -49
  183. package/src/util/parseObjectStyles.js +0 -19
  184. package/src/util/pluginUtils.js +0 -192
  185. package/src/util/prefixSelector.js +0 -14
  186. package/src/util/resolveConfig.js +0 -269
  187. package/src/util/resolveConfigPath.js +0 -55
  188. package/src/util/responsive.js +0 -10
  189. package/src/util/tap.js +0 -4
  190. package/src/util/toColorValue.js +0 -3
  191. package/src/util/toPath.js +0 -26
  192. package/src/util/transformThemeValue.js +0 -52
  193. package/src/util/withAlphaVariable.js +0 -49
  194. package/stubs/defaultConfig.stub.js +0 -950
  195. package/stubs/defaultPostCssConfig.stub.js +0 -6
  196. package/stubs/simpleConfig.stub.js +0 -7
  197. package/tailwind.css +0 -5
  198. package/variants.css +0 -1
@@ -1,631 +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
- var _log = _interopRequireDefault(require("../util/log"));
13
- var sharedState = _interopRequireWildcard(require("./sharedState"));
14
- var _formatVariantSelector = require("../util/formatVariantSelector");
15
- var _nameClass = require("../util/nameClass");
16
- var _dataTypes = require("../util/dataTypes");
17
- var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
18
- function _interopRequireDefault(obj) {
19
- return obj && obj.__esModule ? obj : {
20
- default: obj
21
- };
22
- }
23
- function _interopRequireWildcard(obj) {
24
- if (obj && obj.__esModule) {
25
- return obj;
26
- } else {
27
- var newObj = {};
28
- if (obj != null) {
29
- for(var key in obj){
30
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
31
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
32
- if (desc.get || desc.set) {
33
- Object.defineProperty(newObj, key, desc);
34
- } else {
35
- newObj[key] = obj[key];
36
- }
37
- }
38
- }
39
- }
40
- newObj.default = obj;
41
- return newObj;
42
- }
43
- }
44
- let classNameParser = (0, _postcssSelectorParser).default((selectors)=>{
45
- return selectors.first.filter(({ type })=>type === 'class'
46
- ).pop().value;
47
- });
48
- function getClassNameFromSelector(selector) {
49
- return classNameParser.transformSync(selector);
50
- }
51
- // Generate match permutations for a class candidate, like:
52
- // ['ring-offset-blue', '100']
53
- // ['ring-offset', 'blue-100']
54
- // ['ring', 'offset-blue-100']
55
- // Example with dynamic classes:
56
- // ['grid-cols', '[[linename],1fr,auto]']
57
- // ['grid', 'cols-[[linename],1fr,auto]']
58
- function* candidatePermutations(candidate) {
59
- let lastIndex = Infinity;
60
- while(lastIndex >= 0){
61
- let dashIdx;
62
- if (lastIndex === Infinity && candidate.endsWith(']')) {
63
- let bracketIdx = candidate.indexOf('[');
64
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
65
- // eg. string[]
66
- dashIdx = [
67
- '-',
68
- '/'
69
- ].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
70
- } else {
71
- dashIdx = candidate.lastIndexOf('-', lastIndex);
72
- }
73
- if (dashIdx < 0) {
74
- break;
75
- }
76
- let prefix = candidate.slice(0, dashIdx);
77
- let modifier = candidate.slice(dashIdx + 1);
78
- yield [
79
- prefix,
80
- modifier
81
- ];
82
- lastIndex = dashIdx - 1;
83
- }
84
- }
85
- function applyPrefix(matches, context) {
86
- if (matches.length === 0 || context.tailwindConfig.prefix === '') {
87
- return matches;
88
- }
89
- for (let match of matches){
90
- let [meta] = match;
91
- if (meta.options.respectPrefix) {
92
- let container = _postcss.default.root({
93
- nodes: [
94
- match[1].clone()
95
- ]
96
- });
97
- let classCandidate = match[1].raws.tailwind.classCandidate;
98
- container.walkRules((r)=>{
99
- // If this is a negative utility with a dash *before* the prefix we
100
- // have to ensure that the generated selector matches the candidate
101
- // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
102
- // The disconnect between candidate <-> class can cause @apply to hard crash.
103
- let shouldPrependNegative = classCandidate.startsWith('-');
104
- r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
105
- });
106
- match[1] = container.nodes[0];
107
- }
108
- }
109
- return matches;
110
- }
111
- function applyImportant(matches, classCandidate) {
112
- if (matches.length === 0) {
113
- return matches;
114
- }
115
- let result = [];
116
- for (let [meta, rule] of matches){
117
- let container = _postcss.default.root({
118
- nodes: [
119
- rule.clone()
120
- ]
121
- });
122
- container.walkRules((r)=>{
123
- r.selector = (0, _pluginUtils).updateAllClasses(r.selector, (className)=>{
124
- if (className === classCandidate) {
125
- return `!${className}`;
126
- }
127
- return className;
128
- });
129
- r.walkDecls((d)=>d.important = true
130
- );
131
- });
132
- result.push([
133
- {
134
- ...meta,
135
- important: true
136
- },
137
- container.nodes[0]
138
- ]);
139
- }
140
- return result;
141
- }
142
- // Takes a list of rule tuples and applies a variant like `hover`, sm`,
143
- // whatever to it. We used to do some extra caching here to avoid generating
144
- // a variant of the same rule more than once, but this was never hit because
145
- // we cache at the entire selector level further up the tree.
146
- //
147
- // Technically you can get a cache hit if you have `hover:focus:text-center`
148
- // and `focus:hover:text-center` in the same project, but it doesn't feel
149
- // worth the complexity for that case.
150
- function applyVariant(variant, matches, context) {
151
- if (matches.length === 0) {
152
- return matches;
153
- }
154
- if (context.variantMap.has(variant)) {
155
- let variantFunctionTuples = context.variantMap.get(variant);
156
- let result = [];
157
- for (let [meta, rule1] of matches){
158
- // Don't generate variants for user css
159
- if (meta.layer === 'user') {
160
- continue;
161
- }
162
- let container = _postcss.default.root({
163
- nodes: [
164
- rule1.clone()
165
- ]
166
- });
167
- for (let [variantSort, variantFunction] of variantFunctionTuples){
168
- let clone = container.clone();
169
- let collectedFormats = [];
170
- let originals = new Map();
171
- function prepareBackup() {
172
- if (originals.size > 0) return; // Already prepared, chicken out
173
- clone.walkRules((rule)=>originals.set(rule, rule.selector)
174
- );
175
- }
176
- function modifySelectors(modifierFunction) {
177
- prepareBackup();
178
- clone.each((rule)=>{
179
- if (rule.type !== 'rule') {
180
- return;
181
- }
182
- rule.selectors = rule.selectors.map((selector)=>{
183
- return modifierFunction({
184
- get className () {
185
- return getClassNameFromSelector(selector);
186
- },
187
- selector
188
- });
189
- });
190
- });
191
- return clone;
192
- }
193
- let ruleWithVariant = variantFunction({
194
- // Public API
195
- get container () {
196
- prepareBackup();
197
- return clone;
198
- },
199
- separator: context.tailwindConfig.separator,
200
- modifySelectors,
201
- // Private API for now
202
- wrap (wrapper) {
203
- let nodes = clone.nodes;
204
- clone.removeAll();
205
- wrapper.append(nodes);
206
- clone.append(wrapper);
207
- },
208
- format (selectorFormat) {
209
- collectedFormats.push(selectorFormat);
210
- }
211
- });
212
- if (typeof ruleWithVariant === 'string') {
213
- collectedFormats.push(ruleWithVariant);
214
- }
215
- if (ruleWithVariant === null) {
216
- continue;
217
- }
218
- // We filled the `originals`, therefore we assume that somebody touched
219
- // `container` or `modifySelectors`. Let's see if they did, so that we
220
- // can restore the selectors, and collect the format strings.
221
- if (originals.size > 0) {
222
- clone.walkRules((rule)=>{
223
- if (!originals.has(rule)) return;
224
- let before = originals.get(rule);
225
- if (before === rule.selector) return; // No mutation happened
226
- let modified = rule.selector;
227
- // Rebuild the base selector, this is what plugin authors would do
228
- // as well. E.g.: `${variant}${separator}${className}`.
229
- // However, plugin authors probably also prepend or append certain
230
- // classes, pseudos, ids, ...
231
- let rebuiltBase = (0, _postcssSelectorParser).default((selectors)=>{
232
- selectors.walkClasses((classNode)=>{
233
- classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
234
- });
235
- }).processSync(before);
236
- // Now that we know the original selector, the new selector, and
237
- // the rebuild part in between, we can replace the part that plugin
238
- // authors need to rebuild with `&`, and eventually store it in the
239
- // collectedFormats. Similar to what `format('...')` would do.
240
- //
241
- // E.g.:
242
- // variant: foo
243
- // selector: .markdown > p
244
- // modified (by plugin): .foo .foo\\:markdown > p
245
- // rebuiltBase (internal): .foo\\:markdown > p
246
- // format: .foo &
247
- collectedFormats.push(modified.replace(rebuiltBase, '&'));
248
- rule.selector = before;
249
- });
250
- }
251
- // This tracks the originating layer for the variant
252
- // For example:
253
- // .sm:underline {} is a variant of something in the utilities layer
254
- // .sm:container {} is a variant of the container component
255
- clone.nodes[0].raws.tailwind = {
256
- ...clone.nodes[0].raws.tailwind,
257
- parentLayer: meta.layer
258
- };
259
- var _collectedFormats;
260
- let withOffset = [
261
- {
262
- ...meta,
263
- sort: variantSort | meta.sort,
264
- collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats)
265
- },
266
- clone.nodes[0],
267
- ];
268
- result.push(withOffset);
269
- }
270
- }
271
- return result;
272
- }
273
- return [];
274
- }
275
- function parseRules(rule, cache, options = {}) {
276
- // PostCSS node
277
- if (!(0, _isPlainObject).default(rule) && !Array.isArray(rule)) {
278
- return [
279
- [
280
- rule
281
- ],
282
- options
283
- ];
284
- }
285
- // Tuple
286
- if (Array.isArray(rule)) {
287
- return parseRules(rule[0], cache, rule[1]);
288
- }
289
- // Simple object
290
- if (!cache.has(rule)) {
291
- cache.set(rule, (0, _parseObjectStyles).default(rule));
292
- }
293
- return [
294
- cache.get(rule),
295
- options
296
- ];
297
- }
298
- const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
299
- function isValidPropName(name) {
300
- return IS_VALID_PROPERTY_NAME.test(name);
301
- }
302
- /**
303
- * @param {string} declaration
304
- * @returns {boolean}
305
- */ function looksLikeUri(declaration) {
306
- // Quick bailout for obvious non-urls
307
- // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
308
- if (!declaration.includes('://')) {
309
- return false;
310
- }
311
- try {
312
- const url = new URL(declaration);
313
- return url.scheme !== '' && url.host !== '';
314
- } catch (err) {
315
- // Definitely not a valid url
316
- return false;
317
- }
318
- }
319
- function isParsableCssValue(property, value) {
320
- // We don't want to to treat [https://example.com] as a custom property
321
- // Even though, according to the CSS grammar, it's a totally valid CSS declaration
322
- // So we short-circuit here by checking if the custom property looks like a url
323
- if (looksLikeUri(`${property}:${value}`)) {
324
- return false;
325
- }
326
- try {
327
- _postcss.default.parse(`a{${property}:${value}}`).toResult();
328
- return true;
329
- } catch (err) {
330
- return false;
331
- }
332
- }
333
- function extractArbitraryProperty(classCandidate, context) {
334
- var ref;
335
- let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
336
- if (value === undefined) {
337
- return null;
338
- }
339
- if (!isValidPropName(property)) {
340
- return null;
341
- }
342
- if (!(0, _isValidArbitraryValue).default(value)) {
343
- return null;
344
- }
345
- let normalized = (0, _dataTypes).normalize(value);
346
- if (!isParsableCssValue(property, normalized)) {
347
- return null;
348
- }
349
- return [
350
- [
351
- {
352
- sort: context.arbitraryPropertiesSort,
353
- layer: 'utilities'
354
- },
355
- ()=>({
356
- [(0, _nameClass).asClass(classCandidate)]: {
357
- [property]: normalized
358
- }
359
- })
360
- ,
361
- ],
362
- ];
363
- }
364
- function* resolveMatchedPlugins(classCandidate, context) {
365
- if (context.candidateRuleMap.has(classCandidate)) {
366
- yield [
367
- context.candidateRuleMap.get(classCandidate),
368
- 'DEFAULT'
369
- ];
370
- }
371
- yield* (function*(arbitraryPropertyRule) {
372
- if (arbitraryPropertyRule !== null) {
373
- yield [
374
- arbitraryPropertyRule,
375
- 'DEFAULT'
376
- ];
377
- }
378
- })(extractArbitraryProperty(classCandidate, context));
379
- let candidatePrefix = classCandidate;
380
- let negative = false;
381
- const twConfigPrefix = context.tailwindConfig.prefix;
382
- const twConfigPrefixLen = twConfigPrefix.length;
383
- if (candidatePrefix[twConfigPrefixLen] === '-') {
384
- negative = true;
385
- candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
386
- }
387
- if (negative && context.candidateRuleMap.has(candidatePrefix)) {
388
- yield [
389
- context.candidateRuleMap.get(candidatePrefix),
390
- '-DEFAULT'
391
- ];
392
- }
393
- for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
394
- if (context.candidateRuleMap.has(prefix)) {
395
- yield [
396
- context.candidateRuleMap.get(prefix),
397
- negative ? `-${modifier}` : modifier
398
- ];
399
- }
400
- }
401
- }
402
- function splitWithSeparator(input, separator) {
403
- if (input === sharedState.NOT_ON_DEMAND) {
404
- return [
405
- sharedState.NOT_ON_DEMAND
406
- ];
407
- }
408
- return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'));
409
- }
410
- function* recordCandidates(matches, classCandidate) {
411
- for (const match of matches){
412
- match[1].raws.tailwind = {
413
- ...match[1].raws.tailwind,
414
- classCandidate
415
- };
416
- yield match;
417
- }
418
- }
419
- function* resolveMatches(candidate, context) {
420
- let separator = context.tailwindConfig.separator;
421
- let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
422
- let important = false;
423
- if (classCandidate.startsWith('!')) {
424
- important = true;
425
- classCandidate = classCandidate.slice(1);
426
- }
427
- // TODO: Reintroduce this in ways that doesn't break on false positives
428
- // function sortAgainst(toSort, against) {
429
- // return toSort.slice().sort((a, z) => {
430
- // return bigSign(against.get(a)[0] - against.get(z)[0])
431
- // })
432
- // }
433
- // let sorted = sortAgainst(variants, context.variantMap)
434
- // if (sorted.toString() !== variants.toString()) {
435
- // let corrected = sorted.reverse().concat(classCandidate).join(':')
436
- // throw new Error(`Class ${candidate} should be written as ${corrected}`)
437
- // }
438
- for (let matchedPlugins of resolveMatchedPlugins(classCandidate, context)){
439
- let matches = [];
440
- let typesByMatches = new Map();
441
- let [plugins, modifier] = matchedPlugins;
442
- let isOnlyPlugin = plugins.length === 1;
443
- for (let [sort, plugin] of plugins){
444
- let matchesPerPlugin = [];
445
- if (typeof plugin === 'function') {
446
- for (let ruleSet of [].concat(plugin(modifier, {
447
- isOnlyPlugin
448
- }))){
449
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
450
- for (let rule of rules){
451
- matchesPerPlugin.push([
452
- {
453
- ...sort,
454
- options: {
455
- ...sort.options,
456
- ...options
457
- }
458
- },
459
- rule
460
- ]);
461
- }
462
- }
463
- } else if (modifier === 'DEFAULT' || modifier === '-DEFAULT') {
464
- let ruleSet = plugin;
465
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
466
- for (let rule of rules){
467
- matchesPerPlugin.push([
468
- {
469
- ...sort,
470
- options: {
471
- ...sort.options,
472
- ...options
473
- }
474
- },
475
- rule
476
- ]);
477
- }
478
- }
479
- if (matchesPerPlugin.length > 0) {
480
- var ref;
481
- typesByMatches.set(matchesPerPlugin, (ref = sort.options) === null || ref === void 0 ? void 0 : ref.type);
482
- matches.push(matchesPerPlugin);
483
- }
484
- }
485
- // Only keep the result of the very first plugin if we are dealing with
486
- // arbitrary values, to protect against ambiguity.
487
- if (isArbitraryValue(modifier) && matches.length > 1) {
488
- var ref1;
489
- let typesPerPlugin = matches.map((match)=>new Set([
490
- ...(ref1 = typesByMatches.get(match)) !== null && ref1 !== void 0 ? ref1 : []
491
- ])
492
- );
493
- // Remove duplicates, so that we can detect proper unique types for each plugin.
494
- for (let pluginTypes of typesPerPlugin){
495
- for (let type of pluginTypes){
496
- let removeFromOwnGroup = false;
497
- for (let otherGroup of typesPerPlugin){
498
- if (pluginTypes === otherGroup) continue;
499
- if (otherGroup.has(type)) {
500
- otherGroup.delete(type);
501
- removeFromOwnGroup = true;
502
- }
503
- }
504
- if (removeFromOwnGroup) pluginTypes.delete(type);
505
- }
506
- }
507
- let messages = [];
508
- for (let [idx, group] of typesPerPlugin.entries()){
509
- for (let type of group){
510
- let rules = matches[idx].map(([, rule])=>rule
511
- ).flat().map((rule)=>rule.toString().split('\n').slice(1, -1) // Remove selector and closing '}'
512
- .map((line)=>line.trim()
513
- ).map((x)=>` ${x}`
514
- ) // Re-indent
515
- .join('\n')
516
- ).join('\n\n');
517
- messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``);
518
- break;
519
- }
520
- }
521
- _log.default.warn([
522
- `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
523
- ...messages,
524
- `If this is content and not a class, replace it with \`${candidate.replace('[', '&lsqb;').replace(']', '&rsqb;')}\` to silence this warning.`,
525
- ]);
526
- continue;
527
- }
528
- matches = matches.flat();
529
- matches = Array.from(recordCandidates(matches, classCandidate));
530
- matches = applyPrefix(matches, context);
531
- if (important) {
532
- matches = applyImportant(matches, classCandidate);
533
- }
534
- for (let variant of variants){
535
- matches = applyVariant(variant, matches, context);
536
- }
537
- for (let match1 of matches){
538
- match1[1].raws.tailwind = {
539
- ...match1[1].raws.tailwind,
540
- candidate
541
- };
542
- // Apply final format selector
543
- if (match1[0].collectedFormats) {
544
- let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...match1[0].collectedFormats);
545
- let container = _postcss.default.root({
546
- nodes: [
547
- match1[1].clone()
548
- ]
549
- });
550
- container.walkRules((rule)=>{
551
- if (inKeyframes(rule)) return;
552
- rule.selector = (0, _formatVariantSelector).finalizeSelector(finalFormat, {
553
- selector: rule.selector,
554
- candidate,
555
- context
556
- });
557
- });
558
- match1[1] = container.nodes[0];
559
- }
560
- yield match1;
561
- }
562
- }
563
- }
564
- function inKeyframes(rule) {
565
- return rule.parent && rule.parent.type === 'atrule' && rule.parent.name === 'keyframes';
566
- }
567
- function generateRules(candidates, context) {
568
- let allRules = [];
569
- for (let candidate of candidates){
570
- if (context.notClassCache.has(candidate)) {
571
- continue;
572
- }
573
- if (context.classCache.has(candidate)) {
574
- allRules.push(context.classCache.get(candidate));
575
- continue;
576
- }
577
- let matches = Array.from(resolveMatches(candidate, context));
578
- if (matches.length === 0) {
579
- context.notClassCache.add(candidate);
580
- continue;
581
- }
582
- context.classCache.set(candidate, matches);
583
- allRules.push(matches);
584
- }
585
- // Strategy based on `tailwindConfig.important`
586
- let strategy = ((important)=>{
587
- if (important === true) {
588
- return (rule)=>{
589
- rule.walkDecls((d)=>{
590
- if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
591
- d.important = true;
592
- }
593
- });
594
- };
595
- }
596
- if (typeof important === 'string') {
597
- return (rule)=>{
598
- rule.selectors = rule.selectors.map((selector)=>{
599
- return `${important} ${selector}`;
600
- });
601
- };
602
- }
603
- })(context.tailwindConfig.important);
604
- return allRules.flat(1).map(([{ sort , layer , options }, rule])=>{
605
- if (options.respectImportant) {
606
- if (strategy) {
607
- let container = _postcss.default.root({
608
- nodes: [
609
- rule.clone()
610
- ]
611
- });
612
- container.walkRules((r)=>{
613
- if (inKeyframes(r)) {
614
- return;
615
- }
616
- strategy(r);
617
- });
618
- rule = container.nodes[0];
619
- }
620
- }
621
- return [
622
- sort | context.layerOrder[layer],
623
- rule
624
- ];
625
- });
626
- }
627
- function isArbitraryValue(input) {
628
- return input.startsWith('[') && input.endsWith(']');
629
- }
630
- exports.resolveMatches = resolveMatches;
631
- 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
- }