tailwindcss 0.0.0-insiders.d3e754a → 0.0.0-insiders.d3f2221

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 (217) hide show
  1. package/README.md +13 -9
  2. package/colors.d.ts +3 -0
  3. package/defaultConfig.d.ts +3 -0
  4. package/defaultTheme.d.ts +4 -0
  5. package/index.css +5 -0
  6. package/lib/cli/build/index.js +57 -0
  7. package/lib/cli/build/plugin.js +431 -0
  8. package/lib/cli/build/utils.js +88 -0
  9. package/lib/cli/build/watching.js +182 -0
  10. package/lib/cli/help/index.js +73 -0
  11. package/lib/cli/index.js +231 -0
  12. package/lib/cli/init/index.js +63 -0
  13. package/lib/cli.js +1 -739
  14. package/lib/corePluginList.js +13 -3
  15. package/lib/corePlugins.js +1094 -478
  16. package/lib/css/preflight.css +17 -4
  17. package/lib/featureFlags.js +49 -23
  18. package/lib/index.js +1 -29
  19. package/lib/lib/cacheInvalidation.js +92 -0
  20. package/lib/lib/collapseAdjacentRules.js +12 -5
  21. package/lib/lib/collapseDuplicateDeclarations.js +12 -7
  22. package/lib/lib/content.js +207 -0
  23. package/lib/lib/defaultExtractor.js +217 -33
  24. package/lib/lib/detectNesting.js +15 -4
  25. package/lib/lib/evaluateTailwindFunctions.js +104 -37
  26. package/lib/lib/expandApplyAtRules.js +312 -211
  27. package/lib/lib/expandTailwindAtRules.js +149 -96
  28. package/lib/lib/findAtConfigPath.js +46 -0
  29. package/lib/lib/generateRules.js +437 -188
  30. package/lib/lib/getModuleDependencies.js +88 -37
  31. package/lib/lib/handleImportAtRules.js +50 -0
  32. package/lib/lib/load-config.js +42 -0
  33. package/lib/lib/normalizeTailwindDirectives.js +9 -19
  34. package/lib/lib/offsets.js +306 -0
  35. package/lib/lib/partitionApplyAtRules.js +11 -6
  36. package/lib/lib/regex.js +74 -0
  37. package/lib/lib/remap-bitfield.js +89 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +80 -58
  39. package/lib/lib/setupContextUtils.js +683 -270
  40. package/lib/lib/setupTrackingContext.js +63 -67
  41. package/lib/lib/sharedState.js +39 -10
  42. package/lib/lib/substituteScreenAtRules.js +13 -9
  43. package/lib/plugin.js +164 -0
  44. package/lib/postcss-plugins/nesting/README.md +2 -2
  45. package/lib/postcss-plugins/nesting/index.js +10 -6
  46. package/lib/postcss-plugins/nesting/plugin.js +15 -11
  47. package/lib/processTailwindFeatures.js +33 -28
  48. package/lib/public/colors.js +55 -29
  49. package/lib/public/create-plugin.js +9 -5
  50. package/lib/public/default-config.js +10 -6
  51. package/lib/public/default-theme.js +10 -6
  52. package/lib/public/load-config.js +12 -0
  53. package/lib/public/resolve-config.js +11 -6
  54. package/lib/util/applyImportantSelector.js +36 -0
  55. package/lib/util/bigSign.js +6 -1
  56. package/lib/util/buildMediaQuery.js +12 -5
  57. package/lib/util/cloneDeep.js +8 -5
  58. package/lib/util/cloneNodes.js +11 -2
  59. package/lib/util/color.js +59 -42
  60. package/lib/util/colorNames.js +752 -0
  61. package/lib/util/configurePlugins.js +7 -2
  62. package/lib/util/createPlugin.js +8 -5
  63. package/lib/util/createUtilityPlugin.js +15 -11
  64. package/lib/util/dataTypes.js +172 -47
  65. package/lib/util/defaults.js +12 -7
  66. package/lib/util/escapeClassName.js +13 -8
  67. package/lib/util/escapeCommas.js +6 -1
  68. package/lib/util/flattenColorPalette.js +9 -8
  69. package/lib/util/formatVariantSelector.js +230 -151
  70. package/lib/util/getAllConfigs.js +34 -12
  71. package/lib/util/hashConfig.js +9 -4
  72. package/lib/util/isKeyframeRule.js +6 -1
  73. package/lib/util/isPlainObject.js +6 -1
  74. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +15 -5
  75. package/lib/util/log.js +36 -9
  76. package/lib/util/nameClass.js +24 -7
  77. package/lib/util/negateValue.js +23 -6
  78. package/lib/util/normalizeConfig.js +142 -69
  79. package/lib/util/normalizeScreens.js +124 -5
  80. package/lib/util/parseAnimationValue.js +8 -4
  81. package/lib/util/parseBoxShadowValue.js +16 -45
  82. package/lib/util/parseDependency.js +38 -54
  83. package/lib/util/parseGlob.js +36 -0
  84. package/lib/util/parseObjectStyles.js +14 -9
  85. package/lib/util/pluginUtils.js +146 -51
  86. package/lib/util/prefixSelector.js +29 -10
  87. package/lib/util/pseudoElements.js +209 -0
  88. package/lib/util/removeAlphaVariables.js +31 -0
  89. package/lib/util/resolveConfig.js +100 -73
  90. package/lib/util/resolveConfigPath.js +27 -8
  91. package/lib/util/responsive.js +10 -5
  92. package/lib/util/splitAtTopLevelOnly.js +51 -0
  93. package/lib/util/tap.js +6 -1
  94. package/lib/util/toColorValue.js +6 -1
  95. package/lib/util/toPath.js +20 -2
  96. package/lib/util/transformThemeValue.js +21 -7
  97. package/lib/util/validateConfig.js +48 -0
  98. package/lib/util/validateFormalSyntax.js +26 -0
  99. package/lib/util/withAlphaVariable.js +24 -12
  100. package/lib/value-parser/LICENSE +22 -0
  101. package/lib/value-parser/README.md +3 -0
  102. package/lib/value-parser/index.d.js +2 -0
  103. package/lib/value-parser/index.js +22 -0
  104. package/lib/value-parser/parse.js +259 -0
  105. package/lib/value-parser/stringify.js +38 -0
  106. package/lib/value-parser/unit.js +86 -0
  107. package/lib/value-parser/walk.js +16 -0
  108. package/loadConfig.d.ts +4 -0
  109. package/loadConfig.js +2 -0
  110. package/package.json +58 -53
  111. package/plugin.d.ts +11 -0
  112. package/resolveConfig.d.ts +12 -0
  113. package/scripts/generate-types.js +105 -0
  114. package/scripts/release-channel.js +18 -0
  115. package/scripts/release-notes.js +21 -0
  116. package/scripts/type-utils.js +27 -0
  117. package/src/cli/build/index.js +53 -0
  118. package/src/cli/build/plugin.js +469 -0
  119. package/src/cli/build/utils.js +76 -0
  120. package/src/cli/build/watching.js +229 -0
  121. package/src/cli/help/index.js +70 -0
  122. package/src/cli/index.js +217 -0
  123. package/src/cli/init/index.js +79 -0
  124. package/src/cli.js +1 -813
  125. package/src/corePluginList.js +1 -1
  126. package/src/corePlugins.js +636 -117
  127. package/src/css/preflight.css +17 -4
  128. package/src/featureFlags.js +13 -3
  129. package/src/index.js +1 -28
  130. package/src/lib/cacheInvalidation.js +52 -0
  131. package/src/lib/collapseAdjacentRules.js +5 -1
  132. package/src/lib/content.js +240 -0
  133. package/src/lib/defaultExtractor.js +192 -35
  134. package/src/lib/detectNesting.js +9 -1
  135. package/src/lib/evaluateTailwindFunctions.js +82 -8
  136. package/src/lib/expandApplyAtRules.js +322 -189
  137. package/src/lib/expandTailwindAtRules.js +87 -60
  138. package/src/lib/findAtConfigPath.js +48 -0
  139. package/src/lib/generateRules.js +428 -128
  140. package/src/lib/getModuleDependencies.js +70 -30
  141. package/src/lib/handleImportAtRules.js +34 -0
  142. package/src/lib/load-config.ts +31 -0
  143. package/src/lib/normalizeTailwindDirectives.js +0 -27
  144. package/src/lib/offsets.js +373 -0
  145. package/src/lib/regex.js +74 -0
  146. package/src/lib/remap-bitfield.js +82 -0
  147. package/src/lib/resolveDefaultsAtRules.js +53 -36
  148. package/src/lib/setupContextUtils.js +608 -157
  149. package/src/lib/setupTrackingContext.js +44 -58
  150. package/src/lib/sharedState.js +14 -4
  151. package/src/plugin.js +133 -0
  152. package/src/postcss-plugins/nesting/README.md +2 -2
  153. package/src/processTailwindFeatures.js +3 -2
  154. package/src/public/colors.js +22 -0
  155. package/src/public/default-config.js +1 -1
  156. package/src/public/default-theme.js +2 -2
  157. package/src/public/load-config.js +2 -0
  158. package/src/util/applyImportantSelector.js +27 -0
  159. package/src/util/buildMediaQuery.js +5 -3
  160. package/src/util/cloneNodes.js +5 -1
  161. package/src/util/color.js +39 -20
  162. package/src/util/colorNames.js +150 -0
  163. package/src/util/dataTypes.js +115 -23
  164. package/src/util/formatVariantSelector.js +265 -144
  165. package/src/util/getAllConfigs.js +21 -2
  166. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  167. package/src/util/log.js +25 -1
  168. package/src/util/nameClass.js +4 -0
  169. package/src/util/negateValue.js +11 -3
  170. package/src/util/normalizeConfig.js +78 -20
  171. package/src/util/normalizeScreens.js +99 -4
  172. package/src/util/parseBoxShadowValue.js +3 -50
  173. package/src/util/parseDependency.js +37 -42
  174. package/src/util/parseGlob.js +24 -0
  175. package/src/util/pluginUtils.js +118 -23
  176. package/src/util/prefixSelector.js +29 -10
  177. package/src/util/pseudoElements.js +167 -0
  178. package/src/util/removeAlphaVariables.js +24 -0
  179. package/src/util/resolveConfig.js +70 -32
  180. package/src/util/resolveConfigPath.js +12 -1
  181. package/src/util/splitAtTopLevelOnly.js +52 -0
  182. package/src/util/toPath.js +1 -1
  183. package/src/util/transformThemeValue.js +13 -3
  184. package/src/util/validateConfig.js +36 -0
  185. package/src/util/validateFormalSyntax.js +34 -0
  186. package/src/util/withAlphaVariable.js +1 -1
  187. package/src/value-parser/LICENSE +22 -0
  188. package/src/value-parser/README.md +3 -0
  189. package/src/value-parser/index.d.ts +177 -0
  190. package/src/value-parser/index.js +28 -0
  191. package/src/value-parser/parse.js +303 -0
  192. package/src/value-parser/stringify.js +41 -0
  193. package/src/value-parser/unit.js +118 -0
  194. package/src/value-parser/walk.js +18 -0
  195. package/stubs/.gitignore +1 -0
  196. package/stubs/.prettierrc.json +6 -0
  197. package/stubs/{defaultConfig.stub.js → config.full.js} +224 -172
  198. package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -1
  199. package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
  200. package/stubs/postcss.config.js +5 -0
  201. package/stubs/tailwind.config.cjs +2 -0
  202. package/stubs/tailwind.config.js +2 -0
  203. package/stubs/tailwind.config.ts +3 -0
  204. package/types/config.d.ts +369 -0
  205. package/types/generated/.gitkeep +0 -0
  206. package/types/generated/colors.d.ts +298 -0
  207. package/types/generated/corePluginList.d.ts +1 -0
  208. package/types/generated/default-theme.d.ts +378 -0
  209. package/types/index.d.ts +7 -0
  210. package/CHANGELOG.md +0 -2075
  211. package/lib/cli-peer-dependencies.js +0 -15
  212. package/lib/constants.js +0 -37
  213. package/peers/index.js +0 -75077
  214. package/scripts/install-integrations.js +0 -27
  215. package/scripts/rebuildFixtures.js +0 -68
  216. package/src/cli-peer-dependencies.js +0 -9
  217. package/src/constants.js +0 -17
@@ -2,39 +2,223 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.defaultExtractor = defaultExtractor;
6
- const PATTERNS = [
7
- /(?:\['([^'\s]+[^<>"'`\s:\\])')/.source,
8
- /(?:\["([^"\s]+[^<>"'`\s:\\])")/.source,
9
- /(?:\[`([^`\s]+[^<>"'`\s:\\])`)/.source,
10
- /([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
11
- /([^<>"'`\s]*\[\w*"[^'`\s]*"?\])/.source,
12
- /([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
13
- /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
14
- /([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
15
- /([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
16
- /([^<>"'`\s]*\[[^<>"'`\s]*\('[^"`\s]*'\)+\])/.source,
17
- /([^<>"'`\s]*\[[^<>"'`\s]*\("[^'`\s]*"\)+\])/.source,
18
- /([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
19
- /([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
20
- /([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source,
21
- /([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
22
- /([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
23
- /([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
24
- /([^"'`\s]*[^<>"'`\s:\\])/.source,
25
- /([^<>"'`\s]*[^"'`\s:\\])/.source,
26
- ].join('|');
27
- const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
28
- const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
29
- function defaultExtractor(content) {
30
- let broadMatches = content.matchAll(BROAD_MATCH_GLOBAL_REGEXP);
31
- let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
32
- let results = [
33
- ...broadMatches,
34
- ...innerMatches
35
- ].flat().filter((v)=>v !== undefined
36
- );
37
- return results;
5
+ Object.defineProperty(exports, "defaultExtractor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return defaultExtractor;
9
+ }
10
+ });
11
+ const _regex = /*#__PURE__*/ _interop_require_wildcard(require("./regex"));
12
+ function _getRequireWildcardCache(nodeInterop) {
13
+ if (typeof WeakMap !== "function") return null;
14
+ var cacheBabelInterop = new WeakMap();
15
+ var cacheNodeInterop = new WeakMap();
16
+ return (_getRequireWildcardCache = function(nodeInterop) {
17
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
+ })(nodeInterop);
19
+ }
20
+ function _interop_require_wildcard(obj, nodeInterop) {
21
+ if (!nodeInterop && obj && obj.__esModule) {
22
+ return obj;
23
+ }
24
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
+ return {
26
+ default: obj
27
+ };
28
+ }
29
+ var cache = _getRequireWildcardCache(nodeInterop);
30
+ if (cache && cache.has(obj)) {
31
+ return cache.get(obj);
32
+ }
33
+ var newObj = {};
34
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
35
+ for(var key in obj){
36
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
37
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
38
+ if (desc && (desc.get || desc.set)) {
39
+ Object.defineProperty(newObj, key, desc);
40
+ } else {
41
+ newObj[key] = obj[key];
42
+ }
43
+ }
44
+ }
45
+ newObj.default = obj;
46
+ if (cache) {
47
+ cache.set(obj, newObj);
48
+ }
49
+ return newObj;
50
+ }
51
+ function defaultExtractor(context) {
52
+ let patterns = Array.from(buildRegExps(context));
53
+ /**
54
+ * @param {string} content
55
+ */ return (content)=>{
56
+ /** @type {(string|string)[]} */ let results = [];
57
+ for (let pattern of patterns){
58
+ var _content_match;
59
+ results = [
60
+ ...results,
61
+ ...(_content_match = content.match(pattern)) !== null && _content_match !== void 0 ? _content_match : []
62
+ ];
63
+ }
64
+ return results.filter((v)=>v !== undefined).map(clipAtBalancedParens);
65
+ };
66
+ }
67
+ function* buildRegExps(context) {
68
+ let separator = context.tailwindConfig.separator;
69
+ let prefix = context.tailwindConfig.prefix !== '' ? _regex.optional(_regex.pattern([
70
+ /-?/,
71
+ _regex.escape(context.tailwindConfig.prefix)
72
+ ])) : '';
73
+ let utility = _regex.any([
74
+ // Arbitrary properties (without square brackets)
75
+ /\[[^\s:'"`]+:[^\s\[\]]+\]/,
76
+ // Arbitrary properties with balanced square brackets
77
+ // This is a targeted fix to continue to allow theme()
78
+ // with square brackets to work in arbitrary properties
79
+ // while fixing a problem with the regex matching too much
80
+ /\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
81
+ // Utilities
82
+ _regex.pattern([
83
+ // Utility Name / Group Name
84
+ /-?(?:\w+)/,
85
+ // Normal/Arbitrary values
86
+ _regex.optional(_regex.any([
87
+ _regex.pattern([
88
+ // Arbitrary values
89
+ /-(?:\w+-)*\[[^\s:]+\]/,
90
+ // Not immediately followed by an `{[(`
91
+ /(?![{([]])/,
92
+ // optionally followed by an opacity modifier
93
+ /(?:\/[^\s'"`\\><$]*)?/
94
+ ]),
95
+ _regex.pattern([
96
+ // Arbitrary values
97
+ /-(?:\w+-)*\[[^\s]+\]/,
98
+ // Not immediately followed by an `{[(`
99
+ /(?![{([]])/,
100
+ // optionally followed by an opacity modifier
101
+ /(?:\/[^\s'"`\\$]*)?/
102
+ ]),
103
+ // Normal values w/o quotes — may include an opacity modifier
104
+ /[-\/][^\s'"`\\$={><]*/
105
+ ]))
106
+ ])
107
+ ]);
108
+ let variantPatterns = [
109
+ // Without quotes
110
+ _regex.any([
111
+ // This is here to provide special support for the `@` variant
112
+ _regex.pattern([
113
+ /@\[[^\s"'`]+\](\/[^\s"'`]+)?/,
114
+ separator
115
+ ]),
116
+ _regex.pattern([
117
+ /([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
118
+ separator
119
+ ]),
120
+ _regex.pattern([
121
+ /[^\s"'`\[\\]+/,
122
+ separator
123
+ ])
124
+ ]),
125
+ // With quotes allowed
126
+ _regex.any([
127
+ _regex.pattern([
128
+ /([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
129
+ separator
130
+ ]),
131
+ _regex.pattern([
132
+ /[^\s`\[\\]+/,
133
+ separator
134
+ ])
135
+ ])
136
+ ];
137
+ for (const variantPattern of variantPatterns){
138
+ yield _regex.pattern([
139
+ // Variants
140
+ '((?=((',
141
+ variantPattern,
142
+ ')+))\\2)?',
143
+ // Important (optional)
144
+ /!?/,
145
+ prefix,
146
+ utility
147
+ ]);
148
+ }
149
+ // 5. Inner matches
150
+ yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
151
+ }
152
+ // We want to capture any "special" characters
153
+ // AND the characters immediately following them (if there is one)
154
+ let SPECIALS = /([\[\]'"`])([^\[\]'"`])?/g;
155
+ let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
156
+ /**
157
+ * Clips a string ensuring that parentheses, quotes, etc… are balanced
158
+ * Used for arbitrary values only
159
+ *
160
+ * We will go past the end of the balanced parens until we find a non-class character
161
+ *
162
+ * Depth matching behavior:
163
+ * w-[calc(100%-theme('spacing[some_key][1.5]'))]']
164
+ * ┬ ┬ ┬┬ ┬ ┬┬ ┬┬┬┬┬┬┬
165
+ * 1 2 3 4 34 3 210 END
166
+ * ╰────┴──────────┴────────┴────────┴┴───┴─┴┴┴
167
+ *
168
+ * @param {string} input
169
+ */ function clipAtBalancedParens(input) {
170
+ // We are care about this for arbitrary values
171
+ if (!input.includes('-[')) {
172
+ return input;
173
+ }
174
+ let depth = 0;
175
+ let openStringTypes = [];
176
+ // Find all parens, brackets, quotes, etc
177
+ // Stop when we end at a balanced pair
178
+ // This is naive and will treat mismatched parens as balanced
179
+ // This shouldn't be a problem in practice though
180
+ let matches = input.matchAll(SPECIALS);
181
+ // We can't use lookbehind assertions because we have to support Safari
182
+ // So, instead, we've emulated it using capture groups and we'll re-work the matches to accommodate
183
+ matches = Array.from(matches).flatMap((match)=>{
184
+ const [, ...groups] = match;
185
+ return groups.map((group, idx)=>Object.assign([], match, {
186
+ index: match.index + idx,
187
+ 0: group
188
+ }));
189
+ });
190
+ for (let match of matches){
191
+ let char = match[0];
192
+ let inStringType = openStringTypes[openStringTypes.length - 1];
193
+ if (char === inStringType) {
194
+ openStringTypes.pop();
195
+ } else if (char === "'" || char === '"' || char === '`') {
196
+ openStringTypes.push(char);
197
+ }
198
+ if (inStringType) {
199
+ continue;
200
+ } else if (char === '[') {
201
+ depth++;
202
+ continue;
203
+ } else if (char === ']') {
204
+ depth--;
205
+ continue;
206
+ }
207
+ // We've gone one character past the point where we should stop
208
+ // This means that there was an extra closing `]`
209
+ // We'll clip to just before it
210
+ if (depth < 0) {
211
+ return input.substring(0, match.index - 1);
212
+ }
213
+ // We've finished balancing the brackets but there still may be characters that can be included
214
+ // For example in the class `text-[#336699]/[.35]`
215
+ // The depth goes to `0` at the closing `]` but goes up again at the `[`
216
+ // If we're at zero and encounter a non-class character then we clip the class there
217
+ if (depth === 0 && !ALLOWED_CLASS_CHARACTERS.test(char)) {
218
+ return input.substring(0, match.index);
219
+ }
220
+ }
221
+ return input;
38
222
  } // Regular utilities
39
223
  // {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
40
224
  // Arbitrary values
@@ -2,18 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ function isRoot(node) {
12
+ return node.type === 'root';
13
+ }
14
+ function isAtLayer(node) {
15
+ return node.type === 'atrule' && node.name === 'layer';
16
+ }
6
17
  function _default(_context) {
7
18
  return (root, result)=>{
8
19
  let found = false;
9
20
  root.walkAtRules('tailwind', (node)=>{
10
21
  if (found) return false;
11
- if (node.parent && node.parent.type !== 'root') {
22
+ if (node.parent && !(isRoot(node.parent) || isAtLayer(node.parent))) {
12
23
  found = true;
13
24
  node.warn(result, [
14
25
  'Nested @tailwind rules were detected, but are not supported.',
15
26
  "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
16
- 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy',
27
+ 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy'
17
28
  ].join('\n'));
18
29
  return false;
19
30
  }
@@ -25,7 +36,7 @@ function _default(_context) {
25
36
  nestedRule.warn(result, [
26
37
  'Nested CSS was detected, but CSS nesting has not been configured correctly.',
27
38
  'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
28
- 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
39
+ 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting'
29
40
  ].join('\n'));
30
41
  return false;
31
42
  });
@@ -2,15 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _dlv = _interopRequireDefault(require("dlv"));
7
- var _didyoumean = _interopRequireDefault(require("didyoumean"));
8
- var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
9
- var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
10
- var _normalizeScreens = require("../util/normalizeScreens");
11
- var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
12
- var _toPath = require("../util/toPath");
13
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _dlv = /*#__PURE__*/ _interop_require_default(require("dlv"));
12
+ const _didyoumean = /*#__PURE__*/ _interop_require_default(require("didyoumean"));
13
+ const _transformThemeValue = /*#__PURE__*/ _interop_require_default(require("../util/transformThemeValue"));
14
+ const _index = /*#__PURE__*/ _interop_require_default(require("../value-parser/index"));
15
+ const _normalizeScreens = require("../util/normalizeScreens");
16
+ const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
17
+ const _toPath = require("../util/toPath");
18
+ const _withAlphaVariable = require("../util/withAlphaVariable");
19
+ const _pluginUtils = require("../util/pluginUtils");
20
+ const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
21
+ function _interop_require_default(obj) {
14
22
  return obj && obj.__esModule ? obj : {
15
23
  default: obj
16
24
  };
@@ -19,10 +27,10 @@ function isObject(input) {
19
27
  return typeof input === 'object' && input !== null;
20
28
  }
21
29
  function findClosestExistingPath(theme, path) {
22
- let parts = (0, _toPath).toPath(path);
30
+ let parts = (0, _toPath.toPath)(path);
23
31
  do {
24
32
  parts.pop();
25
- if ((0, _dlv).default(theme, parts) !== undefined) break;
33
+ if ((0, _dlv.default)(theme, parts) !== undefined) break;
26
34
  }while (parts.length)
27
35
  return parts.length ? parts : undefined;
28
36
  }
@@ -34,27 +42,25 @@ function pathToString(path) {
34
42
  }, '');
35
43
  }
36
44
  function list(items) {
37
- return items.map((key)=>`'${key}'`
38
- ).join(', ');
45
+ return items.map((key)=>`'${key}'`).join(', ');
39
46
  }
40
47
  function listKeys(obj) {
41
48
  return list(Object.keys(obj));
42
49
  }
43
- function validatePath(config, path, defaultValue) {
44
- const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
45
- const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
46
- const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
50
+ function validatePath(config, path, defaultValue, themeOpts = {}) {
51
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, '');
52
+ const pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString);
53
+ const value = (0, _dlv.default)(config.theme, pathSegments, defaultValue);
47
54
  if (value === undefined) {
48
55
  let error = `'${pathString}' does not exist in your theme config.`;
49
56
  const parentSegments = pathSegments.slice(0, -1);
50
- const parentValue = (0, _dlv).default(config.theme, parentSegments);
57
+ const parentValue = (0, _dlv.default)(config.theme, parentSegments);
51
58
  if (isObject(parentValue)) {
52
59
  const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
53
60
  ...parentSegments,
54
61
  key
55
- ]).isValid
56
- );
57
- const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
62
+ ]).isValid);
63
+ const suggestion = (0, _didyoumean.default)(pathSegments[pathSegments.length - 1], validKeys);
58
64
  if (suggestion) {
59
65
  error += ` Did you mean '${pathToString([
60
66
  ...parentSegments,
@@ -66,7 +72,7 @@ function validatePath(config, path, defaultValue) {
66
72
  } else {
67
73
  const closestPath = findClosestExistingPath(config.theme, pathString);
68
74
  if (closestPath) {
69
- const closestValue = (0, _dlv).default(config.theme, closestPath);
75
+ const closestValue = (0, _dlv.default)(config.theme, closestPath);
70
76
  if (isObject(closestValue)) {
71
77
  error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
72
78
  } else {
@@ -87,8 +93,7 @@ function validatePath(config, path, defaultValue) {
87
93
  let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
88
94
  ...pathSegments,
89
95
  key
90
- ]).isValid
91
- );
96
+ ]).isValid);
92
97
  if (validKeys.length) {
93
98
  error += ` Did you mean something like '${pathToString([
94
99
  ...pathSegments,
@@ -104,20 +109,19 @@ function validatePath(config, path, defaultValue) {
104
109
  const [themeSection] = pathSegments;
105
110
  return {
106
111
  isValid: true,
107
- value: (0, _transformThemeValue).default(themeSection)(value)
112
+ value: (0, _transformThemeValue.default)(themeSection)(value, themeOpts)
108
113
  };
109
114
  }
110
115
  function extractArgs(node, vNodes, functions) {
111
- vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
112
- );
116
+ vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
113
117
  let args = [
114
118
  ''
115
119
  ];
116
- for (let vNode1 of vNodes){
117
- if (vNode1.type === 'div' && vNode1.value === ',') {
120
+ for (let vNode of vNodes){
121
+ if (vNode.type === 'div' && vNode.value === ',') {
118
122
  args.push('');
119
123
  } else {
120
- args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
124
+ args[args.length - 1] += _index.default.stringify(vNode);
121
125
  }
122
126
  }
123
127
  return args;
@@ -131,7 +135,9 @@ function resolveVNode(node, vNode, functions) {
131
135
  return vNode;
132
136
  }
133
137
  function resolveFunctions(node, input, functions) {
134
- return (0, _postcssValueParser).default(input).walk((vNode)=>{
138
+ let hasAnyFn = Object.keys(functions).some((fn)=>input.includes(`${fn}(`));
139
+ if (!hasAnyFn) return input;
140
+ return (0, _index.default)(input).walk((vNode)=>{
135
141
  resolveVNode(node, vNode, functions);
136
142
  }).toString();
137
143
  }
@@ -139,24 +145,85 @@ let nodeTypePropertyMap = {
139
145
  atrule: 'params',
140
146
  decl: 'value'
141
147
  };
142
- function _default({ tailwindConfig: config }) {
148
+ /**
149
+ * @param {string} path
150
+ * @returns {Iterable<[path: string, alpha: string|undefined]>}
151
+ */ function* toPaths(path) {
152
+ // Strip quotes from beginning and end of string
153
+ // This allows the alpha value to be present inside of quotes
154
+ path = path.replace(/^['"]+|['"]+$/g, '');
155
+ let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
156
+ let alpha = undefined;
157
+ yield [
158
+ path,
159
+ undefined
160
+ ];
161
+ if (matches) {
162
+ path = matches[1];
163
+ alpha = matches[2];
164
+ yield [
165
+ path,
166
+ alpha
167
+ ];
168
+ }
169
+ }
170
+ /**
171
+ *
172
+ * @param {any} config
173
+ * @param {string} path
174
+ * @param {any} defaultValue
175
+ */ function resolvePath(config, path, defaultValue) {
176
+ const results = Array.from(toPaths(path)).map(([path, alpha])=>{
177
+ return Object.assign(validatePath(config, path, defaultValue, {
178
+ opacityValue: alpha
179
+ }), {
180
+ resolvedPath: path,
181
+ alpha
182
+ });
183
+ });
184
+ var _results_find;
185
+ return (_results_find = results.find((result)=>result.isValid)) !== null && _results_find !== void 0 ? _results_find : results[0];
186
+ }
187
+ function _default(context) {
188
+ let config = context.tailwindConfig;
143
189
  let functions = {
144
190
  theme: (node, path, ...defaultValue)=>{
145
- const { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
191
+ let { isValid, value, error, alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
146
192
  if (!isValid) {
193
+ var _parentNode_raws_tailwind, _parentNode;
194
+ let parentNode = node.parent;
195
+ let candidate = (_parentNode = parentNode) === null || _parentNode === void 0 ? void 0 : (_parentNode_raws_tailwind = _parentNode.raws.tailwind) === null || _parentNode_raws_tailwind === void 0 ? void 0 : _parentNode_raws_tailwind.candidate;
196
+ if (parentNode && candidate !== undefined) {
197
+ // Remove this utility from any caches
198
+ context.markInvalidUtilityNode(parentNode);
199
+ // Remove the CSS node from the markup
200
+ parentNode.remove();
201
+ // Show a warning
202
+ _log.default.warn('invalid-theme-key-in-class', [
203
+ `The utility \`${candidate}\` contains an invalid theme value and was not generated.`
204
+ ]);
205
+ return;
206
+ }
147
207
  throw node.error(error);
148
208
  }
209
+ let maybeColor = (0, _pluginUtils.parseColorFormat)(value);
210
+ let isColorFunction = maybeColor !== undefined && typeof maybeColor === 'function';
211
+ if (alpha !== undefined || isColorFunction) {
212
+ if (alpha === undefined) {
213
+ alpha = 1.0;
214
+ }
215
+ value = (0, _withAlphaVariable.withAlphaValue)(maybeColor, alpha, maybeColor);
216
+ }
149
217
  return value;
150
218
  },
151
219
  screen: (node, screen)=>{
152
220
  screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
153
- let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
154
- let screenDefinition = screens.find(({ name })=>name === screen
155
- );
221
+ let screens = (0, _normalizeScreens.normalizeScreens)(config.theme.screens);
222
+ let screenDefinition = screens.find(({ name })=>name === screen);
156
223
  if (!screenDefinition) {
157
224
  throw node.error(`The '${screen}' screen does not exist in your theme.`);
158
225
  }
159
- return (0, _buildMediaQuery).default(screenDefinition);
226
+ return (0, _buildMediaQuery.default)(screenDefinition);
160
227
  }
161
228
  };
162
229
  return (root)=>{