tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21

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 (120) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/README.md +1 -1
  3. package/colors.js +1 -304
  4. package/defaultConfig.js +1 -4
  5. package/defaultTheme.js +1 -4
  6. package/lib/cli-peer-dependencies.js +4 -9
  7. package/lib/cli.js +646 -705
  8. package/lib/constants.js +15 -15
  9. package/lib/corePluginList.js +174 -4
  10. package/lib/corePlugins.js +3637 -2934
  11. package/lib/css/preflight.css +14 -1
  12. package/lib/featureFlags.js +44 -44
  13. package/lib/index.js +25 -24
  14. package/lib/lib/collapseAdjacentRules.js +33 -35
  15. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  16. package/lib/lib/detectNesting.js +34 -0
  17. package/lib/lib/evaluateTailwindFunctions.js +134 -155
  18. package/lib/lib/expandApplyAtRules.js +183 -200
  19. package/lib/lib/expandTailwindAtRules.js +219 -232
  20. package/lib/lib/generateRules.js +478 -311
  21. package/lib/lib/getModuleDependencies.js +36 -41
  22. package/lib/lib/normalizeTailwindDirectives.js +66 -58
  23. package/lib/lib/resolveDefaultsAtRules.js +110 -90
  24. package/lib/lib/setupContextUtils.js +740 -580
  25. package/lib/lib/setupTrackingContext.js +142 -162
  26. package/lib/lib/setupWatchingContext.js +235 -278
  27. package/lib/lib/sharedState.js +7 -17
  28. package/lib/lib/substituteScreenAtRules.js +22 -26
  29. package/lib/processTailwindFeatures.js +38 -44
  30. package/lib/public/colors.js +329 -0
  31. package/lib/public/create-plugin.js +13 -0
  32. package/lib/public/default-config.js +14 -0
  33. package/lib/public/default-theme.js +14 -0
  34. package/lib/public/resolve-config.js +19 -0
  35. package/lib/util/bigSign.js +3 -5
  36. package/lib/util/buildMediaQuery.js +15 -31
  37. package/lib/util/cloneDeep.js +14 -13
  38. package/lib/util/cloneNodes.js +9 -13
  39. package/lib/util/color.js +69 -59
  40. package/lib/util/configurePlugins.js +13 -14
  41. package/lib/util/createPlugin.js +21 -24
  42. package/lib/util/createUtilityPlugin.js +47 -45
  43. package/lib/util/dataTypes.js +231 -0
  44. package/lib/util/defaults.js +10 -14
  45. package/lib/util/escapeClassName.js +12 -14
  46. package/lib/util/escapeCommas.js +3 -5
  47. package/lib/util/flattenColorPalette.js +14 -10
  48. package/lib/util/formatVariantSelector.js +186 -0
  49. package/lib/util/getAllConfigs.js +23 -16
  50. package/lib/util/hashConfig.js +10 -10
  51. package/lib/util/isKeyframeRule.js +3 -5
  52. package/lib/util/isPlainObject.js +7 -10
  53. package/lib/util/isValidArbitraryValue.js +64 -0
  54. package/lib/util/log.js +39 -30
  55. package/lib/util/nameClass.js +23 -23
  56. package/lib/util/negateValue.js +14 -15
  57. package/lib/util/normalizeConfig.js +208 -0
  58. package/lib/util/normalizeScreens.js +58 -0
  59. package/lib/util/parseAnimationValue.js +82 -53
  60. package/lib/util/parseBoxShadowValue.js +77 -0
  61. package/lib/util/parseDependency.js +49 -60
  62. package/lib/util/parseObjectStyles.js +23 -20
  63. package/lib/util/pluginUtils.js +153 -285
  64. package/lib/util/prefixSelector.js +14 -16
  65. package/lib/util/resolveConfig.js +194 -249
  66. package/lib/util/resolveConfigPath.js +38 -45
  67. package/lib/util/responsive.js +12 -11
  68. package/lib/util/tap.js +4 -6
  69. package/lib/util/toColorValue.js +4 -5
  70. package/lib/util/toPath.js +4 -6
  71. package/lib/util/transformThemeValue.js +57 -26
  72. package/lib/util/withAlphaVariable.js +56 -54
  73. package/package.json +27 -37
  74. package/peers/index.js +73099 -84294
  75. package/plugin.js +1 -3
  76. package/resolveConfig.js +1 -7
  77. package/scripts/create-plugin-list.js +2 -2
  78. package/src/cli.js +27 -18
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +2124 -1968
  81. package/src/css/preflight.css +14 -1
  82. package/src/featureFlags.js +12 -6
  83. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  84. package/src/lib/detectNesting.js +39 -0
  85. package/src/lib/evaluateTailwindFunctions.js +5 -2
  86. package/src/lib/expandTailwindAtRules.js +24 -32
  87. package/src/lib/generateRules.js +230 -20
  88. package/src/lib/normalizeTailwindDirectives.js +3 -2
  89. package/src/lib/resolveDefaultsAtRules.js +46 -30
  90. package/src/lib/setupContextUtils.js +275 -113
  91. package/src/lib/setupTrackingContext.js +9 -8
  92. package/src/lib/setupWatchingContext.js +12 -7
  93. package/src/lib/sharedState.js +1 -4
  94. package/src/lib/substituteScreenAtRules.js +6 -3
  95. package/src/processTailwindFeatures.js +8 -1
  96. package/src/public/colors.js +300 -0
  97. package/src/public/create-plugin.js +2 -0
  98. package/src/public/default-config.js +4 -0
  99. package/src/public/default-theme.js +4 -0
  100. package/src/public/resolve-config.js +7 -0
  101. package/src/util/buildMediaQuery.js +14 -18
  102. package/src/util/createUtilityPlugin.js +2 -11
  103. package/src/util/dataTypes.js +246 -0
  104. package/src/util/formatVariantSelector.js +196 -0
  105. package/src/util/isValidArbitraryValue.js +61 -0
  106. package/src/util/log.js +18 -21
  107. package/src/util/nameClass.js +10 -6
  108. package/src/util/negateValue.js +4 -2
  109. package/src/util/normalizeConfig.js +249 -0
  110. package/src/util/normalizeScreens.js +42 -0
  111. package/src/util/parseAnimationValue.js +7 -1
  112. package/src/util/parseBoxShadowValue.js +71 -0
  113. package/src/util/parseDependency.js +4 -0
  114. package/src/util/pluginUtils.js +101 -204
  115. package/src/util/prefixSelector.js +1 -4
  116. package/src/util/resolveConfig.js +12 -65
  117. package/src/util/transformThemeValue.js +22 -7
  118. package/src/util/withAlphaVariable.js +13 -8
  119. package/stubs/defaultConfig.stub.js +163 -97
  120. package/stubs/simpleConfig.stub.js +0 -1
@@ -1,53 +1,48 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = getModuleDependencies;
7
-
8
6
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
7
  var _path = _interopRequireDefault(require("path"));
11
-
12
8
  var _resolve = _interopRequireDefault(require("resolve"));
13
-
14
9
  var _detective = _interopRequireDefault(require("detective"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
18
15
  function createModule(file) {
19
- const source = _fs.default.readFileSync(file, 'utf-8');
20
-
21
- const requires = (0, _detective.default)(source);
22
- return {
23
- file,
24
- requires
25
- };
16
+ const source = _fs.default.readFileSync(file, 'utf-8');
17
+ const requires = (0, _detective).default(source);
18
+ return {
19
+ file,
20
+ requires
21
+ };
26
22
  }
27
-
28
23
  function getModuleDependencies(entryFile) {
29
- const rootModule = createModule(entryFile);
30
- const modules = [rootModule]; // Iterate over the modules, even when new
31
- // ones are being added
32
-
33
- for (const mdl of modules) {
34
- mdl.requires.filter(dep => {
35
- // Only track local modules, not node_modules
36
- return dep.startsWith('./') || dep.startsWith('../');
37
- }).forEach(dep => {
38
- try {
39
- const basedir = _path.default.dirname(mdl.file);
40
-
41
- const depPath = _resolve.default.sync(dep, {
42
- basedir
24
+ const rootModule = createModule(entryFile);
25
+ const modules = [
26
+ rootModule
27
+ ];
28
+ // Iterate over the modules, even when new
29
+ // ones are being added
30
+ for (const mdl of modules){
31
+ mdl.requires.filter((dep)=>{
32
+ // Only track local modules, not node_modules
33
+ return dep.startsWith('./') || dep.startsWith('../');
34
+ }).forEach((dep)=>{
35
+ try {
36
+ const basedir = _path.default.dirname(mdl.file);
37
+ const depPath = _resolve.default.sync(dep, {
38
+ basedir
39
+ });
40
+ const depModule = createModule(depPath);
41
+ modules.push(depModule);
42
+ } catch (_err) {
43
+ // eslint-disable-next-line no-empty
44
+ }
43
45
  });
44
-
45
- const depModule = createModule(depPath);
46
- modules.push(depModule);
47
- } catch (_err) {// eslint-disable-next-line no-empty
48
- }
49
- });
50
- }
51
-
52
- return modules;
53
- }
46
+ }
47
+ return modules;
48
+ }
@@ -1,68 +1,76 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = normalizeTailwindDirectives;
7
-
8
6
  var _log = _interopRequireDefault(require("../util/log"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
7
+ function _interopRequireDefault(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
12
  function normalizeTailwindDirectives(root) {
13
- let tailwindDirectives = new Set();
14
- let layerDirectives = new Set();
15
- root.walkAtRules(atRule => {
16
- if (atRule.name === 'import') {
17
- if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
18
- atRule.name = 'tailwind';
19
- atRule.params = 'base';
20
- } else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
21
- atRule.name = 'tailwind';
22
- atRule.params = 'components';
23
- } else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
24
- atRule.name = 'tailwind';
25
- atRule.params = 'utilities';
26
- } else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
27
- atRule.name = 'tailwind';
28
- atRule.params = 'variants';
29
- }
30
- }
31
-
32
- if (atRule.name === 'tailwind') {
33
- if (atRule.params === 'screens') {
34
- atRule.params = 'variants';
35
- }
36
-
37
- tailwindDirectives.add(atRule.params);
38
- }
39
-
40
- if (['layer', 'responsive', 'variants'].includes(atRule.name)) {
41
- if (['responsive', 'variants'].includes(atRule.name)) {
42
- _log.default.warn([`'@${atRule.name}' is deprecated, use '@layer utilities' or '@layer components' instead.`]);
43
- }
44
-
45
- layerDirectives.add(atRule);
46
- }
47
- });
48
-
49
- if (!tailwindDirectives.has('base') || !tailwindDirectives.has('components') || !tailwindDirectives.has('utilities')) {
50
- for (let rule of layerDirectives) {
51
- if (rule.name === 'layer' && ['base', 'components', 'utilities'].includes(rule.params)) {
52
- if (!tailwindDirectives.has(rule.params)) {
53
- throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
13
+ let tailwindDirectives = new Set();
14
+ let layerDirectives = new Set();
15
+ root.walkAtRules((atRule)=>{
16
+ if (atRule.name === 'import') {
17
+ if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
18
+ atRule.name = 'tailwind';
19
+ atRule.params = 'base';
20
+ } else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
21
+ atRule.name = 'tailwind';
22
+ atRule.params = 'components';
23
+ } else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
24
+ atRule.name = 'tailwind';
25
+ atRule.params = 'utilities';
26
+ } else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
27
+ atRule.name = 'tailwind';
28
+ atRule.params = 'variants';
29
+ }
30
+ }
31
+ if (atRule.name === 'tailwind') {
32
+ if (atRule.params === 'screens') {
33
+ atRule.params = 'variants';
34
+ }
35
+ tailwindDirectives.add(atRule.params);
54
36
  }
55
- } else if (rule.name === 'responsive') {
56
- if (!tailwindDirectives.has('utilities')) {
57
- throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.');
37
+ if ([
38
+ 'layer',
39
+ 'responsive',
40
+ 'variants'
41
+ ].includes(atRule.name)) {
42
+ if ([
43
+ 'responsive',
44
+ 'variants'
45
+ ].includes(atRule.name)) {
46
+ _log.default.warn(`${atRule.name}-at-rule-deprecated`, [
47
+ `The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
48
+ `Use \`@layer utilities\` or \`@layer components\` instead.`,
49
+ ]);
50
+ }
51
+ layerDirectives.add(atRule);
58
52
  }
59
- } else if (rule.name === 'variants') {
60
- if (!tailwindDirectives.has('utilities')) {
61
- throw rule.error('`@variants` is used but `@tailwind utilities` is missing.');
53
+ });
54
+ if (!tailwindDirectives.has('base') || !tailwindDirectives.has('components') || !tailwindDirectives.has('utilities')) {
55
+ for (let rule of layerDirectives){
56
+ if (rule.name === 'layer' && [
57
+ 'base',
58
+ 'components',
59
+ 'utilities'
60
+ ].includes(rule.params)) {
61
+ if (!tailwindDirectives.has(rule.params)) {
62
+ throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
63
+ }
64
+ } else if (rule.name === 'responsive') {
65
+ if (!tailwindDirectives.has('utilities')) {
66
+ throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.');
67
+ }
68
+ } else if (rule.name === 'variants') {
69
+ if (!tailwindDirectives.has('utilities')) {
70
+ throw rule.error('`@variants` is used but `@tailwind utilities` is missing.');
71
+ }
72
+ }
62
73
  }
63
- }
64
74
  }
65
- }
66
-
67
- return tailwindDirectives;
68
- }
75
+ return tailwindDirectives;
76
+ }
@@ -1,105 +1,125 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = resolveDefaultsAtRules;
7
-
6
+ exports.elementSelectorParser = void 0;
8
7
  var _postcss = _interopRequireDefault(require("postcss"));
9
-
10
8
  var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
11
-
12
9
  var _featureFlags = require("../featureFlags");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ let getNode = {
16
+ id (node) {
17
+ return _postcssSelectorParser.default.attribute({
18
+ attribute: 'id',
19
+ operator: '=',
20
+ value: node.value,
21
+ quoteMark: '"'
22
+ });
23
+ }
24
+ };
16
25
  function minimumImpactSelector(nodes) {
17
- let pseudos = nodes.filter(n => n.type === 'pseudo');
18
- let [bestNode] = nodes;
19
-
20
- for (let [type, getNode = n => n] of [['class'], ['id', n => _postcssSelectorParser.default.attribute({
21
- attribute: 'id',
22
- operator: '=',
23
- value: n.value,
24
- quoteMark: '"'
25
- })], ['attribute']]) {
26
- let match = nodes.find(n => n.type === type);
27
-
28
- if (match) {
29
- bestNode = getNode(match);
30
- break;
26
+ let rest = nodes.filter((node)=>{
27
+ // Keep non-pseudo nodes
28
+ if (node.type !== 'pseudo') return true;
29
+ // Keep pseudo nodes that have subnodes
30
+ // E.g.: `:not()` contains subnodes inside the parentheses
31
+ if (node.nodes.length > 0) return true;
32
+ // Keep pseudo `elements`
33
+ // This implicitly means that we ignore pseudo `classes`
34
+ return node.value.startsWith('::') || [
35
+ ':before',
36
+ ':after',
37
+ ':first-line',
38
+ ':first-letter'
39
+ ].includes(node.value);
40
+ }).reverse();
41
+ let searchFor = new Set([
42
+ 'tag',
43
+ 'class',
44
+ 'id',
45
+ 'attribute'
46
+ ]);
47
+ let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type)
48
+ );
49
+ if (splitPointIdx === -1) return rest.reverse().join('').trim();
50
+ let node1 = rest[splitPointIdx];
51
+ let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
52
+ rest = rest.slice(0, splitPointIdx);
53
+ let combinatorIdx = rest.findIndex((n)=>n.type === 'combinator' && n.value === '>'
54
+ );
55
+ if (combinatorIdx !== -1) {
56
+ rest.splice(0, combinatorIdx);
57
+ rest.unshift(_postcssSelectorParser.default.universal());
31
58
  }
32
- }
33
-
34
- return [bestNode, ...pseudos].join('').trim();
59
+ return [
60
+ bestNode,
61
+ ...rest.reverse()
62
+ ].join('').trim();
35
63
  }
36
-
37
- let elementSelectorParser = (0, _postcssSelectorParser.default)(selectors => {
38
- return selectors.map(s => {
39
- let nodes = s.split(n => n.type === 'combinator').pop().filter(n => n.type !== 'pseudo' || n.value.startsWith('::'));
40
- return minimumImpactSelector(nodes);
41
- });
64
+ let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
65
+ return selectors.map((s)=>{
66
+ let nodes = s.split((n)=>n.type === 'combinator' && n.value === ' '
67
+ ).pop();
68
+ return minimumImpactSelector(nodes);
69
+ });
42
70
  });
71
+ exports.elementSelectorParser = elementSelectorParser;
43
72
  let cache = new Map();
44
-
45
73
  function extractElementSelector(selector) {
46
- if (!cache.has(selector)) {
47
- cache.set(selector, elementSelectorParser.transformSync(selector));
48
- }
49
-
50
- return cache.get(selector);
74
+ if (!cache.has(selector)) {
75
+ cache.set(selector, elementSelectorParser.transformSync(selector));
76
+ }
77
+ return cache.get(selector);
51
78
  }
52
-
53
- function resolveDefaultsAtRules({
54
- tailwindConfig
55
- }) {
56
- return root => {
57
- let variableNodeMap = new Map();
58
- let universals = new Set();
59
- root.walkAtRules('defaults', rule => {
60
- if (rule.nodes && rule.nodes.length > 0) {
61
- universals.add(rule);
62
- return;
63
- }
64
-
65
- let variable = rule.params;
66
-
67
- if (!variableNodeMap.has(variable)) {
68
- variableNodeMap.set(variable, new Set());
69
- }
70
-
71
- variableNodeMap.get(variable).add(rule.parent);
72
- rule.remove();
73
- });
74
-
75
- for (let universal of universals) {
76
- var _variableNodeMap$get;
77
-
78
- let selectors = new Set();
79
- let rules = (_variableNodeMap$get = variableNodeMap.get(universal.params)) !== null && _variableNodeMap$get !== void 0 ? _variableNodeMap$get : [];
80
-
81
- for (let rule of rules) {
82
- for (let selector of extractElementSelector(rule.selector)) {
83
- selectors.add(selector);
79
+ function resolveDefaultsAtRules({ tailwindConfig }) {
80
+ return (root)=>{
81
+ let variableNodeMap = new Map();
82
+ let universals = new Set();
83
+ root.walkAtRules('defaults', (rule)=>{
84
+ if (rule.nodes && rule.nodes.length > 0) {
85
+ universals.add(rule);
86
+ return;
87
+ }
88
+ let variable = rule.params;
89
+ if (!variableNodeMap.has(variable)) {
90
+ variableNodeMap.set(variable, new Set());
91
+ }
92
+ variableNodeMap.get(variable).add(rule.parent);
93
+ rule.remove();
94
+ });
95
+ for (let universal of universals){
96
+ let selectors = new Set();
97
+ var ref;
98
+ let rules = (ref = variableNodeMap.get(universal.params)) !== null && ref !== void 0 ? ref : [];
99
+ for (let rule of rules){
100
+ for (let selector of extractElementSelector(rule.selector)){
101
+ selectors.add(selector);
102
+ }
103
+ }
104
+ if (selectors.size === 0) {
105
+ universal.remove();
106
+ continue;
107
+ }
108
+ let universalRule = _postcss.default.rule();
109
+ if ((0, _featureFlags).flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
110
+ universalRule.selectors = [
111
+ ...selectors
112
+ ];
113
+ } else {
114
+ universalRule.selectors = [
115
+ '*',
116
+ '::before',
117
+ '::after'
118
+ ];
119
+ }
120
+ universalRule.append(universal.nodes);
121
+ universal.before(universalRule);
122
+ universal.remove();
84
123
  }
85
- }
86
-
87
- if (selectors.size === 0) {
88
- universal.remove();
89
- continue;
90
- }
91
-
92
- let universalRule = _postcss.default.rule();
93
-
94
- if ((0, _featureFlags.flagEnabled)(tailwindConfig, 'optimizeUniversalDefaults')) {
95
- universalRule.selectors = [...selectors];
96
- } else {
97
- universalRule.selectors = ['*', '::before', '::after'];
98
- }
99
-
100
- universalRule.append(universal.nodes);
101
- universal.before(universalRule);
102
- universal.remove();
103
- }
104
- };
105
- }
124
+ };
125
+ }