tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-insiders.b2e3cf2

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