tailwindcss 0.0.0-insiders.ff2c25f → 0.0.0-internal.b2586d4e

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