tailwindcss 0.0.0-insiders.f9fb2ce → 0.0.0-insiders.fa3f45f

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