tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4

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