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

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