tailwindcss 0.0.0-insiders.bbafc8e → 0.0.0-insiders.bbf2b1b

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 (128) hide show
  1. package/CHANGELOG.md +163 -8
  2. package/README.md +6 -3
  3. package/colors.d.ts +3 -0
  4. package/defaultConfig.d.ts +3 -0
  5. package/defaultTheme.d.ts +4 -0
  6. package/lib/cli-peer-dependencies.js +20 -7
  7. package/lib/cli.js +314 -247
  8. package/lib/constants.js +27 -20
  9. package/lib/corePluginList.js +6 -3
  10. package/lib/corePlugins.js +1719 -1628
  11. package/lib/css/preflight.css +1 -8
  12. package/lib/featureFlags.js +27 -18
  13. package/lib/index.js +17 -15
  14. package/lib/lib/cacheInvalidation.js +45 -24
  15. package/lib/lib/collapseAdjacentRules.js +14 -9
  16. package/lib/lib/collapseDuplicateDeclarations.js +12 -9
  17. package/lib/lib/defaultExtractor.js +220 -33
  18. package/lib/lib/detectNesting.js +13 -10
  19. package/lib/lib/evaluateTailwindFunctions.js +101 -54
  20. package/lib/lib/expandApplyAtRules.js +254 -209
  21. package/lib/lib/expandTailwindAtRules.js +86 -69
  22. package/lib/lib/generateRules.js +244 -145
  23. package/lib/lib/getModuleDependencies.js +11 -8
  24. package/lib/lib/normalizeTailwindDirectives.js +35 -32
  25. package/lib/lib/partitionApplyAtRules.js +11 -8
  26. package/lib/lib/regex.js +60 -0
  27. package/lib/lib/resolveDefaultsAtRules.js +89 -71
  28. package/lib/lib/setupContextUtils.js +290 -205
  29. package/lib/lib/setupTrackingContext.js +44 -37
  30. package/lib/lib/sharedState.js +22 -16
  31. package/lib/lib/substituteScreenAtRules.js +11 -9
  32. package/lib/postcss-plugins/nesting/README.md +2 -2
  33. package/lib/postcss-plugins/nesting/index.js +8 -6
  34. package/lib/postcss-plugins/nesting/plugin.js +18 -16
  35. package/lib/processTailwindFeatures.js +31 -28
  36. package/lib/public/colors.js +247 -245
  37. package/lib/public/create-plugin.js +6 -4
  38. package/lib/public/default-config.js +7 -5
  39. package/lib/public/default-theme.js +7 -5
  40. package/lib/public/resolve-config.js +8 -5
  41. package/lib/util/bigSign.js +4 -1
  42. package/lib/util/buildMediaQuery.js +7 -5
  43. package/lib/util/cloneDeep.js +7 -6
  44. package/lib/util/cloneNodes.js +10 -3
  45. package/lib/util/color.js +53 -54
  46. package/lib/util/configurePlugins.js +4 -1
  47. package/lib/util/createPlugin.js +6 -5
  48. package/lib/util/createUtilityPlugin.js +9 -7
  49. package/lib/util/dataTypes.js +110 -100
  50. package/lib/util/defaults.js +4 -1
  51. package/lib/util/escapeClassName.js +7 -4
  52. package/lib/util/escapeCommas.js +5 -2
  53. package/lib/util/flattenColorPalette.js +9 -10
  54. package/lib/util/formatVariantSelector.js +100 -85
  55. package/lib/util/getAllConfigs.js +17 -8
  56. package/lib/util/hashConfig.js +6 -3
  57. package/lib/util/isKeyframeRule.js +5 -2
  58. package/lib/util/isPlainObject.js +5 -2
  59. package/lib/util/isValidArbitraryValue.js +21 -13
  60. package/lib/util/log.js +18 -12
  61. package/lib/util/nameClass.js +17 -9
  62. package/lib/util/negateValue.js +8 -6
  63. package/lib/util/normalizeConfig.js +84 -71
  64. package/lib/util/normalizeScreens.js +22 -8
  65. package/lib/util/parseAnimationValue.js +42 -40
  66. package/lib/util/parseBoxShadowValue.js +29 -62
  67. package/lib/util/parseDependency.js +18 -15
  68. package/lib/util/parseObjectStyles.js +10 -7
  69. package/lib/util/pluginUtils.js +47 -31
  70. package/lib/util/prefixSelector.js +7 -4
  71. package/lib/util/removeAlphaVariables.js +29 -0
  72. package/lib/util/resolveConfig.js +88 -84
  73. package/lib/util/resolveConfigPath.js +10 -7
  74. package/lib/util/responsive.js +8 -5
  75. package/lib/util/splitAtTopLevelOnly.js +93 -0
  76. package/lib/util/tap.js +4 -1
  77. package/lib/util/toColorValue.js +5 -2
  78. package/lib/util/toPath.js +20 -4
  79. package/lib/util/transformThemeValue.js +30 -25
  80. package/lib/util/validateConfig.js +24 -0
  81. package/lib/util/withAlphaVariable.js +23 -15
  82. package/package.json +32 -27
  83. package/peers/index.js +8612 -4245
  84. package/plugin.d.ts +11 -0
  85. package/resolveConfig.d.ts +3 -0
  86. package/scripts/generate-types.js +105 -0
  87. package/scripts/type-utils.js +27 -0
  88. package/src/cli-peer-dependencies.js +7 -1
  89. package/src/cli.js +125 -25
  90. package/src/corePluginList.js +1 -1
  91. package/src/corePlugins.js +145 -49
  92. package/src/css/preflight.css +1 -8
  93. package/src/featureFlags.js +2 -2
  94. package/src/lib/collapseAdjacentRules.js +5 -1
  95. package/src/lib/defaultExtractor.js +193 -35
  96. package/src/lib/evaluateTailwindFunctions.js +56 -6
  97. package/src/lib/expandApplyAtRules.js +252 -187
  98. package/src/lib/expandTailwindAtRules.js +4 -4
  99. package/src/lib/generateRules.js +156 -59
  100. package/src/lib/regex.js +74 -0
  101. package/src/lib/resolveDefaultsAtRules.js +53 -36
  102. package/src/lib/setupContextUtils.js +142 -46
  103. package/src/lib/setupTrackingContext.js +5 -1
  104. package/src/postcss-plugins/nesting/README.md +2 -2
  105. package/src/util/cloneNodes.js +5 -1
  106. package/src/util/color.js +25 -21
  107. package/src/util/dataTypes.js +13 -7
  108. package/src/util/formatVariantSelector.js +82 -63
  109. package/src/util/getAllConfigs.js +8 -0
  110. package/src/util/log.js +1 -1
  111. package/src/util/normalizeConfig.js +0 -8
  112. package/src/util/parseBoxShadowValue.js +3 -50
  113. package/src/util/pluginUtils.js +13 -1
  114. package/src/util/removeAlphaVariables.js +24 -0
  115. package/src/util/resolveConfig.js +66 -52
  116. package/src/util/splitAtTopLevelOnly.js +71 -0
  117. package/src/util/toPath.js +1 -1
  118. package/src/util/transformThemeValue.js +4 -2
  119. package/src/util/validateConfig.js +13 -0
  120. package/src/util/withAlphaVariable.js +1 -1
  121. package/stubs/defaultConfig.stub.js +5 -1
  122. package/stubs/simpleConfig.stub.js +1 -0
  123. package/types/config.d.ts +327 -0
  124. package/types/generated/.gitkeep +0 -0
  125. package/types/generated/colors.d.ts +276 -0
  126. package/types/generated/corePluginList.d.ts +1 -0
  127. package/types/generated/default-theme.d.ts +331 -0
  128. package/types/index.d.ts +7 -0
@@ -2,52 +2,72 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = expandTailwindAtRules;
6
- var _quickLru = _interopRequireDefault(require("quick-lru"));
7
- var sharedState = _interopRequireWildcard(require("./sharedState"));
8
- var _generateRules = require("./generateRules");
9
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
10
- var _log = _interopRequireDefault(require("../util/log"));
11
- var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
12
- var _defaultExtractor = require("./defaultExtractor");
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>expandTailwindAtRules
8
+ });
9
+ const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
10
+ const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
11
+ const _generateRules = require("./generateRules");
12
+ const _bigSign = /*#__PURE__*/ _interopRequireDefault(require("../util/bigSign"));
13
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
14
+ const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
15
+ const _defaultExtractor = require("./defaultExtractor");
13
16
  function _interopRequireDefault(obj) {
14
17
  return obj && obj.__esModule ? obj : {
15
18
  default: obj
16
19
  };
17
20
  }
18
- function _interopRequireWildcard(obj) {
19
- if (obj && obj.__esModule) {
21
+ function _getRequireWildcardCache(nodeInterop) {
22
+ if (typeof WeakMap !== "function") return null;
23
+ var cacheBabelInterop = new WeakMap();
24
+ var cacheNodeInterop = new WeakMap();
25
+ return (_getRequireWildcardCache = function(nodeInterop) {
26
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
27
+ })(nodeInterop);
28
+ }
29
+ function _interopRequireWildcard(obj, nodeInterop) {
30
+ if (!nodeInterop && obj && obj.__esModule) {
20
31
  return obj;
21
- } else {
22
- var newObj = {};
23
- if (obj != null) {
24
- for(var key in obj){
25
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
26
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
27
- if (desc.get || desc.set) {
28
- Object.defineProperty(newObj, key, desc);
29
- } else {
30
- newObj[key] = obj[key];
31
- }
32
- }
32
+ }
33
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
34
+ return {
35
+ default: obj
36
+ };
37
+ }
38
+ var cache = _getRequireWildcardCache(nodeInterop);
39
+ if (cache && cache.has(obj)) {
40
+ return cache.get(obj);
41
+ }
42
+ var newObj = {};
43
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
44
+ for(var key in obj){
45
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
46
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
47
+ if (desc && (desc.get || desc.set)) {
48
+ Object.defineProperty(newObj, key, desc);
49
+ } else {
50
+ newObj[key] = obj[key];
33
51
  }
34
52
  }
35
- newObj.default = obj;
36
- return newObj;
37
53
  }
54
+ newObj.default = obj;
55
+ if (cache) {
56
+ cache.set(obj, newObj);
57
+ }
58
+ return newObj;
38
59
  }
39
- let env = sharedState.env;
60
+ let env = _sharedState.env;
40
61
  const builtInExtractors = {
41
62
  DEFAULT: _defaultExtractor.defaultExtractor
42
63
  };
43
64
  const builtInTransformers = {
44
- DEFAULT: (content)=>content
45
- ,
46
- svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
65
+ DEFAULT: (content)=>content,
66
+ svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
47
67
  };
48
- function getExtractor(tailwindConfig, fileExtension) {
49
- let extractors = tailwindConfig.content.extract;
50
- return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
68
+ function getExtractor(context, fileExtension) {
69
+ let extractors = context.tailwindConfig.content.extract;
70
+ return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
51
71
  }
52
72
  function getTransformer(tailwindConfig, fileExtension) {
53
73
  let transformers = tailwindConfig.content.transform;
@@ -63,7 +83,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
63
83
  maxSize: 25000
64
84
  }));
65
85
  }
66
- for (let line of content.split('\n')){
86
+ for (let line of content.split("\n")){
67
87
  line = line.trim();
68
88
  if (seen.has(line)) {
69
89
  continue;
@@ -74,19 +94,17 @@ function getClassCandidates(content, extractor, candidates, seen) {
74
94
  candidates.add(match);
75
95
  }
76
96
  } else {
77
- let extractorMatches = extractor(line).filter((s)=>s !== '!*'
78
- );
97
+ let extractorMatches = extractor(line).filter((s)=>s !== "!*");
79
98
  let lineMatchesSet = new Set(extractorMatches);
80
- for (let match of lineMatchesSet){
81
- candidates.add(match);
99
+ for (let match1 of lineMatchesSet){
100
+ candidates.add(match1);
82
101
  }
83
102
  extractorCache.get(extractor).set(line, lineMatchesSet);
84
103
  }
85
104
  }
86
105
  }
87
106
  function buildStylesheet(rules, context) {
88
- let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
89
- );
107
+ let sortedRules = rules.sort(([a], [z])=>(0, _bigSign.default)(a - z));
90
108
  let returnValue = {
91
109
  base: new Set(),
92
110
  defaults: new Set(),
@@ -144,37 +162,36 @@ function expandTailwindAtRules(context) {
144
162
  // a lot of work and bail early. Also we don't have to register our touch
145
163
  // file as a dependency since the output of this CSS does not depend on
146
164
  // the source of any templates. Think Vue <style> blocks for example.
147
- if (rule.name === 'tailwind') {
165
+ if (rule.name === "tailwind") {
148
166
  if (Object.keys(layerNodes).includes(rule.params)) {
149
167
  layerNodes[rule.params] = rule;
150
168
  }
151
169
  }
152
170
  });
153
- if (Object.values(layerNodes).every((n)=>n === null
154
- )) {
171
+ if (Object.values(layerNodes).every((n)=>n === null)) {
155
172
  return root;
156
173
  }
157
174
  // ---
158
175
  // Find potential rules in changed files
159
176
  let candidates = new Set([
160
- sharedState.NOT_ON_DEMAND
177
+ _sharedState.NOT_ON_DEMAND
161
178
  ]);
162
179
  let seen = new Set();
163
- env.DEBUG && console.time('Reading changed files');
180
+ env.DEBUG && console.time("Reading changed files");
164
181
  for (let { content , extension } of context.changedContent){
165
182
  let transformer = getTransformer(context.tailwindConfig, extension);
166
- let extractor = getExtractor(context.tailwindConfig, extension);
183
+ let extractor = getExtractor(context, extension);
167
184
  getClassCandidates(transformer(content), extractor, candidates, seen);
168
185
  }
169
- env.DEBUG && console.timeEnd('Reading changed files');
186
+ env.DEBUG && console.timeEnd("Reading changed files");
170
187
  // ---
171
188
  // Generate the actual CSS
172
189
  let classCacheCount = context.classCache.size;
173
- env.DEBUG && console.time('Generate rules');
174
- let rules = (0, _generateRules).generateRules(candidates, context);
175
- env.DEBUG && console.timeEnd('Generate rules');
190
+ env.DEBUG && console.time("Generate rules");
191
+ let rules = (0, _generateRules.generateRules)(candidates, context);
192
+ env.DEBUG && console.timeEnd("Generate rules");
176
193
  // We only ever add to the classCache, so if it didn't grow, there is nothing new.
177
- env.DEBUG && console.time('Build stylesheet');
194
+ env.DEBUG && console.time("Build stylesheet");
178
195
  if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
179
196
  for (let rule of rules){
180
197
  context.ruleCache.add(rule);
@@ -183,32 +200,32 @@ function expandTailwindAtRules(context) {
183
200
  ...context.ruleCache
184
201
  ], context);
185
202
  }
186
- env.DEBUG && console.timeEnd('Build stylesheet');
203
+ env.DEBUG && console.timeEnd("Build stylesheet");
187
204
  let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
188
205
  // ---
189
206
  // Replace any Tailwind directives with generated CSS
190
207
  if (layerNodes.base) {
191
- layerNodes.base.before((0, _cloneNodes).default([
208
+ layerNodes.base.before((0, _cloneNodes.default)([
192
209
  ...baseNodes,
193
210
  ...defaultNodes
194
211
  ], layerNodes.base.source, {
195
- layer: 'base'
212
+ layer: "base"
196
213
  }));
197
214
  layerNodes.base.remove();
198
215
  }
199
216
  if (layerNodes.components) {
200
- layerNodes.components.before((0, _cloneNodes).default([
217
+ layerNodes.components.before((0, _cloneNodes.default)([
201
218
  ...componentNodes
202
219
  ], layerNodes.components.source, {
203
- layer: 'components'
220
+ layer: "components"
204
221
  }));
205
222
  layerNodes.components.remove();
206
223
  }
207
224
  if (layerNodes.utilities) {
208
- layerNodes.utilities.before((0, _cloneNodes).default([
225
+ layerNodes.utilities.before((0, _cloneNodes.default)([
209
226
  ...utilityNodes
210
227
  ], layerNodes.utilities.source, {
211
- layer: 'utilities'
228
+ layer: "utilities"
212
229
  }));
213
230
  layerNodes.utilities.remove();
214
231
  }
@@ -216,44 +233,44 @@ function expandTailwindAtRules(context) {
216
233
  const variantNodes = Array.from(screenNodes).filter((node)=>{
217
234
  var ref;
218
235
  const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
219
- if (parentLayer === 'components') {
236
+ if (parentLayer === "components") {
220
237
  return layerNodes.components !== null;
221
238
  }
222
- if (parentLayer === 'utilities') {
239
+ if (parentLayer === "utilities") {
223
240
  return layerNodes.utilities !== null;
224
241
  }
225
242
  return true;
226
243
  });
227
244
  if (layerNodes.variants) {
228
- layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source, {
229
- layer: 'variants'
245
+ layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
246
+ layer: "variants"
230
247
  }));
231
248
  layerNodes.variants.remove();
232
249
  } else if (variantNodes.length > 0) {
233
- root.append((0, _cloneNodes).default(variantNodes, root.source, {
234
- layer: 'variants'
250
+ root.append((0, _cloneNodes.default)(variantNodes, root.source, {
251
+ layer: "variants"
235
252
  }));
236
253
  }
237
254
  // If we've got a utility layer and no utilities are generated there's likely something wrong
238
255
  const hasUtilityVariants = variantNodes.some((node)=>{
239
256
  var ref;
240
- return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === 'utilities';
257
+ return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
241
258
  });
242
259
  if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
243
- _log.default.warn('content-problems', [
244
- 'No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.',
245
- 'https://tailwindcss.com/docs/content-configuration',
260
+ _log.default.warn("content-problems", [
261
+ "No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
262
+ "https://tailwindcss.com/docs/content-configuration",
246
263
  ]);
247
264
  }
248
265
  // ---
249
266
  if (env.DEBUG) {
250
- console.log('Potential classes: ', candidates.size);
251
- console.log('Active contexts: ', sharedState.contextSourcesMap.size);
267
+ console.log("Potential classes: ", candidates.size);
268
+ console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
252
269
  }
253
270
  // Clear the cache for the changed files
254
271
  context.changedContent = [];
255
272
  // Cleanup any leftover @layer atrules
256
- root.walkAtRules('layer', (rule)=>{
273
+ root.walkAtRules("layer", (rule)=>{
257
274
  if (Object.keys(layerNodes).includes(rule.params)) {
258
275
  rule.remove();
259
276
  }