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,120 +1,111 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = expandApplyAtRules;
7
-
8
6
  var _postcss = _interopRequireDefault(require("postcss"));
9
-
10
7
  var _generateRules = require("./generateRules");
11
-
12
8
  var _bigSign = _interopRequireDefault(require("../util/bigSign"));
13
-
14
9
  var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function prefix(context, selector) {
19
- let prefix = context.tailwindConfig.prefix;
20
- return typeof prefix === 'function' ? prefix(selector) : prefix + selector;
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ function prefix1(context, selector) {
16
+ let prefix = context.tailwindConfig.prefix;
17
+ return typeof prefix === 'function' ? prefix(selector) : prefix + selector;
21
18
  }
22
-
23
19
  function buildApplyCache(applyCandidates, context) {
24
- for (let candidate of applyCandidates) {
25
- if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
26
- continue;
27
- }
28
-
29
- if (context.classCache.has(candidate)) {
30
- context.applyClassCache.set(candidate, context.classCache.get(candidate).map(([meta, rule]) => [meta, rule.clone()]));
31
- continue;
32
- }
33
-
34
- let matches = Array.from((0, _generateRules.resolveMatches)(candidate, context));
35
-
36
- if (matches.length === 0) {
37
- context.notClassCache.add(candidate);
38
- continue;
20
+ for (let candidate of applyCandidates){
21
+ if (context.notClassCache.has(candidate) || context.applyClassCache.has(candidate)) {
22
+ continue;
23
+ }
24
+ if (context.classCache.has(candidate)) {
25
+ context.applyClassCache.set(candidate, context.classCache.get(candidate).map(([meta, rule])=>[
26
+ meta,
27
+ rule.clone()
28
+ ]
29
+ ));
30
+ continue;
31
+ }
32
+ let matches = Array.from((0, _generateRules).resolveMatches(candidate, context));
33
+ if (matches.length === 0) {
34
+ context.notClassCache.add(candidate);
35
+ continue;
36
+ }
37
+ context.applyClassCache.set(candidate, matches);
39
38
  }
40
-
41
- context.applyClassCache.set(candidate, matches);
42
- }
43
-
44
- return context.applyClassCache;
39
+ return context.applyClassCache;
45
40
  }
46
-
47
41
  function extractApplyCandidates(params) {
48
- let candidates = params.split(/[\s\t\n]+/g);
49
-
50
- if (candidates[candidates.length - 1] === '!important') {
51
- return [candidates.slice(0, -1), true];
52
- }
53
-
54
- return [candidates, false];
42
+ let candidates = params.split(/[\s\t\n]+/g);
43
+ if (candidates[candidates.length - 1] === '!important') {
44
+ return [
45
+ candidates.slice(0, -1),
46
+ true
47
+ ];
48
+ }
49
+ return [
50
+ candidates,
51
+ false
52
+ ];
55
53
  }
56
-
57
54
  function partitionApplyParents(root) {
58
- let applyParents = new Set();
59
- root.walkAtRules('apply', rule => {
60
- applyParents.add(rule.parent);
61
- });
62
-
63
- for (let rule of applyParents) {
64
- let nodeGroups = [];
65
- let lastGroup = [];
66
-
67
- for (let node of rule.nodes) {
68
- if (node.type === 'atrule' && node.name === 'apply') {
55
+ let applyParents = new Set();
56
+ root.walkAtRules('apply', (rule)=>{
57
+ applyParents.add(rule.parent);
58
+ });
59
+ for (let rule1 of applyParents){
60
+ let nodeGroups = [];
61
+ let lastGroup = [];
62
+ for (let node of rule1.nodes){
63
+ if (node.type === 'atrule' && node.name === 'apply') {
64
+ if (lastGroup.length > 0) {
65
+ nodeGroups.push(lastGroup);
66
+ lastGroup = [];
67
+ }
68
+ nodeGroups.push([
69
+ node
70
+ ]);
71
+ } else {
72
+ lastGroup.push(node);
73
+ }
74
+ }
69
75
  if (lastGroup.length > 0) {
70
- nodeGroups.push(lastGroup);
71
- lastGroup = [];
76
+ nodeGroups.push(lastGroup);
72
77
  }
73
-
74
- nodeGroups.push([node]);
75
- } else {
76
- lastGroup.push(node);
77
- }
78
- }
79
-
80
- if (lastGroup.length > 0) {
81
- nodeGroups.push(lastGroup);
82
- }
83
-
84
- if (nodeGroups.length === 1) {
85
- continue;
86
- }
87
-
88
- for (let group of [...nodeGroups].reverse()) {
89
- let newParent = rule.clone({
90
- nodes: []
91
- });
92
- newParent.append(group);
93
- rule.after(newParent);
78
+ if (nodeGroups.length === 1) {
79
+ continue;
80
+ }
81
+ for (let group of [
82
+ ...nodeGroups
83
+ ].reverse()){
84
+ let newParent = rule1.clone({
85
+ nodes: []
86
+ });
87
+ newParent.append(group);
88
+ rule1.after(newParent);
89
+ }
90
+ rule1.remove();
94
91
  }
95
-
96
- rule.remove();
97
- }
98
92
  }
99
-
100
93
  function processApply(root, context) {
101
- let applyCandidates = new Set(); // Collect all @apply rules and candidates
102
-
103
- let applies = [];
104
- root.walkAtRules('apply', rule => {
105
- let [candidates] = extractApplyCandidates(rule.params);
106
-
107
- for (let util of candidates) {
108
- applyCandidates.add(util);
109
- }
110
-
111
- applies.push(rule);
112
- }); // Start the @apply process if we have rules with @apply in them
113
-
114
- if (applies.length > 0) {
115
- // Fill up some caches!
116
- let applyClassCache = buildApplyCache(applyCandidates, context);
117
- /**
94
+ let applyCandidates = new Set();
95
+ // Collect all @apply rules and candidates
96
+ let applies = [];
97
+ root.walkAtRules('apply', (rule)=>{
98
+ let [candidates] = extractApplyCandidates(rule.params);
99
+ for (let util of candidates){
100
+ applyCandidates.add(util);
101
+ }
102
+ applies.push(rule);
103
+ });
104
+ // Start the @apply process if we have rules with @apply in them
105
+ if (applies.length > 0) {
106
+ // Fill up some caches!
107
+ let applyClassCache = buildApplyCache(applyCandidates, context);
108
+ /**
118
109
  * When we have an apply like this:
119
110
  *
120
111
  * .abc {
@@ -133,113 +124,105 @@ function processApply(root, context) {
133
124
  * What happens in this function is that we prepend a `.` and escape the candidate.
134
125
  * This will result in `.hover\:font-bold`
135
126
  * Which means that we can replace `.hover\:font-bold` with `.abc` in `.hover\:font-bold:hover` resulting in `.abc:hover`
136
- */
137
- // TODO: Should we use postcss-selector-parser for this instead?
138
-
139
- function replaceSelector(selector, utilitySelectors, candidate) {
140
- let needle = `.${(0, _escapeClassName.default)(candidate)}`;
141
- let utilitySelectorsList = utilitySelectors.split(/\s*,\s*/g);
142
- return selector.split(/\s*,\s*/g).map(s => {
143
- let replaced = [];
144
-
145
- for (let utilitySelector of utilitySelectorsList) {
146
- let replacedSelector = utilitySelector.replace(needle, s);
147
-
148
- if (replacedSelector === utilitySelector) {
149
- continue;
150
- }
151
-
152
- replaced.push(replacedSelector);
127
+ */ // TODO: Should we use postcss-selector-parser for this instead?
128
+ function replaceSelector(selector, utilitySelectors, candidate) {
129
+ let needle = `.${(0, _escapeClassName).default(candidate)}`;
130
+ let utilitySelectorsList = utilitySelectors.split(/\s*,\s*/g);
131
+ return selector.split(/\s*,\s*/g).map((s)=>{
132
+ let replaced = [];
133
+ for (let utilitySelector of utilitySelectorsList){
134
+ let replacedSelector = utilitySelector.replace(needle, s);
135
+ if (replacedSelector === utilitySelector) {
136
+ continue;
137
+ }
138
+ replaced.push(replacedSelector);
139
+ }
140
+ return replaced.join(', ');
141
+ }).join(', ');
153
142
  }
154
-
155
- return replaced.join(', ');
156
- }).join(', ');
157
- }
158
-
159
- let perParentApplies = new Map(); // Collect all apply candidates and their rules
160
-
161
- for (let apply of applies) {
162
- let candidates = perParentApplies.get(apply.parent) || [];
163
- perParentApplies.set(apply.parent, candidates);
164
- let [applyCandidates, important] = extractApplyCandidates(apply.params);
165
-
166
- if (apply.parent.type === 'atrule') {
167
- if (apply.parent.name === 'screen') {
168
- const screenType = apply.parent.params;
169
- throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map(c => `${screenType}:${c}`).join(' ')} instead.`);
143
+ let perParentApplies = new Map();
144
+ // Collect all apply candidates and their rules
145
+ for (let apply of applies){
146
+ let candidates = perParentApplies.get(apply.parent) || [];
147
+ perParentApplies.set(apply.parent, candidates);
148
+ let [applyCandidates, important] = extractApplyCandidates(apply.params);
149
+ if (apply.parent.type === 'atrule') {
150
+ if (apply.parent.name === 'screen') {
151
+ const screenType = apply.parent.params;
152
+ throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map((c)=>`${screenType}:${c}`
153
+ ).join(' ')} instead.`);
154
+ }
155
+ throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
156
+ }
157
+ for (let applyCandidate of applyCandidates){
158
+ if (!applyClassCache.has(applyCandidate)) {
159
+ if (applyCandidate === prefix1(context, 'group')) {
160
+ // TODO: Link to specific documentation page with error code.
161
+ throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
162
+ }
163
+ throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
164
+ }
165
+ let rules = applyClassCache.get(applyCandidate);
166
+ candidates.push([
167
+ applyCandidate,
168
+ important,
169
+ rules
170
+ ]);
171
+ }
170
172
  }
171
-
172
- throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
173
- }
174
-
175
- for (let applyCandidate of applyCandidates) {
176
- if (!applyClassCache.has(applyCandidate)) {
177
- if (applyCandidate === prefix(context, 'group')) {
178
- // TODO: Link to specific documentation page with error code.
179
- throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
180
- }
181
-
182
- throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
173
+ for (const [parent, candidates] of perParentApplies){
174
+ let siblings = [];
175
+ for (let [applyCandidate, important, rules] of candidates){
176
+ for (let [meta, node] of rules){
177
+ let root = _postcss.default.root({
178
+ nodes: [
179
+ node.clone()
180
+ ]
181
+ });
182
+ let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
183
+ if (canRewriteSelector) {
184
+ root.walkRules((rule)=>{
185
+ rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
186
+ rule.walkDecls((d)=>{
187
+ d.important = meta.important || important;
188
+ });
189
+ });
190
+ }
191
+ // Insert it
192
+ siblings.push([
193
+ // Ensure that when we are sorting, that we take the layer order into account
194
+ {
195
+ ...meta,
196
+ sort: meta.sort | context.layerOrder[meta.layer]
197
+ },
198
+ root.nodes[0],
199
+ ]);
200
+ }
201
+ }
202
+ // Inject the rules, sorted, correctly
203
+ let nodes = siblings.sort(([a], [z])=>(0, _bigSign).default(a.sort - z.sort)
204
+ ).map((s)=>s[1]
205
+ );
206
+ // console.log(parent)
207
+ // `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
208
+ parent.after(nodes);
183
209
  }
184
-
185
- let rules = applyClassCache.get(applyCandidate);
186
- candidates.push([applyCandidate, important, rules]);
187
- }
188
- }
189
-
190
- for (const [parent, candidates] of perParentApplies) {
191
- let siblings = [];
192
-
193
- for (let [applyCandidate, important, rules] of candidates) {
194
- for (let [meta, node] of rules) {
195
- let root = _postcss.default.root({
196
- nodes: [node.clone()]
197
- });
198
-
199
- let canRewriteSelector = node.type !== 'atrule' || node.type === 'atrule' && node.name !== 'keyframes';
200
-
201
- if (canRewriteSelector) {
202
- root.walkRules(rule => {
203
- rule.selector = replaceSelector(parent.selector, rule.selector, applyCandidate);
204
- rule.walkDecls(d => {
205
- d.important = meta.important || important;
206
- });
207
- });
208
- } // Insert it
209
-
210
-
211
- siblings.push([// Ensure that when we are sorting, that we take the layer order into account
212
- { ...meta,
213
- sort: meta.sort | context.layerOrder[meta.layer]
214
- }, root.nodes[0]]);
210
+ for (let apply1 of applies){
211
+ // If there are left-over declarations, just remove the @apply
212
+ if (apply1.parent.nodes.length > 1) {
213
+ apply1.remove();
214
+ } else {
215
+ // The node is empty, drop the full node
216
+ apply1.parent.remove();
217
+ }
215
218
  }
216
- } // Inject the rules, sorted, correctly
217
-
218
-
219
- let nodes = siblings.sort(([a], [z]) => (0, _bigSign.default)(a.sort - z.sort)).map(s => s[1]); // console.log(parent)
220
- // `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
221
-
222
- parent.after(nodes);
219
+ // Do it again, in case we have other `@apply` rules
220
+ processApply(root, context);
223
221
  }
224
-
225
- for (let apply of applies) {
226
- // If there are left-over declarations, just remove the @apply
227
- if (apply.parent.nodes.length > 1) {
228
- apply.remove();
229
- } else {
230
- // The node is empty, drop the full node
231
- apply.parent.remove();
232
- }
233
- } // Do it again, in case we have other `@apply` rules
234
-
235
-
236
- processApply(root, context);
237
- }
238
222
  }
239
-
240
223
  function expandApplyAtRules(context) {
241
- return root => {
242
- partitionApplyParents(root);
243
- processApply(root, context);
244
- };
245
- }
224
+ return (root)=>{
225
+ partitionApplyParents(root);
226
+ processApply(root, context);
227
+ };
228
+ }