tailwindcss 0.0.0-insiders.67bf816 → 0.0.0-insiders.67d2286

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.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
  - Require matching prefix when detecting negatives ([#8121](https://github.com/tailwindlabs/tailwindcss/pull/8121))
15
15
  - Handle duplicate At Rules without children ([#8122](https://github.com/tailwindlabs/tailwindcss/pull/8122))
16
16
  - Allow arbitrary values with commas in `@apply` ([#8125](https://github.com/tailwindlabs/tailwindcss/pull/8125))
17
+ - Fix intellisense for plugins with multiple `@apply` rules ([#8213](https://github.com/tailwindlabs/tailwindcss/pull/8213))
18
+ - Improve type detection for arbitrary color values ([#8201](https://github.com/tailwindlabs/tailwindcss/pull/8201))
19
+ - Support PostCSS config options in config file in CLI ([#8226](https://github.com/tailwindlabs/tailwindcss/pull/8226))
20
+ - Remove default `[hidden]` style in preflight ([#8248](https://github.com/tailwindlabs/tailwindcss/pull/8248))
21
+ - Only check selectors containing base apply candidates for circular dependencies ([#8222](https://github.com/tailwindlabs/tailwindcss/pull/8222))
22
+ - Rewrite default class extractor ([#8204](https://github.com/tailwindlabs/tailwindcss/pull/8204))
23
+
24
+ ### Changed
25
+
26
+ - Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
17
27
 
18
28
  ### Added
19
29
 
@@ -27,8 +37,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
37
  - Add `enabled` variant ([#7905](https://github.com/tailwindlabs/tailwindcss/pull/7905))
28
38
  - Add TypeScript types for the `tailwind.config.js` file ([#7891](https://github.com/tailwindlabs/tailwindcss/pull/7891))
29
39
  - Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924))
40
+ - Add `grid-flow-dense` utility ([#8193](https://github.com/tailwindlabs/tailwindcss/pull/8193))
30
41
 
31
- ## [3.0.24] - 2022-05-12
42
+ ## [3.0.24] - 2022-04-12
32
43
 
33
44
  ### Fixed
34
45
 
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ exports.lazyPostcss = lazyPostcss;
5
6
  exports.lazyAutoprefixer = lazyAutoprefixer;
6
7
  exports.lazyCssnano = lazyCssnano;
7
- exports.postcss = void 0;
8
- let postcss = require("postcss");
9
- exports.postcss = postcss;
8
+ function lazyPostcss() {
9
+ return require("postcss");
10
+ }
10
11
  function lazyAutoprefixer() {
11
12
  return require("autoprefixer");
12
13
  }
package/lib/cli.js CHANGED
@@ -9,6 +9,8 @@ var _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config"));
9
9
  var _lilconfig = require("lilconfig");
10
10
  var _plugins // Little bit scary, looking at private/internal API
11
11
  = _interopRequireDefault(require("postcss-load-config/src/plugins"));
12
+ var _options // Little bit scary, looking at private/internal API
13
+ = _interopRequireDefault(require("postcss-load-config/src/options"));
12
14
  var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
13
15
  var _resolveConfig = _interopRequireDefault(require("../resolveConfig"));
14
16
  var _fastGlob = _interopRequireDefault(require("fast-glob"));
@@ -128,6 +130,13 @@ function oneOf(...options) {
128
130
  manualParsing: true
129
131
  });
130
132
  }
133
+ function loadPostcss() {
134
+ // Try to load a local `postcss` version first
135
+ try {
136
+ return require("postcss");
137
+ } catch {}
138
+ return (0, _indexJs).lazyPostcss();
139
+ }
131
140
  let commands = {
132
141
  init: {
133
142
  run: init,
@@ -384,7 +393,7 @@ async function build() {
384
393
  )(_path.default.resolve("./tailwind.config.js"));
385
394
  async function loadPostCssPlugins() {
386
395
  let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
387
- let { plugins: configPlugins } = customPostCssPath ? await (async ()=>{
396
+ let config1 = customPostCssPath ? await (async ()=>{
388
397
  let file = _path.default.resolve(customPostCssPath);
389
398
  // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
390
399
  let { config ={} } = await (0, _lilconfig).lilconfig("postcss").load(file);
@@ -397,9 +406,12 @@ async function build() {
397
406
  config.plugins = [];
398
407
  }
399
408
  return {
400
- plugins: (0, _plugins).default(config, file)
409
+ file,
410
+ plugins: (0, _plugins).default(config, file),
411
+ options: (0, _options).default(config, file)
401
412
  };
402
413
  })() : await (0, _postcssLoadConfig).default();
414
+ let configPlugins = config1.plugins;
403
415
  let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
404
416
  if (typeof plugin === "function" && plugin.name === "tailwindcss") {
405
417
  return true;
@@ -413,7 +425,8 @@ async function build() {
413
425
  let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
414
426
  return [
415
427
  beforePlugins,
416
- afterPlugins
428
+ afterPlugins,
429
+ config1.options
417
430
  ];
418
431
  }
419
432
  function resolveConfig() {
@@ -489,9 +502,10 @@ async function build() {
489
502
  };
490
503
  };
491
504
  tailwindPlugin.postcss = true;
492
- let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
505
+ let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins() : [
493
506
  [],
494
- []
507
+ [],
508
+ {}
495
509
  ];
496
510
  let plugins = [
497
511
  ...beforePlugins,
@@ -521,13 +535,15 @@ async function build() {
521
535
  return (0, _indexJs).lazyCssnano()(options);
522
536
  })(),
523
537
  ].filter(Boolean);
524
- let processor = (0, _indexJs).postcss(plugins);
538
+ let postcss = loadPostcss();
539
+ let processor = postcss(plugins);
525
540
  function processCSS(css) {
526
541
  let start = process.hrtime.bigint();
527
542
  return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
528
543
  recursive: true
529
544
  }) : null
530
545
  ).then(()=>processor.process(css, {
546
+ ...postcssOptions,
531
547
  from: input,
532
548
  to: output
533
549
  })
@@ -641,7 +657,8 @@ async function build() {
641
657
  let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
642
658
  let copy = plugins.slice();
643
659
  copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
644
- let processor = (0, _indexJs).postcss(copy);
660
+ let postcss = loadPostcss();
661
+ let processor = postcss(copy);
645
662
  function processCSS(css) {
646
663
  let start = process.hrtime.bigint();
647
664
  return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
@@ -694,13 +711,13 @@ async function build() {
694
711
  env.DEBUG && console.timeEnd("Finished in");
695
712
  return result1;
696
713
  }
697
- let config1 = refreshConfig(configPath);
714
+ let config2 = refreshConfig(configPath);
698
715
  if (input) {
699
716
  contextDependencies.add(_path.default.resolve(input));
700
717
  }
701
718
  watcher = _chokidar.default.watch([
702
719
  ...contextDependencies,
703
- ...extractFileGlobs(config1)
720
+ ...extractFileGlobs(config2)
704
721
  ], {
705
722
  usePolling: shouldPoll,
706
723
  interval: shouldPoll ? pollInterval : undefined,
@@ -715,16 +732,16 @@ async function build() {
715
732
  if (contextDependencies.has(file)) {
716
733
  env.DEBUG && console.time("Resolve config");
717
734
  context = null;
718
- config1 = refreshConfig(configPath);
735
+ config2 = refreshConfig(configPath);
719
736
  env.DEBUG && console.timeEnd("Resolve config");
720
737
  env.DEBUG && console.time("Watch new files");
721
- let globs = extractFileGlobs(config1);
738
+ let globs = extractFileGlobs(config2);
722
739
  watcher.add(configDependencies);
723
740
  watcher.add(globs);
724
741
  env.DEBUG && console.timeEnd("Watch new files");
725
742
  chain = chain.then(async ()=>{
726
- changedContent.push(...getChangedContent(config1));
727
- await rebuild(config1);
743
+ changedContent.push(...getChangedContent(config2));
744
+ await rebuild(config2);
728
745
  });
729
746
  } else {
730
747
  chain = chain.then(async ()=>{
@@ -732,7 +749,7 @@ async function build() {
732
749
  content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
733
750
  extension: _path.default.extname(file).slice(1)
734
751
  });
735
- await rebuild(config1);
752
+ await rebuild(config2);
736
753
  });
737
754
  }
738
755
  });
@@ -742,12 +759,12 @@ async function build() {
742
759
  content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
743
760
  extension: _path.default.extname(file).slice(1)
744
761
  });
745
- await rebuild(config1);
762
+ await rebuild(config2);
746
763
  });
747
764
  });
748
765
  chain = chain.then(()=>{
749
- changedContent.push(...getChangedContent(config1));
750
- return rebuild(config1);
766
+ changedContent.push(...getChangedContent(config2));
767
+ return rebuild(config2);
751
768
  });
752
769
  }
753
770
  if (shouldWatch) {
@@ -1420,6 +1420,9 @@ let corePlugins = {
1420
1420
  ".grid-flow-col": {
1421
1421
  gridAutoFlow: "column"
1422
1422
  },
1423
+ ".grid-flow-dense": {
1424
+ gridAutoFlow: "dense"
1425
+ },
1423
1426
  ".grid-flow-row-dense": {
1424
1427
  gridAutoFlow: "row dense"
1425
1428
  },
@@ -358,11 +358,3 @@ video {
358
358
  max-width: 100%;
359
359
  height: auto;
360
360
  }
361
-
362
- /*
363
- Ensure the default browser behavior of the `hidden` attribute.
364
- */
365
-
366
- [hidden] {
367
- display: none;
368
- }
@@ -3,38 +3,149 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
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;
6
+ var regex = _interopRequireWildcard(require("./regex"));
7
+ function _interopRequireWildcard(obj) {
8
+ if (obj && obj.__esModule) {
9
+ return obj;
10
+ } else {
11
+ var newObj = {};
12
+ if (obj != null) {
13
+ for(var key in obj){
14
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
15
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
16
+ if (desc.get || desc.set) {
17
+ Object.defineProperty(newObj, key, desc);
18
+ } else {
19
+ newObj[key] = obj[key];
20
+ }
21
+ }
22
+ }
23
+ }
24
+ newObj.default = obj;
25
+ return newObj;
26
+ }
27
+ }
28
+ let patterns = Array.from(buildRegExps());
29
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;
30
+ /** @type {(string|string)[]} */ let results = [];
31
+ for (let pattern of patterns){
32
+ var ref;
33
+ results.push(...(ref = content.match(pattern)) !== null && ref !== void 0 ? ref : []);
34
+ }
35
+ return results.filter((v)=>v !== undefined
36
+ ).map(clipAtBalancedParens);
37
+ }
38
+ function* buildRegExps() {
39
+ yield regex.pattern([
40
+ // Variants
41
+ /((?=([^\s"'\\\[]+:))\2)?/,
42
+ // Important (optional)
43
+ /!?/,
44
+ regex.any([
45
+ // Arbitrary properties
46
+ /\[[^\s:'"]+:[^\s\]]+\]/,
47
+ // Utilities
48
+ regex.pattern([
49
+ // Utility Name / Group Name
50
+ /-?(?:\w+)/,
51
+ // Normal/Arbitrary values
52
+ regex.optional(regex.any([
53
+ regex.pattern([
54
+ // Arbitrary values
55
+ /-\[[^\s:]+\]/,
56
+ // Not immediately followed by an `{[(`
57
+ /(?![{([]])/,
58
+ // optionally followed by an opacity modifier
59
+ /(?:\/[^\s'"\\$]*)?/,
60
+ ]),
61
+ regex.pattern([
62
+ // Arbitrary values
63
+ /-\[[^\s]+\]/,
64
+ // Not immediately followed by an `{[(`
65
+ /(?![{([]])/,
66
+ // optionally followed by an opacity modifier
67
+ /(?:\/[^\s'"\\$]*)?/,
68
+ ]),
69
+ // Normal values w/o quotes — may include an opacity modifier
70
+ /[-\/][^\s'"\\$={]*/,
71
+ ])),
72
+ ]),
73
+ ]),
74
+ ]);
75
+ // 5. Inner matches
76
+ // yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g
77
+ }
78
+ // We want to capture any "special" characters
79
+ // AND the characters immediately following them (if there is one)
80
+ let SPECIALS = /([\[\]'"`])([^\[\]'"`])?/g;
81
+ let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
82
+ /**
83
+ * Clips a string ensuring that parentheses, quotes, etc… are balanced
84
+ * Used for arbitrary values only
85
+ *
86
+ * We will go past the end of the balanced parens until we find a non-class character
87
+ *
88
+ * Depth matching behavior:
89
+ * w-[calc(100%-theme('spacing[some_key][1.5]'))]']
90
+ * ┬ ┬ ┬┬ ┬ ┬┬ ┬┬┬┬┬┬┬
91
+ * 1 2 3 4 34 3 210 END
92
+ * ╰────┴──────────┴────────┴────────┴┴───┴─┴┴┴
93
+ *
94
+ * @param {string} input
95
+ */ function clipAtBalancedParens(input) {
96
+ // We are care about this for arbitrary values
97
+ if (!input.includes("-[")) {
98
+ return input;
99
+ }
100
+ let depth = 0;
101
+ let openStringTypes = [];
102
+ // Find all parens, brackets, quotes, etc
103
+ // Stop when we end at a balanced pair
104
+ // This is naive and will treat mismatched parens as balanced
105
+ // This shouldn't be a problem in practice though
106
+ let matches = input.matchAll(SPECIALS);
107
+ // We can't use lookbehind assertions because we have to support Safari
108
+ // So, instead, we've emulated it using capture groups and we'll re-work the matches to accommodate
109
+ matches = Array.from(matches).flatMap((match)=>{
110
+ const [, ...groups] = match;
111
+ return groups.map((group, idx)=>Object.assign([], match, {
112
+ index: match.index + idx,
113
+ 0: group
114
+ })
115
+ );
116
+ });
117
+ for (let match1 of matches){
118
+ let char = match1[0];
119
+ let inStringType = openStringTypes[openStringTypes.length - 1];
120
+ if (char === inStringType) {
121
+ openStringTypes.pop();
122
+ } else if (char === "'" || char === '"' || char === "`") {
123
+ openStringTypes.push(char);
124
+ }
125
+ if (inStringType) {
126
+ continue;
127
+ } else if (char === "[") {
128
+ depth++;
129
+ continue;
130
+ } else if (char === "]") {
131
+ depth--;
132
+ continue;
133
+ }
134
+ // We've gone one character past the point where we should stop
135
+ // This means that there was an extra closing `]`
136
+ // We'll clip to just before it
137
+ if (depth < 0) {
138
+ return input.substring(0, match1.index);
139
+ }
140
+ // We've finished balancing the brackets but there still may be characters that can be included
141
+ // For example in the class `text-[#336699]/[.35]`
142
+ // The depth goes to `0` at the closing `]` but goes up again at the `[`
143
+ // If we're at zero and encounter a non-class character then we clip the class there
144
+ if (depth === 0 && !ALLOWED_CLASS_CHARACTERS.test(char)) {
145
+ return input.substring(0, match1.index);
146
+ }
147
+ }
148
+ return input;
38
149
  } // Regular utilities
39
150
  // {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
40
151
  // Arbitrary values
@@ -22,7 +22,7 @@ function _interopRequireDefault(obj) {
22
22
  };
23
23
  }
24
24
  /** @typedef {Map<string, [any, import('postcss').Rule[]]>} ApplyCache */ function extractClasses(node) {
25
- let classes = new Set();
25
+ /** @type {Map<string, Set<string>>} */ let groups = new Map();
26
26
  let container = _postcss.default.root({
27
27
  nodes: [
28
28
  node.clone()
@@ -31,11 +31,29 @@ function _interopRequireDefault(obj) {
31
31
  container.walkRules((rule)=>{
32
32
  (0, _postcssSelectorParser).default((selectors)=>{
33
33
  selectors.walkClasses((classSelector)=>{
34
+ let parentSelector = classSelector.parent.toString();
35
+ let classes = groups.get(parentSelector);
36
+ if (!classes) {
37
+ groups.set(parentSelector, classes = new Set());
38
+ }
34
39
  classes.add(classSelector.value);
35
40
  });
36
41
  }).processSync(rule.selector);
37
42
  });
38
- return Array.from(classes);
43
+ let normalizedGroups = Array.from(groups.values(), (classes)=>Array.from(classes)
44
+ );
45
+ let classes1 = normalizedGroups.flat();
46
+ return Object.assign(classes1, {
47
+ groups: normalizedGroups
48
+ });
49
+ }
50
+ let selectorExtractor = (0, _postcssSelectorParser).default((root)=>root.nodes.map((node)=>node.toString()
51
+ )
52
+ );
53
+ /**
54
+ * @param {string} ruleSelectors
55
+ */ function extractSelectors(ruleSelectors) {
56
+ return selectorExtractor.transformSync(ruleSelectors);
39
57
  }
40
58
  function extractBaseCandidates(candidates, separator) {
41
59
  let baseClasses = new Set();
@@ -271,8 +289,8 @@ function processApply(root, context, localCache) {
271
289
  needle1.replace(/\\2c /g, "\\,")
272
290
  ])
273
291
  ];
274
- let utilitySelectorsList = utilitySelectors.split(/\s*(?<!\\)\,(?![^(]*\))\s*/g);
275
- return selector.split(/\s*(?<!\\)\,(?![^(]*\))\s*/g).map((s)=>{
292
+ let utilitySelectorsList = extractSelectors(utilitySelectors);
293
+ return extractSelectors(selector).map((s)=>{
276
294
  let replaced = [];
277
295
  for (let utilitySelector of utilitySelectorsList){
278
296
  let replacedSelector = utilitySelector;
@@ -290,7 +308,10 @@ function processApply(root, context, localCache) {
290
308
  let perParentApplies = new Map();
291
309
  // Collect all apply candidates and their rules
292
310
  for (let apply of applies){
293
- let candidates = perParentApplies.get(apply.parent) || [];
311
+ let [candidates] = perParentApplies.get(apply.parent) || [
312
+ [],
313
+ apply.source
314
+ ];
294
315
  perParentApplies.set(apply.parent, [
295
316
  candidates,
296
317
  apply.source
@@ -326,9 +347,20 @@ function processApply(root, context, localCache) {
326
347
  for (const [parent, [candidates1, atApplySource]] of perParentApplies){
327
348
  let siblings = [];
328
349
  for (let [applyCandidate, important, rules] of candidates1){
350
+ let potentialApplyCandidates = [
351
+ applyCandidate,
352
+ ...extractBaseCandidates([
353
+ applyCandidate
354
+ ], context.tailwindConfig.separator),
355
+ ];
329
356
  for (let [meta, node1] of rules){
330
357
  let parentClasses = extractClasses(parent);
331
358
  let nodeClasses = extractClasses(node1);
359
+ // When we encounter a rule like `.dark .a, .b { … }` we only want to be left with `[.dark, .a]` if the base applyCandidate is `.a` or with `[.b]` if the base applyCandidate is `.b`
360
+ // So we've split them into groups
361
+ nodeClasses = nodeClasses.groups.filter((classList)=>classList.some((className)=>potentialApplyCandidates.includes(className)
362
+ )
363
+ ).flat();
332
364
  // Add base utility classes from the @apply node to the list of
333
365
  // classes to check whether it intersects and therefore results in a
334
366
  // circular dependency or not.
@@ -42,7 +42,7 @@ function expandTailwindAtRules(context) {
42
42
  env.DEBUG && console.time("Reading changed files");
43
43
  for (let { content , extension } of context.changedContent){
44
44
  let transformer = getTransformer(context.tailwindConfig, extension);
45
- let extractor = getExtractor(context.tailwindConfig, extension);
45
+ let extractor = getExtractor(context, extension);
46
46
  getClassCandidates(transformer(content), extractor, candidates, seen);
47
47
  }
48
48
  env.DEBUG && console.timeEnd("Reading changed files");
@@ -174,8 +174,8 @@ const builtInTransformers = {
174
174
  ,
175
175
  svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
176
176
  };
177
- function getExtractor(tailwindConfig, fileExtension) {
178
- let extractors = tailwindConfig.content.extract;
177
+ function getExtractor(context, fileExtension) {
178
+ let extractors = context.tailwindConfig.content.extract;
179
179
  return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
180
180
  }
181
181
  function getTransformer(tailwindConfig, fileExtension) {
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.pattern = pattern;
6
+ exports.withoutCapturing = withoutCapturing;
7
+ exports.any = any;
8
+ exports.optional = optional;
9
+ exports.zeroOrMore = zeroOrMore;
10
+ exports.nestedBrackets = nestedBrackets;
11
+ exports.escape = escape;
12
+ const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
13
+ const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
14
+ /**
15
+ * @param {string|RegExp|Array<string|RegExp>} source
16
+ */ function toSource(source) {
17
+ source = Array.isArray(source) ? source : [
18
+ source
19
+ ];
20
+ source = source.map((item)=>item instanceof RegExp ? item.source : item
21
+ );
22
+ return source.join("");
23
+ }
24
+ function pattern(source) {
25
+ return new RegExp(toSource(source), "g");
26
+ }
27
+ function withoutCapturing(source) {
28
+ return new RegExp(`(?:${toSource(source)})`, "g");
29
+ }
30
+ function any(sources) {
31
+ return `(?:${sources.map(toSource).join("|")})`;
32
+ }
33
+ function optional(source) {
34
+ return `(?:${toSource(source)})?`;
35
+ }
36
+ function zeroOrMore(source) {
37
+ return `(?:${toSource(source)})*`;
38
+ }
39
+ function nestedBrackets(open, close, depth = 1) {
40
+ return withoutCapturing([
41
+ escape(open),
42
+ /[^\s]*/,
43
+ depth === 1 ? `[^${escape(open)}${escape(close)}\s]*` : any([
44
+ `[^${escape(open)}${escape(close)}\s]*`,
45
+ nestedBrackets(open, close, depth - 1)
46
+ ]),
47
+ /[^\s]*/,
48
+ escape(close),
49
+ ]);
50
+ }
51
+ function escape(string) {
52
+ return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
53
+ }
package/lib/util/color.js CHANGED
@@ -16,9 +16,10 @@ let VALUE = /(?:\d+|\d*\.\d+)%?/;
16
16
  let SEP = /(?:\s*,\s*|\s+)/;
17
17
  let ALPHA_SEP = /\s*[,/]\s*/;
18
18
  let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/;
19
- let RGB = new RegExp(`^rgba?\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
20
- let HSL = new RegExp(`^hsla?\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
21
- function parseColor(value) {
19
+ let RGB = new RegExp(`^(rgb)a?\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
20
+ let HSL = new RegExp(`^(hsl)a?\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
21
+ function parseColor(value, { loose =false } = {}) {
22
+ var ref, ref1;
22
23
  if (typeof value !== "string") {
23
24
  return null;
24
25
  }
@@ -64,35 +65,29 @@ function parseColor(value) {
64
65
  alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
65
66
  };
66
67
  }
67
- let rgbMatch = value.match(RGB);
68
- if (rgbMatch !== null) {
69
- var ref, ref1;
70
- return {
71
- mode: "rgb",
72
- color: [
73
- rgbMatch[1],
74
- rgbMatch[2],
75
- rgbMatch[3]
76
- ].map((v)=>v.toString()
77
- ),
78
- alpha: (ref = rgbMatch[4]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
79
- };
68
+ var ref2;
69
+ let match = (ref2 = value.match(RGB)) !== null && ref2 !== void 0 ? ref2 : value.match(HSL);
70
+ if (match === null) {
71
+ return null;
80
72
  }
81
- let hslMatch = value.match(HSL);
82
- if (hslMatch !== null) {
83
- var ref2, ref3;
84
- return {
85
- mode: "hsl",
86
- color: [
87
- hslMatch[1],
88
- hslMatch[2],
89
- hslMatch[3]
90
- ].map((v)=>v.toString()
91
- ),
92
- alpha: (ref2 = hslMatch[4]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.toString) === null || ref3 === void 0 ? void 0 : ref3.call(ref2)
93
- };
73
+ let color = [
74
+ match[2],
75
+ match[3],
76
+ match[4]
77
+ ].filter(Boolean).map((v)=>v.toString()
78
+ );
79
+ if (!loose && color.length !== 3) {
80
+ return null;
81
+ }
82
+ if (color.length < 3 && !color.some((part)=>/^var\(.*?\)$/.test(part)
83
+ )) {
84
+ return null;
94
85
  }
95
- return null;
86
+ return {
87
+ mode: match[1],
88
+ color,
89
+ alpha: (ref = match[5]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
90
+ };
96
91
  }
97
92
  function formatColor({ mode , color , alpha }) {
98
93
  let hasAlpha = alpha !== undefined;
@@ -116,7 +116,9 @@ function color(value) {
116
116
  let result = value.split(UNDERSCORE).every((part)=>{
117
117
  part = normalize(part);
118
118
  if (part.startsWith("var(")) return true;
119
- if ((0, _color).parseColor(part) !== null) return colors++, true;
119
+ if ((0, _color).parseColor(part, {
120
+ loose: true
121
+ }) !== null) return colors++, true;
120
122
  return false;
121
123
  });
122
124
  if (!result) return false;