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