tailwindcss 0.0.0-insiders.fda68f7 → 0.0.0-oxide.6bf5e56

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