tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21

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 (161) hide show
  1. package/CHANGELOG.md +246 -6
  2. package/README.md +13 -9
  3. package/defaultTheme.d.ts +2 -1
  4. package/lib/cli/build/deps.js +54 -0
  5. package/lib/cli/build/index.js +48 -0
  6. package/lib/cli/build/plugin.js +362 -0
  7. package/lib/cli/build/utils.js +78 -0
  8. package/lib/cli/build/watching.js +178 -0
  9. package/lib/cli/help/index.js +71 -0
  10. package/lib/cli/index.js +18 -0
  11. package/lib/cli/init/index.js +46 -0
  12. package/lib/cli/shared.js +12 -0
  13. package/lib/cli-peer-dependencies.js +18 -5
  14. package/lib/cli.js +62 -592
  15. package/lib/constants.js +19 -12
  16. package/lib/corePluginList.js +5 -3
  17. package/lib/corePlugins.js +619 -347
  18. package/lib/css/preflight.css +7 -0
  19. package/lib/featureFlags.js +34 -22
  20. package/lib/index.js +16 -9
  21. package/lib/lib/cacheInvalidation.js +42 -21
  22. package/lib/lib/collapseAdjacentRules.js +16 -14
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -10
  24. package/lib/lib/content.js +177 -0
  25. package/lib/lib/defaultExtractor.js +230 -33
  26. package/lib/lib/detectNesting.js +13 -4
  27. package/lib/lib/evaluateTailwindFunctions.js +105 -42
  28. package/lib/lib/expandApplyAtRules.js +151 -92
  29. package/lib/lib/expandTailwindAtRules.js +134 -149
  30. package/lib/lib/findAtConfigPath.js +44 -0
  31. package/lib/lib/generateRules.js +404 -185
  32. package/lib/lib/getModuleDependencies.js +21 -18
  33. package/lib/lib/normalizeTailwindDirectives.js +11 -8
  34. package/lib/lib/offsets.js +285 -0
  35. package/lib/lib/partitionApplyAtRules.js +14 -11
  36. package/lib/lib/regex.js +60 -0
  37. package/lib/lib/remap-bitfield.js +87 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -79
  39. package/lib/lib/setupContextUtils.js +567 -242
  40. package/lib/lib/setupTrackingContext.js +77 -106
  41. package/lib/lib/sharedState.js +18 -10
  42. package/lib/lib/substituteScreenAtRules.js +9 -7
  43. package/lib/postcss-plugins/nesting/index.js +7 -5
  44. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  45. package/lib/processTailwindFeatures.js +34 -31
  46. package/lib/public/colors.js +7 -5
  47. package/lib/public/create-plugin.js +6 -4
  48. package/lib/public/default-config.js +7 -5
  49. package/lib/public/default-theme.js +7 -5
  50. package/lib/public/resolve-config.js +13 -10
  51. package/lib/util/bigSign.js +4 -1
  52. package/lib/util/buildMediaQuery.js +10 -5
  53. package/lib/util/cloneDeep.js +6 -5
  54. package/lib/util/cloneNodes.js +9 -2
  55. package/lib/util/color.js +20 -17
  56. package/lib/util/configurePlugins.js +5 -2
  57. package/lib/util/createPlugin.js +6 -5
  58. package/lib/util/createUtilityPlugin.js +15 -13
  59. package/lib/util/dataTypes.js +75 -51
  60. package/lib/util/defaults.js +8 -5
  61. package/lib/util/escapeClassName.js +13 -10
  62. package/lib/util/escapeCommas.js +4 -1
  63. package/lib/util/flattenColorPalette.js +7 -8
  64. package/lib/util/formatVariantSelector.js +270 -103
  65. package/lib/util/getAllConfigs.js +34 -15
  66. package/lib/util/hashConfig.js +10 -7
  67. package/lib/util/isKeyframeRule.js +4 -1
  68. package/lib/util/isPlainObject.js +4 -1
  69. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
  70. package/lib/util/log.js +14 -8
  71. package/lib/util/nameClass.js +19 -8
  72. package/lib/util/negateValue.js +20 -5
  73. package/lib/util/normalizeConfig.js +94 -53
  74. package/lib/util/normalizeScreens.js +115 -4
  75. package/lib/util/parseAnimationValue.js +43 -41
  76. package/lib/util/parseBoxShadowValue.js +12 -45
  77. package/lib/util/parseDependency.js +37 -55
  78. package/lib/util/parseGlob.js +34 -0
  79. package/lib/util/parseObjectStyles.js +15 -12
  80. package/lib/util/pluginUtils.js +146 -42
  81. package/lib/util/prefixSelector.js +26 -9
  82. package/lib/util/removeAlphaVariables.js +29 -0
  83. package/lib/util/resolveConfig.js +104 -105
  84. package/lib/util/resolveConfigPath.js +20 -17
  85. package/lib/util/responsive.js +12 -9
  86. package/lib/util/splitAtTopLevelOnly.js +43 -0
  87. package/lib/util/tap.js +4 -1
  88. package/lib/util/toColorValue.js +4 -1
  89. package/lib/util/toPath.js +18 -2
  90. package/lib/util/transformThemeValue.js +23 -11
  91. package/lib/util/validateConfig.js +24 -0
  92. package/lib/util/validateFormalSyntax.js +24 -0
  93. package/lib/util/withAlphaVariable.js +32 -24
  94. package/package.json +32 -29
  95. package/peers/index.js +6693 -3036
  96. package/plugin.d.ts +10 -5
  97. package/resolveConfig.d.ts +12 -0
  98. package/scripts/generate-types.js +53 -0
  99. package/scripts/release-channel.js +18 -0
  100. package/scripts/release-notes.js +21 -0
  101. package/scripts/type-utils.js +27 -0
  102. package/src/cli/build/deps.js +56 -0
  103. package/src/cli/build/index.js +49 -0
  104. package/src/cli/build/plugin.js +434 -0
  105. package/src/cli/build/utils.js +76 -0
  106. package/src/cli/build/watching.js +227 -0
  107. package/src/cli/help/index.js +70 -0
  108. package/src/cli/index.js +3 -0
  109. package/src/cli/init/index.js +50 -0
  110. package/src/cli/shared.js +5 -0
  111. package/src/cli-peer-dependencies.js +7 -1
  112. package/src/cli.js +46 -659
  113. package/src/corePlugins.js +346 -79
  114. package/src/css/preflight.css +7 -0
  115. package/src/featureFlags.js +12 -2
  116. package/src/index.js +5 -0
  117. package/src/lib/content.js +213 -0
  118. package/src/lib/defaultExtractor.js +202 -35
  119. package/src/lib/detectNesting.js +9 -1
  120. package/src/lib/evaluateTailwindFunctions.js +78 -7
  121. package/src/lib/expandApplyAtRules.js +129 -34
  122. package/src/lib/expandTailwindAtRules.js +12 -50
  123. package/src/lib/findAtConfigPath.js +48 -0
  124. package/src/lib/generateRules.js +379 -126
  125. package/src/lib/offsets.js +351 -0
  126. package/src/lib/regex.js +74 -0
  127. package/src/lib/remap-bitfield.js +82 -0
  128. package/src/lib/resolveDefaultsAtRules.js +53 -36
  129. package/src/lib/setupContextUtils.js +510 -120
  130. package/src/lib/setupTrackingContext.js +8 -45
  131. package/src/lib/sharedState.js +2 -0
  132. package/src/util/buildMediaQuery.js +5 -3
  133. package/src/util/cloneNodes.js +5 -1
  134. package/src/util/dataTypes.js +51 -26
  135. package/src/util/formatVariantSelector.js +317 -101
  136. package/src/util/getAllConfigs.js +19 -0
  137. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  138. package/src/util/log.js +1 -1
  139. package/src/util/nameClass.js +4 -0
  140. package/src/util/negateValue.js +10 -2
  141. package/src/util/normalizeConfig.js +40 -10
  142. package/src/util/normalizeScreens.js +99 -4
  143. package/src/util/parseBoxShadowValue.js +3 -50
  144. package/src/util/parseDependency.js +37 -42
  145. package/src/util/parseGlob.js +24 -0
  146. package/src/util/pluginUtils.js +132 -10
  147. package/src/util/prefixSelector.js +28 -10
  148. package/src/util/removeAlphaVariables.js +24 -0
  149. package/src/util/resolveConfig.js +70 -62
  150. package/src/util/splitAtTopLevelOnly.js +45 -0
  151. package/src/util/toPath.js +1 -1
  152. package/src/util/transformThemeValue.js +13 -3
  153. package/src/util/validateConfig.js +13 -0
  154. package/src/util/validateFormalSyntax.js +34 -0
  155. package/src/util/withAlphaVariable.js +1 -1
  156. package/stubs/defaultConfig.stub.js +165 -164
  157. package/stubs/simpleConfig.stub.js +1 -0
  158. package/types/config.d.ts +77 -37
  159. package/types/generated/default-theme.d.ts +342 -0
  160. package/types/index.d.ts +7 -1
  161. package/types.d.ts +0 -1
@@ -2,65 +2,120 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
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");
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ isValidVariantFormatString: ()=>isValidVariantFormatString,
13
+ parseVariant: ()=>parseVariant,
14
+ getFileModifiedMap: ()=>getFileModifiedMap,
15
+ createContext: ()=>createContext,
16
+ getContext: ()=>getContext
17
+ });
18
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
19
+ const _url = /*#__PURE__*/ _interopRequireDefault(require("url"));
20
+ const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
21
+ const _dlv = /*#__PURE__*/ _interopRequireDefault(require("dlv"));
22
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
23
+ const _transformThemeValue = /*#__PURE__*/ _interopRequireDefault(require("../util/transformThemeValue"));
24
+ const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
25
+ const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
26
+ const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isPlainObject"));
27
+ const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
28
+ const _nameClass = /*#__PURE__*/ _interopRequireWildcard(require("../util/nameClass"));
29
+ const _pluginUtils = require("../util/pluginUtils");
30
+ const _corePlugins = require("../corePlugins");
31
+ const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
32
+ const _toPath = require("../util/toPath");
33
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
34
+ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("../util/negateValue"));
35
+ const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
36
+ const _generateRules = require("./generateRules");
37
+ const _cacheInvalidationJs = require("./cacheInvalidation.js");
38
+ const _offsetsJs = require("./offsets.js");
39
+ const _featureFlagsJs = require("../featureFlags.js");
40
+ const _formatVariantSelector = require("../util/formatVariantSelector");
29
41
  function _interopRequireDefault(obj) {
30
42
  return obj && obj.__esModule ? obj : {
31
43
  default: obj
32
44
  };
33
45
  }
34
- function _interopRequireWildcard(obj) {
35
- if (obj && obj.__esModule) {
46
+ function _getRequireWildcardCache(nodeInterop) {
47
+ if (typeof WeakMap !== "function") return null;
48
+ var cacheBabelInterop = new WeakMap();
49
+ var cacheNodeInterop = new WeakMap();
50
+ return (_getRequireWildcardCache = function(nodeInterop) {
51
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
52
+ })(nodeInterop);
53
+ }
54
+ function _interopRequireWildcard(obj, nodeInterop) {
55
+ if (!nodeInterop && obj && obj.__esModule) {
36
56
  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
- }
57
+ }
58
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
59
+ return {
60
+ default: obj
61
+ };
62
+ }
63
+ var cache = _getRequireWildcardCache(nodeInterop);
64
+ if (cache && cache.has(obj)) {
65
+ return cache.get(obj);
66
+ }
67
+ var newObj = {};
68
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
69
+ for(var key in obj){
70
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
71
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
72
+ if (desc && (desc.get || desc.set)) {
73
+ Object.defineProperty(newObj, key, desc);
74
+ } else {
75
+ newObj[key] = obj[key];
49
76
  }
50
77
  }
51
- newObj.default = obj;
52
- return newObj;
53
78
  }
79
+ newObj.default = obj;
80
+ if (cache) {
81
+ cache.set(obj, newObj);
82
+ }
83
+ return newObj;
54
84
  }
85
+ const VARIANT_TYPES = {
86
+ AddVariant: Symbol.for("ADD_VARIANT"),
87
+ MatchVariant: Symbol.for("MATCH_VARIANT")
88
+ };
89
+ const VARIANT_INFO = {
90
+ Base: 1 << 0,
91
+ Dynamic: 1 << 1
92
+ };
55
93
  function prefix(context, selector) {
56
- let prefix1 = context.tailwindConfig.prefix;
57
- return typeof prefix1 === "function" ? prefix1(selector) : prefix1 + selector;
94
+ let prefix = context.tailwindConfig.prefix;
95
+ return typeof prefix === "function" ? prefix(selector) : prefix + selector;
96
+ }
97
+ function normalizeOptionTypes({ type ="any" , ...options }) {
98
+ let types = [].concat(type);
99
+ return {
100
+ ...options,
101
+ types: types.map((type)=>{
102
+ if (Array.isArray(type)) {
103
+ return {
104
+ type: type[0],
105
+ ...type[1]
106
+ };
107
+ }
108
+ return {
109
+ type,
110
+ preferOnConflict: false
111
+ };
112
+ })
113
+ };
58
114
  }
59
115
  function parseVariantFormatString(input) {
60
116
  if (input.includes("{")) {
61
117
  if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
62
- return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)
63
- ).filter(Boolean);
118
+ return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)).filter(Boolean);
64
119
  }
65
120
  return [
66
121
  input.trim()
@@ -101,12 +156,12 @@ function parseStyles(styles) {
101
156
  ]);
102
157
  }
103
158
  return styles.flatMap((style)=>{
104
- let isNode = !Array.isArray(style) && !(0, _isPlainObject).default(style);
105
- return isNode ? style : (0, _parseObjectStyles).default(style);
159
+ let isNode = !Array.isArray(style) && !(0, _isPlainObject.default)(style);
160
+ return isNode ? style : (0, _parseObjectStyles.default)(style);
106
161
  });
107
162
  }
108
163
  function getClasses(selector, mutate) {
109
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
164
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
110
165
  let allClasses = [];
111
166
  if (mutate) {
112
167
  mutate(selectors);
@@ -147,8 +202,7 @@ function extractCandidates(node, state = {
147
202
  }
148
203
  } else if (node.type === "atrule") {
149
204
  node.walkRules((rule)=>{
150
- for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector)
151
- )){
205
+ for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
152
206
  classes.push(classCandidate);
153
207
  }
154
208
  });
@@ -167,7 +221,7 @@ function withIdentifiers(styles) {
167
221
  let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
168
222
  // If this isn't "on-demandable", assign it a universal candidate to always include it.
169
223
  if (containsNonOnDemandableSelectors) {
170
- candidates.unshift(sharedState.NOT_ON_DEMAND);
224
+ candidates.unshift(_sharedState.NOT_ON_DEMAND);
171
225
  }
172
226
  // However, it could be that it also contains "on-demandable" candidates.
173
227
  // E.g.: `span, .foo {}`, in that case it should still be possible to use
@@ -183,70 +237,64 @@ function withIdentifiers(styles) {
183
237
  });
184
238
  });
185
239
  }
186
- function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
240
+ function isValidVariantFormatString(format) {
241
+ return format.startsWith("@") || format.includes("&");
242
+ }
243
+ function parseVariant(variant) {
244
+ variant = variant.replace(/\n+/g, "").replace(/\s{1,}/g, " ").trim();
245
+ let fns = parseVariantFormatString(variant).map((str)=>{
246
+ if (!str.startsWith("@")) {
247
+ return ({ format })=>format(str);
248
+ }
249
+ let [, name, params] = /@(.*?)( .+|[({].*)/g.exec(str);
250
+ return ({ wrap })=>wrap(_postcss.default.atRule({
251
+ name,
252
+ params: params.trim()
253
+ }));
254
+ }).reverse();
255
+ return (api)=>{
256
+ for (let fn of fns){
257
+ fn(api);
258
+ }
259
+ };
260
+ }
261
+ /**
262
+ *
263
+ * @param {any} tailwindConfig
264
+ * @param {any} context
265
+ * @param {object} param2
266
+ * @param {Offsets} param2.offsets
267
+ */ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
187
268
  function getConfigValue(path, defaultValue) {
188
- return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
269
+ return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
189
270
  }
190
271
  function applyConfiguredPrefix(selector) {
191
- return (0, _prefixSelector).default(tailwindConfig.prefix, selector);
272
+ return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
192
273
  }
193
274
  function prefixIdentifier(identifier, options) {
194
- if (identifier === sharedState.NOT_ON_DEMAND) {
195
- return sharedState.NOT_ON_DEMAND;
275
+ if (identifier === _sharedState.NOT_ON_DEMAND) {
276
+ return _sharedState.NOT_ON_DEMAND;
196
277
  }
197
278
  if (!options.respectPrefix) {
198
279
  return identifier;
199
280
  }
200
281
  return context.tailwindConfig.prefix + identifier;
201
282
  }
202
- return {
203
- addVariant (variantName, variantFunctions, options = {}) {
204
- variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
205
- if (typeof variantFunction !== "string") {
206
- // Safelist public API functions
207
- return ({ modifySelectors , container , separator })=>{
208
- return variantFunction({
209
- modifySelectors,
210
- container,
211
- separator
212
- });
213
- };
214
- }
215
- variantFunction = variantFunction.replace(/\n+/g, "").replace(/\s{1,}/g, " ").trim();
216
- let fns = parseVariantFormatString(variantFunction).map((str)=>{
217
- if (!str.startsWith("@")) {
218
- return ({ format })=>format(str)
219
- ;
220
- }
221
- let [, name, params] = /@(.*?) (.*)/g.exec(str);
222
- return ({ wrap })=>wrap(_postcss.default.atRule({
223
- name,
224
- params
225
- }))
226
- ;
227
- }).reverse();
228
- return (api)=>{
229
- for (let fn of fns){
230
- fn(api);
231
- }
232
- };
233
- });
234
- insertInto(variantList, variantName, options);
235
- variantMap.set(variantName, variantFunctions);
236
- },
283
+ function resolveThemeValue(path, defaultValue, opts = {}) {
284
+ let parts = (0, _toPath.toPath)(path);
285
+ let value = getConfigValue([
286
+ "theme",
287
+ ...parts
288
+ ], defaultValue);
289
+ return (0, _transformThemeValue.default)(parts[0])(value, opts);
290
+ }
291
+ let variantIdentifier = 0;
292
+ let api = {
237
293
  postcss: _postcss.default,
238
294
  prefix: applyConfiguredPrefix,
239
295
  e: _escapeClassName.default,
240
296
  config: getConfigValue,
241
- theme (path, defaultValue) {
242
- const [pathRoot, ...subPaths] = (0, _toPath).toPath(path);
243
- const value = getConfigValue([
244
- "theme",
245
- pathRoot,
246
- ...subPaths
247
- ], defaultValue);
248
- return (0, _transformThemeValue).default(pathRoot)(value);
249
- },
297
+ theme: resolveThemeValue,
250
298
  corePlugins: (path)=>{
251
299
  if (Array.isArray(tailwindConfig.corePlugins)) {
252
300
  return tailwindConfig.corePlugins.includes(path);
@@ -263,7 +311,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
263
311
  addBase (base) {
264
312
  for (let [identifier, rule] of withIdentifiers(base)){
265
313
  let prefixedIdentifier = prefixIdentifier(identifier, {});
266
- let offset = offsets.base++;
314
+ let offset = offsets.create("base");
267
315
  if (!context.candidateRuleMap.has(prefixedIdentifier)) {
268
316
  context.candidateRuleMap.set(prefixedIdentifier, []);
269
317
  }
@@ -290,7 +338,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
290
338
  }
291
339
  context.candidateRuleMap.get(prefixedIdentifier).push([
292
340
  {
293
- sort: offsets.base++,
341
+ sort: offsets.create("defaults"),
294
342
  layer: "defaults"
295
343
  },
296
344
  rule
@@ -299,6 +347,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
299
347
  },
300
348
  addComponents (components, options) {
301
349
  let defaultOptions = {
350
+ preserveSource: false,
302
351
  respectPrefix: true,
303
352
  respectImportant: false
304
353
  };
@@ -311,7 +360,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
311
360
  }
312
361
  context.candidateRuleMap.get(prefixedIdentifier).push([
313
362
  {
314
- sort: offsets.components++,
363
+ sort: offsets.create("components"),
315
364
  layer: "components",
316
365
  options
317
366
  },
@@ -321,6 +370,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
321
370
  },
322
371
  addUtilities (utilities, options) {
323
372
  let defaultOptions = {
373
+ preserveSource: false,
324
374
  respectPrefix: true,
325
375
  respectImportant: true
326
376
  };
@@ -333,7 +383,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
333
383
  }
334
384
  context.candidateRuleMap.get(prefixedIdentifier).push([
335
385
  {
336
- sort: offsets.utilities++,
386
+ sort: offsets.create("utilities"),
337
387
  layer: "utilities",
338
388
  options
339
389
  },
@@ -344,13 +394,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
344
394
  matchUtilities: function(utilities, options) {
345
395
  let defaultOptions = {
346
396
  respectPrefix: true,
347
- respectImportant: true
397
+ respectImportant: true,
398
+ modifiers: false
348
399
  };
349
- options = {
400
+ options = normalizeOptionTypes({
350
401
  ...defaultOptions,
351
402
  ...options
352
- };
353
- let offset = offsets.utilities++;
403
+ });
404
+ let offset = offsets.create("utilities");
354
405
  for(let identifier in utilities){
355
406
  let prefixedIdentifier = prefixIdentifier(identifier, options);
356
407
  let rule = utilities[identifier];
@@ -359,22 +410,37 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
359
410
  options
360
411
  ]);
361
412
  function wrapped(modifier, { isOnlyPlugin }) {
362
- let { type ="any" } = options;
363
- type = [].concat(type);
364
- let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
413
+ let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
365
414
  if (value === undefined) {
366
415
  return [];
367
416
  }
368
- if (!type.includes(coercedType) && !isOnlyPlugin) {
369
- return [];
417
+ if (!options.types.some(({ type })=>type === coercedType)) {
418
+ if (isOnlyPlugin) {
419
+ _log.default.warn([
420
+ `Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
421
+ `You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
422
+ ]);
423
+ } else {
424
+ return [];
425
+ }
370
426
  }
371
- if (!(0, _isValidArbitraryValue).default(value)) {
427
+ if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
372
428
  return [];
373
429
  }
374
- let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
375
- [(0, _nameClass).default(identifier, modifier)]: declaration
376
- })
377
- );
430
+ let extras = {
431
+ get modifier () {
432
+ if (!options.modifiers) {
433
+ _log.default.warn(`modifier-used-without-options-for-${identifier}`, [
434
+ "Your plugin must set `modifiers: true` in its options to support modifiers."
435
+ ]);
436
+ }
437
+ return utilityModifier;
438
+ }
439
+ };
440
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
441
+ let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
442
+ [(0, _nameClass.default)(identifier, modifier)]: declaration
443
+ }));
378
444
  return ruleSets;
379
445
  }
380
446
  let withOffsets = [
@@ -394,13 +460,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
394
460
  matchComponents: function(components, options) {
395
461
  let defaultOptions = {
396
462
  respectPrefix: true,
397
- respectImportant: false
463
+ respectImportant: false,
464
+ modifiers: false
398
465
  };
399
- options = {
466
+ options = normalizeOptionTypes({
400
467
  ...defaultOptions,
401
468
  ...options
402
- };
403
- let offset = offsets.components++;
469
+ });
470
+ let offset = offsets.create("components");
404
471
  for(let identifier in components){
405
472
  let prefixedIdentifier = prefixIdentifier(identifier, options);
406
473
  let rule = components[identifier];
@@ -409,29 +476,37 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
409
476
  options
410
477
  ]);
411
478
  function wrapped(modifier, { isOnlyPlugin }) {
412
- let { type ="any" } = options;
413
- type = [].concat(type);
414
- let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
479
+ let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
415
480
  if (value === undefined) {
416
481
  return [];
417
482
  }
418
- if (!type.includes(coercedType)) {
483
+ if (!options.types.some(({ type })=>type === coercedType)) {
419
484
  if (isOnlyPlugin) {
420
485
  _log.default.warn([
421
486
  `Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
422
- `You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`,
487
+ `You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
423
488
  ]);
424
489
  } else {
425
490
  return [];
426
491
  }
427
492
  }
428
- if (!(0, _isValidArbitraryValue).default(value)) {
493
+ if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
429
494
  return [];
430
495
  }
431
- let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
432
- [(0, _nameClass).default(identifier, modifier)]: declaration
433
- })
434
- );
496
+ let extras = {
497
+ get modifier () {
498
+ if (!options.modifiers) {
499
+ _log.default.warn(`modifier-used-without-options-for-${identifier}`, [
500
+ "Your plugin must set `modifiers: true` in its options to support modifiers."
501
+ ]);
502
+ }
503
+ return utilityModifier;
504
+ }
505
+ };
506
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
507
+ let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
508
+ [(0, _nameClass.default)(identifier, modifier)]: declaration
509
+ }));
435
510
  return ruleSets;
436
511
  }
437
512
  let withOffsets = [
@@ -447,8 +522,90 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
447
522
  }
448
523
  context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
449
524
  }
525
+ },
526
+ addVariant (variantName, variantFunctions, options = {}) {
527
+ variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
528
+ if (typeof variantFunction !== "string") {
529
+ // Safelist public API functions
530
+ return (api = {})=>{
531
+ let { args , modifySelectors , container , separator , wrap , format } = api;
532
+ let result = variantFunction(Object.assign({
533
+ modifySelectors,
534
+ container,
535
+ separator
536
+ }, options.type === VARIANT_TYPES.MatchVariant && {
537
+ args,
538
+ wrap,
539
+ format
540
+ }));
541
+ if (typeof result === "string" && !isValidVariantFormatString(result)) {
542
+ throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
543
+ }
544
+ if (Array.isArray(result)) {
545
+ return result.filter((variant)=>typeof variant === "string").map((variant)=>parseVariant(variant));
546
+ }
547
+ // result may be undefined with legacy variants that use APIs like `modifySelectors`
548
+ // result may also be a postcss node if someone was returning the result from `modifySelectors`
549
+ return result && typeof result === "string" && parseVariant(result)(api);
550
+ };
551
+ }
552
+ if (!isValidVariantFormatString(variantFunction)) {
553
+ throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
554
+ }
555
+ return parseVariant(variantFunction);
556
+ });
557
+ insertInto(variantList, variantName, options);
558
+ variantMap.set(variantName, variantFunctions);
559
+ context.variantOptions.set(variantName, options);
560
+ },
561
+ matchVariant (variant, variantFn, options) {
562
+ var _options_id;
563
+ // A unique identifier that "groups" these variants together.
564
+ // This is for internal use only which is why it is not present in the types
565
+ let id = (_options_id = options === null || options === void 0 ? void 0 : options.id) !== null && _options_id !== void 0 ? _options_id : ++variantIdentifier;
566
+ let isSpecial = variant === "@";
567
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
568
+ var _options_values;
569
+ for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
570
+ if (key === "DEFAULT") continue;
571
+ api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>{
572
+ return variantFn(value, modifiersEnabled ? {
573
+ modifier: args === null || args === void 0 ? void 0 : args.modifier,
574
+ container
575
+ } : {
576
+ container
577
+ });
578
+ }, {
579
+ ...options,
580
+ value,
581
+ id,
582
+ type: VARIANT_TYPES.MatchVariant,
583
+ variantInfo: VARIANT_INFO.Base
584
+ });
585
+ }
586
+ var _options_values1;
587
+ let hasDefault = "DEFAULT" in ((_options_values1 = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {});
588
+ api.addVariant(variant, ({ args , container })=>{
589
+ if ((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE && !hasDefault) {
590
+ return null;
591
+ }
592
+ var // (JetBrains) plugins.
593
+ _args_value;
594
+ return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (_args_value = args === null || args === void 0 ? void 0 : args.value) !== null && _args_value !== void 0 ? _args_value : typeof args === "string" ? args : "", modifiersEnabled ? {
595
+ modifier: args === null || args === void 0 ? void 0 : args.modifier,
596
+ container
597
+ } : {
598
+ container
599
+ });
600
+ }, {
601
+ ...options,
602
+ id,
603
+ type: VARIANT_TYPES.MatchVariant,
604
+ variantInfo: VARIANT_INFO.Dynamic
605
+ });
450
606
  }
451
607
  };
608
+ return api;
452
609
  }
453
610
  let fileModifiedMapCache = new WeakMap();
454
611
  function getFileModifiedMap(context) {
@@ -460,14 +617,14 @@ function getFileModifiedMap(context) {
460
617
  function trackModified(files, fileModifiedMap) {
461
618
  let changed = false;
462
619
  for (let file of files){
463
- var ref;
620
+ var _fs_statSync;
464
621
  if (!file) continue;
465
622
  let parsed = _url.default.parse(file);
466
623
  let pathname = parsed.hash ? parsed.href.replace(parsed.hash, "") : parsed.href;
467
624
  pathname = parsed.search ? pathname.replace(parsed.search, "") : pathname;
468
- let newModified = (ref = _fs.default.statSync(decodeURIComponent(pathname), {
625
+ let newModified = (_fs_statSync = _fs.default.statSync(decodeURIComponent(pathname), {
469
626
  throwIfNoEntry: false
470
- })) === null || ref === void 0 ? void 0 : ref.mtimeMs;
627
+ })) === null || _fs_statSync === void 0 ? void 0 : _fs_statSync.mtimeMs;
471
628
  if (!newModified) {
472
629
  continue;
473
630
  }
@@ -514,19 +671,21 @@ function collectLayerPlugins(root) {
514
671
  }
515
672
  layerRule.remove();
516
673
  } else if (layerRule.params === "components") {
517
- for (let node of layerRule.nodes){
674
+ for (let node1 of layerRule.nodes){
518
675
  layerPlugins.push(function({ addComponents }) {
519
- addComponents(node, {
520
- respectPrefix: false
676
+ addComponents(node1, {
677
+ respectPrefix: false,
678
+ preserveSource: true
521
679
  });
522
680
  });
523
681
  }
524
682
  layerRule.remove();
525
683
  } else if (layerRule.params === "utilities") {
526
- for (let node of layerRule.nodes){
684
+ for (let node2 of layerRule.nodes){
527
685
  layerPlugins.push(function({ addUtilities }) {
528
- addUtilities(node, {
529
- respectPrefix: false
686
+ addUtilities(node2, {
687
+ respectPrefix: false,
688
+ preserveSource: true
530
689
  });
531
690
  });
532
691
  }
@@ -556,15 +715,19 @@ function resolvePlugins(context, root) {
556
715
  // were historically sorted before screen/stackable variants.
557
716
  let beforeVariants = [
558
717
  _corePlugins.variantPlugins["pseudoElementVariants"],
559
- _corePlugins.variantPlugins["pseudoClassVariants"],
718
+ _corePlugins.variantPlugins["pseudoClassVariants"],
719
+ _corePlugins.variantPlugins["ariaVariants"],
720
+ _corePlugins.variantPlugins["dataVariants"]
560
721
  ];
561
722
  let afterVariants = [
723
+ _corePlugins.variantPlugins["supportsVariants"],
562
724
  _corePlugins.variantPlugins["directionVariants"],
563
725
  _corePlugins.variantPlugins["reducedMotionVariants"],
726
+ _corePlugins.variantPlugins["prefersContrastVariants"],
564
727
  _corePlugins.variantPlugins["darkVariants"],
565
728
  _corePlugins.variantPlugins["printVariant"],
566
729
  _corePlugins.variantPlugins["screenVariants"],
567
- _corePlugins.variantPlugins["orientationVariants"],
730
+ _corePlugins.variantPlugins["orientationVariants"]
568
731
  ];
569
732
  return [
570
733
  ...corePluginList,
@@ -577,13 +740,9 @@ function resolvePlugins(context, root) {
577
740
  function registerPlugins(plugins, context) {
578
741
  let variantList = [];
579
742
  let variantMap = new Map();
580
- let offsets = {
581
- defaults: 0n,
582
- base: 0n,
583
- components: 0n,
584
- utilities: 0n,
585
- user: 0n
586
- };
743
+ context.variantMap = variantMap;
744
+ let offsets = new _offsetsJs.Offsets();
745
+ context.offsets = offsets;
587
746
  let classList = new Set();
588
747
  let pluginApi = buildPluginApi(context.tailwindConfig, context, {
589
748
  variantList,
@@ -600,89 +759,53 @@ function registerPlugins(plugins, context) {
600
759
  plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
601
760
  }
602
761
  }
603
- let highestOffset = ((args)=>args.reduce((m, e)=>e > m ? e : m
604
- )
605
- )([
606
- offsets.base,
607
- offsets.defaults,
608
- offsets.components,
609
- offsets.utilities,
610
- offsets.user,
611
- ]);
612
- let reservedBits = BigInt(highestOffset.toString(2).length);
613
- // A number one less than the top range of the highest offset area
614
- // so arbitrary properties are always sorted at the end.
615
- context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
616
- context.layerOrder = {
617
- defaults: 1n << reservedBits << 0n,
618
- base: 1n << reservedBits << 1n,
619
- components: 1n << reservedBits << 2n,
620
- utilities: 1n << reservedBits << 3n,
621
- user: 1n << reservedBits << 4n
622
- };
623
- reservedBits += 5n;
624
- let offset = 0;
625
- context.variantOrder = new Map(variantList.map((variant, i)=>{
626
- let variantFunctions = variantMap.get(variant).length;
627
- let bits = 1n << BigInt(i + offset) << reservedBits;
628
- offset += variantFunctions - 1;
629
- return [
630
- variant,
631
- bits
632
- ];
633
- }).sort(([, a], [, z])=>(0, _bigSign).default(a - z)
634
- ));
635
- context.minimumScreen = [
636
- ...context.variantOrder.values()
637
- ].shift();
762
+ // Make sure to record bit masks for every variant
763
+ offsets.recordVariants(variantList, (variant)=>variantMap.get(variant).length);
638
764
  // Build variantMap
639
- for (let [variantName, variantFunctions1] of variantMap.entries()){
640
- let sort = context.variantOrder.get(variantName);
641
- context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
642
- sort << BigInt(idx),
765
+ for (let [variantName, variantFunctions] of variantMap.entries()){
766
+ context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
767
+ offsets.forVariant(variantName, idx),
643
768
  variantFunction
644
- ]
645
- ));
769
+ ]));
646
770
  }
647
- var _safelist;
648
- let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
771
+ var _context_tailwindConfig_safelist;
772
+ let safelist = ((_context_tailwindConfig_safelist = context.tailwindConfig.safelist) !== null && _context_tailwindConfig_safelist !== void 0 ? _context_tailwindConfig_safelist : []).filter(Boolean);
649
773
  if (safelist.length > 0) {
650
774
  let checks = [];
651
- for (let value1 of safelist){
652
- if (typeof value1 === "string") {
775
+ for (let value of safelist){
776
+ if (typeof value === "string") {
653
777
  context.changedContent.push({
654
- content: value1,
778
+ content: value,
655
779
  extension: "html"
656
780
  });
657
781
  continue;
658
782
  }
659
- if (value1 instanceof RegExp) {
783
+ if (value instanceof RegExp) {
660
784
  _log.default.warn("root-regex", [
661
785
  "Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
662
786
  "Update your `safelist` configuration to eliminate this warning.",
663
- "https://tailwindcss.com/docs/content-configuration#safelisting-classes",
787
+ "https://tailwindcss.com/docs/content-configuration#safelisting-classes"
664
788
  ]);
665
789
  continue;
666
790
  }
667
- checks.push(value1);
791
+ checks.push(value);
668
792
  }
669
793
  if (checks.length > 0) {
670
794
  let patternMatchingCount = new Map();
671
795
  let prefixLength = context.tailwindConfig.prefix.length;
796
+ let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
672
797
  for (let util of classList){
673
798
  let utils = Array.isArray(util) ? (()=>{
674
799
  let [utilName, options] = util;
675
- var ref;
676
- let values = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {});
677
- let classes = values.map((value)=>(0, _nameClass).formatClass(utilName, value)
678
- );
800
+ var _options_values;
801
+ let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
802
+ let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
679
803
  if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
680
804
  // This is the normal negated version
681
805
  // e.g. `-inset-1` or `-tw-inset-1`
682
806
  classes = [
683
807
  ...classes,
684
- ...classes.map((cls)=>"-" + cls
685
- )
808
+ ...classes.map((cls)=>"-" + cls)
686
809
  ];
687
810
  // This is the negated version *after* the prefix
688
811
  // e.g. `tw--inset-1`
@@ -690,8 +813,19 @@ function registerPlugins(plugins, context) {
690
813
  // So we add the negative after the prefix
691
814
  classes = [
692
815
  ...classes,
693
- ...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength)
694
- ),
816
+ ...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
817
+ ];
818
+ }
819
+ if (options.types.some(({ type })=>type === "color")) {
820
+ classes = [
821
+ ...classes,
822
+ ...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
823
+ ];
824
+ }
825
+ if (checkImportantUtils && (options === null || options === void 0 ? void 0 : options.respectImportant)) {
826
+ classes = [
827
+ ...classes,
828
+ ...classes.map((cls)=>"!" + cls)
695
829
  ];
696
830
  }
697
831
  return classes;
@@ -726,33 +860,45 @@ function registerPlugins(plugins, context) {
726
860
  _log.default.warn([
727
861
  `The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
728
862
  "Fix this pattern or remove it from your `safelist` configuration.",
729
- "https://tailwindcss.com/docs/content-configuration#safelisting-classes",
863
+ "https://tailwindcss.com/docs/content-configuration#safelisting-classes"
730
864
  ]);
731
865
  }
732
866
  }
733
867
  }
868
+ var _context_tailwindConfig_darkMode, _concat_;
869
+ let darkClassName = (_concat_ = [].concat((_context_tailwindConfig_darkMode = context.tailwindConfig.darkMode) !== null && _context_tailwindConfig_darkMode !== void 0 ? _context_tailwindConfig_darkMode : "media")[1]) !== null && _concat_ !== void 0 ? _concat_ : "dark";
734
870
  // A list of utilities that are used by certain Tailwind CSS utilities but
735
871
  // that don't exist on their own. This will result in them "not existing" and
736
872
  // sorting could be weird since you still require them in order to make the
737
- // host utitlies work properly. (Thanks Biology)
738
- let parasiteUtilities = new Set([
873
+ // host utilities work properly. (Thanks Biology)
874
+ let parasiteUtilities = [
875
+ prefix(context, darkClassName),
739
876
  prefix(context, "group"),
740
877
  prefix(context, "peer")
741
- ]);
878
+ ];
742
879
  context.getClassOrder = function getClassOrder(classes) {
743
- let sortedClassNames = new Map();
744
- for (let [sort, rule] of (0, _generateRules).generateRules(new Set(classes), context)){
745
- if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue;
746
- sortedClassNames.set(rule.raws.tailwind.candidate, sort);
880
+ // Non-util classes won't be generated, so we default them to null
881
+ let sortedClassNames = new Map(classes.map((className)=>[
882
+ className,
883
+ null
884
+ ]));
885
+ // Sort all classes in order
886
+ // Non-tailwind classes won't be generated and will be left as `null`
887
+ let rules = (0, _generateRules.generateRules)(new Set(classes), context);
888
+ rules = context.offsets.sort(rules);
889
+ let idx = BigInt(parasiteUtilities.length);
890
+ for (const [, rule] of rules){
891
+ sortedClassNames.set(rule.raws.tailwind.candidate, idx++);
747
892
  }
748
893
  return classes.map((className)=>{
749
- var ref;
750
- let order = (ref = sortedClassNames.get(className)) !== null && ref !== void 0 ? ref : null;
751
- if (order === null && parasiteUtilities.has(className)) {
894
+ var _sortedClassNames_get;
895
+ let order = (_sortedClassNames_get = sortedClassNames.get(className)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : null;
896
+ let parasiteIndex = parasiteUtilities.indexOf(className);
897
+ if (order === null && parasiteIndex !== -1) {
752
898
  // This will make sure that it is at the very beginning of the
753
899
  // `components` layer which technically means 'before any
754
900
  // components'.
755
- order = context.layerOrder.components;
901
+ order = BigInt(parasiteIndex);
756
902
  }
757
903
  return [
758
904
  className,
@@ -768,11 +914,15 @@ function registerPlugins(plugins, context) {
768
914
  if (Array.isArray(util)) {
769
915
  let [utilName, options] = util;
770
916
  let negativeClasses = [];
771
- var ref;
772
- for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
773
- output.push((0, _nameClass).formatClass(utilName, key));
774
- if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
775
- negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
917
+ var _options_values;
918
+ for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
919
+ // Ignore undefined and null values
920
+ if (value == null) {
921
+ continue;
922
+ }
923
+ output.push((0, _nameClass.formatClass)(utilName, key));
924
+ if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue.default)(value)) {
925
+ negativeClasses.push((0, _nameClass.formatClass)(utilName, `-${key}`));
776
926
  }
777
927
  }
778
928
  output.push(...negativeClasses);
@@ -782,32 +932,204 @@ function registerPlugins(plugins, context) {
782
932
  }
783
933
  return output;
784
934
  };
935
+ // Generate a list of available variants with meta information of the type of variant.
936
+ context.getVariants = function getVariants() {
937
+ let result = [];
938
+ for (let [name, options] of context.variantOptions.entries()){
939
+ if (options.variantInfo === VARIANT_INFO.Base) continue;
940
+ var _options_values;
941
+ result.push({
942
+ name,
943
+ isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
944
+ values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
945
+ hasDash: name !== "@",
946
+ selectors ({ modifier , value } = {}) {
947
+ let candidate = "__TAILWIND_PLACEHOLDER__";
948
+ let rule = _postcss.default.rule({
949
+ selector: `.${candidate}`
950
+ });
951
+ let container = _postcss.default.root({
952
+ nodes: [
953
+ rule.clone()
954
+ ]
955
+ });
956
+ let before = container.toString();
957
+ var _context_variantMap_get;
958
+ let fns = ((_context_variantMap_get = context.variantMap.get(name)) !== null && _context_variantMap_get !== void 0 ? _context_variantMap_get : []).flatMap(([_, fn])=>fn);
959
+ let formatStrings = [];
960
+ for (let fn of fns){
961
+ var _options_values;
962
+ let localFormatStrings = [];
963
+ var _options_values_value;
964
+ let api = {
965
+ args: {
966
+ modifier,
967
+ value: (_options_values_value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[value]) !== null && _options_values_value !== void 0 ? _options_values_value : value
968
+ },
969
+ separator: context.tailwindConfig.separator,
970
+ modifySelectors (modifierFunction) {
971
+ // Run the modifierFunction over each rule
972
+ container.each((rule)=>{
973
+ if (rule.type !== "rule") {
974
+ return;
975
+ }
976
+ rule.selectors = rule.selectors.map((selector)=>{
977
+ return modifierFunction({
978
+ get className () {
979
+ return (0, _generateRules.getClassNameFromSelector)(selector);
980
+ },
981
+ selector
982
+ });
983
+ });
984
+ });
985
+ return container;
986
+ },
987
+ format (str) {
988
+ localFormatStrings.push(str);
989
+ },
990
+ wrap (wrapper) {
991
+ localFormatStrings.push(`@${wrapper.name} ${wrapper.params} { & }`);
992
+ },
993
+ container
994
+ };
995
+ let ruleWithVariant = fn(api);
996
+ if (localFormatStrings.length > 0) {
997
+ formatStrings.push(localFormatStrings);
998
+ }
999
+ if (Array.isArray(ruleWithVariant)) {
1000
+ for (let variantFunction of ruleWithVariant){
1001
+ localFormatStrings = [];
1002
+ variantFunction(api);
1003
+ formatStrings.push(localFormatStrings);
1004
+ }
1005
+ }
1006
+ }
1007
+ // Reverse engineer the result of the `container`
1008
+ let manualFormatStrings = [];
1009
+ let after = container.toString();
1010
+ if (before !== after) {
1011
+ // Figure out all selectors
1012
+ container.walkRules((rule)=>{
1013
+ let modified = rule.selector;
1014
+ // Rebuild the base selector, this is what plugin authors would do
1015
+ // as well. E.g.: `${variant}${separator}${className}`.
1016
+ // However, plugin authors probably also prepend or append certain
1017
+ // classes, pseudos, ids, ...
1018
+ let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
1019
+ selectors.walkClasses((classNode)=>{
1020
+ classNode.value = `${name}${context.tailwindConfig.separator}${classNode.value}`;
1021
+ });
1022
+ }).processSync(modified);
1023
+ // Now that we know the original selector, the new selector, and
1024
+ // the rebuild part in between, we can replace the part that plugin
1025
+ // authors need to rebuild with `&`, and eventually store it in the
1026
+ // collectedFormats. Similar to what `format('...')` would do.
1027
+ //
1028
+ // E.g.:
1029
+ // variant: foo
1030
+ // selector: .markdown > p
1031
+ // modified (by plugin): .foo .foo\\:markdown > p
1032
+ // rebuiltBase (internal): .foo\\:markdown > p
1033
+ // format: .foo &
1034
+ manualFormatStrings.push(modified.replace(rebuiltBase, "&").replace(candidate, "&"));
1035
+ });
1036
+ // Figure out all atrules
1037
+ container.walkAtRules((atrule)=>{
1038
+ manualFormatStrings.push(`@${atrule.name} (${atrule.params}) { & }`);
1039
+ });
1040
+ }
1041
+ var _options_values1;
1042
+ let isArbitraryVariant = !(value in ((_options_values1 = options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {}));
1043
+ formatStrings = formatStrings.map((format)=>format.map((str)=>({
1044
+ format: str,
1045
+ isArbitraryVariant
1046
+ })));
1047
+ manualFormatStrings = manualFormatStrings.map((format)=>({
1048
+ format,
1049
+ isArbitraryVariant
1050
+ }));
1051
+ let opts = {
1052
+ candidate,
1053
+ context
1054
+ };
1055
+ let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
1056
+ if (manualFormatStrings.length > 0) {
1057
+ result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
1058
+ }
1059
+ return result;
1060
+ }
1061
+ });
1062
+ }
1063
+ return result;
1064
+ };
1065
+ }
1066
+ /**
1067
+ * Mark as class as retroactively invalid
1068
+ *
1069
+ *
1070
+ * @param {string} candidate
1071
+ */ function markInvalidUtilityCandidate(context, candidate) {
1072
+ if (!context.classCache.has(candidate)) {
1073
+ return;
1074
+ }
1075
+ // Mark this as not being a real utility
1076
+ context.notClassCache.add(candidate);
1077
+ // Remove it from any candidate-specific caches
1078
+ context.classCache.delete(candidate);
1079
+ context.applyClassCache.delete(candidate);
1080
+ context.candidateRuleMap.delete(candidate);
1081
+ context.candidateRuleCache.delete(candidate);
1082
+ // Ensure the stylesheet gets rebuilt
1083
+ context.stylesheetCache = null;
1084
+ }
1085
+ /**
1086
+ * Mark as class as retroactively invalid
1087
+ *
1088
+ * @param {import('postcss').Node} node
1089
+ */ function markInvalidUtilityNode(context, node) {
1090
+ let candidate = node.raws.tailwind.candidate;
1091
+ if (!candidate) {
1092
+ return;
1093
+ }
1094
+ for (const entry of context.ruleCache){
1095
+ if (entry[1].raws.tailwind.candidate === candidate) {
1096
+ context.ruleCache.delete(entry);
1097
+ // context.postCssNodeCache.delete(node)
1098
+ }
1099
+ }
1100
+ markInvalidUtilityCandidate(context, candidate);
785
1101
  }
786
1102
  function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
1103
+ var _tailwindConfig_blocklist;
787
1104
  let context = {
788
1105
  disposables: [],
789
1106
  ruleCache: new Set(),
1107
+ candidateRuleCache: new Map(),
790
1108
  classCache: new Map(),
791
1109
  applyClassCache: new Map(),
792
- notClassCache: new Set(),
1110
+ // Seed the not class cache with the blocklist (which is only strings)
1111
+ notClassCache: new Set((_tailwindConfig_blocklist = tailwindConfig.blocklist) !== null && _tailwindConfig_blocklist !== void 0 ? _tailwindConfig_blocklist : []),
793
1112
  postCssNodeCache: new Map(),
794
1113
  candidateRuleMap: new Map(),
795
1114
  tailwindConfig,
796
1115
  changedContent: changedContent,
797
1116
  variantMap: new Map(),
798
- stylesheetCache: null
1117
+ stylesheetCache: null,
1118
+ variantOptions: new Map(),
1119
+ markInvalidUtilityCandidate: (candidate)=>markInvalidUtilityCandidate(context, candidate),
1120
+ markInvalidUtilityNode: (node)=>markInvalidUtilityNode(context, node)
799
1121
  };
800
1122
  let resolvedPlugins = resolvePlugins(context, root);
801
1123
  registerPlugins(resolvedPlugins, context);
802
1124
  return context;
803
1125
  }
804
- let contextMap = sharedState.contextMap;
805
- let configContextMap = sharedState.configContextMap;
806
- let contextSourcesMap = sharedState.contextSourcesMap;
1126
+ let contextMap = _sharedState.contextMap;
1127
+ let configContextMap = _sharedState.configContextMap;
1128
+ let contextSourcesMap = _sharedState.contextSourcesMap;
807
1129
  function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
808
1130
  let sourcePath = result.opts.from;
809
1131
  let isConfigFile = userConfigPath !== null;
810
- sharedState.env.DEBUG && console.log("Source path:", sourcePath);
1132
+ _sharedState.env.DEBUG && console.log("Source path:", sourcePath);
811
1133
  let existingContext;
812
1134
  if (isConfigFile && contextMap.has(sourcePath)) {
813
1135
  existingContext = contextMap.get(sourcePath);
@@ -817,7 +1139,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
817
1139
  contextMap.set(sourcePath, context);
818
1140
  existingContext = context;
819
1141
  }
820
- let cssDidChange = (0, _cacheInvalidationJs).hasContentChanged(sourcePath, root);
1142
+ let cssDidChange = (0, _cacheInvalidationJs.hasContentChanged)(sourcePath, root);
821
1143
  // If there's already a context in the cache and we don't need to
822
1144
  // reset the context, return the cached context.
823
1145
  if (existingContext) {
@@ -842,9 +1164,9 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
842
1164
  contextSourcesMap.get(oldContext).delete(sourcePath);
843
1165
  if (contextSourcesMap.get(oldContext).size === 0) {
844
1166
  contextSourcesMap.delete(oldContext);
845
- for (let [tailwindConfigHash, context] of configContextMap){
846
- if (context === oldContext) {
847
- configContextMap.delete(tailwindConfigHash);
1167
+ for (let [tailwindConfigHash1, context1] of configContextMap){
1168
+ if (context1 === oldContext) {
1169
+ configContextMap.delete(tailwindConfigHash1);
848
1170
  }
849
1171
  }
850
1172
  for (let disposable of oldContext.disposables.splice(0)){
@@ -853,21 +1175,24 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
853
1175
  }
854
1176
  }
855
1177
  }
856
- sharedState.env.DEBUG && console.log("Setting up new context...");
857
- let context = createContext(tailwindConfig, [], root);
1178
+ _sharedState.env.DEBUG && console.log("Setting up new context...");
1179
+ let context2 = createContext(tailwindConfig, [], root);
1180
+ Object.assign(context2, {
1181
+ userConfigPath
1182
+ });
858
1183
  trackModified([
859
1184
  ...contextDependencies
860
- ], getFileModifiedMap(context));
1185
+ ], getFileModifiedMap(context2));
861
1186
  // ---
862
1187
  // Update all context tracking state
863
- configContextMap.set(tailwindConfigHash, context);
864
- contextMap.set(sourcePath, context);
865
- if (!contextSourcesMap.has(context)) {
866
- contextSourcesMap.set(context, new Set());
1188
+ configContextMap.set(tailwindConfigHash, context2);
1189
+ contextMap.set(sourcePath, context2);
1190
+ if (!contextSourcesMap.has(context2)) {
1191
+ contextSourcesMap.set(context2, new Set());
867
1192
  }
868
- contextSourcesMap.get(context).add(sourcePath);
1193
+ contextSourcesMap.get(context2).add(sourcePath);
869
1194
  return [
870
- context,
1195
+ context2,
871
1196
  true
872
1197
  ];
873
1198
  }