tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cb6e45a

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