tailwindcss 3.0.7 → 3.0.11

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/peers/index.js CHANGED
@@ -5406,7 +5406,7 @@ var require_processor = __commonJS({
5406
5406
  var Root = require_root();
5407
5407
  var Processor = class {
5408
5408
  constructor(plugins = []) {
5409
- this.version = "8.4.4";
5409
+ this.version = "8.4.5";
5410
5410
  this.plugins = this.normalize(plugins);
5411
5411
  }
5412
5412
  use(plugin) {
@@ -23880,25 +23880,6 @@ var require_dist2 = __commonJS({
23880
23880
  }
23881
23881
  });
23882
23882
 
23883
- // node_modules/is-resolvable/index.js
23884
- var require_is_resolvable = __commonJS({
23885
- "node_modules/is-resolvable/index.js"(exports2, module2) {
23886
- "use strict";
23887
- var inspect = require("util").inspect;
23888
- module2.exports = function isResolvable(moduleId, options) {
23889
- if (typeof moduleId !== "string") {
23890
- throw new TypeError(inspect(moduleId) + " is not a string. Expected a valid Node.js module identifier (<string>), for example 'eslint', './index.js', './lib'.");
23891
- }
23892
- try {
23893
- require.resolve(moduleId, options);
23894
- return true;
23895
- } catch (err) {
23896
- return false;
23897
- }
23898
- };
23899
- }
23900
- });
23901
-
23902
23883
  // node_modules/timsort/build/timsort.js
23903
23884
  var require_timsort = __commonJS({
23904
23885
  "node_modules/timsort/build/timsort.js"(exports2) {
@@ -29271,7 +29252,7 @@ var require_attributes = __commonJS({
29271
29252
  if (/\s/.test(value)) {
29272
29253
  return boolbase_1.falseFunc;
29273
29254
  }
29274
- var regex = new RegExp("(?:^|\\s)" + escapeRegex(value) + "(?:$|\\s)", ignoreCase ? "i" : "");
29255
+ var regex = new RegExp("(?:^|\\s)".concat(escapeRegex(value), "(?:$|\\s)"), ignoreCase ? "i" : "");
29275
29256
  return function element(elem) {
29276
29257
  var attr = adapter.getAttributeValue(elem, name);
29277
29258
  return attr != null && attr.length >= value.length && regex.test(attr) && next(elem);
@@ -29520,7 +29501,7 @@ var require_filters = __commonJS({
29520
29501
  },
29521
29502
  "nth-child": function(next, rule, _a) {
29522
29503
  var adapter = _a.adapter, equals = _a.equals;
29523
- var func = nth_check_1.default(rule);
29504
+ var func = (0, nth_check_1.default)(rule);
29524
29505
  if (func === boolbase_1.falseFunc)
29525
29506
  return boolbase_1.falseFunc;
29526
29507
  if (func === boolbase_1.trueFunc)
@@ -29540,7 +29521,7 @@ var require_filters = __commonJS({
29540
29521
  },
29541
29522
  "nth-last-child": function(next, rule, _a) {
29542
29523
  var adapter = _a.adapter, equals = _a.equals;
29543
- var func = nth_check_1.default(rule);
29524
+ var func = (0, nth_check_1.default)(rule);
29544
29525
  if (func === boolbase_1.falseFunc)
29545
29526
  return boolbase_1.falseFunc;
29546
29527
  if (func === boolbase_1.trueFunc)
@@ -29560,7 +29541,7 @@ var require_filters = __commonJS({
29560
29541
  },
29561
29542
  "nth-of-type": function(next, rule, _a) {
29562
29543
  var adapter = _a.adapter, equals = _a.equals;
29563
- var func = nth_check_1.default(rule);
29544
+ var func = (0, nth_check_1.default)(rule);
29564
29545
  if (func === boolbase_1.falseFunc)
29565
29546
  return boolbase_1.falseFunc;
29566
29547
  if (func === boolbase_1.trueFunc)
@@ -29581,7 +29562,7 @@ var require_filters = __commonJS({
29581
29562
  },
29582
29563
  "nth-last-of-type": function(next, rule, _a) {
29583
29564
  var adapter = _a.adapter, equals = _a.equals;
29584
- var func = nth_check_1.default(rule);
29565
+ var func = (0, nth_check_1.default)(rule);
29585
29566
  if (func === boolbase_1.falseFunc)
29586
29567
  return boolbase_1.falseFunc;
29587
29568
  if (func === boolbase_1.trueFunc)
@@ -29716,10 +29697,10 @@ var require_pseudos = __commonJS({
29716
29697
  function verifyPseudoArgs(func, name, subselect) {
29717
29698
  if (subselect === null) {
29718
29699
  if (func.length > 2) {
29719
- throw new Error("pseudo-selector :" + name + " requires an argument");
29700
+ throw new Error("pseudo-selector :".concat(name, " requires an argument"));
29720
29701
  }
29721
29702
  } else if (func.length === 2) {
29722
- throw new Error("pseudo-selector :" + name + " doesn't have any arguments");
29703
+ throw new Error("pseudo-selector :".concat(name, " doesn't have any arguments"));
29723
29704
  }
29724
29705
  }
29725
29706
  exports2.verifyPseudoArgs = verifyPseudoArgs;
@@ -29761,10 +29742,16 @@ var require_aliases = __commonJS({
29761
29742
  var require_subselects = __commonJS({
29762
29743
  "node_modules/css-select/lib/pseudo-selectors/subselects.js"(exports2) {
29763
29744
  "use strict";
29764
- var __spreadArray = exports2 && exports2.__spreadArray || function(to, from) {
29765
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
29766
- to[j] = from[i];
29767
- return to;
29745
+ var __spreadArray = exports2 && exports2.__spreadArray || function(to, from, pack) {
29746
+ if (pack || arguments.length === 2)
29747
+ for (var i = 0, l = from.length, ar; i < l; i++) {
29748
+ if (ar || !(i in from)) {
29749
+ if (!ar)
29750
+ ar = Array.prototype.slice.call(from, 0, i);
29751
+ ar[i] = from[i];
29752
+ }
29753
+ }
29754
+ return to.concat(ar || Array.prototype.slice.call(from));
29768
29755
  };
29769
29756
  Object.defineProperty(exports2, "__esModule", { value: true });
29770
29757
  exports2.subselects = exports2.getNextSiblings = exports2.ensureIsTag = exports2.PLACEHOLDER_ELEMENT = void 0;
@@ -29803,6 +29790,7 @@ var require_subselects = __commonJS({
29803
29790
  exports2.subselects = {
29804
29791
  is,
29805
29792
  matches: is,
29793
+ where: is,
29806
29794
  not: function(next, token, options, context, compileToken) {
29807
29795
  var opts = {
29808
29796
  xmlMode: !!options.xmlMode,
@@ -29842,7 +29830,7 @@ var require_subselects = __commonJS({
29842
29830
  return function(elem) {
29843
29831
  context[0] = elem;
29844
29832
  var childs = adapter.getChildren(elem);
29845
- var nextElements = shouldTestNextSiblings ? __spreadArray(__spreadArray([], childs), getNextSiblings(elem, adapter)) : childs;
29833
+ var nextElements = shouldTestNextSiblings ? __spreadArray(__spreadArray([], childs, true), getNextSiblings(elem, adapter), true) : childs;
29846
29834
  return next(elem) && adapter.existsOne(hasElement, nextElements);
29847
29835
  };
29848
29836
  }
@@ -29882,9 +29870,9 @@ var require_pseudo_selectors = __commonJS({
29882
29870
  }
29883
29871
  if (name in aliases_1.aliases) {
29884
29872
  if (data != null) {
29885
- throw new Error("Pseudo " + name + " doesn't have any arguments");
29873
+ throw new Error("Pseudo ".concat(name, " doesn't have any arguments"));
29886
29874
  }
29887
- var alias = css_what_1.parse(aliases_1.aliases[name], options);
29875
+ var alias = (0, css_what_1.parse)(aliases_1.aliases[name], options);
29888
29876
  return subselects_1.subselects.is(next, alias, options, context, compileToken);
29889
29877
  }
29890
29878
  if (name in filters_1.filters) {
@@ -29892,14 +29880,14 @@ var require_pseudo_selectors = __commonJS({
29892
29880
  }
29893
29881
  if (name in pseudos_1.pseudos) {
29894
29882
  var pseudo_1 = pseudos_1.pseudos[name];
29895
- pseudos_1.verifyPseudoArgs(pseudo_1, name, data);
29883
+ (0, pseudos_1.verifyPseudoArgs)(pseudo_1, name, data);
29896
29884
  return pseudo_1 === boolbase_1.falseFunc ? boolbase_1.falseFunc : next === boolbase_1.trueFunc ? function(elem) {
29897
29885
  return pseudo_1(elem, options, data);
29898
29886
  } : function(elem) {
29899
29887
  return pseudo_1(elem, options, data) && next(elem);
29900
29888
  };
29901
29889
  }
29902
- throw new Error("unmatched pseudo-class :" + name);
29890
+ throw new Error("unmatched pseudo-class :".concat(name));
29903
29891
  }
29904
29892
  exports2.compilePseudoSelector = compilePseudoSelector;
29905
29893
  }
@@ -29921,7 +29909,7 @@ var require_general = __commonJS({
29921
29909
  case "attribute":
29922
29910
  return attributes_1.attributeRules[selector.action](next, selector, options);
29923
29911
  case "pseudo":
29924
- return pseudo_selectors_1.compilePseudoSelector(next, selector, options, context, compileToken);
29912
+ return (0, pseudo_selectors_1.compilePseudoSelector)(next, selector, options, context, compileToken);
29925
29913
  case "tag":
29926
29914
  return function tag(elem) {
29927
29915
  return adapter.getName(elem) === selector.name && next(elem);
@@ -30023,11 +30011,11 @@ var require_compile2 = __commonJS({
30023
30011
  var subselects_1 = require_subselects();
30024
30012
  function compile(selector, options, context) {
30025
30013
  var next = compileUnsafe(selector, options, context);
30026
- return subselects_1.ensureIsTag(next, options.adapter);
30014
+ return (0, subselects_1.ensureIsTag)(next, options.adapter);
30027
30015
  }
30028
30016
  exports2.compile = compile;
30029
30017
  function compileUnsafe(selector, options, context) {
30030
- var token = typeof selector === "string" ? css_what_1.parse(selector, options) : selector;
30018
+ var token = typeof selector === "string" ? (0, css_what_1.parse)(selector, options) : selector;
30031
30019
  return compileToken(token, options, context);
30032
30020
  }
30033
30021
  exports2.compileUnsafe = compileUnsafe;
@@ -30049,7 +30037,7 @@ var require_compile2 = __commonJS({
30049
30037
  }));
30050
30038
  for (var _i = 0, token_1 = token; _i < token_1.length; _i++) {
30051
30039
  var t = token_1[_i];
30052
- if (t.length > 0 && procedure_1.isTraversal(t[0]) && t[0].type !== "descendant") {
30040
+ if (t.length > 0 && (0, procedure_1.isTraversal)(t[0]) && t[0].type !== "descendant") {
30053
30041
  } else if (hasContext && !t.some(includesScopePseudo)) {
30054
30042
  t.unshift(DESCENDANT_TOKEN);
30055
30043
  } else {
@@ -30088,7 +30076,7 @@ var require_compile2 = __commonJS({
30088
30076
  function compileRules(rules, options, context) {
30089
30077
  var _a;
30090
30078
  return rules.reduce(function(previous, rule) {
30091
- return previous === boolbase_1.falseFunc ? boolbase_1.falseFunc : general_1.compileGeneralSelector(previous, rule, options, context, compileToken);
30079
+ return previous === boolbase_1.falseFunc ? boolbase_1.falseFunc : (0, general_1.compileGeneralSelector)(previous, rule, options, context, compileToken);
30092
30080
  }, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.trueFunc);
30093
30081
  }
30094
30082
  function reduceRules(a, b) {
@@ -30170,7 +30158,7 @@ var require_lib9 = __commonJS({
30170
30158
  return function select(query, elements, options) {
30171
30159
  var opts = convertOptionFormats(options);
30172
30160
  if (typeof query !== "function") {
30173
- query = compile_1.compileUnsafe(query, opts, elements);
30161
+ query = (0, compile_1.compileUnsafe)(query, opts, elements);
30174
30162
  }
30175
30163
  var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
30176
30164
  return searchFunc(query, filteredElements, opts);
@@ -30188,8 +30176,9 @@ var require_lib9 = __commonJS({
30188
30176
  exports2.prepareContext = prepareContext;
30189
30177
  function appendNextSiblings(elem, adapter) {
30190
30178
  var elems = Array.isArray(elem) ? elem.slice(0) : [elem];
30191
- for (var i = 0; i < elems.length; i++) {
30192
- var nextSiblings = subselects_1.getNextSiblings(elems[i], adapter);
30179
+ var elemsLength = elems.length;
30180
+ for (var i = 0; i < elemsLength; i++) {
30181
+ var nextSiblings = (0, subselects_1.getNextSiblings)(elems[i], adapter);
30193
30182
  elems.push.apply(elems, nextSiblings);
30194
30183
  }
30195
30184
  return elems;
@@ -30202,7 +30191,7 @@ var require_lib9 = __commonJS({
30202
30191
  });
30203
30192
  function is(elem, query, options) {
30204
30193
  var opts = convertOptionFormats(options);
30205
- return (typeof query === "function" ? query : compile_1.compile(query, opts))(elem);
30194
+ return (typeof query === "function" ? query : (0, compile_1.compile)(query, opts))(elem);
30206
30195
  }
30207
30196
  exports2.is = is;
30208
30197
  exports2.default = exports2.selectAll;
@@ -70088,18 +70077,9 @@ var require_minifyColor = __commonJS({
70088
70077
  }
70089
70078
  (0, _colord.extend)([_names.default, _minify.default]);
70090
70079
  function minifyColor(input, options = {}) {
70091
- const settings = {
70092
- supportsAlphaHex: false,
70093
- supportsTransparent: true,
70094
- ...options
70095
- };
70096
70080
  const instance = (0, _colord.colord)(input);
70097
70081
  if (instance.isValid()) {
70098
- const minified = instance.minify({
70099
- alphaHex: settings.supportsAlphaHex,
70100
- transparent: settings.supportsTransparent,
70101
- name: true
70102
- });
70082
+ const minified = instance.minify(options);
70103
70083
  return minified.length < input.length ? minified : input.toLowerCase();
70104
70084
  } else {
70105
70085
  return input;
@@ -70205,21 +70185,29 @@ var require_dist13 = __commonJS({
70205
70185
  });
70206
70186
  return parsed.toString();
70207
70187
  }
70208
- function pluginCreator() {
70188
+ function addPluginDefaults(options, browsers) {
70189
+ const defaults = {
70190
+ transparent: browsers.some(hasTransparentBug) === false,
70191
+ alphaHex: (0, _caniuseApi.isSupported)("css-rrggbbaa", browsers),
70192
+ name: true
70193
+ };
70194
+ return {
70195
+ ...defaults,
70196
+ ...options
70197
+ };
70198
+ }
70199
+ function pluginCreator(config = {}) {
70209
70200
  return {
70210
70201
  postcssPlugin: "postcss-colormin",
70211
70202
  prepare(result) {
70212
- const resultOpts = result.opts || {};
70203
+ const resultOptions = result.opts || {};
70213
70204
  const browsers = (0, _browserslist.default)(null, {
70214
- stats: resultOpts.stats,
70205
+ stats: resultOptions.stats,
70215
70206
  path: __dirname,
70216
- env: resultOpts.env
70207
+ env: resultOptions.env
70217
70208
  });
70218
- const options = {
70219
- supportsTransparent: browsers.some(hasTransparentBug) === false,
70220
- supportsAlphaHex: (0, _caniuseApi.isSupported)("css-rrggbbaa", browsers)
70221
- };
70222
70209
  const cache = {};
70210
+ const options = addPluginDefaults(config, browsers);
70223
70211
  return {
70224
70212
  OnceExit(css) {
70225
70213
  css.walkDecls((decl) => {
@@ -72142,22 +72130,6 @@ var require_normalize_url = __commonJS({
72142
72130
  }
72143
72131
  });
72144
72132
 
72145
- // node_modules/is-absolute-url/index.js
72146
- var require_is_absolute_url = __commonJS({
72147
- "node_modules/is-absolute-url/index.js"(exports2, module2) {
72148
- "use strict";
72149
- module2.exports = (url) => {
72150
- if (typeof url !== "string") {
72151
- throw new TypeError(`Expected a \`string\`, got \`${typeof url}\``);
72152
- }
72153
- if (/^[a-zA-Z]:\\/.test(url)) {
72154
- return false;
72155
- }
72156
- return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url);
72157
- };
72158
- }
72159
- });
72160
-
72161
72133
  // node_modules/postcss-normalize-url/dist/index.js
72162
72134
  var require_dist19 = __commonJS({
72163
72135
  "node_modules/postcss-normalize-url/dist/index.js"(exports2, module2) {
@@ -72169,14 +72141,21 @@ var require_dist19 = __commonJS({
72169
72141
  var _path = _interopRequireDefault(require("path"));
72170
72142
  var _postcssValueParser = _interopRequireDefault(require_lib());
72171
72143
  var _normalizeUrl = _interopRequireDefault(require_normalize_url());
72172
- var _isAbsoluteUrl = _interopRequireDefault(require_is_absolute_url());
72173
72144
  function _interopRequireDefault(obj) {
72174
72145
  return obj && obj.__esModule ? obj : { default: obj };
72175
72146
  }
72176
72147
  var multiline = /\\[\r\n]/;
72177
72148
  var escapeChars = /([\s\(\)"'])/g;
72149
+ var ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
72150
+ var WINDOWS_PATH_REGEX = /^[a-zA-Z]:\\/;
72151
+ function isAbsolute(url) {
72152
+ if (WINDOWS_PATH_REGEX.test(url)) {
72153
+ return false;
72154
+ }
72155
+ return ABSOLUTE_URL_REGEX.test(url);
72156
+ }
72178
72157
  function convert(url, options) {
72179
- if ((0, _isAbsoluteUrl.default)(url) || url.startsWith("//")) {
72158
+ if (isAbsolute(url) || url.startsWith("//")) {
72180
72159
  let normalizedURL = null;
72181
72160
  try {
72182
72161
  normalizedURL = (0, _normalizeUrl.default)(url, options);
@@ -75970,11 +75949,18 @@ var require_dist35 = __commonJS({
75970
75949
  var _postcss = _interopRequireDefault(require_postcss());
75971
75950
  var _yaml = _interopRequireDefault(require_yaml());
75972
75951
  var _lilconfig = require_dist2();
75973
- var _isResolvable = _interopRequireDefault(require_is_resolvable());
75974
75952
  function _interopRequireDefault(obj) {
75975
75953
  return obj && obj.__esModule ? obj : { default: obj };
75976
75954
  }
75977
75955
  var cssnano = "cssnano";
75956
+ function isResolvable(moduleId) {
75957
+ try {
75958
+ require.resolve(moduleId);
75959
+ return true;
75960
+ } catch (e) {
75961
+ return false;
75962
+ }
75963
+ }
75978
75964
  function resolvePreset(preset) {
75979
75965
  let fn, options;
75980
75966
  if (Array.isArray(preset)) {
@@ -75993,11 +75979,11 @@ var require_dist35 = __commonJS({
75993
75979
  if (typeof fn === "function") {
75994
75980
  return fn(options).plugins;
75995
75981
  }
75996
- if ((0, _isResolvable.default)(fn)) {
75982
+ if (isResolvable(fn)) {
75997
75983
  return require(fn)(options).plugins;
75998
75984
  }
75999
75985
  const sugar = `cssnano-preset-${fn}`;
76000
- if ((0, _isResolvable.default)(sugar)) {
75986
+ if (isResolvable(sugar)) {
76001
75987
  return require(sugar)(options).plugins;
76002
75988
  }
76003
75989
  throw new Error(`Cannot load preset "${fn}". Please check your configuration for errors and try again.`);
@@ -76035,12 +76021,12 @@ var require_dist35 = __commonJS({
76035
76021
  options.plugins.forEach((plugin) => {
76036
76022
  if (Array.isArray(plugin)) {
76037
76023
  const [pluginDef, opts = {}] = plugin;
76038
- if (typeof pluginDef === "string" && (0, _isResolvable.default)(pluginDef)) {
76024
+ if (typeof pluginDef === "string" && isResolvable(pluginDef)) {
76039
76025
  options.preset.plugins.push([require(pluginDef), opts]);
76040
76026
  } else {
76041
76027
  options.preset.plugins.push([pluginDef, opts]);
76042
76028
  }
76043
- } else if (typeof plugin === "string" && (0, _isResolvable.default)(plugin)) {
76029
+ } else if (typeof plugin === "string" && isResolvable(plugin)) {
76044
76030
  options.preset.plugins.push([require(plugin), {}]);
76045
76031
  } else {
76046
76032
  options.preset.plugins.push([plugin, {}]);
package/src/cli.js CHANGED
@@ -41,6 +41,26 @@ function formatNodes(root) {
41
41
  }
42
42
  }
43
43
 
44
+ async function outputFile(file, contents) {
45
+ if (fs.existsSync(file) && (await fs.promises.readFile(file, 'utf8')) === contents) {
46
+ return // Skip writing the file
47
+ }
48
+
49
+ // Write the file
50
+ await fs.promises.writeFile(file, contents, 'utf8')
51
+ }
52
+
53
+ function drainStdin() {
54
+ return new Promise((resolve, reject) => {
55
+ let result = ''
56
+ process.stdin.on('data', (chunk) => {
57
+ result += chunk
58
+ })
59
+ process.stdin.on('end', () => resolve(result))
60
+ process.stdin.on('error', (err) => reject(err))
61
+ })
62
+ }
63
+
44
64
  function help({ message, usage, commands, options }) {
45
65
  let indent = 2
46
66
 
@@ -355,7 +375,7 @@ async function build() {
355
375
  input = args['--input'] = args['_'][1]
356
376
  }
357
377
 
358
- if (input && !fs.existsSync((input = path.resolve(input)))) {
378
+ if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) {
359
379
  console.error(`Specified input file ${args['--input']} does not exist.`)
360
380
  process.exit(9)
361
381
  }
@@ -534,10 +554,11 @@ async function build() {
534
554
  if (!output) {
535
555
  return process.stdout.write(result.css)
536
556
  }
557
+
537
558
  return Promise.all(
538
559
  [
539
- fs.promises.writeFile(output, result.css, () => true),
540
- result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
560
+ outputFile(output, result.css),
561
+ result.map && outputFile(output + '.map', result.map.toString()),
541
562
  ].filter(Boolean)
542
563
  )
543
564
  })
@@ -548,9 +569,21 @@ async function build() {
548
569
  })
549
570
  }
550
571
 
551
- let css = input
552
- ? fs.readFileSync(path.resolve(input), 'utf8')
553
- : '@tailwind base; @tailwind components; @tailwind utilities'
572
+ let css = await (() => {
573
+ // Piping in data, let's drain the stdin
574
+ if (input === '-') {
575
+ return drainStdin()
576
+ }
577
+
578
+ // Input file has been provided
579
+ if (input) {
580
+ return fs.readFileSync(path.resolve(input), 'utf8')
581
+ }
582
+
583
+ // No input file provided, fallback to default atrules
584
+ return '@tailwind base; @tailwind components; @tailwind utilities'
585
+ })()
586
+
554
587
  return processCSS(css)
555
588
  }
556
589
 
@@ -664,10 +697,10 @@ async function build() {
664
697
  return process.stdout.write(result.css)
665
698
  }
666
699
 
667
- await Promise.all(
700
+ return Promise.all(
668
701
  [
669
- fs.promises.writeFile(output, result.css, () => true),
670
- result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
702
+ outputFile(output, result.css),
703
+ result.map && outputFile(output + '.map', result.map.toString()),
671
704
  ].filter(Boolean)
672
705
  )
673
706
  })
@@ -684,9 +717,21 @@ async function build() {
684
717
  })
685
718
  }
686
719
 
687
- let css = input
688
- ? fs.readFileSync(path.resolve(input), 'utf8')
689
- : '@tailwind base; @tailwind components; @tailwind utilities'
720
+ let css = await (() => {
721
+ // Piping in data, let's drain the stdin
722
+ if (input === '-') {
723
+ return drainStdin()
724
+ }
725
+
726
+ // Input file has been provided
727
+ if (input) {
728
+ return fs.readFileSync(path.resolve(input), 'utf8')
729
+ }
730
+
731
+ // No input file provided, fallback to default atrules
732
+ return '@tailwind base; @tailwind components; @tailwind utilities'
733
+ })()
734
+
690
735
  let result = await processCSS(css)
691
736
  env.DEBUG && console.timeEnd('Finished in')
692
737
  return result
@@ -58,7 +58,7 @@ hr {
58
58
  Add the correct text decoration in Chrome, Edge, and Safari.
59
59
  */
60
60
 
61
- abbr[title] {
61
+ abbr:where([title]) {
62
62
  text-decoration: underline dotted;
63
63
  }
64
64
 
package/src/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import setupTrackingContext from './lib/setupTrackingContext'
2
- import setupWatchingContext from './lib/setupWatchingContext'
3
2
  import processTailwindFeatures from './processTailwindFeatures'
4
3
  import { env } from './lib/sharedState'
5
4
 
@@ -14,12 +13,7 @@ module.exports = function tailwindcss(configOrPath) {
14
13
  return root
15
14
  },
16
15
  function (root, result) {
17
- let setupContext =
18
- env.TAILWIND_MODE === 'watch'
19
- ? setupWatchingContext(configOrPath)
20
- : setupTrackingContext(configOrPath)
21
-
22
- processTailwindFeatures(setupContext)(root, result)
16
+ processTailwindFeatures(setupTrackingContext(configOrPath))(root, result)
23
17
  },
24
18
  env.DEBUG &&
25
19
  function (root) {
@@ -3,6 +3,7 @@ export default function collapseDuplicateDeclarations() {
3
3
  root.walkRules((node) => {
4
4
  let seen = new Map()
5
5
  let droppable = new Set([])
6
+ let byProperty = new Map()
6
7
 
7
8
  node.walkDecls((decl) => {
8
9
  // This could happen if we have nested selectors. In that case the
@@ -14,15 +15,79 @@ export default function collapseDuplicateDeclarations() {
14
15
  }
15
16
 
16
17
  if (seen.has(decl.prop)) {
17
- droppable.add(seen.get(decl.prop))
18
+ // Exact same value as what we have seen so far
19
+ if (seen.get(decl.prop).value === decl.value) {
20
+ // Keep the last one, drop the one we've seen so far
21
+ droppable.add(seen.get(decl.prop))
22
+ // Override the existing one with the new value. This is necessary
23
+ // so that if we happen to have more than one declaration with the
24
+ // same value, that we keep removing the previous one. Otherwise we
25
+ // will only remove the *first* one.
26
+ seen.set(decl.prop, decl)
27
+ return
28
+ }
29
+
30
+ // Not the same value, so we need to check if we can merge it so
31
+ // let's collect it first.
32
+ if (!byProperty.has(decl.prop)) {
33
+ byProperty.set(decl.prop, new Set())
34
+ }
35
+
36
+ byProperty.get(decl.prop).add(seen.get(decl.prop))
37
+ byProperty.get(decl.prop).add(decl)
18
38
  }
19
39
 
20
40
  seen.set(decl.prop, decl)
21
41
  })
22
42
 
43
+ // Drop all the duplicate declarations with the exact same value we've
44
+ // already seen so far.
23
45
  for (let decl of droppable) {
24
46
  decl.remove()
25
47
  }
48
+
49
+ // Analyze the declarations based on its unit, drop all the declarations
50
+ // with the same unit but the last one in the list.
51
+ for (let declarations of byProperty.values()) {
52
+ let byUnit = new Map()
53
+
54
+ for (let decl of declarations) {
55
+ let unit = resolveUnit(decl.value)
56
+ if (unit === null) {
57
+ // We don't have a unit, so should never try and collapse this
58
+ // value. This is because we can't know how to do it in a correct
59
+ // way (e.g.: overrides for older browsers)
60
+ continue
61
+ }
62
+
63
+ if (!byUnit.has(unit)) {
64
+ byUnit.set(unit, new Set())
65
+ }
66
+
67
+ byUnit.get(unit).add(decl)
68
+ }
69
+
70
+ for (let declarations of byUnit.values()) {
71
+ // Get all but the last one
72
+ let removableDeclarations = Array.from(declarations).slice(0, -1)
73
+
74
+ for (let decl of removableDeclarations) {
75
+ decl.remove()
76
+ }
77
+ }
78
+ }
26
79
  })
27
80
  }
28
81
  }
82
+
83
+ let UNITLESS_NUMBER = Symbol('unitless-number')
84
+
85
+ function resolveUnit(input) {
86
+ let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input)
87
+
88
+ if (result) {
89
+ return result[1] ?? UNITLESS_NUMBER
90
+ }
91
+
92
+ return null
93
+ }
@@ -10,10 +10,17 @@ const PATTERNS = [
10
10
  /([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source, // bg-[url("..."),url("...")]
11
11
  /([^<>"'`\s]*\['[^"'`\s]*'\])/.source, // `content-['hello']` but not `content-['hello']']`
12
12
  /([^<>"'`\s]*\["[^"'`\s]*"\])/.source, // `content-["hello"]` but not `content-["hello"]"]`
13
+ /([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source, // `[attr:value]`
13
14
  /([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source, // `[content:'hello']` but not `[content:"hello"]`
14
15
  /([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source, // `[content:"hello"]` but not `[content:'hello']`
15
16
  /([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source, // `fill-[#bada55]`, `fill-[#bada55]/50`
17
+ /([^"'`\s]*[^<>"'`\s:\\])/.source, // `<sm:underline`, `md>:font-bold`
16
18
  /([^<>"'`\s]*[^"'`\s:\\])/.source, // `px-1.5`, `uppercase` but not `uppercase:`
19
+
20
+ // Arbitrary properties
21
+ // /([^"\s]*\[[^\s]+?\][^"\s]*)/.source,
22
+ // /([^'\s]*\[[^\s]+?\][^'\s]*)/.source,
23
+ // /([^`\s]*\[[^\s]+?\][^`\s]*)/.source,
17
24
  ].join('|')
18
25
 
19
26
  const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g')
@@ -29,3 +36,13 @@ export function defaultExtractor(content) {
29
36
 
30
37
  return results
31
38
  }
39
+
40
+ // Regular utilities
41
+ // {{modifier}:}*{namespace}{-{suffix}}*{/{opacityModifier}}?
42
+
43
+ // Arbitrary values
44
+ // {{modifier}:}*{namespace}-[{arbitraryValue}]{/{opacityModifier}}?
45
+ // arbitraryValue: no whitespace, balanced quotes unless within quotes, balanced brackets unless within quotes
46
+
47
+ // Arbitrary properties
48
+ // {{modifier}:}*[{validCssPropertyName}:{arbitraryValue}]
@@ -297,7 +297,7 @@ function processApply(root, context) {
297
297
  // would have replaced this with something that didn't exist and
298
298
  // therefore it removed the selector altogether. In this specific
299
299
  // case it would result in `{}` instead of `.something-unrelated {}`
300
- if (!extractClasses(rule).some((thing) => thing === applyCandidate)) {
300
+ if (!extractClasses(rule).some((candidate) => candidate === applyCandidate)) {
301
301
  rule.remove()
302
302
  return
303
303
  }