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,643 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFileModifiedMap = getFileModifiedMap;
7
- exports.createContext = createContext;
8
- exports.getContext = getContext;
9
-
10
- var _fs = _interopRequireDefault(require("fs"));
11
-
12
- var _url = _interopRequireDefault(require("url"));
13
-
14
- var _postcss = _interopRequireDefault(require("postcss"));
15
-
16
- var _dlv = _interopRequireDefault(require("dlv"));
17
-
18
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
19
-
20
- var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
21
-
22
- var _parseObjectStyles = _interopRequireDefault(require("../util/parseObjectStyles"));
23
-
24
- var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
25
-
26
- var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
27
-
28
- var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
29
-
30
- var _nameClass = _interopRequireDefault(require("../util/nameClass"));
31
-
32
- var _pluginUtils = require("../util/pluginUtils");
33
-
34
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
35
-
36
- var corePlugins = _interopRequireWildcard(require("../corePlugins"));
37
-
38
- var sharedState = _interopRequireWildcard(require("./sharedState"));
39
-
40
- var _toPath = require("../util/toPath");
41
-
42
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
43
-
44
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
-
46
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
-
48
- function insertInto(list, value, {
49
- before = []
50
- } = {}) {
51
- before = [].concat(before);
52
-
53
- if (before.length <= 0) {
54
- list.push(value);
55
- return;
56
- }
57
-
58
- let idx = list.length - 1;
59
-
60
- for (let other of before) {
61
- let iidx = list.indexOf(other);
62
- if (iidx === -1) continue;
63
- idx = Math.min(idx, iidx);
64
- }
65
-
66
- list.splice(idx, 0, value);
67
- }
68
-
69
- function parseStyles(styles) {
70
- if (!Array.isArray(styles)) {
71
- return parseStyles([styles]);
72
- }
73
-
74
- return styles.flatMap(style => {
75
- let isNode = !Array.isArray(style) && !(0, _isPlainObject.default)(style);
76
- return isNode ? style : (0, _parseObjectStyles.default)(style);
77
- });
78
- }
79
-
80
- function getClasses(selector) {
81
- let parser = (0, _postcssSelectorParser.default)(selectors => {
82
- let allClasses = [];
83
- selectors.walkClasses(classNode => {
84
- allClasses.push(classNode.value);
85
- });
86
- return allClasses;
87
- });
88
- return parser.transformSync(selector);
89
- }
90
-
91
- function extractCandidates(node) {
92
- let classes = node.type === 'rule' ? getClasses(node.selector) : [];
93
-
94
- if (node.type === 'atrule') {
95
- node.walkRules(rule => {
96
- classes = [...classes, ...getClasses(rule.selector)];
97
- });
98
- }
99
-
100
- return classes;
101
- }
102
-
103
- function withIdentifiers(styles) {
104
- return parseStyles(styles).flatMap(node => {
105
- let nodeMap = new Map();
106
- let candidates = extractCandidates(node); // If this isn't "on-demandable", assign it a universal candidate.
107
-
108
- if (candidates.length === 0) {
109
- return [['*', node]];
110
- }
111
-
112
- return candidates.map(c => {
113
- if (!nodeMap.has(node)) {
114
- nodeMap.set(node, node);
115
- }
116
-
117
- return [c, nodeMap.get(node)];
118
- });
119
- });
120
- }
121
-
122
- let matchingBrackets = new Map([['{', '}'], ['[', ']'], ['(', ')']]);
123
- let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v]) => [v, k]));
124
- let quotes = new Set(['"', "'", '`']); // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
125
- // values don't count, and brackets inside quotes also don't count.
126
- //
127
- // E.g.: w-[this-is]w-[weird-and-invalid]
128
- // E.g.: w-[this-is\\]w-\\[weird-but-valid]
129
- // E.g.: content-['this-is-also-valid]-weirdly-enough']
130
-
131
- function isValidArbitraryValue(value) {
132
- let stack = [];
133
- let inQuotes = false;
134
-
135
- for (let i = 0; i < value.length; i++) {
136
- let char = value[i]; // Non-escaped quotes allow us to "allow" anything in between
137
-
138
- if (quotes.has(char) && value[i - 1] !== '\\') {
139
- inQuotes = !inQuotes;
140
- }
141
-
142
- if (inQuotes) continue;
143
- if (value[i - 1] === '\\') continue; // Escaped
144
-
145
- if (matchingBrackets.has(char)) {
146
- stack.push(char);
147
- } else if (inverseMatchingBrackets.has(char)) {
148
- let inverse = inverseMatchingBrackets.get(char); // Nothing to pop from, therefore it is unbalanced
149
-
150
- if (stack.length <= 0) {
151
- return false;
152
- } // Popped value must match the inverse value, otherwise it is unbalanced
153
-
154
-
155
- if (stack.pop() !== inverse) {
156
- return false;
157
- }
158
- }
159
- } // If there is still something on the stack, it is also unbalanced
160
-
161
-
162
- if (stack.length > 0) {
163
- return false;
164
- } // All good, totally balanced!
165
-
166
-
167
- return true;
168
- }
169
-
170
- function buildPluginApi(tailwindConfig, context, {
171
- variantList,
172
- variantMap,
173
- offsets
174
- }) {
175
- function getConfigValue(path, defaultValue) {
176
- return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
177
- }
178
-
179
- function applyConfiguredPrefix(selector) {
180
- return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
181
- }
182
-
183
- function prefixIdentifier(identifier, options) {
184
- if (identifier === '*') {
185
- return '*';
186
- }
187
-
188
- if (!options.respectPrefix) {
189
- return identifier;
190
- }
191
-
192
- if (typeof context.tailwindConfig.prefix === 'function') {
193
- return (0, _prefixSelector.default)(context.tailwindConfig.prefix, `.${identifier}`).substr(1);
194
- }
195
-
196
- return context.tailwindConfig.prefix + identifier;
197
- }
198
-
199
- return {
200
- addVariant(variantName, variantFunctions, options = {}) {
201
- variantFunctions = [].concat(variantFunctions);
202
- insertInto(variantList, variantName, options);
203
- variantMap.set(variantName, variantFunctions);
204
- },
205
-
206
- postcss: _postcss.default,
207
- prefix: applyConfiguredPrefix,
208
- e: _escapeClassName.default,
209
- config: getConfigValue,
210
-
211
- theme(path, defaultValue) {
212
- const [pathRoot, ...subPaths] = (0, _toPath.toPath)(path);
213
- const value = getConfigValue(['theme', pathRoot, ...subPaths], defaultValue);
214
- return (0, _transformThemeValue.default)(pathRoot)(value);
215
- },
216
-
217
- corePlugins: path => {
218
- if (Array.isArray(tailwindConfig.corePlugins)) {
219
- return tailwindConfig.corePlugins.includes(path);
220
- }
221
-
222
- return getConfigValue(['corePlugins', path], true);
223
- },
224
- variants: () => {
225
- // Preserved for backwards compatibility but not used in v3.0+
226
- return [];
227
- },
228
-
229
- addUserCss(userCss) {
230
- for (let [identifier, rule] of withIdentifiers(userCss)) {
231
- let offset = offsets.user++;
232
-
233
- if (!context.candidateRuleMap.has(identifier)) {
234
- context.candidateRuleMap.set(identifier, []);
235
- }
236
-
237
- context.candidateRuleMap.get(identifier).push([{
238
- sort: offset,
239
- layer: 'user'
240
- }, rule]);
241
- }
242
- },
243
-
244
- addBase(base) {
245
- for (let [identifier, rule] of withIdentifiers(base)) {
246
- let prefixedIdentifier = prefixIdentifier(identifier, {});
247
- let offset = offsets.base++;
248
-
249
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
250
- context.candidateRuleMap.set(prefixedIdentifier, []);
251
- }
252
-
253
- context.candidateRuleMap.get(prefixedIdentifier).push([{
254
- sort: offset,
255
- layer: 'base'
256
- }, rule]);
257
- }
258
- },
259
-
260
- addComponents(components, options) {
261
- let defaultOptions = {
262
- variants: [],
263
- respectPrefix: true,
264
- respectImportant: false,
265
- respectVariants: true
266
- };
267
- options = Object.assign({}, defaultOptions, Array.isArray(options) ? {
268
- variants: options
269
- } : options);
270
-
271
- for (let [identifier, rule] of withIdentifiers(components)) {
272
- let prefixedIdentifier = prefixIdentifier(identifier, options);
273
- let offset = offsets.components++;
274
-
275
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
276
- context.candidateRuleMap.set(prefixedIdentifier, []);
277
- }
278
-
279
- context.candidateRuleMap.get(prefixedIdentifier).push([{
280
- sort: offset,
281
- layer: 'components',
282
- options
283
- }, rule]);
284
- }
285
- },
286
-
287
- addUtilities(utilities, options) {
288
- let defaultOptions = {
289
- variants: [],
290
- respectPrefix: true,
291
- respectImportant: true,
292
- respectVariants: true
293
- };
294
- options = Object.assign({}, defaultOptions, Array.isArray(options) ? {
295
- variants: options
296
- } : options);
297
-
298
- for (let [identifier, rule] of withIdentifiers(utilities)) {
299
- let prefixedIdentifier = prefixIdentifier(identifier, options);
300
- let offset = offsets.utilities++;
301
-
302
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
303
- context.candidateRuleMap.set(prefixedIdentifier, []);
304
- }
305
-
306
- context.candidateRuleMap.get(prefixedIdentifier).push([{
307
- sort: offset,
308
- layer: 'utilities',
309
- options
310
- }, rule]);
311
- }
312
- },
313
-
314
- matchUtilities: function (utilities, options) {
315
- let defaultOptions = {
316
- variants: [],
317
- respectPrefix: true,
318
- respectImportant: true,
319
- respectVariants: true
320
- };
321
- options = { ...defaultOptions,
322
- ...options
323
- };
324
- let offset = offsets.utilities++;
325
-
326
- for (let identifier in utilities) {
327
- let prefixedIdentifier = prefixIdentifier(identifier, options);
328
- let rule = utilities[identifier];
329
-
330
- function wrapped(modifier) {
331
- let {
332
- type = 'any'
333
- } = options;
334
- type = [].concat(type);
335
- let [value, coercedType] = (0, _pluginUtils.coerceValue)(type, modifier, options.values, tailwindConfig);
336
-
337
- if (!type.includes(coercedType) || value === undefined) {
338
- return [];
339
- }
340
-
341
- if (!isValidArbitraryValue(value)) {
342
- return [];
343
- }
344
-
345
- let includedRules = [];
346
- let ruleSets = [].concat(rule(value, {
347
- includeRules(rules) {
348
- includedRules.push(...rules);
349
- }
350
-
351
- })).filter(Boolean).map(declaration => ({
352
- [(0, _nameClass.default)(identifier, modifier)]: declaration
353
- }));
354
- return [...includedRules, ...ruleSets];
355
- }
356
-
357
- let withOffsets = [{
358
- sort: offset,
359
- layer: 'utilities',
360
- options
361
- }, wrapped];
362
-
363
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
364
- context.candidateRuleMap.set(prefixedIdentifier, []);
365
- }
366
-
367
- context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
368
- }
369
- }
370
- };
371
- }
372
-
373
- let fileModifiedMapCache = new WeakMap();
374
-
375
- function getFileModifiedMap(context) {
376
- if (!fileModifiedMapCache.has(context)) {
377
- fileModifiedMapCache.set(context, new Map());
378
- }
379
-
380
- return fileModifiedMapCache.get(context);
381
- }
382
-
383
- function trackModified(files, fileModifiedMap) {
384
- let changed = false;
385
-
386
- for (let file of files) {
387
- if (!file) continue;
388
-
389
- let parsed = _url.default.parse(file);
390
-
391
- let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href;
392
- pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname;
393
-
394
- let newModified = _fs.default.statSync(decodeURIComponent(pathname)).mtimeMs;
395
-
396
- if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
397
- changed = true;
398
- }
399
-
400
- fileModifiedMap.set(file, newModified);
401
- }
402
-
403
- return changed;
404
- }
405
-
406
- function extractVariantAtRules(node) {
407
- node.walkAtRules(atRule => {
408
- if (['responsive', 'variants'].includes(atRule.name)) {
409
- extractVariantAtRules(atRule);
410
- atRule.before(atRule.nodes);
411
- atRule.remove();
412
- }
413
- });
414
- }
415
-
416
- function collectLayerPlugins(root) {
417
- let layerPlugins = [];
418
- root.each(node => {
419
- if (node.type === 'atrule' && ['responsive', 'variants'].includes(node.name)) {
420
- node.name = 'layer';
421
- node.params = 'utilities';
422
- }
423
- }); // Walk @layer rules and treat them like plugins
424
-
425
- root.walkAtRules('layer', layerRule => {
426
- extractVariantAtRules(layerRule);
427
-
428
- if (layerRule.params === 'base') {
429
- for (let node of layerRule.nodes) {
430
- layerPlugins.push(function ({
431
- addBase
432
- }) {
433
- addBase(node, {
434
- respectPrefix: false
435
- });
436
- });
437
- }
438
-
439
- layerRule.remove();
440
- } else if (layerRule.params === 'components') {
441
- for (let node of layerRule.nodes) {
442
- layerPlugins.push(function ({
443
- addComponents
444
- }) {
445
- addComponents(node, {
446
- respectPrefix: false
447
- });
448
- });
449
- }
450
-
451
- layerRule.remove();
452
- } else if (layerRule.params === 'utilities') {
453
- for (let node of layerRule.nodes) {
454
- layerPlugins.push(function ({
455
- addUtilities
456
- }) {
457
- addUtilities(node, {
458
- respectPrefix: false
459
- });
460
- });
461
- }
462
-
463
- layerRule.remove();
464
- }
465
- });
466
- root.walkRules(rule => {
467
- // At this point it is safe to include all the left-over css from the
468
- // user's css file. This is because the `@tailwind` and `@layer` directives
469
- // will already be handled and will be removed from the css tree.
470
- layerPlugins.push(function ({
471
- addUserCss
472
- }) {
473
- addUserCss(rule, {
474
- respectPrefix: false
475
- });
476
- });
477
- });
478
- return layerPlugins;
479
- }
480
-
481
- function resolvePlugins(context, tailwindDirectives, root) {
482
- let corePluginList = Object.entries(corePlugins).map(([name, plugin]) => {
483
- if (!context.tailwindConfig.corePlugins.includes(name)) {
484
- return null;
485
- }
486
-
487
- return plugin;
488
- }).filter(Boolean);
489
- let userPlugins = context.tailwindConfig.plugins.map(plugin => {
490
- if (plugin.__isOptionsFunction) {
491
- plugin = plugin();
492
- }
493
-
494
- return typeof plugin === 'function' ? plugin : plugin.handler;
495
- });
496
- let layerPlugins = collectLayerPlugins(root, tailwindDirectives); // TODO: This is a workaround for backwards compatibility, since custom variants
497
- // were historically sorted before screen/stackable variants.
498
-
499
- let beforeVariants = [corePlugins['pseudoElementVariants'], corePlugins['pseudoClassVariants']];
500
- let afterVariants = [corePlugins['directionVariants'], corePlugins['reducedMotionVariants'], corePlugins['darkVariants'], corePlugins['screenVariants']];
501
- return [...corePluginList, ...beforeVariants, ...userPlugins, ...afterVariants, ...layerPlugins];
502
- }
503
-
504
- function registerPlugins(plugins, context) {
505
- let variantList = [];
506
- let variantMap = new Map();
507
- let offsets = {
508
- base: 0n,
509
- components: 0n,
510
- utilities: 0n,
511
- user: 0n
512
- };
513
- let pluginApi = buildPluginApi(context.tailwindConfig, context, {
514
- variantList,
515
- variantMap,
516
- offsets
517
- });
518
-
519
- for (let plugin of plugins) {
520
- if (Array.isArray(plugin)) {
521
- for (let pluginItem of plugin) {
522
- pluginItem(pluginApi);
523
- }
524
- } else {
525
- plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
526
- }
527
- }
528
-
529
- let highestOffset = (args => args.reduce((m, e) => e > m ? e : m))([offsets.base, offsets.components, offsets.utilities, offsets.user]);
530
-
531
- let reservedBits = BigInt(highestOffset.toString(2).length);
532
- context.layerOrder = {
533
- base: 1n << reservedBits << 0n,
534
- components: 1n << reservedBits << 1n,
535
- utilities: 1n << reservedBits << 2n,
536
- user: 1n << reservedBits << 3n
537
- };
538
- reservedBits += 4n;
539
- let offset = 0;
540
- context.variantOrder = new Map(variantList.map((variant, i) => {
541
- let variantFunctions = variantMap.get(variant).length;
542
- let bits = 1n << BigInt(i + offset) << reservedBits;
543
- offset += variantFunctions - 1;
544
- return [variant, bits];
545
- }).sort(([, a], [, z]) => (0, _bigSign.default)(a - z)));
546
- context.minimumScreen = [...context.variantOrder.values()].shift(); // Build variantMap
547
-
548
- for (let [variantName, variantFunctions] of variantMap.entries()) {
549
- let sort = context.variantOrder.get(variantName);
550
- context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx) => [sort << BigInt(idx), variantFunction]));
551
- }
552
- }
553
-
554
- function createContext(tailwindConfig, changedContent = [], tailwindDirectives = new Set(), root = _postcss.default.root()) {
555
- let context = {
556
- disposables: [],
557
- ruleCache: new Set(),
558
- classCache: new Map(),
559
- applyClassCache: new Map(),
560
- notClassCache: new Set(),
561
- postCssNodeCache: new Map(),
562
- candidateRuleMap: new Map(),
563
- tailwindConfig,
564
- changedContent: changedContent,
565
- variantMap: new Map(),
566
- stylesheetCache: null
567
- };
568
- let resolvedPlugins = resolvePlugins(context, tailwindDirectives, root);
569
- registerPlugins(resolvedPlugins, context);
570
- return context;
571
- }
572
-
573
- let contextMap = sharedState.contextMap;
574
- let configContextMap = sharedState.configContextMap;
575
- let contextSourcesMap = sharedState.contextSourcesMap;
576
-
577
- function getContext(tailwindDirectives, root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
578
- let sourcePath = result.opts.from;
579
- let isConfigFile = userConfigPath !== null;
580
- sharedState.env.DEBUG && console.log('Source path:', sourcePath);
581
- let existingContext;
582
-
583
- if (isConfigFile && contextMap.has(sourcePath)) {
584
- existingContext = contextMap.get(sourcePath);
585
- } else if (configContextMap.has(tailwindConfigHash)) {
586
- let context = configContextMap.get(tailwindConfigHash);
587
- contextSourcesMap.get(context).add(sourcePath);
588
- contextMap.set(sourcePath, context);
589
- existingContext = context;
590
- } // If there's already a context in the cache and we don't need to
591
- // reset the context, return the cached context.
592
-
593
-
594
- if (existingContext) {
595
- let contextDependenciesChanged = trackModified([...contextDependencies], getFileModifiedMap(existingContext));
596
-
597
- if (!contextDependenciesChanged) {
598
- return [existingContext, false];
599
- }
600
- } // If this source is in the context map, get the old context.
601
- // Remove this source from the context sources for the old context,
602
- // and clean up that context if no one else is using it. This can be
603
- // called by many processes in rapid succession, so we check for presence
604
- // first because the first process to run this code will wipe it out first.
605
-
606
-
607
- if (contextMap.has(sourcePath)) {
608
- let oldContext = contextMap.get(sourcePath);
609
-
610
- if (contextSourcesMap.has(oldContext)) {
611
- contextSourcesMap.get(oldContext).delete(sourcePath);
612
-
613
- if (contextSourcesMap.get(oldContext).size === 0) {
614
- contextSourcesMap.delete(oldContext);
615
-
616
- for (let [tailwindConfigHash, context] of configContextMap) {
617
- if (context === oldContext) {
618
- configContextMap.delete(tailwindConfigHash);
619
- }
620
- }
621
-
622
- for (let disposable of oldContext.disposables.splice(0)) {
623
- disposable(oldContext);
624
- }
625
- }
626
- }
627
- }
628
-
629
- sharedState.env.DEBUG && console.log('Setting up new context...');
630
- let context = createContext(tailwindConfig, [], tailwindDirectives, root);
631
- trackModified([...contextDependencies], getFileModifiedMap(context)); // ---
632
- // Update all context tracking state
633
-
634
- configContextMap.set(tailwindConfigHash, context);
635
- contextMap.set(sourcePath, context);
636
-
637
- if (!contextSourcesMap.has(context)) {
638
- contextSourcesMap.set(context, new Set());
639
- }
640
-
641
- contextSourcesMap.get(context).add(sourcePath);
642
- return [context, true];
643
- }