tailwindcss 0.0.0-insiders.4e21639 → 0.0.0-insiders.4e62334

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 (157) hide show
  1. package/CHANGELOG.md +435 -3
  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-peer-dependencies.js +20 -7
  11. package/lib/cli.js +460 -259
  12. package/lib/constants.js +27 -20
  13. package/lib/corePluginList.js +9 -3
  14. package/lib/corePlugins.js +1840 -1753
  15. package/lib/css/preflight.css +8 -9
  16. package/lib/featureFlags.js +29 -20
  17. package/lib/index.js +22 -11
  18. package/lib/lib/cacheInvalidation.js +90 -0
  19. package/lib/lib/collapseAdjacentRules.js +27 -9
  20. package/lib/lib/collapseDuplicateDeclarations.js +58 -4
  21. package/lib/lib/defaultExtractor.js +231 -0
  22. package/lib/lib/detectNesting.js +13 -10
  23. package/lib/lib/evaluateTailwindFunctions.js +119 -52
  24. package/lib/lib/expandApplyAtRules.js +440 -161
  25. package/lib/lib/expandTailwindAtRules.js +130 -128
  26. package/lib/lib/generateRules.js +410 -171
  27. package/lib/lib/getModuleDependencies.js +11 -8
  28. package/lib/lib/normalizeTailwindDirectives.js +43 -32
  29. package/lib/lib/offsets.js +199 -0
  30. package/lib/lib/partitionApplyAtRules.js +56 -0
  31. package/lib/lib/regex.js +60 -0
  32. package/lib/lib/resolveDefaultsAtRules.js +91 -55
  33. package/lib/lib/setupContextUtils.js +453 -347
  34. package/lib/lib/setupTrackingContext.js +52 -44
  35. package/lib/lib/sharedState.js +48 -9
  36. package/lib/lib/substituteScreenAtRules.js +13 -8
  37. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  38. package/lib/postcss-plugins/nesting/index.js +19 -0
  39. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  40. package/lib/processTailwindFeatures.js +36 -25
  41. package/lib/public/colors.js +247 -245
  42. package/lib/public/create-plugin.js +6 -4
  43. package/lib/public/default-config.js +7 -5
  44. package/lib/public/default-theme.js +7 -5
  45. package/lib/public/resolve-config.js +8 -5
  46. package/lib/util/bigSign.js +4 -1
  47. package/lib/util/buildMediaQuery.js +16 -25
  48. package/lib/util/cloneDeep.js +7 -6
  49. package/lib/util/cloneNodes.js +21 -3
  50. package/lib/util/color.js +54 -40
  51. package/lib/util/configurePlugins.js +4 -1
  52. package/lib/util/createPlugin.js +6 -6
  53. package/lib/util/createUtilityPlugin.js +12 -14
  54. package/lib/util/dataTypes.js +119 -102
  55. package/lib/util/defaults.js +10 -1
  56. package/lib/util/escapeClassName.js +7 -4
  57. package/lib/util/escapeCommas.js +5 -2
  58. package/lib/util/flattenColorPalette.js +9 -12
  59. package/lib/util/formatVariantSelector.js +223 -40
  60. package/lib/util/getAllConfigs.js +27 -8
  61. package/lib/util/hashConfig.js +6 -3
  62. package/lib/util/isKeyframeRule.js +5 -2
  63. package/lib/util/isPlainObject.js +5 -2
  64. package/lib/util/isValidArbitraryValue.js +72 -0
  65. package/lib/util/log.js +22 -12
  66. package/lib/util/nameClass.js +17 -8
  67. package/lib/util/negateValue.js +22 -7
  68. package/lib/util/normalizeConfig.js +99 -54
  69. package/lib/util/normalizeScreens.js +73 -0
  70. package/lib/util/parseAnimationValue.js +42 -40
  71. package/lib/util/parseBoxShadowValue.js +30 -23
  72. package/lib/util/parseDependency.js +18 -15
  73. package/lib/util/parseObjectStyles.js +10 -7
  74. package/lib/util/pluginUtils.js +51 -42
  75. package/lib/util/prefixSelector.js +10 -8
  76. package/lib/util/removeAlphaVariables.js +29 -0
  77. package/lib/util/resolveConfig.js +91 -66
  78. package/lib/util/resolveConfigPath.js +11 -9
  79. package/lib/util/responsive.js +8 -5
  80. package/lib/util/splitAtTopLevelOnly.js +43 -0
  81. package/lib/util/tap.js +4 -1
  82. package/lib/util/toColorValue.js +5 -3
  83. package/lib/util/toPath.js +24 -3
  84. package/lib/util/transformThemeValue.js +37 -29
  85. package/lib/util/validateConfig.js +24 -0
  86. package/lib/util/withAlphaVariable.js +23 -15
  87. package/nesting/index.js +2 -12
  88. package/package.json +43 -43
  89. package/peers/index.js +11543 -8114
  90. package/plugin.d.ts +11 -0
  91. package/plugin.js +2 -1
  92. package/resolveConfig.d.ts +3 -0
  93. package/resolveConfig.js +2 -1
  94. package/scripts/generate-types.js +105 -0
  95. package/scripts/type-utils.js +27 -0
  96. package/src/cli-peer-dependencies.js +7 -1
  97. package/src/cli.js +293 -36
  98. package/src/corePluginList.js +1 -1
  99. package/src/corePlugins.js +428 -285
  100. package/src/css/preflight.css +8 -9
  101. package/src/featureFlags.js +9 -5
  102. package/src/index.js +14 -6
  103. package/src/lib/cacheInvalidation.js +52 -0
  104. package/src/lib/collapseAdjacentRules.js +21 -2
  105. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  106. package/src/lib/defaultExtractor.js +208 -0
  107. package/src/lib/evaluateTailwindFunctions.js +84 -10
  108. package/src/lib/expandApplyAtRules.js +488 -153
  109. package/src/lib/expandTailwindAtRules.js +82 -80
  110. package/src/lib/generateRules.js +352 -120
  111. package/src/lib/normalizeTailwindDirectives.js +7 -1
  112. package/src/lib/offsets.js +239 -0
  113. package/src/lib/partitionApplyAtRules.js +52 -0
  114. package/src/lib/regex.js +74 -0
  115. package/src/lib/resolveDefaultsAtRules.js +59 -17
  116. package/src/lib/setupContextUtils.js +337 -174
  117. package/src/lib/setupTrackingContext.js +13 -8
  118. package/src/lib/sharedState.js +42 -4
  119. package/src/lib/substituteScreenAtRules.js +6 -3
  120. package/src/postcss-plugins/nesting/README.md +42 -0
  121. package/src/postcss-plugins/nesting/index.js +13 -0
  122. package/src/postcss-plugins/nesting/plugin.js +80 -0
  123. package/src/processTailwindFeatures.js +12 -2
  124. package/src/util/buildMediaQuery.js +14 -18
  125. package/src/util/cloneNodes.js +19 -2
  126. package/src/util/color.js +31 -14
  127. package/src/util/dataTypes.js +28 -19
  128. package/src/util/defaults.js +6 -0
  129. package/src/util/formatVariantSelector.js +237 -23
  130. package/src/util/getAllConfigs.js +19 -0
  131. package/src/util/isValidArbitraryValue.js +61 -0
  132. package/src/util/log.js +11 -7
  133. package/src/util/nameClass.js +1 -1
  134. package/src/util/negateValue.js +10 -2
  135. package/src/util/normalizeConfig.js +16 -3
  136. package/src/util/normalizeScreens.js +45 -0
  137. package/src/util/parseBoxShadowValue.js +4 -3
  138. package/src/util/pluginUtils.js +14 -2
  139. package/src/util/prefixSelector.js +7 -5
  140. package/src/util/removeAlphaVariables.js +24 -0
  141. package/src/util/resolveConfig.js +71 -17
  142. package/src/util/splitAtTopLevelOnly.js +45 -0
  143. package/src/util/toPath.js +23 -1
  144. package/src/util/transformThemeValue.js +13 -3
  145. package/src/util/validateConfig.js +13 -0
  146. package/src/util/withAlphaVariable.js +1 -1
  147. package/stubs/defaultConfig.stub.js +24 -3
  148. package/stubs/simpleConfig.stub.js +1 -0
  149. package/types/config.d.ts +334 -0
  150. package/types/generated/.gitkeep +0 -0
  151. package/types/generated/colors.d.ts +276 -0
  152. package/types/generated/corePluginList.d.ts +1 -0
  153. package/types/generated/default-theme.d.ts +331 -0
  154. package/types/index.d.ts +7 -0
  155. package/lib/lib/setupWatchingContext.js +0 -288
  156. package/nesting/plugin.js +0 -41
  157. package/src/lib/setupWatchingContext.js +0 -311
@@ -2,19 +2,22 @@
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;
9
- root.walkAtRules('tailwind', (node)=>{
12
+ root.walkAtRules("tailwind", (node)=>{
10
13
  if (found) return false;
11
- if (node.parent && node.parent.type !== 'root') {
14
+ if (node.parent && node.parent.type !== "root") {
12
15
  found = true;
13
16
  node.warn(result, [
14
- 'Nested @tailwind rules were detected, but are not supported.',
17
+ "Nested @tailwind rules were detected, but are not supported.",
15
18
  "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',
17
- ].join('\n'));
19
+ "Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy",
20
+ ].join("\n"));
18
21
  return false;
19
22
  }
20
23
  });
@@ -23,10 +26,10 @@ function _default(_context) {
23
26
  rule.walkRules((nestedRule)=>{
24
27
  found = true;
25
28
  nestedRule.warn(result, [
26
- 'Nested CSS was detected, but CSS nesting has not been configured correctly.',
27
- 'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
28
- 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
29
- ].join('\n'));
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"));
30
33
  return false;
31
34
  });
32
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,79 +85,141 @@ 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
- for (let vNode1 of vNodes){
116
- if (vNode1.type === 'div' && vNode1.value === ',') {
117
- args.push('');
118
+ for (let vNode of vNodes){
119
+ if (vNode.type === "div" && vNode.value === ",") {
120
+ args.push("");
118
121
  } else {
119
- args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
122
+ args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
120
123
  }
121
124
  }
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)=>{