tailwindcss 0.0.0-insiders.eb8d929 → 0.0.0-insiders.ec0049a

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