tailwindcss 0.0.0-insiders.d2bb6f1 → 0.0.0-insiders.d2fdddf

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