tailwindcss 0.0.0-insiders.bda8421 → 0.0.0-insiders.bdcd708

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 (279) hide show
  1. package/README.md +7 -11
  2. package/dist/chunk-5JIJA4QV.mjs +1 -0
  3. package/dist/chunk-C2OYBFIH.mjs +1 -0
  4. package/dist/chunk-DCG7AFIE.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 +1 -0
  17. package/dist/flatten-color-palette.mjs +1 -0
  18. package/dist/lib.d.mts +379 -0
  19. package/dist/lib.d.ts +3 -0
  20. package/dist/lib.js +38 -0
  21. package/dist/lib.mjs +38 -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-DWdTiksJ.d.mts +128 -0
  29. package/index.css +950 -0
  30. package/package.json +76 -105
  31. package/preflight.css +398 -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/deps.js +0 -62
  42. package/lib/cli/build/index.js +0 -54
  43. package/lib/cli/build/plugin.js +0 -371
  44. package/lib/cli/build/utils.js +0 -88
  45. package/lib/cli/build/watching.js +0 -182
  46. package/lib/cli/help/index.js +0 -73
  47. package/lib/cli/index.js +0 -230
  48. package/lib/cli/init/index.js +0 -63
  49. package/lib/cli-peer-dependencies.js +0 -36
  50. package/lib/cli.js +0 -3
  51. package/lib/corePluginList.js +0 -191
  52. package/lib/corePlugins.js +0 -4311
  53. package/lib/css/LICENSE +0 -25
  54. package/lib/css/preflight.css +0 -386
  55. package/lib/featureFlags.js +0 -79
  56. package/lib/index.js +0 -2
  57. package/lib/lib/cacheInvalidation.js +0 -92
  58. package/lib/lib/collapseAdjacentRules.js +0 -61
  59. package/lib/lib/collapseDuplicateDeclarations.js +0 -85
  60. package/lib/lib/content.js +0 -214
  61. package/lib/lib/defaultExtractor.js +0 -251
  62. package/lib/lib/evaluateTailwindFunctions.js +0 -238
  63. package/lib/lib/expandApplyAtRules.js +0 -553
  64. package/lib/lib/expandTailwindAtRules.js +0 -279
  65. package/lib/lib/findAtConfigPath.js +0 -46
  66. package/lib/lib/generateRules.js +0 -904
  67. package/lib/lib/getModuleDependencies.js +0 -99
  68. package/lib/lib/load-config.js +0 -57
  69. package/lib/lib/normalizeTailwindDirectives.js +0 -89
  70. package/lib/lib/offsets.js +0 -355
  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 -167
  75. package/lib/lib/setupContextUtils.js +0 -1298
  76. package/lib/lib/setupTrackingContext.js +0 -166
  77. package/lib/lib/sharedState.js +0 -79
  78. package/lib/lib/substituteScreenAtRules.js +0 -31
  79. package/lib/plugin.js +0 -48
  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 -62
  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 -54
  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 -415
  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 -270
  106. package/lib/util/getAllConfigs.js +0 -50
  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 -61
  112. package/lib/util/nameClass.js +0 -49
  113. package/lib/util/negateValue.js +0 -36
  114. package/lib/util/normalizeConfig.js +0 -282
  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 -289
  122. package/lib/util/prefixSelector.js +0 -39
  123. package/lib/util/pseudoElements.js +0 -212
  124. package/lib/util/removeAlphaVariables.js +0 -31
  125. package/lib/util/resolveConfig.js +0 -256
  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 -37
  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.d.ts +0 -4
  147. package/nesting/index.js +0 -2
  148. package/peers/index.js +0 -96503
  149. package/plugin.d.ts +0 -11
  150. package/plugin.js +0 -2
  151. package/prettier.config.js +0 -19
  152. package/resolveConfig.d.ts +0 -31
  153. package/resolveConfig.js +0 -2
  154. package/screens.css +0 -1
  155. package/scripts/create-plugin-list.js +0 -10
  156. package/scripts/generate-types.js +0 -104
  157. package/scripts/release-channel.js +0 -18
  158. package/scripts/release-notes.js +0 -21
  159. package/scripts/type-utils.js +0 -27
  160. package/src/cli/build/deps.js +0 -56
  161. package/src/cli/build/index.js +0 -49
  162. package/src/cli/build/plugin.js +0 -437
  163. package/src/cli/build/utils.js +0 -76
  164. package/src/cli/build/watching.js +0 -229
  165. package/src/cli/help/index.js +0 -70
  166. package/src/cli/index.js +0 -216
  167. package/src/cli/init/index.js +0 -79
  168. package/src/cli-peer-dependencies.js +0 -15
  169. package/src/cli.js +0 -3
  170. package/src/corePluginList.js +0 -1
  171. package/src/corePlugins.js +0 -2965
  172. package/src/css/LICENSE +0 -25
  173. package/src/css/preflight.css +0 -386
  174. package/src/featureFlags.js +0 -62
  175. package/src/index.js +0 -1
  176. package/src/lib/cacheInvalidation.js +0 -52
  177. package/src/lib/collapseAdjacentRules.js +0 -58
  178. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  179. package/src/lib/content.js +0 -249
  180. package/src/lib/defaultExtractor.js +0 -230
  181. package/src/lib/evaluateTailwindFunctions.js +0 -272
  182. package/src/lib/expandApplyAtRules.js +0 -637
  183. package/src/lib/expandTailwindAtRules.js +0 -282
  184. package/src/lib/findAtConfigPath.js +0 -48
  185. package/src/lib/generateRules.js +0 -951
  186. package/src/lib/getModuleDependencies.js +0 -79
  187. package/src/lib/load-config.ts +0 -44
  188. package/src/lib/normalizeTailwindDirectives.js +0 -84
  189. package/src/lib/offsets.js +0 -432
  190. package/src/lib/partitionApplyAtRules.js +0 -52
  191. package/src/lib/regex.js +0 -74
  192. package/src/lib/remap-bitfield.js +0 -82
  193. package/src/lib/resolveDefaultsAtRules.js +0 -167
  194. package/src/lib/setupContextUtils.js +0 -1371
  195. package/src/lib/setupTrackingContext.js +0 -169
  196. package/src/lib/sharedState.js +0 -57
  197. package/src/lib/substituteScreenAtRules.js +0 -19
  198. package/src/plugin.js +0 -47
  199. package/src/postcss-plugins/nesting/README.md +0 -42
  200. package/src/postcss-plugins/nesting/index.js +0 -13
  201. package/src/postcss-plugins/nesting/plugin.js +0 -80
  202. package/src/processTailwindFeatures.js +0 -56
  203. package/src/public/colors.js +0 -322
  204. package/src/public/create-plugin.js +0 -2
  205. package/src/public/default-config.js +0 -4
  206. package/src/public/default-theme.js +0 -4
  207. package/src/public/load-config.js +0 -2
  208. package/src/public/resolve-config.js +0 -7
  209. package/src/util/applyImportantSelector.js +0 -27
  210. package/src/util/bigSign.js +0 -3
  211. package/src/util/buildMediaQuery.js +0 -22
  212. package/src/util/cloneDeep.js +0 -11
  213. package/src/util/cloneNodes.js +0 -49
  214. package/src/util/color.js +0 -88
  215. package/src/util/colorNames.js +0 -150
  216. package/src/util/configurePlugins.js +0 -23
  217. package/src/util/createPlugin.js +0 -27
  218. package/src/util/createUtilityPlugin.js +0 -37
  219. package/src/util/dataTypes.js +0 -406
  220. package/src/util/defaults.js +0 -17
  221. package/src/util/escapeClassName.js +0 -8
  222. package/src/util/escapeCommas.js +0 -3
  223. package/src/util/flattenColorPalette.js +0 -13
  224. package/src/util/formatVariantSelector.js +0 -324
  225. package/src/util/getAllConfigs.js +0 -38
  226. package/src/util/hashConfig.js +0 -5
  227. package/src/util/isKeyframeRule.js +0 -3
  228. package/src/util/isPlainObject.js +0 -8
  229. package/src/util/isSyntacticallyValidPropertyValue.js +0 -61
  230. package/src/util/log.js +0 -29
  231. package/src/util/nameClass.js +0 -30
  232. package/src/util/negateValue.js +0 -24
  233. package/src/util/normalizeConfig.js +0 -301
  234. package/src/util/normalizeScreens.js +0 -140
  235. package/src/util/parseAnimationValue.js +0 -68
  236. package/src/util/parseBoxShadowValue.js +0 -72
  237. package/src/util/parseDependency.js +0 -44
  238. package/src/util/parseGlob.js +0 -24
  239. package/src/util/parseObjectStyles.js +0 -19
  240. package/src/util/pluginUtils.js +0 -307
  241. package/src/util/prefixSelector.js +0 -33
  242. package/src/util/pseudoElements.js +0 -171
  243. package/src/util/removeAlphaVariables.js +0 -24
  244. package/src/util/resolveConfig.js +0 -277
  245. package/src/util/resolveConfigPath.js +0 -66
  246. package/src/util/responsive.js +0 -10
  247. package/src/util/splitAtTopLevelOnly.js +0 -52
  248. package/src/util/tap.js +0 -4
  249. package/src/util/toColorValue.js +0 -3
  250. package/src/util/toPath.js +0 -26
  251. package/src/util/transformThemeValue.js +0 -62
  252. package/src/util/validateConfig.js +0 -26
  253. package/src/util/validateFormalSyntax.js +0 -34
  254. package/src/util/withAlphaVariable.js +0 -49
  255. package/src/value-parser/LICENSE +0 -22
  256. package/src/value-parser/README.md +0 -3
  257. package/src/value-parser/index.d.ts +0 -177
  258. package/src/value-parser/index.js +0 -28
  259. package/src/value-parser/parse.js +0 -303
  260. package/src/value-parser/stringify.js +0 -41
  261. package/src/value-parser/unit.js +0 -118
  262. package/src/value-parser/walk.js +0 -18
  263. package/stubs/.gitignore +0 -1
  264. package/stubs/.prettierrc.json +0 -6
  265. package/stubs/config.full.js +0 -1062
  266. package/stubs/config.simple.js +0 -7
  267. package/stubs/postcss.config.cjs +0 -6
  268. package/stubs/postcss.config.js +0 -6
  269. package/stubs/tailwind.config.cjs +0 -2
  270. package/stubs/tailwind.config.js +0 -2
  271. package/stubs/tailwind.config.ts +0 -3
  272. package/tailwind.css +0 -5
  273. package/types/config.d.ts +0 -376
  274. package/types/generated/.gitkeep +0 -0
  275. package/types/generated/colors.d.ts +0 -298
  276. package/types/generated/corePluginList.d.ts +0 -1
  277. package/types/generated/default-theme.d.ts +0 -397
  278. package/types/index.d.ts +0 -11
  279. package/variants.css +0 -1
@@ -1,1298 +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["screenVariants"],
766
- _corePlugins.variantPlugins["orientationVariants"],
767
- _corePlugins.variantPlugins["directionVariants"],
768
- _corePlugins.variantPlugins["darkVariants"],
769
- _corePlugins.variantPlugins["forcedColorsVariants"],
770
- _corePlugins.variantPlugins["printVariant"]
771
- ];
772
- // This is a compatibility fix for the pre 3.4 dark mode behavior
773
- // `class` retains the old behavior, but `selector` keeps the new behavior
774
- let isLegacyDarkMode = context.tailwindConfig.darkMode === "class" || Array.isArray(context.tailwindConfig.darkMode) && context.tailwindConfig.darkMode[0] === "class";
775
- if (isLegacyDarkMode) {
776
- afterVariants = [
777
- _corePlugins.variantPlugins["supportsVariants"],
778
- _corePlugins.variantPlugins["reducedMotionVariants"],
779
- _corePlugins.variantPlugins["prefersContrastVariants"],
780
- _corePlugins.variantPlugins["darkVariants"],
781
- _corePlugins.variantPlugins["screenVariants"],
782
- _corePlugins.variantPlugins["orientationVariants"],
783
- _corePlugins.variantPlugins["directionVariants"],
784
- _corePlugins.variantPlugins["forcedColorsVariants"],
785
- _corePlugins.variantPlugins["printVariant"]
786
- ];
787
- }
788
- return [
789
- ...corePluginList,
790
- ...beforeVariants,
791
- ...userPlugins,
792
- ...afterVariants,
793
- ...layerPlugins
794
- ];
795
- }
796
- function registerPlugins(plugins, context) {
797
- let variantList = [];
798
- let variantMap = new Map();
799
- context.variantMap = variantMap;
800
- let offsets = new _offsets.Offsets();
801
- context.offsets = offsets;
802
- let classList = new Set();
803
- let pluginApi = buildPluginApi(context.tailwindConfig, context, {
804
- variantList,
805
- variantMap,
806
- offsets,
807
- classList
808
- });
809
- for (let plugin of plugins){
810
- if (Array.isArray(plugin)) {
811
- for (let pluginItem of plugin){
812
- pluginItem(pluginApi);
813
- }
814
- } else {
815
- plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
816
- }
817
- }
818
- // Make sure to record bit masks for every variant
819
- offsets.recordVariants(variantList, (variant)=>variantMap.get(variant).length);
820
- // Build variantMap
821
- for (let [variantName, variantFunctions] of variantMap.entries()){
822
- context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
823
- offsets.forVariant(variantName, idx),
824
- variantFunction
825
- ]));
826
- }
827
- var _context_tailwindConfig_safelist;
828
- let safelist = ((_context_tailwindConfig_safelist = context.tailwindConfig.safelist) !== null && _context_tailwindConfig_safelist !== void 0 ? _context_tailwindConfig_safelist : []).filter(Boolean);
829
- if (safelist.length > 0) {
830
- let checks = [];
831
- for (let value of safelist){
832
- if (typeof value === "string") {
833
- context.changedContent.push({
834
- content: value,
835
- extension: "html"
836
- });
837
- continue;
838
- }
839
- if (value instanceof RegExp) {
840
- _log.default.warn("root-regex", [
841
- "Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
842
- "Update your `safelist` configuration to eliminate this warning.",
843
- "https://tailwindcss.com/docs/content-configuration#safelisting-classes"
844
- ]);
845
- continue;
846
- }
847
- checks.push(value);
848
- }
849
- if (checks.length > 0) {
850
- let patternMatchingCount = new Map();
851
- let prefixLength = context.tailwindConfig.prefix.length;
852
- let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
853
- for (let util of classList){
854
- let utils = Array.isArray(util) ? (()=>{
855
- let [utilName, options] = util;
856
- var _options_values;
857
- let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
858
- let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
859
- if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
860
- // This is the normal negated version
861
- // e.g. `-inset-1` or `-tw-inset-1`
862
- classes = [
863
- ...classes,
864
- ...classes.map((cls)=>"-" + cls)
865
- ];
866
- // This is the negated version *after* the prefix
867
- // e.g. `tw--inset-1`
868
- // The prefix is already attached to util name
869
- // So we add the negative after the prefix
870
- classes = [
871
- ...classes,
872
- ...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
873
- ];
874
- }
875
- if (options.types.some(({ type })=>type === "color")) {
876
- classes = [
877
- ...classes,
878
- ...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
879
- ];
880
- }
881
- if (checkImportantUtils && (options === null || options === void 0 ? void 0 : options.respectImportant)) {
882
- classes = [
883
- ...classes,
884
- ...classes.map((cls)=>"!" + cls)
885
- ];
886
- }
887
- return classes;
888
- })() : [
889
- util
890
- ];
891
- for (let util of utils){
892
- for (let { pattern , variants =[] } of checks){
893
- // RegExp with the /g flag are stateful, so let's reset the last
894
- // index pointer to reset the state.
895
- pattern.lastIndex = 0;
896
- if (!patternMatchingCount.has(pattern)) {
897
- patternMatchingCount.set(pattern, 0);
898
- }
899
- if (!pattern.test(util)) continue;
900
- patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
901
- context.changedContent.push({
902
- content: util,
903
- extension: "html"
904
- });
905
- for (let variant of variants){
906
- context.changedContent.push({
907
- content: variant + context.tailwindConfig.separator + util,
908
- extension: "html"
909
- });
910
- }
911
- }
912
- }
913
- }
914
- for (let [regex, count] of patternMatchingCount.entries()){
915
- if (count !== 0) continue;
916
- _log.default.warn([
917
- `The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
918
- "Fix this pattern or remove it from your `safelist` configuration.",
919
- "https://tailwindcss.com/docs/content-configuration#safelisting-classes"
920
- ]);
921
- }
922
- }
923
- }
924
- var _context_tailwindConfig_darkMode, _concat_;
925
- 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";
926
- // A list of utilities that are used by certain Tailwind CSS utilities but
927
- // that don't exist on their own. This will result in them "not existing" and
928
- // sorting could be weird since you still require them in order to make the
929
- // host utilities work properly. (Thanks Biology)
930
- let parasiteUtilities = [
931
- prefix(context, darkClassName),
932
- prefix(context, "group"),
933
- prefix(context, "peer")
934
- ];
935
- context.getClassOrder = function getClassOrder(classes) {
936
- // Sort classes so they're ordered in a deterministic manner
937
- let sorted = [
938
- ...classes
939
- ].sort((a, z)=>{
940
- if (a === z) return 0;
941
- if (a < z) return -1;
942
- return 1;
943
- });
944
- // Non-util classes won't be generated, so we default them to null
945
- let sortedClassNames = new Map(sorted.map((className)=>[
946
- className,
947
- null
948
- ]));
949
- // Sort all classes in order
950
- // Non-tailwind classes won't be generated and will be left as `null`
951
- let rules = (0, _generateRules.generateRules)(new Set(sorted), context, true);
952
- rules = context.offsets.sort(rules);
953
- let idx = BigInt(parasiteUtilities.length);
954
- for (const [, rule] of rules){
955
- let candidate = rule.raws.tailwind.candidate;
956
- var _sortedClassNames_get;
957
- // When multiple rules match a candidate
958
- // always take the position of the first one
959
- sortedClassNames.set(candidate, (_sortedClassNames_get = sortedClassNames.get(candidate)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : idx++);
960
- }
961
- return classes.map((className)=>{
962
- var _sortedClassNames_get;
963
- let order = (_sortedClassNames_get = sortedClassNames.get(className)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : null;
964
- let parasiteIndex = parasiteUtilities.indexOf(className);
965
- if (order === null && parasiteIndex !== -1) {
966
- // This will make sure that it is at the very beginning of the
967
- // `components` layer which technically means 'before any
968
- // components'.
969
- order = BigInt(parasiteIndex);
970
- }
971
- return [
972
- className,
973
- order
974
- ];
975
- });
976
- };
977
- // Generate a list of strings for autocompletion purposes, e.g.
978
- // ['uppercase', 'lowercase', ...]
979
- context.getClassList = function getClassList(options = {}) {
980
- let output = [];
981
- for (let util of classList){
982
- if (Array.isArray(util)) {
983
- var _utilOptions_types;
984
- let [utilName, utilOptions] = util;
985
- let negativeClasses = [];
986
- var _utilOptions_modifiers;
987
- let modifiers = Object.keys((_utilOptions_modifiers = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.modifiers) !== null && _utilOptions_modifiers !== void 0 ? _utilOptions_modifiers : {});
988
- 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")) {
989
- var _context_tailwindConfig_theme_opacity;
990
- modifiers.push(...Object.keys((_context_tailwindConfig_theme_opacity = context.tailwindConfig.theme.opacity) !== null && _context_tailwindConfig_theme_opacity !== void 0 ? _context_tailwindConfig_theme_opacity : {}));
991
- }
992
- let metadata = {
993
- modifiers
994
- };
995
- let includeMetadata = options.includeMetadata && modifiers.length > 0;
996
- var _utilOptions_values;
997
- 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 : {})){
998
- // Ignore undefined and null values
999
- if (value == null) {
1000
- continue;
1001
- }
1002
- let cls = (0, _nameClass.formatClass)(utilName, key);
1003
- output.push(includeMetadata ? [
1004
- cls,
1005
- metadata
1006
- ] : cls);
1007
- if ((utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.supportsNegativeValues) && (0, _negateValue.default)(value)) {
1008
- let cls = (0, _nameClass.formatClass)(utilName, `-${key}`);
1009
- negativeClasses.push(includeMetadata ? [
1010
- cls,
1011
- metadata
1012
- ] : cls);
1013
- }
1014
- }
1015
- output.push(...negativeClasses);
1016
- } else {
1017
- output.push(util);
1018
- }
1019
- }
1020
- return output;
1021
- };
1022
- // Generate a list of available variants with meta information of the type of variant.
1023
- context.getVariants = function getVariants() {
1024
- // We use a unique, random ID for candidate names to avoid conflicts
1025
- // We can't use characters like `_`, `:`, `@` or `.` because they might
1026
- // be used as a separator
1027
- let id = Math.random().toString(36).substring(7).toUpperCase();
1028
- let result = [];
1029
- for (let [name, options] of context.variantOptions.entries()){
1030
- if (options.variantInfo === VARIANT_INFO.Base) continue;
1031
- var _options_values;
1032
- result.push({
1033
- name,
1034
- isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
1035
- values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
1036
- hasDash: name !== "@",
1037
- selectors ({ modifier , value } = {}) {
1038
- let candidate = `TAILWINDPLACEHOLDER${id}`;
1039
- let rule = _postcss.default.rule({
1040
- selector: `.${candidate}`
1041
- });
1042
- let container = _postcss.default.root({
1043
- nodes: [
1044
- rule.clone()
1045
- ]
1046
- });
1047
- let before = container.toString();
1048
- var _context_variantMap_get;
1049
- let fns = ((_context_variantMap_get = context.variantMap.get(name)) !== null && _context_variantMap_get !== void 0 ? _context_variantMap_get : []).flatMap(([_, fn])=>fn);
1050
- let formatStrings = [];
1051
- for (let fn of fns){
1052
- var _options_values;
1053
- let localFormatStrings = [];
1054
- var _options_values_value;
1055
- let api = {
1056
- args: {
1057
- modifier,
1058
- 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
1059
- },
1060
- separator: context.tailwindConfig.separator,
1061
- modifySelectors (modifierFunction) {
1062
- // Run the modifierFunction over each rule
1063
- container.each((rule)=>{
1064
- if (rule.type !== "rule") {
1065
- return;
1066
- }
1067
- rule.selectors = rule.selectors.map((selector)=>{
1068
- return modifierFunction({
1069
- get className () {
1070
- return (0, _generateRules.getClassNameFromSelector)(selector);
1071
- },
1072
- selector
1073
- });
1074
- });
1075
- });
1076
- return container;
1077
- },
1078
- format (str) {
1079
- localFormatStrings.push(str);
1080
- },
1081
- wrap (wrapper) {
1082
- localFormatStrings.push(`@${wrapper.name} ${wrapper.params} { & }`);
1083
- },
1084
- container
1085
- };
1086
- let ruleWithVariant = fn(api);
1087
- if (localFormatStrings.length > 0) {
1088
- formatStrings.push(localFormatStrings);
1089
- }
1090
- if (Array.isArray(ruleWithVariant)) {
1091
- for (let variantFunction of ruleWithVariant){
1092
- localFormatStrings = [];
1093
- variantFunction(api);
1094
- formatStrings.push(localFormatStrings);
1095
- }
1096
- }
1097
- }
1098
- // Reverse engineer the result of the `container`
1099
- let manualFormatStrings = [];
1100
- let after = container.toString();
1101
- if (before !== after) {
1102
- // Figure out all selectors
1103
- container.walkRules((rule)=>{
1104
- let modified = rule.selector;
1105
- // Rebuild the base selector, this is what plugin authors would do
1106
- // as well. E.g.: `${variant}${separator}${className}`.
1107
- // However, plugin authors probably also prepend or append certain
1108
- // classes, pseudos, ids, ...
1109
- let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
1110
- selectors.walkClasses((classNode)=>{
1111
- classNode.value = `${name}${context.tailwindConfig.separator}${classNode.value}`;
1112
- });
1113
- }).processSync(modified);
1114
- // Now that we know the original selector, the new selector, and
1115
- // the rebuild part in between, we can replace the part that plugin
1116
- // authors need to rebuild with `&`, and eventually store it in the
1117
- // collectedFormats. Similar to what `format('...')` would do.
1118
- //
1119
- // E.g.:
1120
- // variant: foo
1121
- // selector: .markdown > p
1122
- // modified (by plugin): .foo .foo\\:markdown > p
1123
- // rebuiltBase (internal): .foo\\:markdown > p
1124
- // format: .foo &
1125
- manualFormatStrings.push(modified.replace(rebuiltBase, "&").replace(candidate, "&"));
1126
- });
1127
- // Figure out all atrules
1128
- container.walkAtRules((atrule)=>{
1129
- manualFormatStrings.push(`@${atrule.name} (${atrule.params}) { & }`);
1130
- });
1131
- }
1132
- var _options_values1;
1133
- let isArbitraryVariant = !(value in ((_options_values1 = options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {}));
1134
- var _options_INTERNAL_FEATURES;
1135
- let internalFeatures = (_options_INTERNAL_FEATURES = options[INTERNAL_FEATURES]) !== null && _options_INTERNAL_FEATURES !== void 0 ? _options_INTERNAL_FEATURES : {};
1136
- let respectPrefix = (()=>{
1137
- if (isArbitraryVariant) return false;
1138
- if (internalFeatures.respectPrefix === false) return false;
1139
- return true;
1140
- })();
1141
- formatStrings = formatStrings.map((format)=>format.map((str)=>({
1142
- format: str,
1143
- respectPrefix
1144
- })));
1145
- manualFormatStrings = manualFormatStrings.map((format)=>({
1146
- format,
1147
- respectPrefix
1148
- }));
1149
- let opts = {
1150
- candidate,
1151
- context
1152
- };
1153
- let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
1154
- if (manualFormatStrings.length > 0) {
1155
- result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
1156
- }
1157
- return result;
1158
- }
1159
- });
1160
- }
1161
- return result;
1162
- };
1163
- }
1164
- /**
1165
- * Mark as class as retroactively invalid
1166
- *
1167
- *
1168
- * @param {string} candidate
1169
- */ function markInvalidUtilityCandidate(context, candidate) {
1170
- if (!context.classCache.has(candidate)) {
1171
- return;
1172
- }
1173
- // Mark this as not being a real utility
1174
- context.notClassCache.add(candidate);
1175
- // Remove it from any candidate-specific caches
1176
- context.classCache.delete(candidate);
1177
- context.applyClassCache.delete(candidate);
1178
- context.candidateRuleMap.delete(candidate);
1179
- context.candidateRuleCache.delete(candidate);
1180
- // Ensure the stylesheet gets rebuilt
1181
- context.stylesheetCache = null;
1182
- }
1183
- /**
1184
- * Mark as class as retroactively invalid
1185
- *
1186
- * @param {import('postcss').Node} node
1187
- */ function markInvalidUtilityNode(context, node) {
1188
- let candidate = node.raws.tailwind.candidate;
1189
- if (!candidate) {
1190
- return;
1191
- }
1192
- for (const entry of context.ruleCache){
1193
- if (entry[1].raws.tailwind.candidate === candidate) {
1194
- context.ruleCache.delete(entry);
1195
- // context.postCssNodeCache.delete(node)
1196
- }
1197
- }
1198
- markInvalidUtilityCandidate(context, candidate);
1199
- }
1200
- function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
1201
- var _tailwindConfig_blocklist;
1202
- let context = {
1203
- disposables: [],
1204
- ruleCache: new Set(),
1205
- candidateRuleCache: new Map(),
1206
- classCache: new Map(),
1207
- applyClassCache: new Map(),
1208
- // Seed the not class cache with the blocklist (which is only strings)
1209
- notClassCache: new Set((_tailwindConfig_blocklist = tailwindConfig.blocklist) !== null && _tailwindConfig_blocklist !== void 0 ? _tailwindConfig_blocklist : []),
1210
- postCssNodeCache: new Map(),
1211
- candidateRuleMap: new Map(),
1212
- tailwindConfig,
1213
- changedContent: changedContent,
1214
- variantMap: new Map(),
1215
- stylesheetCache: null,
1216
- variantOptions: new Map(),
1217
- markInvalidUtilityCandidate: (candidate)=>markInvalidUtilityCandidate(context, candidate),
1218
- markInvalidUtilityNode: (node)=>markInvalidUtilityNode(context, node)
1219
- };
1220
- let resolvedPlugins = resolvePlugins(context, root);
1221
- registerPlugins(resolvedPlugins, context);
1222
- return context;
1223
- }
1224
- let contextMap = _sharedState.contextMap;
1225
- let configContextMap = _sharedState.configContextMap;
1226
- let contextSourcesMap = _sharedState.contextSourcesMap;
1227
- function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
1228
- let sourcePath = result.opts.from;
1229
- let isConfigFile = userConfigPath !== null;
1230
- _sharedState.env.DEBUG && console.log("Source path:", sourcePath);
1231
- let existingContext;
1232
- if (isConfigFile && contextMap.has(sourcePath)) {
1233
- existingContext = contextMap.get(sourcePath);
1234
- } else if (configContextMap.has(tailwindConfigHash)) {
1235
- let context = configContextMap.get(tailwindConfigHash);
1236
- contextSourcesMap.get(context).add(sourcePath);
1237
- contextMap.set(sourcePath, context);
1238
- existingContext = context;
1239
- }
1240
- let cssDidChange = (0, _cacheInvalidation.hasContentChanged)(sourcePath, root);
1241
- // If there's already a context in the cache and we don't need to
1242
- // reset the context, return the cached context.
1243
- if (existingContext) {
1244
- let [contextDependenciesChanged, mtimesToCommit] = trackModified([
1245
- ...contextDependencies
1246
- ], getFileModifiedMap(existingContext));
1247
- if (!contextDependenciesChanged && !cssDidChange) {
1248
- return [
1249
- existingContext,
1250
- false,
1251
- mtimesToCommit
1252
- ];
1253
- }
1254
- }
1255
- // If this source is in the context map, get the old context.
1256
- // Remove this source from the context sources for the old context,
1257
- // and clean up that context if no one else is using it. This can be
1258
- // called by many processes in rapid succession, so we check for presence
1259
- // first because the first process to run this code will wipe it out first.
1260
- if (contextMap.has(sourcePath)) {
1261
- let oldContext = contextMap.get(sourcePath);
1262
- if (contextSourcesMap.has(oldContext)) {
1263
- contextSourcesMap.get(oldContext).delete(sourcePath);
1264
- if (contextSourcesMap.get(oldContext).size === 0) {
1265
- contextSourcesMap.delete(oldContext);
1266
- for (let [tailwindConfigHash, context] of configContextMap){
1267
- if (context === oldContext) {
1268
- configContextMap.delete(tailwindConfigHash);
1269
- }
1270
- }
1271
- for (let disposable of oldContext.disposables.splice(0)){
1272
- disposable(oldContext);
1273
- }
1274
- }
1275
- }
1276
- }
1277
- _sharedState.env.DEBUG && console.log("Setting up new context...");
1278
- let context = createContext(tailwindConfig, [], root);
1279
- Object.assign(context, {
1280
- userConfigPath
1281
- });
1282
- let [, mtimesToCommit] = trackModified([
1283
- ...contextDependencies
1284
- ], getFileModifiedMap(context));
1285
- // ---
1286
- // Update all context tracking state
1287
- configContextMap.set(tailwindConfigHash, context);
1288
- contextMap.set(sourcePath, context);
1289
- if (!contextSourcesMap.has(context)) {
1290
- contextSourcesMap.set(context, new Set());
1291
- }
1292
- contextSourcesMap.get(context).add(sourcePath);
1293
- return [
1294
- context,
1295
- true,
1296
- mtimesToCommit
1297
- ];
1298
- }