tailwindcss 3.4.1 → 4.0.0-alpha.2

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 (280) hide show
  1. package/README.md +5 -6
  2. package/dist/lib.d.mts +324 -0
  3. package/dist/lib.d.ts +324 -0
  4. package/dist/lib.js +11 -0
  5. package/dist/lib.mjs +11 -0
  6. package/index.css +5 -0
  7. package/package.json +29 -107
  8. package/preflight.css +355 -0
  9. package/theme.css +465 -0
  10. package/CHANGELOG.md +0 -2571
  11. package/base.css +0 -1
  12. package/colors.d.ts +0 -3
  13. package/colors.js +0 -2
  14. package/components.css +0 -1
  15. package/defaultConfig.d.ts +0 -3
  16. package/defaultConfig.js +0 -2
  17. package/defaultTheme.d.ts +0 -4
  18. package/defaultTheme.js +0 -2
  19. package/lib/cli/build/deps.js +0 -62
  20. package/lib/cli/build/index.js +0 -54
  21. package/lib/cli/build/plugin.js +0 -378
  22. package/lib/cli/build/utils.js +0 -88
  23. package/lib/cli/build/watching.js +0 -182
  24. package/lib/cli/help/index.js +0 -73
  25. package/lib/cli/index.js +0 -230
  26. package/lib/cli/init/index.js +0 -63
  27. package/lib/cli-peer-dependencies.js +0 -36
  28. package/lib/cli.js +0 -7
  29. package/lib/corePluginList.js +0 -190
  30. package/lib/corePlugins.js +0 -4282
  31. package/lib/css/LICENSE +0 -25
  32. package/lib/css/preflight.css +0 -385
  33. package/lib/featureFlags.js +0 -83
  34. package/lib/index.js +0 -2
  35. package/lib/lib/cacheInvalidation.js +0 -92
  36. package/lib/lib/collapseAdjacentRules.js +0 -61
  37. package/lib/lib/collapseDuplicateDeclarations.js +0 -85
  38. package/lib/lib/content.js +0 -181
  39. package/lib/lib/defaultExtractor.js +0 -251
  40. package/lib/lib/detectNesting.js +0 -45
  41. package/lib/lib/evaluateTailwindFunctions.js +0 -238
  42. package/lib/lib/expandApplyAtRules.js +0 -540
  43. package/lib/lib/expandTailwindAtRules.js +0 -291
  44. package/lib/lib/findAtConfigPath.js +0 -46
  45. package/lib/lib/generateRules.js +0 -904
  46. package/lib/lib/getModuleDependencies.js +0 -99
  47. package/lib/lib/load-config.js +0 -53
  48. package/lib/lib/normalizeTailwindDirectives.js +0 -89
  49. package/lib/lib/offsets.js +0 -306
  50. package/lib/lib/partitionApplyAtRules.js +0 -58
  51. package/lib/lib/regex.js +0 -74
  52. package/lib/lib/remap-bitfield.js +0 -89
  53. package/lib/lib/resolveDefaultsAtRules.js +0 -165
  54. package/lib/lib/setupContextUtils.js +0 -1294
  55. package/lib/lib/setupTrackingContext.js +0 -166
  56. package/lib/lib/sharedState.js +0 -87
  57. package/lib/lib/substituteScreenAtRules.js +0 -31
  58. package/lib/oxide/cli/build/deps.js +0 -89
  59. package/lib/oxide/cli/build/index.js +0 -53
  60. package/lib/oxide/cli/build/plugin.js +0 -375
  61. package/lib/oxide/cli/build/utils.js +0 -87
  62. package/lib/oxide/cli/build/watching.js +0 -179
  63. package/lib/oxide/cli/help/index.js +0 -72
  64. package/lib/oxide/cli/index.js +0 -214
  65. package/lib/oxide/cli/init/index.js +0 -52
  66. package/lib/oxide/cli.js +0 -5
  67. package/lib/oxide/postcss-plugin.js +0 -2
  68. package/lib/plugin.js +0 -98
  69. package/lib/postcss-plugins/nesting/README.md +0 -42
  70. package/lib/postcss-plugins/nesting/index.js +0 -21
  71. package/lib/postcss-plugins/nesting/plugin.js +0 -89
  72. package/lib/processTailwindFeatures.js +0 -64
  73. package/lib/public/colors.js +0 -355
  74. package/lib/public/create-plugin.js +0 -17
  75. package/lib/public/default-config.js +0 -18
  76. package/lib/public/default-theme.js +0 -18
  77. package/lib/public/load-config.js +0 -12
  78. package/lib/public/resolve-config.js +0 -24
  79. package/lib/util/applyImportantSelector.js +0 -36
  80. package/lib/util/bigSign.js +0 -13
  81. package/lib/util/buildMediaQuery.js +0 -27
  82. package/lib/util/cloneDeep.js +0 -22
  83. package/lib/util/cloneNodes.js +0 -54
  84. package/lib/util/color.js +0 -116
  85. package/lib/util/colorNames.js +0 -752
  86. package/lib/util/configurePlugins.js +0 -23
  87. package/lib/util/createPlugin.js +0 -32
  88. package/lib/util/createUtilityPlugin.js +0 -53
  89. package/lib/util/dataTypes.js +0 -415
  90. package/lib/util/defaults.js +0 -27
  91. package/lib/util/escapeClassName.js +0 -24
  92. package/lib/util/escapeCommas.js +0 -13
  93. package/lib/util/flattenColorPalette.js +0 -18
  94. package/lib/util/formatVariantSelector.js +0 -270
  95. package/lib/util/getAllConfigs.js +0 -50
  96. package/lib/util/hashConfig.js +0 -21
  97. package/lib/util/isKeyframeRule.js +0 -13
  98. package/lib/util/isPlainObject.js +0 -17
  99. package/lib/util/isSyntacticallyValidPropertyValue.js +0 -74
  100. package/lib/util/log.js +0 -61
  101. package/lib/util/nameClass.js +0 -49
  102. package/lib/util/negateValue.js +0 -36
  103. package/lib/util/normalizeConfig.js +0 -282
  104. package/lib/util/normalizeScreens.js +0 -178
  105. package/lib/util/parseAnimationValue.js +0 -93
  106. package/lib/util/parseBoxShadowValue.js +0 -88
  107. package/lib/util/parseDependency.js +0 -47
  108. package/lib/util/parseGlob.js +0 -36
  109. package/lib/util/parseObjectStyles.js +0 -36
  110. package/lib/util/pluginUtils.js +0 -289
  111. package/lib/util/prefixSelector.js +0 -39
  112. package/lib/util/pseudoElements.js +0 -212
  113. package/lib/util/removeAlphaVariables.js +0 -31
  114. package/lib/util/resolveConfig.js +0 -256
  115. package/lib/util/resolveConfigPath.js +0 -70
  116. package/lib/util/responsive.js +0 -24
  117. package/lib/util/splitAtTopLevelOnly.js +0 -51
  118. package/lib/util/tap.js +0 -14
  119. package/lib/util/toColorValue.js +0 -13
  120. package/lib/util/toPath.js +0 -32
  121. package/lib/util/transformThemeValue.js +0 -73
  122. package/lib/util/validateConfig.js +0 -37
  123. package/lib/util/validateFormalSyntax.js +0 -26
  124. package/lib/util/withAlphaVariable.js +0 -79
  125. package/lib/value-parser/LICENSE +0 -22
  126. package/lib/value-parser/README.md +0 -3
  127. package/lib/value-parser/index.d.js +0 -2
  128. package/lib/value-parser/index.js +0 -22
  129. package/lib/value-parser/parse.js +0 -259
  130. package/lib/value-parser/stringify.js +0 -38
  131. package/lib/value-parser/unit.js +0 -86
  132. package/lib/value-parser/walk.js +0 -16
  133. package/loadConfig.d.ts +0 -4
  134. package/loadConfig.js +0 -2
  135. package/nesting/index.d.ts +0 -4
  136. package/nesting/index.js +0 -2
  137. package/peers/index.js +0 -96624
  138. package/plugin.d.ts +0 -11
  139. package/plugin.js +0 -2
  140. package/prettier.config.js +0 -19
  141. package/resolveConfig.d.ts +0 -31
  142. package/resolveConfig.js +0 -2
  143. package/screens.css +0 -1
  144. package/scripts/create-plugin-list.js +0 -10
  145. package/scripts/generate-types.js +0 -104
  146. package/scripts/release-channel.js +0 -18
  147. package/scripts/release-notes.js +0 -21
  148. package/scripts/swap-engines.js +0 -40
  149. package/scripts/type-utils.js +0 -27
  150. package/src/cli/build/deps.js +0 -56
  151. package/src/cli/build/index.js +0 -49
  152. package/src/cli/build/plugin.js +0 -444
  153. package/src/cli/build/utils.js +0 -76
  154. package/src/cli/build/watching.js +0 -229
  155. package/src/cli/help/index.js +0 -70
  156. package/src/cli/index.js +0 -216
  157. package/src/cli/init/index.js +0 -79
  158. package/src/cli-peer-dependencies.js +0 -15
  159. package/src/cli.js +0 -7
  160. package/src/corePluginList.js +0 -1
  161. package/src/corePlugins.js +0 -2943
  162. package/src/css/LICENSE +0 -25
  163. package/src/css/preflight.css +0 -385
  164. package/src/featureFlags.js +0 -66
  165. package/src/index.js +0 -1
  166. package/src/lib/cacheInvalidation.js +0 -52
  167. package/src/lib/collapseAdjacentRules.js +0 -58
  168. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  169. package/src/lib/content.js +0 -208
  170. package/src/lib/defaultExtractor.js +0 -230
  171. package/src/lib/detectNesting.js +0 -47
  172. package/src/lib/evaluateTailwindFunctions.js +0 -272
  173. package/src/lib/expandApplyAtRules.js +0 -620
  174. package/src/lib/expandTailwindAtRules.js +0 -300
  175. package/src/lib/findAtConfigPath.js +0 -48
  176. package/src/lib/generateRules.js +0 -951
  177. package/src/lib/getModuleDependencies.js +0 -79
  178. package/src/lib/load-config.ts +0 -39
  179. package/src/lib/normalizeTailwindDirectives.js +0 -84
  180. package/src/lib/offsets.js +0 -373
  181. package/src/lib/partitionApplyAtRules.js +0 -52
  182. package/src/lib/regex.js +0 -74
  183. package/src/lib/remap-bitfield.js +0 -82
  184. package/src/lib/resolveDefaultsAtRules.js +0 -163
  185. package/src/lib/setupContextUtils.js +0 -1366
  186. package/src/lib/setupTrackingContext.js +0 -169
  187. package/src/lib/sharedState.js +0 -61
  188. package/src/lib/substituteScreenAtRules.js +0 -19
  189. package/src/oxide/cli/build/deps.ts +0 -91
  190. package/src/oxide/cli/build/index.ts +0 -47
  191. package/src/oxide/cli/build/plugin.ts +0 -442
  192. package/src/oxide/cli/build/utils.ts +0 -74
  193. package/src/oxide/cli/build/watching.ts +0 -225
  194. package/src/oxide/cli/help/index.ts +0 -69
  195. package/src/oxide/cli/index.ts +0 -204
  196. package/src/oxide/cli/init/index.ts +0 -59
  197. package/src/oxide/cli.ts +0 -1
  198. package/src/oxide/postcss-plugin.ts +0 -1
  199. package/src/plugin.js +0 -107
  200. package/src/postcss-plugins/nesting/README.md +0 -42
  201. package/src/postcss-plugins/nesting/index.js +0 -13
  202. package/src/postcss-plugins/nesting/plugin.js +0 -80
  203. package/src/processTailwindFeatures.js +0 -59
  204. package/src/public/colors.js +0 -322
  205. package/src/public/create-plugin.js +0 -2
  206. package/src/public/default-config.js +0 -4
  207. package/src/public/default-theme.js +0 -4
  208. package/src/public/load-config.js +0 -2
  209. package/src/public/resolve-config.js +0 -7
  210. package/src/util/applyImportantSelector.js +0 -27
  211. package/src/util/bigSign.js +0 -3
  212. package/src/util/buildMediaQuery.js +0 -22
  213. package/src/util/cloneDeep.js +0 -11
  214. package/src/util/cloneNodes.js +0 -49
  215. package/src/util/color.js +0 -88
  216. package/src/util/colorNames.js +0 -150
  217. package/src/util/configurePlugins.js +0 -23
  218. package/src/util/createPlugin.js +0 -27
  219. package/src/util/createUtilityPlugin.js +0 -37
  220. package/src/util/dataTypes.js +0 -406
  221. package/src/util/defaults.js +0 -17
  222. package/src/util/escapeClassName.js +0 -8
  223. package/src/util/escapeCommas.js +0 -3
  224. package/src/util/flattenColorPalette.js +0 -13
  225. package/src/util/formatVariantSelector.js +0 -324
  226. package/src/util/getAllConfigs.js +0 -38
  227. package/src/util/hashConfig.js +0 -5
  228. package/src/util/isKeyframeRule.js +0 -3
  229. package/src/util/isPlainObject.js +0 -8
  230. package/src/util/isSyntacticallyValidPropertyValue.js +0 -61
  231. package/src/util/log.js +0 -29
  232. package/src/util/nameClass.js +0 -30
  233. package/src/util/negateValue.js +0 -24
  234. package/src/util/normalizeConfig.js +0 -301
  235. package/src/util/normalizeScreens.js +0 -140
  236. package/src/util/parseAnimationValue.js +0 -68
  237. package/src/util/parseBoxShadowValue.js +0 -72
  238. package/src/util/parseDependency.js +0 -44
  239. package/src/util/parseGlob.js +0 -24
  240. package/src/util/parseObjectStyles.js +0 -19
  241. package/src/util/pluginUtils.js +0 -307
  242. package/src/util/prefixSelector.js +0 -33
  243. package/src/util/pseudoElements.js +0 -171
  244. package/src/util/removeAlphaVariables.js +0 -24
  245. package/src/util/resolveConfig.js +0 -277
  246. package/src/util/resolveConfigPath.js +0 -66
  247. package/src/util/responsive.js +0 -10
  248. package/src/util/splitAtTopLevelOnly.js +0 -52
  249. package/src/util/tap.js +0 -4
  250. package/src/util/toColorValue.js +0 -3
  251. package/src/util/toPath.js +0 -26
  252. package/src/util/transformThemeValue.js +0 -62
  253. package/src/util/validateConfig.js +0 -26
  254. package/src/util/validateFormalSyntax.js +0 -34
  255. package/src/util/withAlphaVariable.js +0 -49
  256. package/src/value-parser/LICENSE +0 -22
  257. package/src/value-parser/README.md +0 -3
  258. package/src/value-parser/index.d.ts +0 -177
  259. package/src/value-parser/index.js +0 -28
  260. package/src/value-parser/parse.js +0 -303
  261. package/src/value-parser/stringify.js +0 -41
  262. package/src/value-parser/unit.js +0 -118
  263. package/src/value-parser/walk.js +0 -18
  264. package/stubs/.gitignore +0 -1
  265. package/stubs/.prettierrc.json +0 -6
  266. package/stubs/config.full.js +0 -1062
  267. package/stubs/config.simple.js +0 -7
  268. package/stubs/postcss.config.cjs +0 -6
  269. package/stubs/postcss.config.js +0 -6
  270. package/stubs/tailwind.config.cjs +0 -2
  271. package/stubs/tailwind.config.js +0 -2
  272. package/stubs/tailwind.config.ts +0 -3
  273. package/tailwind.css +0 -5
  274. package/types/config.d.ts +0 -376
  275. package/types/generated/.gitkeep +0 -0
  276. package/types/generated/colors.d.ts +0 -298
  277. package/types/generated/corePluginList.d.ts +0 -1
  278. package/types/generated/default-theme.d.ts +0 -397
  279. package/types/index.d.ts +0 -11
  280. package/variants.css +0 -1
@@ -1,904 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- getClassNameFromSelector: function() {
13
- return getClassNameFromSelector;
14
- },
15
- resolveMatches: function() {
16
- return resolveMatches;
17
- },
18
- generateRules: function() {
19
- return generateRules;
20
- }
21
- });
22
- const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
23
- const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
24
- const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
25
- const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
26
- const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
27
- const _pluginUtils = require("../util/pluginUtils");
28
- const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
29
- const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
30
- const _formatVariantSelector = require("../util/formatVariantSelector");
31
- const _nameClass = require("../util/nameClass");
32
- const _dataTypes = require("../util/dataTypes");
33
- const _setupContextUtils = require("./setupContextUtils");
34
- const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
35
- const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
36
- const _featureFlags = require("../featureFlags");
37
- const _applyImportantSelector = require("../util/applyImportantSelector");
38
- function _interop_require_default(obj) {
39
- return obj && obj.__esModule ? obj : {
40
- default: obj
41
- };
42
- }
43
- function _getRequireWildcardCache(nodeInterop) {
44
- if (typeof WeakMap !== "function") return null;
45
- var cacheBabelInterop = new WeakMap();
46
- var cacheNodeInterop = new WeakMap();
47
- return (_getRequireWildcardCache = function(nodeInterop) {
48
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
49
- })(nodeInterop);
50
- }
51
- function _interop_require_wildcard(obj, nodeInterop) {
52
- if (!nodeInterop && obj && obj.__esModule) {
53
- return obj;
54
- }
55
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
56
- return {
57
- default: obj
58
- };
59
- }
60
- var cache = _getRequireWildcardCache(nodeInterop);
61
- if (cache && cache.has(obj)) {
62
- return cache.get(obj);
63
- }
64
- var newObj = {};
65
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
66
- for(var key in obj){
67
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
68
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
69
- if (desc && (desc.get || desc.set)) {
70
- Object.defineProperty(newObj, key, desc);
71
- } else {
72
- newObj[key] = obj[key];
73
- }
74
- }
75
- }
76
- newObj.default = obj;
77
- if (cache) {
78
- cache.set(obj, newObj);
79
- }
80
- return newObj;
81
- }
82
- let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
83
- return selectors.first.filter(({ type })=>type === "class").pop().value;
84
- });
85
- function getClassNameFromSelector(selector) {
86
- return classNameParser.transformSync(selector);
87
- }
88
- // Generate match permutations for a class candidate, like:
89
- // ['ring-offset-blue', '100']
90
- // ['ring-offset', 'blue-100']
91
- // ['ring', 'offset-blue-100']
92
- // Example with dynamic classes:
93
- // ['grid-cols', '[[linename],1fr,auto]']
94
- // ['grid', 'cols-[[linename],1fr,auto]']
95
- function* candidatePermutations(candidate) {
96
- let lastIndex = Infinity;
97
- while(lastIndex >= 0){
98
- let dashIdx;
99
- let wasSlash = false;
100
- if (lastIndex === Infinity && candidate.endsWith("]")) {
101
- let bracketIdx = candidate.indexOf("[");
102
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
103
- // eg. string[]
104
- if (candidate[bracketIdx - 1] === "-") {
105
- dashIdx = bracketIdx - 1;
106
- } else if (candidate[bracketIdx - 1] === "/") {
107
- dashIdx = bracketIdx - 1;
108
- wasSlash = true;
109
- } else {
110
- dashIdx = -1;
111
- }
112
- } else if (lastIndex === Infinity && candidate.includes("/")) {
113
- dashIdx = candidate.lastIndexOf("/");
114
- wasSlash = true;
115
- } else {
116
- dashIdx = candidate.lastIndexOf("-", lastIndex);
117
- }
118
- if (dashIdx < 0) {
119
- break;
120
- }
121
- let prefix = candidate.slice(0, dashIdx);
122
- let modifier = candidate.slice(wasSlash ? dashIdx : dashIdx + 1);
123
- lastIndex = dashIdx - 1;
124
- // TODO: This feels a bit hacky
125
- if (prefix === "" || modifier === "/") {
126
- continue;
127
- }
128
- yield [
129
- prefix,
130
- modifier
131
- ];
132
- }
133
- }
134
- function applyPrefix(matches, context) {
135
- if (matches.length === 0 || context.tailwindConfig.prefix === "") {
136
- return matches;
137
- }
138
- for (let match of matches){
139
- let [meta] = match;
140
- if (meta.options.respectPrefix) {
141
- let container = _postcss.default.root({
142
- nodes: [
143
- match[1].clone()
144
- ]
145
- });
146
- let classCandidate = match[1].raws.tailwind.classCandidate;
147
- container.walkRules((r)=>{
148
- // If this is a negative utility with a dash *before* the prefix we
149
- // have to ensure that the generated selector matches the candidate
150
- // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
151
- // The disconnect between candidate <-> class can cause @apply to hard crash.
152
- let shouldPrependNegative = classCandidate.startsWith("-");
153
- r.selector = (0, _prefixSelector.default)(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
154
- });
155
- match[1] = container.nodes[0];
156
- }
157
- }
158
- return matches;
159
- }
160
- function applyImportant(matches, classCandidate) {
161
- if (matches.length === 0) {
162
- return matches;
163
- }
164
- let result = [];
165
- function isInKeyframes(rule) {
166
- return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
167
- }
168
- for (let [meta, rule] of matches){
169
- let container = _postcss.default.root({
170
- nodes: [
171
- rule.clone()
172
- ]
173
- });
174
- container.walkRules((r)=>{
175
- // Declarations inside keyframes cannot be marked as important
176
- // They will be ignored by the browser
177
- if (isInKeyframes(r)) {
178
- return;
179
- }
180
- let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
181
- // Remove extraneous selectors that do not include the base candidate
182
- ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
183
- // Update all instances of the base candidate to include the important marker
184
- (0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
185
- r.selector = ast.toString();
186
- r.walkDecls((d)=>d.important = true);
187
- });
188
- result.push([
189
- {
190
- ...meta,
191
- important: true
192
- },
193
- container.nodes[0]
194
- ]);
195
- }
196
- return result;
197
- }
198
- // Takes a list of rule tuples and applies a variant like `hover`, sm`,
199
- // whatever to it. We used to do some extra caching here to avoid generating
200
- // a variant of the same rule more than once, but this was never hit because
201
- // we cache at the entire selector level further up the tree.
202
- //
203
- // Technically you can get a cache hit if you have `hover:focus:text-center`
204
- // and `focus:hover:text-center` in the same project, but it doesn't feel
205
- // worth the complexity for that case.
206
- function applyVariant(variant, matches, context) {
207
- if (matches.length === 0) {
208
- return matches;
209
- }
210
- /** @type {{modifier: string | null, value: string | null}} */ let args = {
211
- modifier: null,
212
- value: _sharedState.NONE
213
- };
214
- // Retrieve "modifier"
215
- {
216
- let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, "/");
217
- // This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
218
- // In this case 1/10 is a value but /20 is a modifier
219
- if (modifiers.length > 1) {
220
- baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
221
- modifiers = modifiers.slice(-1);
222
- }
223
- if (modifiers.length && !context.variantMap.has(variant)) {
224
- variant = baseVariant;
225
- args.modifier = modifiers[0];
226
- if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
227
- return [];
228
- }
229
- }
230
- }
231
- // Retrieve "arbitrary value"
232
- if (variant.endsWith("]") && !variant.startsWith("[")) {
233
- // We either have:
234
- // @[200px]
235
- // group-[:hover]
236
- //
237
- // But we don't want:
238
- // @-[200px] (`-` is incorrect)
239
- // group[:hover] (`-` is missing)
240
- let match = /(.)(-?)\[(.*)\]/g.exec(variant);
241
- if (match) {
242
- let [, char, separator, value] = match;
243
- // @-[200px] case
244
- if (char === "@" && separator === "-") return [];
245
- // group[:hover] case
246
- if (char !== "@" && separator === "") return [];
247
- variant = variant.replace(`${separator}[${value}]`, "");
248
- args.value = value;
249
- }
250
- }
251
- // Register arbitrary variants
252
- if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
253
- let sort = context.offsets.recordVariant(variant);
254
- let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
255
- let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ",");
256
- // We do not support multiple selectors for arbitrary variants
257
- if (selectors.length > 1) {
258
- return [];
259
- }
260
- if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
261
- return [];
262
- }
263
- let records = selectors.map((sel, idx)=>[
264
- context.offsets.applyParallelOffset(sort, idx),
265
- (0, _setupContextUtils.parseVariant)(sel.trim())
266
- ]);
267
- context.variantMap.set(variant, records);
268
- }
269
- if (context.variantMap.has(variant)) {
270
- var _context_variantOptions_get;
271
- let isArbitraryVariant = isArbitraryValue(variant);
272
- var _context_variantOptions_get_INTERNAL_FEATURES;
273
- let internalFeatures = (_context_variantOptions_get_INTERNAL_FEATURES = (_context_variantOptions_get = context.variantOptions.get(variant)) === null || _context_variantOptions_get === void 0 ? void 0 : _context_variantOptions_get[_setupContextUtils.INTERNAL_FEATURES]) !== null && _context_variantOptions_get_INTERNAL_FEATURES !== void 0 ? _context_variantOptions_get_INTERNAL_FEATURES : {};
274
- let variantFunctionTuples = context.variantMap.get(variant).slice();
275
- let result = [];
276
- let respectPrefix = (()=>{
277
- if (isArbitraryVariant) return false;
278
- if (internalFeatures.respectPrefix === false) return false;
279
- return true;
280
- })();
281
- for (let [meta, rule] of matches){
282
- // Don't generate variants for user css
283
- if (meta.layer === "user") {
284
- continue;
285
- }
286
- let container = _postcss.default.root({
287
- nodes: [
288
- rule.clone()
289
- ]
290
- });
291
- for (let [variantSort, variantFunction, containerFromArray] of variantFunctionTuples){
292
- let clone = (containerFromArray !== null && containerFromArray !== void 0 ? containerFromArray : container).clone();
293
- let collectedFormats = [];
294
- function prepareBackup() {
295
- // Already prepared, chicken out
296
- if (clone.raws.neededBackup) {
297
- return;
298
- }
299
- clone.raws.neededBackup = true;
300
- clone.walkRules((rule)=>rule.raws.originalSelector = rule.selector);
301
- }
302
- function modifySelectors(modifierFunction) {
303
- prepareBackup();
304
- clone.each((rule)=>{
305
- if (rule.type !== "rule") {
306
- return;
307
- }
308
- rule.selectors = rule.selectors.map((selector)=>{
309
- return modifierFunction({
310
- get className () {
311
- return getClassNameFromSelector(selector);
312
- },
313
- selector
314
- });
315
- });
316
- });
317
- return clone;
318
- }
319
- let ruleWithVariant = variantFunction({
320
- // Public API
321
- get container () {
322
- prepareBackup();
323
- return clone;
324
- },
325
- separator: context.tailwindConfig.separator,
326
- modifySelectors,
327
- // Private API for now
328
- wrap (wrapper) {
329
- let nodes = clone.nodes;
330
- clone.removeAll();
331
- wrapper.append(nodes);
332
- clone.append(wrapper);
333
- },
334
- format (selectorFormat) {
335
- collectedFormats.push({
336
- format: selectorFormat,
337
- respectPrefix
338
- });
339
- },
340
- args
341
- });
342
- // It can happen that a list of format strings is returned from within the function. In that
343
- // case, we have to process them as well. We can use the existing `variantSort`.
344
- if (Array.isArray(ruleWithVariant)) {
345
- for (let [idx, variantFunction] of ruleWithVariant.entries()){
346
- // This is a little bit scary since we are pushing to an array of items that we are
347
- // currently looping over. However, you can also think of it like a processing queue
348
- // where you keep handling jobs until everything is done and each job can queue more
349
- // jobs if needed.
350
- variantFunctionTuples.push([
351
- context.offsets.applyParallelOffset(variantSort, idx),
352
- variantFunction,
353
- // If the clone has been modified we have to pass that back
354
- // though so each rule can use the modified container
355
- clone.clone()
356
- ]);
357
- }
358
- continue;
359
- }
360
- if (typeof ruleWithVariant === "string") {
361
- collectedFormats.push({
362
- format: ruleWithVariant,
363
- respectPrefix
364
- });
365
- }
366
- if (ruleWithVariant === null) {
367
- continue;
368
- }
369
- // We had to backup selectors, therefore we assume that somebody touched
370
- // `container` or `modifySelectors`. Let's see if they did, so that we
371
- // can restore the selectors, and collect the format strings.
372
- if (clone.raws.neededBackup) {
373
- delete clone.raws.neededBackup;
374
- clone.walkRules((rule)=>{
375
- let before = rule.raws.originalSelector;
376
- if (!before) return;
377
- delete rule.raws.originalSelector;
378
- if (before === rule.selector) return; // No mutation happened
379
- let modified = rule.selector;
380
- // Rebuild the base selector, this is what plugin authors would do
381
- // as well. E.g.: `${variant}${separator}${className}`.
382
- // However, plugin authors probably also prepend or append certain
383
- // classes, pseudos, ids, ...
384
- let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
385
- selectors.walkClasses((classNode)=>{
386
- classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
387
- });
388
- }).processSync(before);
389
- // Now that we know the original selector, the new selector, and
390
- // the rebuild part in between, we can replace the part that plugin
391
- // authors need to rebuild with `&`, and eventually store it in the
392
- // collectedFormats. Similar to what `format('...')` would do.
393
- //
394
- // E.g.:
395
- // variant: foo
396
- // selector: .markdown > p
397
- // modified (by plugin): .foo .foo\\:markdown > p
398
- // rebuiltBase (internal): .foo\\:markdown > p
399
- // format: .foo &
400
- collectedFormats.push({
401
- format: modified.replace(rebuiltBase, "&"),
402
- respectPrefix
403
- });
404
- rule.selector = before;
405
- });
406
- }
407
- // This tracks the originating layer for the variant
408
- // For example:
409
- // .sm:underline {} is a variant of something in the utilities layer
410
- // .sm:container {} is a variant of the container component
411
- clone.nodes[0].raws.tailwind = {
412
- ...clone.nodes[0].raws.tailwind,
413
- parentLayer: meta.layer
414
- };
415
- var _meta_collectedFormats;
416
- let withOffset = [
417
- {
418
- ...meta,
419
- sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
420
- collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
421
- },
422
- clone.nodes[0]
423
- ];
424
- result.push(withOffset);
425
- }
426
- }
427
- return result;
428
- }
429
- return [];
430
- }
431
- function parseRules(rule, cache, options = {}) {
432
- // PostCSS node
433
- if (!(0, _isPlainObject.default)(rule) && !Array.isArray(rule)) {
434
- return [
435
- [
436
- rule
437
- ],
438
- options
439
- ];
440
- }
441
- // Tuple
442
- if (Array.isArray(rule)) {
443
- return parseRules(rule[0], cache, rule[1]);
444
- }
445
- // Simple object
446
- if (!cache.has(rule)) {
447
- cache.set(rule, (0, _parseObjectStyles.default)(rule));
448
- }
449
- return [
450
- cache.get(rule),
451
- options
452
- ];
453
- }
454
- const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
455
- function isValidPropName(name) {
456
- return IS_VALID_PROPERTY_NAME.test(name);
457
- }
458
- /**
459
- * @param {string} declaration
460
- * @returns {boolean}
461
- */ function looksLikeUri(declaration) {
462
- // Quick bailout for obvious non-urls
463
- // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
464
- if (!declaration.includes("://")) {
465
- return false;
466
- }
467
- try {
468
- const url = new URL(declaration);
469
- return url.scheme !== "" && url.host !== "";
470
- } catch (err) {
471
- // Definitely not a valid url
472
- return false;
473
- }
474
- }
475
- function isParsableNode(node) {
476
- let isParsable = true;
477
- node.walkDecls((decl)=>{
478
- if (!isParsableCssValue(decl.prop, decl.value)) {
479
- isParsable = false;
480
- return false;
481
- }
482
- });
483
- return isParsable;
484
- }
485
- function isParsableCssValue(property, value) {
486
- // We don't want to to treat [https://example.com] as a custom property
487
- // Even though, according to the CSS grammar, it's a totally valid CSS declaration
488
- // So we short-circuit here by checking if the custom property looks like a url
489
- if (looksLikeUri(`${property}:${value}`)) {
490
- return false;
491
- }
492
- try {
493
- _postcss.default.parse(`a{${property}:${value}}`).toResult();
494
- return true;
495
- } catch (err) {
496
- return false;
497
- }
498
- }
499
- function extractArbitraryProperty(classCandidate, context) {
500
- var _classCandidate_match;
501
- let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
502
- if (value === undefined) {
503
- return null;
504
- }
505
- if (!isValidPropName(property)) {
506
- return null;
507
- }
508
- if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
509
- return null;
510
- }
511
- let normalized = (0, _dataTypes.normalize)(value, {
512
- property
513
- });
514
- if (!isParsableCssValue(property, normalized)) {
515
- return null;
516
- }
517
- let sort = context.offsets.arbitraryProperty();
518
- return [
519
- [
520
- {
521
- sort,
522
- layer: "utilities"
523
- },
524
- ()=>({
525
- [(0, _nameClass.asClass)(classCandidate)]: {
526
- [property]: normalized
527
- }
528
- })
529
- ]
530
- ];
531
- }
532
- function* resolveMatchedPlugins(classCandidate, context) {
533
- if (context.candidateRuleMap.has(classCandidate)) {
534
- yield [
535
- context.candidateRuleMap.get(classCandidate),
536
- "DEFAULT"
537
- ];
538
- }
539
- yield* function*(arbitraryPropertyRule) {
540
- if (arbitraryPropertyRule !== null) {
541
- yield [
542
- arbitraryPropertyRule,
543
- "DEFAULT"
544
- ];
545
- }
546
- }(extractArbitraryProperty(classCandidate, context));
547
- let candidatePrefix = classCandidate;
548
- let negative = false;
549
- const twConfigPrefix = context.tailwindConfig.prefix;
550
- const twConfigPrefixLen = twConfigPrefix.length;
551
- const hasMatchingPrefix = candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`);
552
- if (candidatePrefix[twConfigPrefixLen] === "-" && hasMatchingPrefix) {
553
- negative = true;
554
- candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
555
- }
556
- if (negative && context.candidateRuleMap.has(candidatePrefix)) {
557
- yield [
558
- context.candidateRuleMap.get(candidatePrefix),
559
- "-DEFAULT"
560
- ];
561
- }
562
- for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
563
- if (context.candidateRuleMap.has(prefix)) {
564
- yield [
565
- context.candidateRuleMap.get(prefix),
566
- negative ? `-${modifier}` : modifier
567
- ];
568
- }
569
- }
570
- }
571
- function splitWithSeparator(input, separator) {
572
- if (input === _sharedState.NOT_ON_DEMAND) {
573
- return [
574
- _sharedState.NOT_ON_DEMAND
575
- ];
576
- }
577
- return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
578
- }
579
- function* recordCandidates(matches, classCandidate) {
580
- for (const match of matches){
581
- var _match__options;
582
- var _match__options_preserveSource;
583
- match[1].raws.tailwind = {
584
- ...match[1].raws.tailwind,
585
- classCandidate,
586
- preserveSource: (_match__options_preserveSource = (_match__options = match[0].options) === null || _match__options === void 0 ? void 0 : _match__options.preserveSource) !== null && _match__options_preserveSource !== void 0 ? _match__options_preserveSource : false
587
- };
588
- yield match;
589
- }
590
- }
591
- function* resolveMatches(candidate, context) {
592
- let separator = context.tailwindConfig.separator;
593
- let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
594
- let important = false;
595
- if (classCandidate.startsWith("!")) {
596
- important = true;
597
- classCandidate = classCandidate.slice(1);
598
- }
599
- // TODO: Reintroduce this in ways that doesn't break on false positives
600
- // function sortAgainst(toSort, against) {
601
- // return toSort.slice().sort((a, z) => {
602
- // return bigSign(against.get(a)[0] - against.get(z)[0])
603
- // })
604
- // }
605
- // let sorted = sortAgainst(variants, context.variantMap)
606
- // if (sorted.toString() !== variants.toString()) {
607
- // let corrected = sorted.reverse().concat(classCandidate).join(':')
608
- // throw new Error(`Class ${candidate} should be written as ${corrected}`)
609
- // }
610
- for (let matchedPlugins of resolveMatchedPlugins(classCandidate, context)){
611
- let matches = [];
612
- let typesByMatches = new Map();
613
- let [plugins, modifier] = matchedPlugins;
614
- let isOnlyPlugin = plugins.length === 1;
615
- for (let [sort, plugin] of plugins){
616
- let matchesPerPlugin = [];
617
- if (typeof plugin === "function") {
618
- for (let ruleSet of [].concat(plugin(modifier, {
619
- isOnlyPlugin
620
- }))){
621
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
622
- for (let rule of rules){
623
- matchesPerPlugin.push([
624
- {
625
- ...sort,
626
- options: {
627
- ...sort.options,
628
- ...options
629
- }
630
- },
631
- rule
632
- ]);
633
- }
634
- }
635
- } else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
636
- let ruleSet = plugin;
637
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
638
- for (let rule of rules){
639
- matchesPerPlugin.push([
640
- {
641
- ...sort,
642
- options: {
643
- ...sort.options,
644
- ...options
645
- }
646
- },
647
- rule
648
- ]);
649
- }
650
- }
651
- if (matchesPerPlugin.length > 0) {
652
- var _sort_options;
653
- var _sort_options_types, _sort_options1;
654
- let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((_sort_options_types = (_sort_options = sort.options) === null || _sort_options === void 0 ? void 0 : _sort_options.types) !== null && _sort_options_types !== void 0 ? _sort_options_types : [], modifier, (_sort_options1 = sort.options) !== null && _sort_options1 !== void 0 ? _sort_options1 : {}, context.tailwindConfig)).map(([_, type])=>type);
655
- if (matchingTypes.length > 0) {
656
- typesByMatches.set(matchesPerPlugin, matchingTypes);
657
- }
658
- matches.push(matchesPerPlugin);
659
- }
660
- }
661
- if (isArbitraryValue(modifier)) {
662
- if (matches.length > 1) {
663
- // Partition plugins in 2 categories so that we can start searching in the plugins that
664
- // don't have `any` as a type first.
665
- let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
666
- let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === "any"));
667
- if (hasAnyType) {
668
- group[0].push(plugin);
669
- } else {
670
- group[1].push(plugin);
671
- }
672
- return group;
673
- }, [
674
- [],
675
- []
676
- ]);
677
- function findFallback(matches) {
678
- // If only a single plugin matches, let's take that one
679
- if (matches.length === 1) {
680
- return matches[0];
681
- }
682
- // Otherwise, find the plugin that creates a valid rule given the arbitrary value, and
683
- // also has the correct type which preferOnConflicts the plugin in case of clashes.
684
- return matches.find((rules)=>{
685
- let matchingTypes = typesByMatches.get(rules);
686
- return rules.some(([{ options }, rule])=>{
687
- if (!isParsableNode(rule)) {
688
- return false;
689
- }
690
- return options.types.some(({ type , preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
691
- });
692
- });
693
- }
694
- var _findFallback;
695
- // Try to find a fallback plugin, because we already know that multiple plugins matched for
696
- // the given arbitrary value.
697
- let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
698
- if (fallback) {
699
- matches = [
700
- fallback
701
- ];
702
- } else {
703
- var _typesByMatches_get;
704
- let typesPerPlugin = matches.map((match)=>new Set([
705
- ...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
706
- ]));
707
- // Remove duplicates, so that we can detect proper unique types for each plugin.
708
- for (let pluginTypes of typesPerPlugin){
709
- for (let type of pluginTypes){
710
- let removeFromOwnGroup = false;
711
- for (let otherGroup of typesPerPlugin){
712
- if (pluginTypes === otherGroup) continue;
713
- if (otherGroup.has(type)) {
714
- otherGroup.delete(type);
715
- removeFromOwnGroup = true;
716
- }
717
- }
718
- if (removeFromOwnGroup) pluginTypes.delete(type);
719
- }
720
- }
721
- let messages = [];
722
- for (let [idx, group] of typesPerPlugin.entries()){
723
- for (let type of group){
724
- let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
725
- .map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
726
- .join("\n")).join("\n\n");
727
- messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
728
- break;
729
- }
730
- }
731
- _log.default.warn([
732
- `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
733
- ...messages,
734
- `If this is content and not a class, replace it with \`${candidate.replace("[", "&lsqb;").replace("]", "&rsqb;")}\` to silence this warning.`
735
- ]);
736
- continue;
737
- }
738
- }
739
- matches = matches.map((list)=>list.filter((match)=>isParsableNode(match[1])));
740
- }
741
- matches = matches.flat();
742
- matches = Array.from(recordCandidates(matches, classCandidate));
743
- matches = applyPrefix(matches, context);
744
- if (important) {
745
- matches = applyImportant(matches, classCandidate);
746
- }
747
- for (let variant of variants){
748
- matches = applyVariant(variant, matches, context);
749
- }
750
- for (let match of matches){
751
- match[1].raws.tailwind = {
752
- ...match[1].raws.tailwind,
753
- candidate
754
- };
755
- // Apply final format selector
756
- match = applyFinalFormat(match, {
757
- context,
758
- candidate
759
- });
760
- // Skip rules with invalid selectors
761
- // This will cause the candidate to be added to the "not class"
762
- // cache skipping it entirely for future builds
763
- if (match === null) {
764
- continue;
765
- }
766
- yield match;
767
- }
768
- }
769
- }
770
- function applyFinalFormat(match, { context , candidate }) {
771
- if (!match[0].collectedFormats) {
772
- return match;
773
- }
774
- let isValid = true;
775
- let finalFormat;
776
- try {
777
- finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
778
- context,
779
- candidate
780
- });
781
- } catch {
782
- // The format selector we produced is invalid
783
- // This could be because:
784
- // - A bug exists
785
- // - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
786
- // - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
787
- // Either way the build will fail because of this
788
- // We would rather that the build pass "silently" given that this could
789
- // happen because of picking up invalid things when scanning content
790
- // So we'll throw out the candidate instead
791
- return null;
792
- }
793
- let container = _postcss.default.root({
794
- nodes: [
795
- match[1].clone()
796
- ]
797
- });
798
- container.walkRules((rule)=>{
799
- if (inKeyframes(rule)) {
800
- return;
801
- }
802
- try {
803
- let selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
804
- candidate,
805
- context
806
- });
807
- // Finalize Selector determined that this candidate is irrelevant
808
- // TODO: This elimination should happen earlier so this never happens
809
- if (selector === null) {
810
- rule.remove();
811
- return;
812
- }
813
- rule.selector = selector;
814
- } catch {
815
- // If this selector is invalid we also want to skip it
816
- // But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
817
- isValid = false;
818
- return false;
819
- }
820
- });
821
- if (!isValid) {
822
- return null;
823
- }
824
- // If all rules have been eliminated we can skip this candidate entirely
825
- if (container.nodes.length === 0) {
826
- return null;
827
- }
828
- match[1] = container.nodes[0];
829
- return match;
830
- }
831
- function inKeyframes(rule) {
832
- return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
833
- }
834
- function getImportantStrategy(important) {
835
- if (important === true) {
836
- return (rule)=>{
837
- if (inKeyframes(rule)) {
838
- return;
839
- }
840
- rule.walkDecls((d)=>{
841
- if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
842
- d.important = true;
843
- }
844
- });
845
- };
846
- }
847
- if (typeof important === "string") {
848
- return (rule)=>{
849
- if (inKeyframes(rule)) {
850
- return;
851
- }
852
- rule.selectors = rule.selectors.map((selector)=>{
853
- return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
854
- });
855
- };
856
- }
857
- }
858
- function generateRules(candidates, context, isSorting = false) {
859
- let allRules = [];
860
- let strategy = getImportantStrategy(context.tailwindConfig.important);
861
- for (let candidate of candidates){
862
- if (context.notClassCache.has(candidate)) {
863
- continue;
864
- }
865
- if (context.candidateRuleCache.has(candidate)) {
866
- allRules = allRules.concat(Array.from(context.candidateRuleCache.get(candidate)));
867
- continue;
868
- }
869
- let matches = Array.from(resolveMatches(candidate, context));
870
- if (matches.length === 0) {
871
- context.notClassCache.add(candidate);
872
- continue;
873
- }
874
- context.classCache.set(candidate, matches);
875
- var _context_candidateRuleCache_get;
876
- let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
877
- context.candidateRuleCache.set(candidate, rules);
878
- for (const match of matches){
879
- let [{ sort , options }, rule] = match;
880
- if (options.respectImportant && strategy) {
881
- let container = _postcss.default.root({
882
- nodes: [
883
- rule.clone()
884
- ]
885
- });
886
- container.walkRules(strategy);
887
- rule = container.nodes[0];
888
- }
889
- // Note: We have to clone rules during sorting
890
- // so we eliminate some shared mutable state
891
- let newEntry = [
892
- sort,
893
- isSorting ? rule.clone() : rule
894
- ];
895
- rules.add(newEntry);
896
- context.ruleCache.add(newEntry);
897
- allRules.push(newEntry);
898
- }
899
- }
900
- return allRules;
901
- }
902
- function isArbitraryValue(input) {
903
- return input.startsWith("[") && input.endsWith("]");
904
- }