tailwindcss 3.4.0 → 4.0.0-alpha.1

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