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,866 +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
- getClassNameFromSelector: ()=>getClassNameFromSelector,
13
- resolveMatches: ()=>resolveMatches,
14
- generateRules: ()=>generateRules
15
- });
16
- const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
17
- const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
18
- const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
19
- const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isPlainObject"));
20
- const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
21
- const _pluginUtils = require("../util/pluginUtils");
22
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
23
- const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
24
- const _formatVariantSelector = require("../util/formatVariantSelector");
25
- const _nameClass = require("../util/nameClass");
26
- const _dataTypes = require("../util/dataTypes");
27
- const _setupContextUtils = require("./setupContextUtils");
28
- const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
29
- const _splitAtTopLevelOnlyJs = require("../util/splitAtTopLevelOnly.js");
30
- const _featureFlags = require("../featureFlags");
31
- function _interopRequireDefault(obj) {
32
- return obj && obj.__esModule ? obj : {
33
- default: obj
34
- };
35
- }
36
- function _getRequireWildcardCache(nodeInterop) {
37
- if (typeof WeakMap !== "function") return null;
38
- var cacheBabelInterop = new WeakMap();
39
- var cacheNodeInterop = new WeakMap();
40
- return (_getRequireWildcardCache = function(nodeInterop) {
41
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
- })(nodeInterop);
43
- }
44
- function _interopRequireWildcard(obj, nodeInterop) {
45
- if (!nodeInterop && obj && obj.__esModule) {
46
- return obj;
47
- }
48
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
- return {
50
- default: obj
51
- };
52
- }
53
- var cache = _getRequireWildcardCache(nodeInterop);
54
- if (cache && cache.has(obj)) {
55
- return cache.get(obj);
56
- }
57
- var newObj = {};
58
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
59
- for(var key in obj){
60
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
61
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
62
- if (desc && (desc.get || desc.set)) {
63
- Object.defineProperty(newObj, key, desc);
64
- } else {
65
- newObj[key] = obj[key];
66
- }
67
- }
68
- }
69
- newObj.default = obj;
70
- if (cache) {
71
- cache.set(obj, newObj);
72
- }
73
- return newObj;
74
- }
75
- let classNameParser = (0, _postcssSelectorParser.default)((selectors)=>{
76
- return selectors.first.filter(({ type })=>type === "class").pop().value;
77
- });
78
- function getClassNameFromSelector(selector) {
79
- return classNameParser.transformSync(selector);
80
- }
81
- // Generate match permutations for a class candidate, like:
82
- // ['ring-offset-blue', '100']
83
- // ['ring-offset', 'blue-100']
84
- // ['ring', 'offset-blue-100']
85
- // Example with dynamic classes:
86
- // ['grid-cols', '[[linename],1fr,auto]']
87
- // ['grid', 'cols-[[linename],1fr,auto]']
88
- function* candidatePermutations(candidate) {
89
- let lastIndex = Infinity;
90
- while(lastIndex >= 0){
91
- let dashIdx;
92
- let wasSlash = false;
93
- if (lastIndex === Infinity && candidate.endsWith("]")) {
94
- let bracketIdx = candidate.indexOf("[");
95
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
96
- // eg. string[]
97
- if (candidate[bracketIdx - 1] === "-") {
98
- dashIdx = bracketIdx - 1;
99
- } else if (candidate[bracketIdx - 1] === "/") {
100
- dashIdx = bracketIdx - 1;
101
- wasSlash = true;
102
- } else {
103
- dashIdx = -1;
104
- }
105
- } else if (lastIndex === Infinity && candidate.includes("/")) {
106
- dashIdx = candidate.lastIndexOf("/");
107
- wasSlash = true;
108
- } else {
109
- dashIdx = candidate.lastIndexOf("-", lastIndex);
110
- }
111
- if (dashIdx < 0) {
112
- break;
113
- }
114
- let prefix = candidate.slice(0, dashIdx);
115
- let modifier = candidate.slice(wasSlash ? dashIdx : dashIdx + 1);
116
- lastIndex = dashIdx - 1;
117
- // TODO: This feels a bit hacky
118
- if (prefix === "" || modifier === "/") {
119
- continue;
120
- }
121
- yield [
122
- prefix,
123
- modifier
124
- ];
125
- }
126
- }
127
- function applyPrefix(matches, context) {
128
- if (matches.length === 0 || context.tailwindConfig.prefix === "") {
129
- return matches;
130
- }
131
- for (let match of matches){
132
- let [meta] = match;
133
- if (meta.options.respectPrefix) {
134
- let container = _postcss.default.root({
135
- nodes: [
136
- match[1].clone()
137
- ]
138
- });
139
- let classCandidate = match[1].raws.tailwind.classCandidate;
140
- container.walkRules((r)=>{
141
- // If this is a negative utility with a dash *before* the prefix we
142
- // have to ensure that the generated selector matches the candidate
143
- // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
144
- // The disconnect between candidate <-> class can cause @apply to hard crash.
145
- let shouldPrependNegative = classCandidate.startsWith("-");
146
- r.selector = (0, _prefixSelector.default)(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
147
- });
148
- match[1] = container.nodes[0];
149
- }
150
- }
151
- return matches;
152
- }
153
- function applyImportant(matches, classCandidate) {
154
- if (matches.length === 0) {
155
- return matches;
156
- }
157
- let result = [];
158
- for (let [meta, rule] of matches){
159
- let container = _postcss.default.root({
160
- nodes: [
161
- rule.clone()
162
- ]
163
- });
164
- container.walkRules((r)=>{
165
- r.selector = (0, _pluginUtils.updateAllClasses)((0, _pluginUtils.filterSelectorsForClass)(r.selector, classCandidate), (className)=>{
166
- if (className === classCandidate) {
167
- return `!${className}`;
168
- }
169
- return className;
170
- });
171
- r.walkDecls((d)=>d.important = true);
172
- });
173
- result.push([
174
- {
175
- ...meta,
176
- important: true
177
- },
178
- container.nodes[0]
179
- ]);
180
- }
181
- return result;
182
- }
183
- // Takes a list of rule tuples and applies a variant like `hover`, sm`,
184
- // whatever to it. We used to do some extra caching here to avoid generating
185
- // a variant of the same rule more than once, but this was never hit because
186
- // we cache at the entire selector level further up the tree.
187
- //
188
- // Technically you can get a cache hit if you have `hover:focus:text-center`
189
- // and `focus:hover:text-center` in the same project, but it doesn't feel
190
- // worth the complexity for that case.
191
- function applyVariant(variant, matches, context) {
192
- if (matches.length === 0) {
193
- return matches;
194
- }
195
- /** @type {{modifier: string | null, value: string | null}} */ let args = {
196
- modifier: null,
197
- value: _sharedState.NONE
198
- };
199
- // Retrieve "modifier"
200
- {
201
- let match = /(.*)\/(.*)$/g.exec(variant);
202
- if (match && !context.variantMap.has(variant)) {
203
- variant = match[1];
204
- args.modifier = match[2];
205
- if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
206
- return [];
207
- }
208
- }
209
- }
210
- // Retrieve "arbitrary value"
211
- if (variant.endsWith("]") && !variant.startsWith("[")) {
212
- // We either have:
213
- // @[200px]
214
- // group-[:hover]
215
- //
216
- // But we don't want:
217
- // @-[200px] (`-` is incorrect)
218
- // group[:hover] (`-` is missing)
219
- let match1 = /(.)(-?)\[(.*)\]/g.exec(variant);
220
- if (match1) {
221
- let [, char, seperator, value] = match1;
222
- // @-[200px] case
223
- if (char === "@" && seperator === "-") return [];
224
- // group[:hover] case
225
- if (char !== "@" && seperator === "") return [];
226
- variant = variant.replace(`${seperator}[${value}]`, "");
227
- args.value = value;
228
- }
229
- }
230
- // Register arbitrary variants
231
- if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
232
- let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
233
- if (!(0, _setupContextUtils.isValidVariantFormatString)(selector)) {
234
- return [];
235
- }
236
- let fn = (0, _setupContextUtils.parseVariant)(selector);
237
- let sort = context.offsets.recordVariant(variant);
238
- context.variantMap.set(variant, [
239
- [
240
- sort,
241
- fn
242
- ]
243
- ]);
244
- }
245
- if (context.variantMap.has(variant)) {
246
- let isArbitraryVariant = isArbitraryValue(variant);
247
- let variantFunctionTuples = context.variantMap.get(variant).slice();
248
- let result = [];
249
- for (let [meta, rule] of matches){
250
- // Don't generate variants for user css
251
- if (meta.layer === "user") {
252
- continue;
253
- }
254
- let container = _postcss.default.root({
255
- nodes: [
256
- rule.clone()
257
- ]
258
- });
259
- for (let [variantSort, variantFunction, containerFromArray] of variantFunctionTuples){
260
- let clone = (containerFromArray !== null && containerFromArray !== void 0 ? containerFromArray : container).clone();
261
- let collectedFormats = [];
262
- function prepareBackup() {
263
- // Already prepared, chicken out
264
- if (clone.raws.neededBackup) {
265
- return;
266
- }
267
- clone.raws.neededBackup = true;
268
- clone.walkRules((rule)=>rule.raws.originalSelector = rule.selector);
269
- }
270
- function modifySelectors(modifierFunction) {
271
- prepareBackup();
272
- clone.each((rule)=>{
273
- if (rule.type !== "rule") {
274
- return;
275
- }
276
- rule.selectors = rule.selectors.map((selector)=>{
277
- return modifierFunction({
278
- get className () {
279
- return getClassNameFromSelector(selector);
280
- },
281
- selector
282
- });
283
- });
284
- });
285
- return clone;
286
- }
287
- let ruleWithVariant = variantFunction({
288
- // Public API
289
- get container () {
290
- prepareBackup();
291
- return clone;
292
- },
293
- separator: context.tailwindConfig.separator,
294
- modifySelectors,
295
- // Private API for now
296
- wrap (wrapper) {
297
- let nodes = clone.nodes;
298
- clone.removeAll();
299
- wrapper.append(nodes);
300
- clone.append(wrapper);
301
- },
302
- format (selectorFormat) {
303
- collectedFormats.push({
304
- format: selectorFormat,
305
- isArbitraryVariant
306
- });
307
- },
308
- args
309
- });
310
- // It can happen that a list of format strings is returned from within the function. In that
311
- // case, we have to process them as well. We can use the existing `variantSort`.
312
- if (Array.isArray(ruleWithVariant)) {
313
- for (let [idx, variantFunction1] of ruleWithVariant.entries()){
314
- // This is a little bit scary since we are pushing to an array of items that we are
315
- // currently looping over. However, you can also think of it like a processing queue
316
- // where you keep handling jobs until everything is done and each job can queue more
317
- // jobs if needed.
318
- variantFunctionTuples.push([
319
- context.offsets.applyParallelOffset(variantSort, idx),
320
- variantFunction1,
321
- // If the clone has been modified we have to pass that back
322
- // though so each rule can use the modified container
323
- clone.clone()
324
- ]);
325
- }
326
- continue;
327
- }
328
- if (typeof ruleWithVariant === "string") {
329
- collectedFormats.push({
330
- format: ruleWithVariant,
331
- isArbitraryVariant
332
- });
333
- }
334
- if (ruleWithVariant === null) {
335
- continue;
336
- }
337
- // We had to backup selectors, therefore we assume that somebody touched
338
- // `container` or `modifySelectors`. Let's see if they did, so that we
339
- // can restore the selectors, and collect the format strings.
340
- if (clone.raws.neededBackup) {
341
- delete clone.raws.neededBackup;
342
- clone.walkRules((rule)=>{
343
- let before = rule.raws.originalSelector;
344
- if (!before) return;
345
- delete rule.raws.originalSelector;
346
- if (before === rule.selector) return; // No mutation happened
347
- let modified = rule.selector;
348
- // Rebuild the base selector, this is what plugin authors would do
349
- // as well. E.g.: `${variant}${separator}${className}`.
350
- // However, plugin authors probably also prepend or append certain
351
- // classes, pseudos, ids, ...
352
- let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
353
- selectors.walkClasses((classNode)=>{
354
- classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
355
- });
356
- }).processSync(before);
357
- // Now that we know the original selector, the new selector, and
358
- // the rebuild part in between, we can replace the part that plugin
359
- // authors need to rebuild with `&`, and eventually store it in the
360
- // collectedFormats. Similar to what `format('...')` would do.
361
- //
362
- // E.g.:
363
- // variant: foo
364
- // selector: .markdown > p
365
- // modified (by plugin): .foo .foo\\:markdown > p
366
- // rebuiltBase (internal): .foo\\:markdown > p
367
- // format: .foo &
368
- collectedFormats.push({
369
- format: modified.replace(rebuiltBase, "&"),
370
- isArbitraryVariant
371
- });
372
- rule.selector = before;
373
- });
374
- }
375
- // This tracks the originating layer for the variant
376
- // For example:
377
- // .sm:underline {} is a variant of something in the utilities layer
378
- // .sm:container {} is a variant of the container component
379
- clone.nodes[0].raws.tailwind = {
380
- ...clone.nodes[0].raws.tailwind,
381
- parentLayer: meta.layer
382
- };
383
- var _meta_collectedFormats;
384
- let withOffset = [
385
- {
386
- ...meta,
387
- sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
388
- collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
389
- },
390
- clone.nodes[0]
391
- ];
392
- result.push(withOffset);
393
- }
394
- }
395
- return result;
396
- }
397
- return [];
398
- }
399
- function parseRules(rule, cache, options = {}) {
400
- // PostCSS node
401
- if (!(0, _isPlainObject.default)(rule) && !Array.isArray(rule)) {
402
- return [
403
- [
404
- rule
405
- ],
406
- options
407
- ];
408
- }
409
- // Tuple
410
- if (Array.isArray(rule)) {
411
- return parseRules(rule[0], cache, rule[1]);
412
- }
413
- // Simple object
414
- if (!cache.has(rule)) {
415
- cache.set(rule, (0, _parseObjectStyles.default)(rule));
416
- }
417
- return [
418
- cache.get(rule),
419
- options
420
- ];
421
- }
422
- const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
423
- function isValidPropName(name) {
424
- return IS_VALID_PROPERTY_NAME.test(name);
425
- }
426
- /**
427
- * @param {string} declaration
428
- * @returns {boolean}
429
- */ function looksLikeUri(declaration) {
430
- // Quick bailout for obvious non-urls
431
- // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
432
- if (!declaration.includes("://")) {
433
- return false;
434
- }
435
- try {
436
- const url = new URL(declaration);
437
- return url.scheme !== "" && url.host !== "";
438
- } catch (err) {
439
- // Definitely not a valid url
440
- return false;
441
- }
442
- }
443
- function isParsableNode(node) {
444
- let isParsable = true;
445
- node.walkDecls((decl)=>{
446
- if (!isParsableCssValue(decl.prop, decl.value)) {
447
- isParsable = false;
448
- return false;
449
- }
450
- });
451
- return isParsable;
452
- }
453
- function isParsableCssValue(property, value) {
454
- // We don't want to to treat [https://example.com] as a custom property
455
- // Even though, according to the CSS grammar, it's a totally valid CSS declaration
456
- // So we short-circuit here by checking if the custom property looks like a url
457
- if (looksLikeUri(`${property}:${value}`)) {
458
- return false;
459
- }
460
- try {
461
- _postcss.default.parse(`a{${property}:${value}}`).toResult();
462
- return true;
463
- } catch (err) {
464
- return false;
465
- }
466
- }
467
- function extractArbitraryProperty(classCandidate, context) {
468
- var _classCandidate_match;
469
- let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
470
- if (value === undefined) {
471
- return null;
472
- }
473
- if (!isValidPropName(property)) {
474
- return null;
475
- }
476
- if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
477
- return null;
478
- }
479
- let normalized = (0, _dataTypes.normalize)(value);
480
- if (!isParsableCssValue(property, normalized)) {
481
- return null;
482
- }
483
- let sort = context.offsets.arbitraryProperty();
484
- return [
485
- [
486
- {
487
- sort,
488
- layer: "utilities"
489
- },
490
- ()=>({
491
- [(0, _nameClass.asClass)(classCandidate)]: {
492
- [property]: normalized
493
- }
494
- })
495
- ]
496
- ];
497
- }
498
- function* resolveMatchedPlugins(classCandidate, context) {
499
- if (context.candidateRuleMap.has(classCandidate)) {
500
- yield [
501
- context.candidateRuleMap.get(classCandidate),
502
- "DEFAULT"
503
- ];
504
- }
505
- yield* function*(arbitraryPropertyRule) {
506
- if (arbitraryPropertyRule !== null) {
507
- yield [
508
- arbitraryPropertyRule,
509
- "DEFAULT"
510
- ];
511
- }
512
- }(extractArbitraryProperty(classCandidate, context));
513
- let candidatePrefix = classCandidate;
514
- let negative = false;
515
- const twConfigPrefix = context.tailwindConfig.prefix;
516
- const twConfigPrefixLen = twConfigPrefix.length;
517
- const hasMatchingPrefix = candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`);
518
- if (candidatePrefix[twConfigPrefixLen] === "-" && hasMatchingPrefix) {
519
- negative = true;
520
- candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
521
- }
522
- if (negative && context.candidateRuleMap.has(candidatePrefix)) {
523
- yield [
524
- context.candidateRuleMap.get(candidatePrefix),
525
- "-DEFAULT"
526
- ];
527
- }
528
- for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
529
- if (context.candidateRuleMap.has(prefix)) {
530
- yield [
531
- context.candidateRuleMap.get(prefix),
532
- negative ? `-${modifier}` : modifier
533
- ];
534
- }
535
- }
536
- }
537
- function splitWithSeparator(input, separator) {
538
- if (input === _sharedState.NOT_ON_DEMAND) {
539
- return [
540
- _sharedState.NOT_ON_DEMAND
541
- ];
542
- }
543
- return (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(input, separator);
544
- }
545
- function* recordCandidates(matches, classCandidate) {
546
- for (const match of matches){
547
- var _match__options;
548
- var _match__options_preserveSource;
549
- match[1].raws.tailwind = {
550
- ...match[1].raws.tailwind,
551
- classCandidate,
552
- preserveSource: (_match__options_preserveSource = (_match__options = match[0].options) === null || _match__options === void 0 ? void 0 : _match__options.preserveSource) !== null && _match__options_preserveSource !== void 0 ? _match__options_preserveSource : false
553
- };
554
- yield match;
555
- }
556
- }
557
- function* resolveMatches(candidate, context, original = candidate) {
558
- let separator = context.tailwindConfig.separator;
559
- let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
560
- let important = false;
561
- if (classCandidate.startsWith("!")) {
562
- important = true;
563
- classCandidate = classCandidate.slice(1);
564
- }
565
- if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
566
- if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
567
- let base = variants.slice().reverse().join(separator);
568
- for (let part of (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
569
- yield* resolveMatches(base + separator + part, context, original);
570
- }
571
- }
572
- }
573
- // TODO: Reintroduce this in ways that doesn't break on false positives
574
- // function sortAgainst(toSort, against) {
575
- // return toSort.slice().sort((a, z) => {
576
- // return bigSign(against.get(a)[0] - against.get(z)[0])
577
- // })
578
- // }
579
- // let sorted = sortAgainst(variants, context.variantMap)
580
- // if (sorted.toString() !== variants.toString()) {
581
- // let corrected = sorted.reverse().concat(classCandidate).join(':')
582
- // throw new Error(`Class ${candidate} should be written as ${corrected}`)
583
- // }
584
- for (let matchedPlugins of resolveMatchedPlugins(classCandidate, context)){
585
- let matches = [];
586
- let typesByMatches = new Map();
587
- let [plugins, modifier] = matchedPlugins;
588
- let isOnlyPlugin = plugins.length === 1;
589
- for (let [sort, plugin] of plugins){
590
- let matchesPerPlugin = [];
591
- if (typeof plugin === "function") {
592
- for (let ruleSet of [].concat(plugin(modifier, {
593
- isOnlyPlugin
594
- }))){
595
- let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
596
- for (let rule of rules){
597
- matchesPerPlugin.push([
598
- {
599
- ...sort,
600
- options: {
601
- ...sort.options,
602
- ...options
603
- }
604
- },
605
- rule
606
- ]);
607
- }
608
- }
609
- } else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
610
- let ruleSet1 = plugin;
611
- let [rules1, options1] = parseRules(ruleSet1, context.postCssNodeCache);
612
- for (let rule1 of rules1){
613
- matchesPerPlugin.push([
614
- {
615
- ...sort,
616
- options: {
617
- ...sort.options,
618
- ...options1
619
- }
620
- },
621
- rule1
622
- ]);
623
- }
624
- }
625
- if (matchesPerPlugin.length > 0) {
626
- var _sort_options;
627
- var _sort_options_types, _sort_options1;
628
- let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((_sort_options_types = (_sort_options = sort.options) === null || _sort_options === void 0 ? void 0 : _sort_options.types) !== null && _sort_options_types !== void 0 ? _sort_options_types : [], modifier, (_sort_options1 = sort.options) !== null && _sort_options1 !== void 0 ? _sort_options1 : {}, context.tailwindConfig)).map(([_, type])=>type);
629
- if (matchingTypes.length > 0) {
630
- typesByMatches.set(matchesPerPlugin, matchingTypes);
631
- }
632
- matches.push(matchesPerPlugin);
633
- }
634
- }
635
- if (isArbitraryValue(modifier)) {
636
- if (matches.length > 1) {
637
- // Partition plugins in 2 categories so that we can start searching in the plugins that
638
- // don't have `any` as a type first.
639
- let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
640
- let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === "any"));
641
- if (hasAnyType) {
642
- group[0].push(plugin);
643
- } else {
644
- group[1].push(plugin);
645
- }
646
- return group;
647
- }, [
648
- [],
649
- []
650
- ]);
651
- function findFallback(matches) {
652
- // If only a single plugin matches, let's take that one
653
- if (matches.length === 1) {
654
- return matches[0];
655
- }
656
- // Otherwise, find the plugin that creates a valid rule given the arbitrary value, and
657
- // also has the correct type which preferOnConflicts the plugin in case of clashes.
658
- return matches.find((rules)=>{
659
- let matchingTypes = typesByMatches.get(rules);
660
- return rules.some(([{ options }, rule])=>{
661
- if (!isParsableNode(rule)) {
662
- return false;
663
- }
664
- return options.types.some(({ type , preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
665
- });
666
- });
667
- }
668
- var _findFallback;
669
- // Try to find a fallback plugin, because we already know that multiple plugins matched for
670
- // the given arbitrary value.
671
- let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
672
- if (fallback) {
673
- matches = [
674
- fallback
675
- ];
676
- } else {
677
- var _typesByMatches_get;
678
- let typesPerPlugin = matches.map((match)=>new Set([
679
- ...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
680
- ]));
681
- // Remove duplicates, so that we can detect proper unique types for each plugin.
682
- for (let pluginTypes of typesPerPlugin){
683
- for (let type of pluginTypes){
684
- let removeFromOwnGroup = false;
685
- for (let otherGroup of typesPerPlugin){
686
- if (pluginTypes === otherGroup) continue;
687
- if (otherGroup.has(type)) {
688
- otherGroup.delete(type);
689
- removeFromOwnGroup = true;
690
- }
691
- }
692
- if (removeFromOwnGroup) pluginTypes.delete(type);
693
- }
694
- }
695
- let messages = [];
696
- for (let [idx, group] of typesPerPlugin.entries()){
697
- for (let type1 of group){
698
- let rules2 = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
699
- .map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
700
- .join("\n")).join("\n\n");
701
- messages.push(` Use \`${candidate.replace("[", `[${type1}:`)}\` for \`${rules2.trim()}\``);
702
- break;
703
- }
704
- }
705
- _log.default.warn([
706
- `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
707
- ...messages,
708
- `If this is content and not a class, replace it with \`${candidate.replace("[", "&lsqb;").replace("]", "&rsqb;")}\` to silence this warning.`
709
- ]);
710
- continue;
711
- }
712
- }
713
- matches = matches.map((list)=>list.filter((match)=>isParsableNode(match[1])));
714
- }
715
- matches = matches.flat();
716
- matches = Array.from(recordCandidates(matches, classCandidate));
717
- matches = applyPrefix(matches, context);
718
- if (important) {
719
- matches = applyImportant(matches, classCandidate);
720
- }
721
- for (let variant of variants){
722
- matches = applyVariant(variant, matches, context);
723
- }
724
- for (let match of matches){
725
- match[1].raws.tailwind = {
726
- ...match[1].raws.tailwind,
727
- candidate
728
- };
729
- // Apply final format selector
730
- match = applyFinalFormat(match, {
731
- context,
732
- candidate,
733
- original
734
- });
735
- // Skip rules with invalid selectors
736
- // This will cause the candidate to be added to the "not class"
737
- // cache skipping it entirely for future builds
738
- if (match === null) {
739
- continue;
740
- }
741
- yield match;
742
- }
743
- }
744
- }
745
- function applyFinalFormat(match, { context , candidate , original }) {
746
- if (!match[0].collectedFormats) {
747
- return match;
748
- }
749
- let isValid = true;
750
- let finalFormat;
751
- try {
752
- finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
753
- context,
754
- candidate
755
- });
756
- } catch {
757
- // The format selector we produced is invalid
758
- // This could be because:
759
- // - A bug exists
760
- // - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
761
- // - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
762
- // Either way the build will fail because of this
763
- // We would rather that the build pass "silently" given that this could
764
- // happen because of picking up invalid things when scanning content
765
- // So we'll throw out the candidate instead
766
- return null;
767
- }
768
- let container = _postcss.default.root({
769
- nodes: [
770
- match[1].clone()
771
- ]
772
- });
773
- container.walkRules((rule)=>{
774
- if (inKeyframes(rule)) {
775
- return;
776
- }
777
- try {
778
- rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
779
- candidate: original,
780
- context
781
- });
782
- } catch {
783
- // If this selector is invalid we also want to skip it
784
- // But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
785
- isValid = false;
786
- return false;
787
- }
788
- });
789
- if (!isValid) {
790
- return null;
791
- }
792
- match[1] = container.nodes[0];
793
- return match;
794
- }
795
- function inKeyframes(rule) {
796
- return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
797
- }
798
- function getImportantStrategy(important) {
799
- if (important === true) {
800
- return (rule)=>{
801
- if (inKeyframes(rule)) {
802
- return;
803
- }
804
- rule.walkDecls((d)=>{
805
- if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
806
- d.important = true;
807
- }
808
- });
809
- };
810
- }
811
- if (typeof important === "string") {
812
- return (rule)=>{
813
- if (inKeyframes(rule)) {
814
- return;
815
- }
816
- rule.selectors = rule.selectors.map((selector)=>{
817
- return `${important} ${selector}`;
818
- });
819
- };
820
- }
821
- }
822
- function generateRules(candidates, context) {
823
- let allRules = [];
824
- let strategy = getImportantStrategy(context.tailwindConfig.important);
825
- for (let candidate of candidates){
826
- if (context.notClassCache.has(candidate)) {
827
- continue;
828
- }
829
- if (context.candidateRuleCache.has(candidate)) {
830
- allRules = allRules.concat(Array.from(context.candidateRuleCache.get(candidate)));
831
- continue;
832
- }
833
- let matches = Array.from(resolveMatches(candidate, context));
834
- if (matches.length === 0) {
835
- context.notClassCache.add(candidate);
836
- continue;
837
- }
838
- context.classCache.set(candidate, matches);
839
- var _context_candidateRuleCache_get;
840
- let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
841
- context.candidateRuleCache.set(candidate, rules);
842
- for (const match of matches){
843
- let [{ sort , options }, rule] = match;
844
- if (options.respectImportant && strategy) {
845
- let container = _postcss.default.root({
846
- nodes: [
847
- rule.clone()
848
- ]
849
- });
850
- container.walkRules(strategy);
851
- rule = container.nodes[0];
852
- }
853
- let newEntry = [
854
- sort,
855
- rule
856
- ];
857
- rules.add(newEntry);
858
- context.ruleCache.add(newEntry);
859
- allRules.push(newEntry);
860
- }
861
- }
862
- return allRules;
863
- }
864
- function isArbitraryValue(input) {
865
- return input.startsWith("[") && input.endsWith("]");
866
- }