tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cc69633

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 (140) hide show
  1. package/CHANGELOG.md +356 -1
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  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 +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +3 -3
  11. package/lib/cli.js +261 -207
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +11 -1
  14. package/lib/corePlugins.js +1875 -1772
  15. package/lib/css/preflight.css +19 -5
  16. package/lib/featureFlags.js +17 -15
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +44 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +25 -21
  24. package/lib/lib/expandApplyAtRules.js +375 -157
  25. package/lib/lib/expandTailwindAtRules.js +153 -148
  26. package/lib/lib/generateRules.js +364 -67
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +45 -36
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/resolveDefaultsAtRules.js +105 -90
  31. package/lib/lib/setupContextUtils.js +364 -282
  32. package/lib/lib/setupTrackingContext.js +57 -56
  33. package/lib/lib/sharedState.js +38 -15
  34. package/lib/lib/substituteScreenAtRules.js +9 -6
  35. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  36. package/lib/postcss-plugins/nesting/index.js +17 -0
  37. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  38. package/lib/processTailwindFeatures.js +21 -9
  39. package/lib/public/colors.js +244 -248
  40. package/lib/public/resolve-config.js +5 -5
  41. package/lib/util/buildMediaQuery.js +13 -24
  42. package/lib/util/cloneDeep.js +1 -1
  43. package/lib/util/cloneNodes.js +12 -1
  44. package/lib/util/color.js +43 -32
  45. package/lib/util/createPlugin.js +1 -2
  46. package/lib/util/createUtilityPlugin.js +13 -17
  47. package/lib/util/dataTypes.js +114 -74
  48. package/lib/util/defaults.js +6 -0
  49. package/lib/util/escapeClassName.js +5 -5
  50. package/lib/util/escapeCommas.js +1 -1
  51. package/lib/util/flattenColorPalette.js +2 -4
  52. package/lib/util/formatVariantSelector.js +186 -0
  53. package/lib/util/getAllConfigs.js +5 -5
  54. package/lib/util/hashConfig.js +5 -5
  55. package/lib/util/isKeyframeRule.js +1 -1
  56. package/lib/util/isPlainObject.js +1 -1
  57. package/lib/util/isValidArbitraryValue.js +64 -0
  58. package/lib/util/log.js +35 -19
  59. package/lib/util/nameClass.js +7 -6
  60. package/lib/util/negateValue.js +5 -3
  61. package/lib/util/normalizeConfig.js +240 -0
  62. package/lib/util/normalizeScreens.js +59 -0
  63. package/lib/util/parseAnimationValue.js +56 -56
  64. package/lib/util/parseBoxShadowValue.js +117 -0
  65. package/lib/util/parseDependency.js +32 -32
  66. package/lib/util/parseObjectStyles.js +6 -6
  67. package/lib/util/pluginUtils.js +67 -170
  68. package/lib/util/prefixSelector.js +4 -7
  69. package/lib/util/resolveConfig.js +83 -121
  70. package/lib/util/resolveConfigPath.js +17 -18
  71. package/lib/util/responsive.js +6 -6
  72. package/lib/util/toColorValue.js +1 -2
  73. package/lib/util/toPath.js +6 -1
  74. package/lib/util/transformThemeValue.js +40 -34
  75. package/lib/util/withAlphaVariable.js +19 -19
  76. package/nesting/index.js +2 -12
  77. package/package.json +40 -42
  78. package/peers/index.js +9110 -10362
  79. package/plugin.d.ts +6 -0
  80. package/plugin.js +2 -1
  81. package/resolveConfig.js +2 -1
  82. package/scripts/create-plugin-list.js +2 -2
  83. package/scripts/generate-types.js +52 -0
  84. package/src/cli.js +107 -31
  85. package/src/corePluginList.js +1 -1
  86. package/src/corePlugins.js +610 -585
  87. package/src/css/preflight.css +19 -5
  88. package/src/featureFlags.js +14 -8
  89. package/src/index.js +14 -6
  90. package/src/lib/cacheInvalidation.js +52 -0
  91. package/src/lib/collapseAdjacentRules.js +21 -2
  92. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  93. package/src/lib/defaultExtractor.js +50 -0
  94. package/src/lib/detectNesting.js +22 -3
  95. package/src/lib/evaluateTailwindFunctions.js +6 -3
  96. package/src/lib/expandApplyAtRules.js +390 -155
  97. package/src/lib/expandTailwindAtRules.js +87 -61
  98. package/src/lib/generateRules.js +367 -41
  99. package/src/lib/normalizeTailwindDirectives.js +10 -3
  100. package/src/lib/partitionApplyAtRules.js +52 -0
  101. package/src/lib/resolveDefaultsAtRules.js +74 -53
  102. package/src/lib/setupContextUtils.js +330 -206
  103. package/src/lib/setupTrackingContext.js +11 -12
  104. package/src/lib/sharedState.js +42 -7
  105. package/src/lib/substituteScreenAtRules.js +6 -3
  106. package/src/postcss-plugins/nesting/README.md +42 -0
  107. package/src/postcss-plugins/nesting/index.js +13 -0
  108. package/src/postcss-plugins/nesting/plugin.js +80 -0
  109. package/src/processTailwindFeatures.js +17 -2
  110. package/src/public/colors.js +4 -9
  111. package/src/util/buildMediaQuery.js +14 -18
  112. package/src/util/cloneNodes.js +14 -1
  113. package/src/util/color.js +31 -14
  114. package/src/util/createUtilityPlugin.js +2 -2
  115. package/src/util/dataTypes.js +56 -16
  116. package/src/util/defaults.js +6 -0
  117. package/src/util/formatVariantSelector.js +196 -0
  118. package/src/util/isValidArbitraryValue.js +61 -0
  119. package/src/util/log.js +23 -22
  120. package/src/util/nameClass.js +2 -2
  121. package/src/util/negateValue.js +4 -2
  122. package/src/util/normalizeConfig.js +270 -0
  123. package/src/util/normalizeScreens.js +45 -0
  124. package/src/util/parseBoxShadowValue.js +119 -0
  125. package/src/util/pluginUtils.js +51 -147
  126. package/src/util/prefixSelector.js +7 -8
  127. package/src/util/resolveConfig.js +52 -65
  128. package/src/util/toPath.js +23 -1
  129. package/src/util/transformThemeValue.js +22 -7
  130. package/stubs/defaultConfig.stub.js +156 -93
  131. package/stubs/simpleConfig.stub.js +0 -1
  132. package/types/config.d.ts +323 -0
  133. package/types/generated/.gitkeep +0 -0
  134. package/types/generated/colors.d.ts +276 -0
  135. package/types/generated/corePluginList.d.ts +1 -0
  136. package/types/index.d.ts +1 -0
  137. package/types.d.ts +1 -0
  138. package/lib/lib/setupWatchingContext.js +0 -284
  139. package/nesting/plugin.js +0 -41
  140. package/src/lib/setupWatchingContext.js +0 -306
@@ -9,7 +9,12 @@
9
9
  box-sizing: border-box; /* 1 */
10
10
  border-width: 0; /* 2 */
11
11
  border-style: solid; /* 2 */
12
- border-color: currentColor; /* 2 */
12
+ border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
13
+ }
14
+
15
+ ::before,
16
+ ::after {
17
+ --tw-content: '';
13
18
  }
14
19
 
15
20
  /*
@@ -53,7 +58,7 @@ hr {
53
58
  Add the correct text decoration in Chrome, Edge, and Safari.
54
59
  */
55
60
 
56
- abbr[title] {
61
+ abbr:where([title]) {
57
62
  text-decoration: underline dotted;
58
63
  }
59
64
 
@@ -139,7 +144,7 @@ sup {
139
144
  table {
140
145
  text-indent: 0; /* 1 */
141
146
  border-color: inherit; /* 2 */
142
- border-collapse: collapse; /* 3 */
147
+ border-collapse: collapse; /* 3 */
143
148
  }
144
149
 
145
150
  /*
@@ -155,6 +160,7 @@ select,
155
160
  textarea {
156
161
  font-family: inherit; /* 1 */
157
162
  font-size: 100%; /* 1 */
163
+ font-weight: inherit; /* 1 */
158
164
  line-height: inherit; /* 1 */
159
165
  color: inherit; /* 1 */
160
166
  margin: 0; /* 2 */
@@ -283,7 +289,8 @@ legend {
283
289
  }
284
290
 
285
291
  ol,
286
- ul {
292
+ ul,
293
+ menu {
287
294
  list-style: none;
288
295
  margin: 0;
289
296
  padding: 0;
@@ -304,7 +311,7 @@ textarea {
304
311
 
305
312
  input::placeholder,
306
313
  textarea::placeholder {
307
- opacity: 1; /* 1 */
314
+ opacity: 1; /* 1 */
308
315
  color: theme('colors.gray.400', #9ca3af); /* 2 */
309
316
  }
310
317
 
@@ -317,6 +324,13 @@ button,
317
324
  cursor: pointer;
318
325
  }
319
326
 
327
+ /*
328
+ Make sure disabled buttons don't get the pointer cursor.
329
+ */
330
+ :disabled {
331
+ cursor: default;
332
+ }
333
+
320
334
  /*
321
335
  1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
322
336
  2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
@@ -5,39 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.flagEnabled = flagEnabled;
6
6
  exports.issueFlagNotices = issueFlagNotices;
7
7
  exports.default = void 0;
8
- var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _picocolors = _interopRequireDefault(require("picocolors"));
9
9
  var _log = _interopRequireDefault(require("./util/log"));
10
10
  function _interopRequireDefault(obj) {
11
11
  return obj && obj.__esModule ? obj : {
12
12
  default: obj
13
13
  };
14
14
  }
15
- const featureFlags = {
15
+ let defaults = {
16
+ optimizeUniversalDefaults: false
17
+ };
18
+ let featureFlags = {
16
19
  future: [],
17
20
  experimental: [
18
- 'optimizeUniversalDefaults'
21
+ "optimizeUniversalDefaults"
19
22
  ]
20
23
  };
21
24
  function flagEnabled(config, flag) {
22
25
  if (featureFlags.future.includes(flag)) {
23
26
  var ref;
24
- var ref1;
25
- return config.future === 'all' || ((ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : false);
27
+ var ref1, ref2;
28
+ return config.future === "all" || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
26
29
  }
27
30
  if (featureFlags.experimental.includes(flag)) {
28
- var ref;
29
- var ref5;
30
- return config.experimental === 'all' || ((ref5 = config === null || config === void 0 ? void 0 : (ref = config.experimental) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref5 !== void 0 ? ref5 : false);
31
+ var ref3;
32
+ var ref4, ref5;
33
+ return config.experimental === "all" || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
31
34
  }
32
35
  return false;
33
36
  }
34
37
  function experimentalFlagsEnabled(config) {
35
- if (config.experimental === 'all') {
38
+ if (config.experimental === "all") {
36
39
  return featureFlags.experimental;
37
40
  }
38
41
  var ref;
39
- return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {
40
- }).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
42
+ return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
41
43
  );
42
44
  }
43
45
  function issueFlagNotices(config) {
@@ -45,11 +47,11 @@ function issueFlagNotices(config) {
45
47
  return;
46
48
  }
47
49
  if (experimentalFlagsEnabled(config).length > 0) {
48
- const changes = experimentalFlagsEnabled(config).map((s)=>_chalk.default.yellow(s)
49
- ).join(', ');
50
- _log.default.warn([
50
+ let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)
51
+ ).join(", ");
52
+ _log.default.warn("experimental-flags-enabled", [
51
53
  `You have enabled experimental features: ${changes}`,
52
- 'Experimental features are not covered by semver, may introduce breaking changes, and can change at any time.',
54
+ "Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.",
53
55
  ]);
54
56
  }
55
57
  }
package/lib/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  var _setupTrackingContext = _interopRequireDefault(require("./lib/setupTrackingContext"));
3
- var _setupWatchingContext = _interopRequireDefault(require("./lib/setupWatchingContext"));
4
3
  var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
5
4
  var _sharedState = require("./lib/sharedState");
6
5
  function _interopRequireDefault(obj) {
@@ -10,20 +9,30 @@ function _interopRequireDefault(obj) {
10
9
  }
11
10
  module.exports = function tailwindcss(configOrPath) {
12
11
  return {
13
- postcssPlugin: 'tailwindcss',
12
+ postcssPlugin: "tailwindcss",
14
13
  plugins: [
15
14
  _sharedState.env.DEBUG && function(root) {
16
- console.log('\n');
17
- console.time('JIT TOTAL');
15
+ console.log("\n");
16
+ console.time("JIT TOTAL");
18
17
  return root;
19
18
  },
20
19
  function(root, result) {
21
- let setupContext = _sharedState.env.TAILWIND_MODE === 'watch' ? (0, _setupWatchingContext).default(configOrPath) : (0, _setupTrackingContext).default(configOrPath);
22
- (0, _processTailwindFeatures).default(setupContext)(root, result);
20
+ let context = (0, _setupTrackingContext).default(configOrPath);
21
+ if (root.type === "document") {
22
+ let roots = root.nodes.filter((node)=>node.type === "root"
23
+ );
24
+ for (const root1 of roots){
25
+ if (root1.type === "root") {
26
+ (0, _processTailwindFeatures).default(context)(root1, result);
27
+ }
28
+ }
29
+ return;
30
+ }
31
+ (0, _processTailwindFeatures).default(context)(root, result);
23
32
  },
24
33
  _sharedState.env.DEBUG && function(root) {
25
- console.timeEnd('JIT TOTAL');
26
- console.log('\n');
34
+ console.timeEnd("JIT TOTAL");
35
+ console.log("\n");
27
36
  return root;
28
37
  },
29
38
  ].filter(Boolean)
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.hasContentChanged = hasContentChanged;
6
+ var _crypto = _interopRequireDefault(require("crypto"));
7
+ var sharedState = _interopRequireWildcard(require("./sharedState"));
8
+ function _interopRequireDefault(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }
13
+ function _interopRequireWildcard(obj) {
14
+ if (obj && obj.__esModule) {
15
+ return obj;
16
+ } else {
17
+ var newObj = {};
18
+ if (obj != null) {
19
+ for(var key in obj){
20
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
21
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
22
+ if (desc.get || desc.set) {
23
+ Object.defineProperty(newObj, key, desc);
24
+ } else {
25
+ newObj[key] = obj[key];
26
+ }
27
+ }
28
+ }
29
+ }
30
+ newObj.default = obj;
31
+ return newObj;
32
+ }
33
+ }
34
+ /**
35
+ * Calculate the hash of a string.
36
+ *
37
+ * This doesn't need to be cryptographically secure or
38
+ * anything like that since it's used only to detect
39
+ * when the CSS changes to invalidate the context.
40
+ *
41
+ * This is wrapped in a try/catch because it's really dependent
42
+ * on how Node itself is build and the environment and OpenSSL
43
+ * version / build that is installed on the user's machine.
44
+ *
45
+ * Based on the environment this can just outright fail.
46
+ *
47
+ * See https://github.com/nodejs/node/issues/40455
48
+ *
49
+ * @param {string} str
50
+ */ function getHash(str) {
51
+ try {
52
+ return _crypto.default.createHash("md5").update(str, "utf-8").digest("binary");
53
+ } catch (err) {
54
+ return "";
55
+ }
56
+ }
57
+ function hasContentChanged(sourcePath, root) {
58
+ let css = root.toString();
59
+ // We only care about files with @tailwind directives
60
+ // Other files use an existing context
61
+ if (!css.includes("@tailwind")) {
62
+ return false;
63
+ }
64
+ let existingHash = sharedState.sourceHashMap.get(sourcePath);
65
+ let rootHash = getHash(css);
66
+ let didChange = existingHash !== rootHash;
67
+ sharedState.sourceHashMap.set(sourcePath, rootHash);
68
+ return didChange;
69
+ }
@@ -3,18 +3,8 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = collapseAdjacentRules;
6
- let comparisonMap = {
7
- atrule: [
8
- 'name',
9
- 'params'
10
- ],
11
- rule: [
12
- 'selector'
13
- ]
14
- };
15
- let types = new Set(Object.keys(comparisonMap));
16
6
  function collapseAdjacentRules() {
17
- return (root)=>{
7
+ function collapseRulesIn(root) {
18
8
  let currentRule = null;
19
9
  root.each((node)=>{
20
10
  if (!types.has(node.type)) {
@@ -27,15 +17,41 @@ function collapseAdjacentRules() {
27
17
  }
28
18
  let properties = comparisonMap[node.type];
29
19
  var _property, _property1;
30
- if (node.type === 'atrule' && node.name === 'font-face') {
20
+ if (node.type === "atrule" && node.name === "font-face") {
31
21
  currentRule = node;
32
- } else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property : '').replace(/\s+/g, ' ') === ((_property1 = currentRule[property]) !== null && _property1 !== void 0 ? _property1 : '').replace(/\s+/g, ' ')
22
+ } else if (properties.every((property)=>((_property = node[property]) !== null && _property !== void 0 ? _property : "").replace(/\s+/g, " ") === ((_property1 = currentRule[property]) !== null && _property1 !== void 0 ? _property1 : "").replace(/\s+/g, " ")
33
23
  )) {
34
- currentRule.append(node.nodes);
24
+ // An AtRule may not have children (for example if we encounter duplicate @import url(…) rules)
25
+ if (node.nodes) {
26
+ currentRule.append(node.nodes);
27
+ }
35
28
  node.remove();
36
29
  } else {
37
30
  currentRule = node;
38
31
  }
39
32
  });
33
+ // After we've collapsed adjacent rules & at-rules, we need to collapse
34
+ // adjacent rules & at-rules that are children of at-rules.
35
+ // We do not care about nesting rules because Tailwind CSS
36
+ // explicitly does not handle rule nesting on its own as
37
+ // the user is expected to use a nesting plugin
38
+ root.each((node)=>{
39
+ if (node.type === "atrule") {
40
+ collapseRulesIn(node);
41
+ }
42
+ });
43
+ }
44
+ return (root)=>{
45
+ collapseRulesIn(root);
40
46
  };
41
47
  }
48
+ let comparisonMap = {
49
+ atrule: [
50
+ "name",
51
+ "params"
52
+ ],
53
+ rule: [
54
+ "selector"
55
+ ]
56
+ };
57
+ let types = new Set(Object.keys(comparisonMap));
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = collapseDuplicateDeclarations;
6
+ function collapseDuplicateDeclarations() {
7
+ return (root)=>{
8
+ root.walkRules((node)=>{
9
+ let seen = new Map();
10
+ let droppable = new Set([]);
11
+ let byProperty = new Map();
12
+ node.walkDecls((decl)=>{
13
+ // This could happen if we have nested selectors. In that case the
14
+ // parent will loop over all its declarations but also the declarations
15
+ // of nested rules. With this we ensure that we are shallowly checking
16
+ // declarations.
17
+ if (decl.parent !== node) {
18
+ return;
19
+ }
20
+ if (seen.has(decl.prop)) {
21
+ // Exact same value as what we have seen so far
22
+ if (seen.get(decl.prop).value === decl.value) {
23
+ // Keep the last one, drop the one we've seen so far
24
+ droppable.add(seen.get(decl.prop));
25
+ // Override the existing one with the new value. This is necessary
26
+ // so that if we happen to have more than one declaration with the
27
+ // same value, that we keep removing the previous one. Otherwise we
28
+ // will only remove the *first* one.
29
+ seen.set(decl.prop, decl);
30
+ return;
31
+ }
32
+ // Not the same value, so we need to check if we can merge it so
33
+ // let's collect it first.
34
+ if (!byProperty.has(decl.prop)) {
35
+ byProperty.set(decl.prop, new Set());
36
+ }
37
+ byProperty.get(decl.prop).add(seen.get(decl.prop));
38
+ byProperty.get(decl.prop).add(decl);
39
+ }
40
+ seen.set(decl.prop, decl);
41
+ });
42
+ // Drop all the duplicate declarations with the exact same value we've
43
+ // already seen so far.
44
+ for (let decl1 of droppable){
45
+ decl1.remove();
46
+ }
47
+ // Analyze the declarations based on its unit, drop all the declarations
48
+ // with the same unit but the last one in the list.
49
+ for (let declarations of byProperty.values()){
50
+ let byUnit = new Map();
51
+ for (let decl of declarations){
52
+ let unit = resolveUnit(decl.value);
53
+ if (unit === null) {
54
+ continue;
55
+ }
56
+ if (!byUnit.has(unit)) {
57
+ byUnit.set(unit, new Set());
58
+ }
59
+ byUnit.get(unit).add(decl);
60
+ }
61
+ for (let declarations1 of byUnit.values()){
62
+ // Get all but the last one
63
+ let removableDeclarations = Array.from(declarations1).slice(0, -1);
64
+ for (let decl of removableDeclarations){
65
+ decl.remove();
66
+ }
67
+ }
68
+ }
69
+ });
70
+ };
71
+ }
72
+ let UNITLESS_NUMBER = Symbol("unitless-number");
73
+ function resolveUnit(input) {
74
+ let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
75
+ if (result) {
76
+ var ref;
77
+ return (ref = result[1]) !== null && ref !== void 0 ? ref : UNITLESS_NUMBER;
78
+ }
79
+ return null;
80
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
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;
38
+ } // Regular utilities
39
+ // {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
40
+ // Arbitrary values
41
+ // {{modifier}:}*{namespace}-[{arbitraryValue}]{/{opacityModifier}}?
42
+ // arbitraryValue: no whitespace, balanced quotes unless within quotes, balanced brackets unless within quotes
43
+ // Arbitrary properties
44
+ // {{modifier}:}*[{validCssPropertyName}:{arbitraryValue}]
@@ -6,12 +6,27 @@ exports.default = _default;
6
6
  function _default(_context) {
7
7
  return (root, result)=>{
8
8
  let found = false;
9
+ root.walkAtRules("tailwind", (node)=>{
10
+ if (found) return false;
11
+ if (node.parent && node.parent.type !== "root") {
12
+ found = true;
13
+ node.warn(result, [
14
+ "Nested @tailwind rules were detected, but are not supported.",
15
+ "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"));
18
+ return false;
19
+ }
20
+ });
9
21
  root.walkRules((rule)=>{
10
22
  if (found) return false;
11
23
  rule.walkRules((nestedRule)=>{
12
24
  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');
25
+ 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"));
15
30
  return false;
16
31
  });
17
32
  });
@@ -7,6 +7,7 @@ var _dlv = _interopRequireDefault(require("dlv"));
7
7
  var _didyoumean = _interopRequireDefault(require("didyoumean"));
8
8
  var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
9
9
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
10
+ var _normalizeScreens = require("../util/normalizeScreens");
10
11
  var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
11
12
  var _toPath = require("../util/toPath");
12
13
  function _interopRequireDefault(obj) {
@@ -15,34 +16,34 @@ function _interopRequireDefault(obj) {
15
16
  };
16
17
  }
17
18
  function isObject(input) {
18
- return typeof input === 'object' && input !== null;
19
+ return typeof input === "object" && input !== null;
19
20
  }
20
21
  function findClosestExistingPath(theme, path) {
21
22
  let parts = (0, _toPath).toPath(path);
22
23
  do {
23
24
  parts.pop();
24
25
  if ((0, _dlv).default(theme, parts) !== undefined) break;
25
- }while (parts.length)
26
+ }while (parts.length);
26
27
  return parts.length ? parts : undefined;
27
28
  }
28
29
  function pathToString(path) {
29
- if (typeof path === 'string') return path;
30
+ if (typeof path === "string") return path;
30
31
  return path.reduce((acc, cur, i)=>{
31
- if (cur.includes('.')) return `${acc}[${cur}]`;
32
+ if (cur.includes(".")) return `${acc}[${cur}]`;
32
33
  return i === 0 ? cur : `${acc}.${cur}`;
33
- }, '');
34
+ }, "");
34
35
  }
35
36
  function list(items) {
36
37
  return items.map((key)=>`'${key}'`
37
- ).join(', ');
38
+ ).join(", ");
38
39
  }
39
40
  function listKeys(obj) {
40
41
  return list(Object.keys(obj));
41
42
  }
42
43
  function validatePath(config, path, defaultValue) {
43
- const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
44
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
44
45
  const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
45
- const value = (0, _dlv).default(config.theme, pathString, defaultValue);
46
+ const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
46
47
  if (value === undefined) {
47
48
  let error = `'${pathString}' does not exist in your theme config.`;
48
49
  const parentSegments = pathSegments.slice(0, -1);
@@ -80,7 +81,7 @@ function validatePath(config, path, defaultValue) {
80
81
  error
81
82
  };
82
83
  }
83
- if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
84
+ if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
84
85
  let error = `'${pathString}' was found but does not resolve to a string.`;
85
86
  if (isObject(value)) {
86
87
  let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
@@ -110,21 +111,21 @@ function extractArgs(node, vNodes, functions) {
110
111
  vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
111
112
  );
112
113
  let args = [
113
- ''
114
+ ""
114
115
  ];
115
- for (let vNode of vNodes){
116
- if (vNode.type === 'div' && vNode.value === ',') {
117
- args.push('');
116
+ for (let vNode1 of vNodes){
117
+ if (vNode1.type === "div" && vNode1.value === ",") {
118
+ args.push("");
118
119
  } else {
119
- args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
120
+ args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
120
121
  }
121
122
  }
122
123
  return args;
123
124
  }
124
125
  function resolveVNode(node, vNode, functions) {
125
- if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
126
+ if (vNode.type === "function" && functions[vNode.value] !== undefined) {
126
127
  let args = extractArgs(node, vNode.nodes, functions);
127
- vNode.type = 'word';
128
+ vNode.type = "word";
128
129
  vNode.value = functions[vNode.value](node, ...args);
129
130
  }
130
131
  return vNode;
@@ -135,8 +136,8 @@ function resolveFunctions(node, input, functions) {
135
136
  }).toString();
136
137
  }
137
138
  let nodeTypePropertyMap = {
138
- atrule: 'params',
139
- decl: 'value'
139
+ atrule: "params",
140
+ decl: "value"
140
141
  };
141
142
  function _default({ tailwindConfig: config }) {
142
143
  let functions = {
@@ -148,11 +149,14 @@ function _default({ tailwindConfig: config }) {
148
149
  return value;
149
150
  },
150
151
  screen: (node, screen)=>{
151
- screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
152
- if (config.theme.screens[screen] === undefined) {
152
+ screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
153
+ let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
154
+ let screenDefinition = screens.find(({ name })=>name === screen
155
+ );
156
+ if (!screenDefinition) {
153
157
  throw node.error(`The '${screen}' screen does not exist in your theme.`);
154
158
  }
155
- return (0, _buildMediaQuery).default(config.theme.screens[screen]);
159
+ return (0, _buildMediaQuery).default(screenDefinition);
156
160
  }
157
161
  };
158
162
  return (root)=>{