tailwindcss 3.0.21 → 3.0.24

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 (89) hide show
  1. package/CHANGELOG.md +45 -2
  2. package/lib/cli-peer-dependencies.js +3 -3
  3. package/lib/cli.js +183 -161
  4. package/lib/constants.js +8 -8
  5. package/lib/corePlugins.js +1597 -1518
  6. package/lib/featureFlags.js +9 -9
  7. package/lib/index.js +19 -6
  8. package/lib/lib/cacheInvalidation.js +69 -0
  9. package/lib/lib/collapseAdjacentRules.js +26 -13
  10. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  11. package/lib/lib/defaultExtractor.js +8 -6
  12. package/lib/lib/detectNesting.js +9 -9
  13. package/lib/lib/evaluateTailwindFunctions.js +16 -16
  14. package/lib/lib/expandApplyAtRules.js +180 -27
  15. package/lib/lib/expandTailwindAtRules.js +132 -122
  16. package/lib/lib/generateRules.js +117 -72
  17. package/lib/lib/getModuleDependencies.js +14 -14
  18. package/lib/lib/normalizeTailwindDirectives.js +35 -35
  19. package/lib/lib/partitionApplyAtRules.js +7 -7
  20. package/lib/lib/resolveDefaultsAtRules.js +81 -77
  21. package/lib/lib/setupContextUtils.js +83 -98
  22. package/lib/lib/setupTrackingContext.js +57 -57
  23. package/lib/lib/sharedState.js +11 -7
  24. package/lib/lib/substituteScreenAtRules.js +2 -2
  25. package/lib/postcss-plugins/nesting/README.md +2 -2
  26. package/lib/postcss-plugins/nesting/index.js +1 -1
  27. package/lib/postcss-plugins/nesting/plugin.js +41 -9
  28. package/lib/processTailwindFeatures.js +7 -7
  29. package/lib/public/colors.js +241 -241
  30. package/lib/public/resolve-config.js +5 -5
  31. package/lib/util/buildMediaQuery.js +2 -2
  32. package/lib/util/cloneDeep.js +1 -1
  33. package/lib/util/cloneNodes.js +12 -1
  34. package/lib/util/color.js +21 -20
  35. package/lib/util/createUtilityPlugin.js +6 -6
  36. package/lib/util/dataTypes.js +77 -75
  37. package/lib/util/escapeClassName.js +5 -5
  38. package/lib/util/escapeCommas.js +1 -1
  39. package/lib/util/flattenColorPalette.js +2 -2
  40. package/lib/util/formatVariantSelector.js +19 -19
  41. package/lib/util/getAllConfigs.js +5 -5
  42. package/lib/util/hashConfig.js +5 -5
  43. package/lib/util/isKeyframeRule.js +1 -1
  44. package/lib/util/isPlainObject.js +1 -1
  45. package/lib/util/isValidArbitraryValue.js +27 -27
  46. package/lib/util/log.js +8 -8
  47. package/lib/util/nameClass.js +7 -7
  48. package/lib/util/negateValue.js +4 -4
  49. package/lib/util/normalizeConfig.js +39 -39
  50. package/lib/util/normalizeScreens.js +4 -4
  51. package/lib/util/parseAnimationValue.js +56 -56
  52. package/lib/util/parseBoxShadowValue.js +60 -20
  53. package/lib/util/parseDependency.js +32 -32
  54. package/lib/util/parseObjectStyles.js +6 -6
  55. package/lib/util/pluginUtils.js +9 -9
  56. package/lib/util/prefixSelector.js +1 -1
  57. package/lib/util/resolveConfig.js +28 -28
  58. package/lib/util/resolveConfigPath.js +16 -16
  59. package/lib/util/responsive.js +6 -6
  60. package/lib/util/toColorValue.js +1 -1
  61. package/lib/util/toPath.js +2 -2
  62. package/lib/util/transformThemeValue.js +27 -27
  63. package/lib/util/withAlphaVariable.js +19 -19
  64. package/package.json +26 -25
  65. package/peers/index.js +4803 -4857
  66. package/scripts/generate-types.js +52 -0
  67. package/src/cli.js +41 -11
  68. package/src/corePlugins.js +104 -9
  69. package/src/featureFlags.js +2 -2
  70. package/src/index.js +17 -1
  71. package/src/lib/cacheInvalidation.js +52 -0
  72. package/src/lib/collapseAdjacentRules.js +16 -1
  73. package/src/lib/defaultExtractor.js +6 -4
  74. package/src/lib/expandApplyAtRules.js +179 -6
  75. package/src/lib/expandTailwindAtRules.js +26 -6
  76. package/src/lib/generateRules.js +73 -46
  77. package/src/lib/resolveDefaultsAtRules.js +6 -2
  78. package/src/lib/setupContextUtils.js +39 -48
  79. package/src/lib/setupTrackingContext.js +3 -3
  80. package/src/lib/sharedState.js +2 -0
  81. package/src/postcss-plugins/nesting/README.md +2 -2
  82. package/src/postcss-plugins/nesting/plugin.js +36 -0
  83. package/src/util/cloneNodes.js +14 -1
  84. package/src/util/color.js +7 -5
  85. package/src/util/dataTypes.js +3 -1
  86. package/src/util/log.js +7 -7
  87. package/src/util/parseBoxShadowValue.js +50 -2
  88. package/src/util/resolveConfig.js +32 -0
  89. package/stubs/defaultConfig.stub.js +5 -0
package/lib/util/log.js CHANGED
@@ -4,27 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.dim = dim;
6
6
  exports.default = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
7
+ var _picocolors = _interopRequireDefault(require("picocolors"));
8
8
  function _interopRequireDefault(obj) {
9
9
  return obj && obj.__esModule ? obj : {
10
10
  default: obj
11
11
  };
12
12
  }
13
13
  let alreadyShown = new Set();
14
- function log(chalk, messages, key) {
14
+ function log(type, messages, key) {
15
15
  if (process.env.JEST_WORKER_ID !== undefined) return;
16
16
  if (key && alreadyShown.has(key)) return;
17
17
  if (key) alreadyShown.add(key);
18
- console.warn('');
19
- messages.forEach((message)=>console.warn(chalk, '-', message)
18
+ console.warn("");
19
+ messages.forEach((message)=>console.warn(type, "-", message)
20
20
  );
21
21
  }
22
22
  function dim(input) {
23
- return _chalk.default.dim(input);
23
+ return _picocolors.default.dim(input);
24
24
  }
25
25
  var _default = {
26
26
  info (key, messages) {
27
- log(_chalk.default.bold.cyan('info'), ...Array.isArray(key) ? [
27
+ log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
28
28
  key
29
29
  ] : [
30
30
  messages,
@@ -32,7 +32,7 @@ var _default = {
32
32
  ]);
33
33
  },
34
34
  warn (key, messages) {
35
- log(_chalk.default.bold.yellow('warn'), ...Array.isArray(key) ? [
35
+ log(_picocolors.default.bold(_picocolors.default.yellow("warn")), ...Array.isArray(key) ? [
36
36
  key
37
37
  ] : [
38
38
  messages,
@@ -40,7 +40,7 @@ var _default = {
40
40
  ]);
41
41
  },
42
42
  risk (key, messages) {
43
- log(_chalk.default.bold.magenta('risk'), ...Array.isArray(key) ? [
43
+ log(_picocolors.default.bold(_picocolors.default.magenta("risk")), ...Array.isArray(key) ? [
44
44
  key
45
45
  ] : [
46
46
  messages,
@@ -2,11 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.asClass = asClass;
6
5
  exports.default = nameClass;
6
+ exports.asClass = asClass;
7
7
  exports.formatClass = formatClass;
8
8
  var _escapeClassName = _interopRequireDefault(require("./escapeClassName"));
9
9
  var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
10
+ function nameClass(classPrefix, key) {
11
+ return asClass(formatClass(classPrefix, key));
12
+ }
10
13
  function _interopRequireDefault(obj) {
11
14
  return obj && obj.__esModule ? obj : {
12
15
  default: obj
@@ -15,17 +18,14 @@ function _interopRequireDefault(obj) {
15
18
  function asClass(name) {
16
19
  return (0, _escapeCommas).default(`.${(0, _escapeClassName).default(name)}`);
17
20
  }
18
- function nameClass(classPrefix, key) {
19
- return asClass(formatClass(classPrefix, key));
20
- }
21
21
  function formatClass(classPrefix, key) {
22
- if (key === 'DEFAULT') {
22
+ if (key === "DEFAULT") {
23
23
  return classPrefix;
24
24
  }
25
- if (key === '-' || key === '-DEFAULT') {
25
+ if (key === "-" || key === "-DEFAULT") {
26
26
  return `-${classPrefix}`;
27
27
  }
28
- if (key.startsWith('-')) {
28
+ if (key.startsWith("-")) {
29
29
  return `-${classPrefix}${key}`;
30
30
  }
31
31
  return `${classPrefix}-${key}`;
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.default = _default;
6
6
  function _default(value) {
7
7
  value = `${value}`;
8
- if (value === '0') {
9
- return '0';
8
+ if (value === "0") {
9
+ return "0";
10
10
  }
11
11
  // Flip sign of numbers
12
12
  if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
13
- return value.replace(/^[+-]?/, (sign)=>sign === '-' ? '' : '-'
13
+ return value.replace(/^[+-]?/, (sign)=>sign === "-" ? "" : "-"
14
14
  );
15
15
  }
16
- if (value.includes('var(') || value.includes('calc(')) {
16
+ if (value.includes("var(") || value.includes("calc(")) {
17
17
  return `calc(${value} * -1)`;
18
18
  }
19
19
  }
@@ -50,31 +50,31 @@ function normalizeConfig(config) {
50
50
  return false;
51
51
  }
52
52
  // `config.content` should be an object or an array
53
- if (!Array.isArray(config.content) && !(typeof config.content === 'object' && config.content !== null)) {
53
+ if (!Array.isArray(config.content) && !(typeof config.content === "object" && config.content !== null)) {
54
54
  return false;
55
55
  }
56
56
  // When `config.content` is an array, it should consist of FilePaths or RawFiles
57
57
  if (Array.isArray(config.content)) {
58
58
  return config.content.every((path)=>{
59
59
  // `path` can be a string
60
- if (typeof path === 'string') return true;
60
+ if (typeof path === "string") return true;
61
61
  // `path` can be an object { raw: string, extension?: string }
62
62
  // `raw` must be a string
63
- if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== 'string') return false;
63
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
64
64
  // `extension` (if provided) should also be a string
65
- if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== 'string') {
65
+ if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
66
66
  return false;
67
67
  }
68
68
  return true;
69
69
  });
70
70
  }
71
71
  // When `config.content` is an object
72
- if (typeof config.content === 'object' && config.content !== null) {
72
+ if (typeof config.content === "object" && config.content !== null) {
73
73
  // Only `files`, `extract` and `transform` can exist in `config.content`
74
74
  if (Object.keys(config.content).some((key)=>![
75
- 'files',
76
- 'extract',
77
- 'transform'
75
+ "files",
76
+ "extract",
77
+ "transform"
78
78
  ].includes(key)
79
79
  )) {
80
80
  return false;
@@ -83,12 +83,12 @@ function normalizeConfig(config) {
83
83
  if (Array.isArray(config.content.files)) {
84
84
  if (!config.content.files.every((path)=>{
85
85
  // `path` can be a string
86
- if (typeof path === 'string') return true;
86
+ if (typeof path === "string") return true;
87
87
  // `path` can be an object { raw: string, extension?: string }
88
88
  // `raw` must be a string
89
- if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== 'string') return false;
89
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
90
90
  // `extension` (if provided) should also be a string
91
- if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== 'string') {
91
+ if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
92
92
  return false;
93
93
  }
94
94
  return true;
@@ -96,23 +96,23 @@ function normalizeConfig(config) {
96
96
  return false;
97
97
  }
98
98
  // `config.content.extract` is optional, and can be a Function or a Record<String, Function>
99
- if (typeof config.content.extract === 'object') {
99
+ if (typeof config.content.extract === "object") {
100
100
  for (let value of Object.values(config.content.extract)){
101
- if (typeof value !== 'function') {
101
+ if (typeof value !== "function") {
102
102
  return false;
103
103
  }
104
104
  }
105
- } else if (!(config.content.extract === undefined || typeof config.content.extract === 'function')) {
105
+ } else if (!(config.content.extract === undefined || typeof config.content.extract === "function")) {
106
106
  return false;
107
107
  }
108
108
  // `config.content.transform` is optional, and can be a Function or a Record<String, Function>
109
- if (typeof config.content.transform === 'object') {
109
+ if (typeof config.content.transform === "object") {
110
110
  for (let value of Object.values(config.content.transform)){
111
- if (typeof value !== 'function') {
111
+ if (typeof value !== "function") {
112
112
  return false;
113
113
  }
114
114
  }
115
- } else if (!(config.content.transform === undefined || typeof config.content.transform === 'function')) {
115
+ } else if (!(config.content.transform === undefined || typeof config.content.transform === "function")) {
116
116
  return false;
117
117
  }
118
118
  }
@@ -121,10 +121,10 @@ function normalizeConfig(config) {
121
121
  return false;
122
122
  })();
123
123
  if (!valid) {
124
- _log.default.warn('purge-deprecation', [
125
- 'The `purge`/`content` options have changed in Tailwind CSS v3.0.',
126
- 'Update your configuration file to eliminate this warning.',
127
- 'https://tailwindcss.com/docs/upgrade-guide#configure-content-sources',
124
+ _log.default.warn("purge-deprecation", [
125
+ "The `purge`/`content` options have changed in Tailwind CSS v3.0.",
126
+ "Update your configuration file to eliminate this warning.",
127
+ "https://tailwindcss.com/docs/upgrade-guide#configure-content-sources",
128
128
  ]);
129
129
  }
130
130
  // Normalize the `safelist`
@@ -138,16 +138,16 @@ function normalizeConfig(config) {
138
138
  return [];
139
139
  })();
140
140
  // Normalize prefix option
141
- if (typeof config.prefix === 'function') {
142
- _log.default.warn('prefix-function', [
143
- 'As of Tailwind CSS v3.0, `prefix` cannot be a function.',
144
- 'Update `prefix` in your configuration to be a string to eliminate this warning.',
145
- 'https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function',
141
+ if (typeof config.prefix === "function") {
142
+ _log.default.warn("prefix-function", [
143
+ "As of Tailwind CSS v3.0, `prefix` cannot be a function.",
144
+ "Update `prefix` in your configuration to be a string to eliminate this warning.",
145
+ "https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function",
146
146
  ]);
147
- config.prefix = '';
147
+ config.prefix = "";
148
148
  } else {
149
149
  var _prefix;
150
- config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : '';
150
+ config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : "";
151
151
  }
152
152
  // Normalize the `content`
153
153
  config.content = {
@@ -186,7 +186,7 @@ function normalizeConfig(config) {
186
186
  extractors.DEFAULT = defaultExtractor;
187
187
  }
188
188
  // Functions
189
- if (typeof extract === 'function') {
189
+ if (typeof extract === "function") {
190
190
  extractors.DEFAULT = extract;
191
191
  } else if (Array.isArray(extract)) {
192
192
  for (let { extensions , extractor } of extract !== null && extract !== void 0 ? extract : []){
@@ -194,7 +194,7 @@ function normalizeConfig(config) {
194
194
  extractors[extension] = extractor;
195
195
  }
196
196
  }
197
- } else if (typeof extract === 'object' && extract !== null) {
197
+ } else if (typeof extract === "object" && extract !== null) {
198
198
  Object.assign(extractors, extract);
199
199
  }
200
200
  return extractors;
@@ -209,10 +209,10 @@ function normalizeConfig(config) {
209
209
  return {};
210
210
  })();
211
211
  let transformers = {};
212
- if (typeof transform === 'function') {
212
+ if (typeof transform === "function") {
213
213
  transformers.DEFAULT = transform;
214
214
  }
215
- if (typeof transform === 'object' && transform !== null) {
215
+ if (typeof transform === "object" && transform !== null) {
216
216
  Object.assign(transformers, transform);
217
217
  }
218
218
  return transformers;
@@ -221,19 +221,19 @@ function normalizeConfig(config) {
221
221
  // Validate globs to prevent bogus globs.
222
222
  // E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
223
223
  for (let file of config.content.files){
224
- if (typeof file === 'string' && /{([^,]*?)}/g.test(file)) {
225
- _log.default.warn('invalid-glob-braces', [
224
+ if (typeof file === "string" && /{([^,]*?)}/g.test(file)) {
225
+ _log.default.warn("invalid-glob-braces", [
226
226
  `The glob pattern ${(0, _log).dim(file)} in your Tailwind CSS configuration is invalid.`,
227
- `Update it to ${(0, _log).dim(file.replace(/{([^,]*?)}/g, '$1'))} to silence this warning.`
227
+ `Update it to ${(0, _log).dim(file.replace(/{([^,]*?)}/g, "$1"))} to silence this warning.`
228
228
  ]);
229
229
  break;
230
230
  }
231
231
  }
232
232
  if (config.content.files.length === 0) {
233
- _log.default.warn('content-problems', [
234
- 'The `content` option in your Tailwind CSS configuration is missing or empty.',
235
- 'Configure your content sources or your generated CSS will be missing styles.',
236
- 'https://tailwindcss.com/docs/content-configuration',
233
+ _log.default.warn("content-problems", [
234
+ "The `content` option in your Tailwind CSS configuration is missing or empty.",
235
+ "Configure your content sources or your generated CSS will be missing styles.",
236
+ "https://tailwindcss.com/docs/content-configuration",
237
237
  ]);
238
238
  }
239
239
  return config;
@@ -7,9 +7,9 @@ function normalizeScreens(screens, root = true) {
7
7
  if (Array.isArray(screens)) {
8
8
  return screens.map((screen)=>{
9
9
  if (root && Array.isArray(screen)) {
10
- throw new Error('The tuple syntax is not supported for `screens`.');
10
+ throw new Error("The tuple syntax is not supported for `screens`.");
11
11
  }
12
- if (typeof screen === 'string') {
12
+ if (typeof screen === "string") {
13
13
  return {
14
14
  name: screen.toString(),
15
15
  values: [
@@ -22,7 +22,7 @@ function normalizeScreens(screens, root = true) {
22
22
  }
23
23
  let [name, options] = screen;
24
24
  name = name.toString();
25
- if (typeof options === 'string') {
25
+ if (typeof options === "string") {
26
26
  return {
27
27
  name,
28
28
  values: [
@@ -50,7 +50,7 @@ function normalizeScreens(screens, root = true) {
50
50
  }
51
51
  return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {}), false);
52
52
  }
53
- function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {}) {
53
+ function resolveValue({ "min-width": _minWidth , min =_minWidth , max , raw } = {}) {
54
54
  return {
55
55
  min,
56
56
  max,
@@ -3,44 +3,6 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = parseAnimationValue;
6
- const DIRECTIONS = new Set([
7
- 'normal',
8
- 'reverse',
9
- 'alternate',
10
- 'alternate-reverse'
11
- ]);
12
- const PLAY_STATES = new Set([
13
- 'running',
14
- 'paused'
15
- ]);
16
- const FILL_MODES = new Set([
17
- 'none',
18
- 'forwards',
19
- 'backwards',
20
- 'both'
21
- ]);
22
- const ITERATION_COUNTS = new Set([
23
- 'infinite'
24
- ]);
25
- const TIMINGS = new Set([
26
- 'linear',
27
- 'ease',
28
- 'ease-in',
29
- 'ease-out',
30
- 'ease-in-out',
31
- 'step-start',
32
- 'step-end',
33
- ]);
34
- const TIMING_FNS = [
35
- 'cubic-bezier',
36
- 'steps'
37
- ];
38
- const COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
39
- ;
40
- const SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
41
- ;
42
- const TIME = /^(-?[\d.]+m?s)$/;
43
- const DIGIT = /^(\d+)$/;
44
6
  function parseAnimationValue(input) {
45
7
  let animations = input.split(COMMA);
46
8
  return animations.map((animation)=>{
@@ -51,34 +13,34 @@ function parseAnimationValue(input) {
51
13
  let parts = value.split(SPACE);
52
14
  let seen = new Set();
53
15
  for (let part of parts){
54
- if (!seen.has('DIRECTIONS') && DIRECTIONS.has(part)) {
16
+ if (!seen.has("DIRECTIONS") && DIRECTIONS.has(part)) {
55
17
  result.direction = part;
56
- seen.add('DIRECTIONS');
57
- } else if (!seen.has('PLAY_STATES') && PLAY_STATES.has(part)) {
18
+ seen.add("DIRECTIONS");
19
+ } else if (!seen.has("PLAY_STATES") && PLAY_STATES.has(part)) {
58
20
  result.playState = part;
59
- seen.add('PLAY_STATES');
60
- } else if (!seen.has('FILL_MODES') && FILL_MODES.has(part)) {
21
+ seen.add("PLAY_STATES");
22
+ } else if (!seen.has("FILL_MODES") && FILL_MODES.has(part)) {
61
23
  result.fillMode = part;
62
- seen.add('FILL_MODES');
63
- } else if (!seen.has('ITERATION_COUNTS') && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
24
+ seen.add("FILL_MODES");
25
+ } else if (!seen.has("ITERATION_COUNTS") && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
64
26
  result.iterationCount = part;
65
- seen.add('ITERATION_COUNTS');
66
- } else if (!seen.has('TIMING_FUNCTION') && TIMINGS.has(part)) {
27
+ seen.add("ITERATION_COUNTS");
28
+ } else if (!seen.has("TIMING_FUNCTION") && TIMINGS.has(part)) {
67
29
  result.timingFunction = part;
68
- seen.add('TIMING_FUNCTION');
69
- } else if (!seen.has('TIMING_FUNCTION') && TIMING_FNS.some((f)=>part.startsWith(`${f}(`)
30
+ seen.add("TIMING_FUNCTION");
31
+ } else if (!seen.has("TIMING_FUNCTION") && TIMING_FNS.some((f)=>part.startsWith(`${f}(`)
70
32
  )) {
71
33
  result.timingFunction = part;
72
- seen.add('TIMING_FUNCTION');
73
- } else if (!seen.has('DURATION') && TIME.test(part)) {
34
+ seen.add("TIMING_FUNCTION");
35
+ } else if (!seen.has("DURATION") && TIME.test(part)) {
74
36
  result.duration = part;
75
- seen.add('DURATION');
76
- } else if (!seen.has('DELAY') && TIME.test(part)) {
37
+ seen.add("DURATION");
38
+ } else if (!seen.has("DELAY") && TIME.test(part)) {
77
39
  result.delay = part;
78
- seen.add('DELAY');
79
- } else if (!seen.has('NAME')) {
40
+ seen.add("DELAY");
41
+ } else if (!seen.has("NAME")) {
80
42
  result.name = part;
81
- seen.add('NAME');
43
+ seen.add("NAME");
82
44
  } else {
83
45
  if (!result.unknown) result.unknown = [];
84
46
  result.unknown.push(part);
@@ -87,3 +49,41 @@ function parseAnimationValue(input) {
87
49
  return result;
88
50
  });
89
51
  }
52
+ const DIRECTIONS = new Set([
53
+ "normal",
54
+ "reverse",
55
+ "alternate",
56
+ "alternate-reverse"
57
+ ]);
58
+ const PLAY_STATES = new Set([
59
+ "running",
60
+ "paused"
61
+ ]);
62
+ const FILL_MODES = new Set([
63
+ "none",
64
+ "forwards",
65
+ "backwards",
66
+ "both"
67
+ ]);
68
+ const ITERATION_COUNTS = new Set([
69
+ "infinite"
70
+ ]);
71
+ const TIMINGS = new Set([
72
+ "linear",
73
+ "ease",
74
+ "ease-in",
75
+ "ease-out",
76
+ "ease-in-out",
77
+ "step-start",
78
+ "step-end",
79
+ ]);
80
+ const TIMING_FNS = [
81
+ "cubic-bezier",
82
+ "steps"
83
+ ];
84
+ const COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
85
+ ;
86
+ const SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
87
+ ;
88
+ const TIME = /^(-?[\d.]+m?s)$/;
89
+ const DIGIT = /^(\d+)$/;
@@ -5,19 +5,59 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.parseBoxShadowValue = parseBoxShadowValue;
6
6
  exports.formatBoxShadowValue = formatBoxShadowValue;
7
7
  let KEYWORDS = new Set([
8
- 'inset',
9
- 'inherit',
10
- 'initial',
11
- 'revert',
12
- 'unset'
8
+ "inset",
9
+ "inherit",
10
+ "initial",
11
+ "revert",
12
+ "unset"
13
13
  ]);
14
- let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
15
- ;
16
14
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
15
  ;
18
16
  let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
17
+ let SPECIALS = /[(),]/g;
18
+ /**
19
+ * This splits a string on top-level commas.
20
+ *
21
+ * Regex doesn't support recursion (at least not the JS-flavored version).
22
+ * So we have to use a tiny state machine to keep track of paren vs comma
23
+ * placement. Before we'd only exclude commas from the inner-most nested
24
+ * set of parens rather than any commas that were not contained in parens
25
+ * at all which is the intended behavior here.
26
+ *
27
+ * Expected behavior:
28
+ * var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
29
+ * ─┬─ ┬ ┬ ┬
30
+ * x x x ╰──────── Split because top-level
31
+ * ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
32
+ *
33
+ * @param {string} input
34
+ */ function* splitByTopLevelCommas(input) {
35
+ SPECIALS.lastIndex = -1;
36
+ let depth = 0;
37
+ let lastIndex = 0;
38
+ let found = false;
39
+ // Find all parens & commas
40
+ // And only split on commas if they're top-level
41
+ for (let match of input.matchAll(SPECIALS)){
42
+ if (match[0] === "(") depth++;
43
+ if (match[0] === ")") depth--;
44
+ if (match[0] === "," && depth === 0) {
45
+ found = true;
46
+ yield input.substring(lastIndex, match.index);
47
+ lastIndex = match.index + match[0].length;
48
+ }
49
+ }
50
+ // Provide the last segment of the string if available
51
+ // Otherwise the whole string since no commas were found
52
+ // This mirrors the behavior of string.split()
53
+ if (found) {
54
+ yield input.substring(lastIndex);
55
+ } else {
56
+ yield input;
57
+ }
58
+ }
19
59
  function parseBoxShadowValue(input) {
20
- let shadows = input.split(COMMA);
60
+ let shadows = Array.from(splitByTopLevelCommas(input));
21
61
  return shadows.map((shadow)=>{
22
62
  let value = shadow.trim();
23
63
  let result = {
@@ -29,22 +69,22 @@ function parseBoxShadowValue(input) {
29
69
  // Reset index, since the regex is stateful.
30
70
  LENGTH.lastIndex = 0;
31
71
  // Keyword
32
- if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
72
+ if (!seen.has("KEYWORD") && KEYWORDS.has(part)) {
33
73
  result.keyword = part;
34
- seen.add('KEYWORD');
74
+ seen.add("KEYWORD");
35
75
  } else if (LENGTH.test(part)) {
36
- if (!seen.has('X')) {
76
+ if (!seen.has("X")) {
37
77
  result.x = part;
38
- seen.add('X');
39
- } else if (!seen.has('Y')) {
78
+ seen.add("X");
79
+ } else if (!seen.has("Y")) {
40
80
  result.y = part;
41
- seen.add('Y');
42
- } else if (!seen.has('BLUR')) {
81
+ seen.add("Y");
82
+ } else if (!seen.has("BLUR")) {
43
83
  result.blur = part;
44
- seen.add('BLUR');
45
- } else if (!seen.has('SPREAD')) {
84
+ seen.add("BLUR");
85
+ } else if (!seen.has("SPREAD")) {
46
86
  result.spread = part;
47
- seen.add('SPREAD');
87
+ seen.add("SPREAD");
48
88
  }
49
89
  } else {
50
90
  if (!result.color) {
@@ -72,6 +112,6 @@ function formatBoxShadowValue(shadows) {
72
112
  shadow.blur,
73
113
  shadow.spread,
74
114
  shadow.color
75
- ].filter(Boolean).join(' ');
76
- }).join(', ');
115
+ ].filter(Boolean).join(" ");
116
+ }).join(", ");
77
117
  }
@@ -6,58 +6,58 @@ exports.default = parseDependency;
6
6
  var _isGlob = _interopRequireDefault(require("is-glob"));
7
7
  var _globParent = _interopRequireDefault(require("glob-parent"));
8
8
  var _path = _interopRequireDefault(require("path"));
9
- function _interopRequireDefault(obj) {
10
- return obj && obj.__esModule ? obj : {
11
- default: obj
12
- };
13
- }
14
- // Based on `glob-base`
15
- // https://github.com/micromatch/glob-base/blob/master/index.js
16
- function parseGlob(pattern) {
17
- let glob = pattern;
18
- let base = (0, _globParent).default(pattern);
19
- if (base !== '.') {
20
- glob = pattern.substr(base.length);
21
- if (glob.charAt(0) === '/') {
22
- glob = glob.substr(1);
23
- }
24
- }
25
- if (glob.substr(0, 2) === './') {
26
- glob = glob.substr(2);
27
- }
28
- if (glob.charAt(0) === '/') {
29
- glob = glob.substr(1);
30
- }
31
- return {
32
- base,
33
- glob
34
- };
35
- }
36
9
  function parseDependency(normalizedFileOrGlob) {
37
- if (normalizedFileOrGlob.startsWith('!')) {
10
+ if (normalizedFileOrGlob.startsWith("!")) {
38
11
  return null;
39
12
  }
40
13
  let message;
41
14
  if ((0, _isGlob).default(normalizedFileOrGlob)) {
42
15
  let { base , glob } = parseGlob(normalizedFileOrGlob);
43
16
  message = {
44
- type: 'dir-dependency',
17
+ type: "dir-dependency",
45
18
  dir: _path.default.resolve(base),
46
19
  glob
47
20
  };
48
21
  } else {
49
22
  message = {
50
- type: 'dependency',
23
+ type: "dependency",
51
24
  file: _path.default.resolve(normalizedFileOrGlob)
52
25
  };
53
26
  }
54
27
  // rollup-plugin-postcss does not support dir-dependency messages
55
28
  // but directories can be watched in the same way as files
56
- if (message.type === 'dir-dependency' && process.env.ROLLUP_WATCH === 'true') {
29
+ if (message.type === "dir-dependency" && process.env.ROLLUP_WATCH === "true") {
57
30
  message = {
58
- type: 'dependency',
31
+ type: "dependency",
59
32
  file: message.dir
60
33
  };
61
34
  }
62
35
  return message;
63
36
  }
37
+ function _interopRequireDefault(obj) {
38
+ return obj && obj.__esModule ? obj : {
39
+ default: obj
40
+ };
41
+ }
42
+ // Based on `glob-base`
43
+ // https://github.com/micromatch/glob-base/blob/master/index.js
44
+ function parseGlob(pattern) {
45
+ let glob = pattern;
46
+ let base = (0, _globParent).default(pattern);
47
+ if (base !== ".") {
48
+ glob = pattern.substr(base.length);
49
+ if (glob.charAt(0) === "/") {
50
+ glob = glob.substr(1);
51
+ }
52
+ }
53
+ if (glob.substr(0, 2) === "./") {
54
+ glob = glob.substr(2);
55
+ }
56
+ if (glob.charAt(0) === "/") {
57
+ glob = glob.substr(1);
58
+ }
59
+ return {
60
+ base,
61
+ glob
62
+ };
63
+ }