tailwindcss 0.0.0-insiders.68260bd → 0.0.0-insiders.685c19e

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