tailwindcss 3.0.22 → 3.1.0

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 (119) hide show
  1. package/CHANGELOG.md +92 -2
  2. package/colors.d.ts +3 -0
  3. package/defaultConfig.d.ts +3 -0
  4. package/defaultTheme.d.ts +3 -0
  5. package/lib/cli-peer-dependencies.js +10 -5
  6. package/lib/cli.js +266 -203
  7. package/lib/constants.js +8 -8
  8. package/lib/corePluginList.js +1 -0
  9. package/lib/corePlugins.js +1662 -1554
  10. package/lib/css/preflight.css +1 -8
  11. package/lib/featureFlags.js +14 -12
  12. package/lib/index.js +16 -6
  13. package/lib/lib/cacheInvalidation.js +87 -0
  14. package/lib/lib/collapseAdjacentRules.js +30 -15
  15. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  16. package/lib/lib/defaultExtractor.js +191 -30
  17. package/lib/lib/detectNesting.js +9 -9
  18. package/lib/lib/evaluateTailwindFunctions.js +37 -28
  19. package/lib/lib/expandApplyAtRules.js +379 -189
  20. package/lib/lib/expandTailwindAtRules.js +168 -144
  21. package/lib/lib/generateRules.js +190 -81
  22. package/lib/lib/getModuleDependencies.js +14 -14
  23. package/lib/lib/normalizeTailwindDirectives.js +35 -35
  24. package/lib/lib/partitionApplyAtRules.js +7 -7
  25. package/lib/lib/regex.js +52 -0
  26. package/lib/lib/resolveDefaultsAtRules.js +80 -79
  27. package/lib/lib/setupContextUtils.js +207 -170
  28. package/lib/lib/setupTrackingContext.js +61 -63
  29. package/lib/lib/sharedState.js +11 -8
  30. package/lib/lib/substituteScreenAtRules.js +3 -4
  31. package/lib/postcss-plugins/nesting/README.md +2 -2
  32. package/lib/postcss-plugins/nesting/index.js +1 -1
  33. package/lib/postcss-plugins/nesting/plugin.js +40 -9
  34. package/lib/processTailwindFeatures.js +7 -7
  35. package/lib/public/colors.js +241 -241
  36. package/lib/public/resolve-config.js +5 -5
  37. package/lib/util/buildMediaQuery.js +2 -3
  38. package/lib/util/cloneDeep.js +3 -5
  39. package/lib/util/cloneNodes.js +12 -1
  40. package/lib/util/color.js +42 -51
  41. package/lib/util/createPlugin.js +1 -2
  42. package/lib/util/createUtilityPlugin.js +6 -7
  43. package/lib/util/dataTypes.js +85 -81
  44. package/lib/util/escapeClassName.js +5 -5
  45. package/lib/util/escapeCommas.js +1 -1
  46. package/lib/util/flattenColorPalette.js +4 -7
  47. package/lib/util/formatVariantSelector.js +82 -75
  48. package/lib/util/getAllConfigs.js +15 -10
  49. package/lib/util/hashConfig.js +5 -5
  50. package/lib/util/isKeyframeRule.js +1 -1
  51. package/lib/util/isPlainObject.js +1 -1
  52. package/lib/util/isValidArbitraryValue.js +26 -27
  53. package/lib/util/log.js +9 -10
  54. package/lib/util/nameClass.js +7 -7
  55. package/lib/util/negateValue.js +4 -5
  56. package/lib/util/normalizeConfig.js +68 -58
  57. package/lib/util/normalizeScreens.js +5 -6
  58. package/lib/util/parseAnimationValue.js +56 -57
  59. package/lib/util/parseBoxShadowValue.js +19 -20
  60. package/lib/util/parseDependency.js +32 -32
  61. package/lib/util/parseObjectStyles.js +6 -6
  62. package/lib/util/pluginUtils.js +20 -12
  63. package/lib/util/prefixSelector.js +1 -1
  64. package/lib/util/resolveConfig.js +81 -58
  65. package/lib/util/resolveConfigPath.js +16 -16
  66. package/lib/util/responsive.js +6 -6
  67. package/lib/util/splitAtTopLevelOnly.js +90 -0
  68. package/lib/util/toColorValue.js +1 -1
  69. package/lib/util/toPath.js +2 -2
  70. package/lib/util/transformThemeValue.js +30 -28
  71. package/lib/util/validateConfig.js +21 -0
  72. package/lib/util/withAlphaVariable.js +23 -23
  73. package/package.json +33 -27
  74. package/peers/index.js +7728 -5848
  75. package/plugin.d.ts +11 -0
  76. package/scripts/generate-types.js +52 -0
  77. package/src/cli-peer-dependencies.js +7 -1
  78. package/src/cli.js +118 -24
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +142 -30
  81. package/src/css/preflight.css +1 -8
  82. package/src/featureFlags.js +4 -4
  83. package/src/index.js +15 -1
  84. package/src/lib/cacheInvalidation.js +52 -0
  85. package/src/lib/collapseAdjacentRules.js +21 -2
  86. package/src/lib/defaultExtractor.js +177 -33
  87. package/src/lib/evaluateTailwindFunctions.js +20 -4
  88. package/src/lib/expandApplyAtRules.js +418 -186
  89. package/src/lib/expandTailwindAtRules.js +30 -10
  90. package/src/lib/generateRules.js +142 -51
  91. package/src/lib/regex.js +74 -0
  92. package/src/lib/resolveDefaultsAtRules.js +7 -3
  93. package/src/lib/setupContextUtils.js +142 -87
  94. package/src/lib/setupTrackingContext.js +7 -3
  95. package/src/lib/sharedState.js +2 -0
  96. package/src/postcss-plugins/nesting/README.md +2 -2
  97. package/src/postcss-plugins/nesting/plugin.js +36 -0
  98. package/src/util/cloneNodes.js +14 -1
  99. package/src/util/color.js +25 -21
  100. package/src/util/dataTypes.js +14 -6
  101. package/src/util/formatVariantSelector.js +79 -62
  102. package/src/util/getAllConfigs.js +7 -0
  103. package/src/util/log.js +8 -8
  104. package/src/util/normalizeConfig.js +0 -8
  105. package/src/util/parseBoxShadowValue.js +3 -2
  106. package/src/util/pluginUtils.js +13 -1
  107. package/src/util/resolveConfig.js +66 -22
  108. package/src/util/splitAtTopLevelOnly.js +71 -0
  109. package/src/util/toPath.js +1 -1
  110. package/src/util/transformThemeValue.js +4 -2
  111. package/src/util/validateConfig.js +13 -0
  112. package/src/util/withAlphaVariable.js +1 -1
  113. package/stubs/defaultConfig.stub.js +5 -1
  114. package/stubs/simpleConfig.stub.js +1 -0
  115. package/types/config.d.ts +325 -0
  116. package/types/generated/.gitkeep +0 -0
  117. package/types/generated/colors.d.ts +276 -0
  118. package/types/generated/corePluginList.d.ts +1 -0
  119. package/types/index.d.ts +1 -0
@@ -4,26 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.normalizeConfig = normalizeConfig;
6
6
  var _log = _interopRequireWildcard(require("./log"));
7
+ function _getRequireWildcardCache() {
8
+ if (typeof WeakMap !== "function") return null;
9
+ var cache = new WeakMap();
10
+ _getRequireWildcardCache = function() {
11
+ return cache;
12
+ };
13
+ return cache;
14
+ }
7
15
  function _interopRequireWildcard(obj) {
8
16
  if (obj && obj.__esModule) {
9
17
  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
- }
18
+ }
19
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
20
+ return {
21
+ default: obj
22
+ };
23
+ }
24
+ var cache = _getRequireWildcardCache();
25
+ if (cache && cache.has(obj)) {
26
+ return cache.get(obj);
27
+ }
28
+ var newObj = {};
29
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
30
+ for(var key in obj){
31
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
32
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
33
+ if (desc && (desc.get || desc.set)) {
34
+ Object.defineProperty(newObj, key, desc);
35
+ } else {
36
+ newObj[key] = obj[key];
22
37
  }
23
38
  }
24
- newObj.default = obj;
25
- return newObj;
26
39
  }
40
+ newObj.default = obj;
41
+ if (cache) {
42
+ cache.set(obj, newObj);
43
+ }
44
+ return newObj;
27
45
  }
28
46
  function normalizeConfig(config) {
29
47
  // Quick structure validation
@@ -50,45 +68,44 @@ function normalizeConfig(config) {
50
68
  return false;
51
69
  }
52
70
  // `config.content` should be an object or an array
53
- if (!Array.isArray(config.content) && !(typeof config.content === 'object' && config.content !== null)) {
71
+ if (!Array.isArray(config.content) && !(typeof config.content === "object" && config.content !== null)) {
54
72
  return false;
55
73
  }
56
74
  // When `config.content` is an array, it should consist of FilePaths or RawFiles
57
75
  if (Array.isArray(config.content)) {
58
76
  return config.content.every((path)=>{
59
77
  // `path` can be a string
60
- if (typeof path === 'string') return true;
78
+ if (typeof path === "string") return true;
61
79
  // `path` can be an object { raw: string, extension?: string }
62
80
  // `raw` must be a string
63
- if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== 'string') return false;
81
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
64
82
  // `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') {
83
+ if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
66
84
  return false;
67
85
  }
68
86
  return true;
69
87
  });
70
88
  }
71
89
  // When `config.content` is an object
72
- if (typeof config.content === 'object' && config.content !== null) {
90
+ if (typeof config.content === "object" && config.content !== null) {
73
91
  // Only `files`, `extract` and `transform` can exist in `config.content`
74
92
  if (Object.keys(config.content).some((key)=>![
75
- 'files',
76
- 'extract',
77
- 'transform'
78
- ].includes(key)
79
- )) {
93
+ "files",
94
+ "extract",
95
+ "transform"
96
+ ].includes(key))) {
80
97
  return false;
81
98
  }
82
99
  // `config.content.files` should exist of FilePaths or RawFiles
83
100
  if (Array.isArray(config.content.files)) {
84
101
  if (!config.content.files.every((path)=>{
85
102
  // `path` can be a string
86
- if (typeof path === 'string') return true;
103
+ if (typeof path === "string") return true;
87
104
  // `path` can be an object { raw: string, extension?: string }
88
105
  // `raw` must be a string
89
- if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== 'string') return false;
106
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
90
107
  // `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') {
108
+ if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
92
109
  return false;
93
110
  }
94
111
  return true;
@@ -96,23 +113,23 @@ function normalizeConfig(config) {
96
113
  return false;
97
114
  }
98
115
  // `config.content.extract` is optional, and can be a Function or a Record<String, Function>
99
- if (typeof config.content.extract === 'object') {
116
+ if (typeof config.content.extract === "object") {
100
117
  for (let value of Object.values(config.content.extract)){
101
- if (typeof value !== 'function') {
118
+ if (typeof value !== "function") {
102
119
  return false;
103
120
  }
104
121
  }
105
- } else if (!(config.content.extract === undefined || typeof config.content.extract === 'function')) {
122
+ } else if (!(config.content.extract === undefined || typeof config.content.extract === "function")) {
106
123
  return false;
107
124
  }
108
125
  // `config.content.transform` is optional, and can be a Function or a Record<String, Function>
109
- if (typeof config.content.transform === 'object') {
126
+ if (typeof config.content.transform === "object") {
110
127
  for (let value of Object.values(config.content.transform)){
111
- if (typeof value !== 'function') {
128
+ if (typeof value !== "function") {
112
129
  return false;
113
130
  }
114
131
  }
115
- } else if (!(config.content.transform === undefined || typeof config.content.transform === 'function')) {
132
+ } else if (!(config.content.transform === undefined || typeof config.content.transform === "function")) {
116
133
  return false;
117
134
  }
118
135
  }
@@ -121,10 +138,10 @@ function normalizeConfig(config) {
121
138
  return false;
122
139
  })();
123
140
  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',
141
+ _log.default.warn("purge-deprecation", [
142
+ "The `purge`/`content` options have changed in Tailwind CSS v3.0.",
143
+ "Update your configuration file to eliminate this warning.",
144
+ "https://tailwindcss.com/docs/upgrade-guide#configure-content-sources",
128
145
  ]);
129
146
  }
130
147
  // Normalize the `safelist`
@@ -138,16 +155,16 @@ function normalizeConfig(config) {
138
155
  return [];
139
156
  })();
140
157
  // 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',
158
+ if (typeof config.prefix === "function") {
159
+ _log.default.warn("prefix-function", [
160
+ "As of Tailwind CSS v3.0, `prefix` cannot be a function.",
161
+ "Update `prefix` in your configuration to be a string to eliminate this warning.",
162
+ "https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function",
146
163
  ]);
147
- config.prefix = '';
164
+ config.prefix = "";
148
165
  } else {
149
166
  var _prefix;
150
- config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : '';
167
+ config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : "";
151
168
  }
152
169
  // Normalize the `content`
153
170
  config.content = {
@@ -186,7 +203,7 @@ function normalizeConfig(config) {
186
203
  extractors.DEFAULT = defaultExtractor;
187
204
  }
188
205
  // Functions
189
- if (typeof extract === 'function') {
206
+ if (typeof extract === "function") {
190
207
  extractors.DEFAULT = extract;
191
208
  } else if (Array.isArray(extract)) {
192
209
  for (let { extensions , extractor } of extract !== null && extract !== void 0 ? extract : []){
@@ -194,7 +211,7 @@ function normalizeConfig(config) {
194
211
  extractors[extension] = extractor;
195
212
  }
196
213
  }
197
- } else if (typeof extract === 'object' && extract !== null) {
214
+ } else if (typeof extract === "object" && extract !== null) {
198
215
  Object.assign(extractors, extract);
199
216
  }
200
217
  return extractors;
@@ -209,10 +226,10 @@ function normalizeConfig(config) {
209
226
  return {};
210
227
  })();
211
228
  let transformers = {};
212
- if (typeof transform === 'function') {
229
+ if (typeof transform === "function") {
213
230
  transformers.DEFAULT = transform;
214
231
  }
215
- if (typeof transform === 'object' && transform !== null) {
232
+ if (typeof transform === "object" && transform !== null) {
216
233
  Object.assign(transformers, transform);
217
234
  }
218
235
  return transformers;
@@ -221,20 +238,13 @@ function normalizeConfig(config) {
221
238
  // Validate globs to prevent bogus globs.
222
239
  // E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
223
240
  for (let file of config.content.files){
224
- if (typeof file === 'string' && /{([^,]*?)}/g.test(file)) {
225
- _log.default.warn('invalid-glob-braces', [
241
+ if (typeof file === "string" && /{([^,]*?)}/g.test(file)) {
242
+ _log.default.warn("invalid-glob-braces", [
226
243
  `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.`
244
+ `Update it to ${(0, _log).dim(file.replace(/{([^,]*?)}/g, "$1"))} to silence this warning.`
228
245
  ]);
229
246
  break;
230
247
  }
231
248
  }
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',
237
- ]);
238
- }
239
249
  return config;
240
250
  }
@@ -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: [
@@ -36,8 +36,7 @@ function normalizeScreens(screens, root = true) {
36
36
  if (Array.isArray(options)) {
37
37
  return {
38
38
  name,
39
- values: options.map((option)=>resolveValue(option)
40
- )
39
+ values: options.map((option)=>resolveValue(option))
41
40
  };
42
41
  }
43
42
  return {
@@ -50,7 +49,7 @@ function normalizeScreens(screens, root = true) {
50
49
  }
51
50
  return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {}), false);
52
51
  }
53
- function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {}) {
52
+ function resolveValue({ "min-width": _minWidth , min =_minWidth , max , raw } = {}) {
54
53
  return {
55
54
  min,
56
55
  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,33 @@ 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}(`)
70
- )) {
30
+ seen.add("TIMING_FUNCTION");
31
+ } else if (!seen.has("TIMING_FUNCTION") && TIMING_FNS.some((f)=>part.startsWith(`${f}(`))) {
71
32
  result.timingFunction = part;
72
- seen.add('TIMING_FUNCTION');
73
- } else if (!seen.has('DURATION') && TIME.test(part)) {
33
+ seen.add("TIMING_FUNCTION");
34
+ } else if (!seen.has("DURATION") && TIME.test(part)) {
74
35
  result.duration = part;
75
- seen.add('DURATION');
76
- } else if (!seen.has('DELAY') && TIME.test(part)) {
36
+ seen.add("DURATION");
37
+ } else if (!seen.has("DELAY") && TIME.test(part)) {
77
38
  result.delay = part;
78
- seen.add('DELAY');
79
- } else if (!seen.has('NAME')) {
39
+ seen.add("DELAY");
40
+ } else if (!seen.has("NAME")) {
80
41
  result.name = part;
81
- seen.add('NAME');
42
+ seen.add("NAME");
82
43
  } else {
83
44
  if (!result.unknown) result.unknown = [];
84
45
  result.unknown.push(part);
@@ -87,3 +48,41 @@ function parseAnimationValue(input) {
87
48
  return result;
88
49
  });
89
50
  }
51
+ const DIRECTIONS = new Set([
52
+ "normal",
53
+ "reverse",
54
+ "alternate",
55
+ "alternate-reverse"
56
+ ]);
57
+ const PLAY_STATES = new Set([
58
+ "running",
59
+ "paused"
60
+ ]);
61
+ const FILL_MODES = new Set([
62
+ "none",
63
+ "forwards",
64
+ "backwards",
65
+ "both"
66
+ ]);
67
+ const ITERATION_COUNTS = new Set([
68
+ "infinite"
69
+ ]);
70
+ const TIMINGS = new Set([
71
+ "linear",
72
+ "ease",
73
+ "ease-in",
74
+ "ease-out",
75
+ "ease-in-out",
76
+ "step-start",
77
+ "step-end",
78
+ ]);
79
+ const TIMING_FNS = [
80
+ "cubic-bezier",
81
+ "steps"
82
+ ];
83
+ const COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
84
+ ;
85
+ const SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
86
+ ;
87
+ const TIME = /^(-?[\d.]+m?s)$/;
88
+ const DIGIT = /^(\d+)$/;
@@ -4,20 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.parseBoxShadowValue = parseBoxShadowValue;
6
6
  exports.formatBoxShadowValue = formatBoxShadowValue;
7
+ var _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
7
8
  let KEYWORDS = new Set([
8
- 'inset',
9
- 'inherit',
10
- 'initial',
11
- 'revert',
12
- 'unset'
9
+ "inset",
10
+ "inherit",
11
+ "initial",
12
+ "revert",
13
+ "unset"
13
14
  ]);
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
15
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
16
  ;
18
17
  let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
19
18
  function parseBoxShadowValue(input) {
20
- let shadows = input.split(COMMA);
19
+ let shadows = Array.from((0, _splitAtTopLevelOnly).splitAtTopLevelOnly(input, ","));
21
20
  return shadows.map((shadow)=>{
22
21
  let value = shadow.trim();
23
22
  let result = {
@@ -29,22 +28,22 @@ function parseBoxShadowValue(input) {
29
28
  // Reset index, since the regex is stateful.
30
29
  LENGTH.lastIndex = 0;
31
30
  // Keyword
32
- if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
31
+ if (!seen.has("KEYWORD") && KEYWORDS.has(part)) {
33
32
  result.keyword = part;
34
- seen.add('KEYWORD');
33
+ seen.add("KEYWORD");
35
34
  } else if (LENGTH.test(part)) {
36
- if (!seen.has('X')) {
35
+ if (!seen.has("X")) {
37
36
  result.x = part;
38
- seen.add('X');
39
- } else if (!seen.has('Y')) {
37
+ seen.add("X");
38
+ } else if (!seen.has("Y")) {
40
39
  result.y = part;
41
- seen.add('Y');
42
- } else if (!seen.has('BLUR')) {
40
+ seen.add("Y");
41
+ } else if (!seen.has("BLUR")) {
43
42
  result.blur = part;
44
- seen.add('BLUR');
45
- } else if (!seen.has('SPREAD')) {
43
+ seen.add("BLUR");
44
+ } else if (!seen.has("SPREAD")) {
46
45
  result.spread = part;
47
- seen.add('SPREAD');
46
+ seen.add("SPREAD");
48
47
  }
49
48
  } else {
50
49
  if (!result.color) {
@@ -72,6 +71,6 @@ function formatBoxShadowValue(shadows) {
72
71
  shadow.blur,
73
72
  shadow.spread,
74
73
  shadow.color
75
- ].filter(Boolean).join(' ');
76
- }).join(', ');
74
+ ].filter(Boolean).join(" ");
75
+ }).join(", ");
77
76
  }
@@ -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
+ }
@@ -6,11 +6,6 @@ exports.default = parseObjectStyles;
6
6
  var _postcss = _interopRequireDefault(require("postcss"));
7
7
  var _postcssNested = _interopRequireDefault(require("postcss-nested"));
8
8
  var _postcssJs = _interopRequireDefault(require("postcss-js"));
9
- function _interopRequireDefault(obj) {
10
- return obj && obj.__esModule ? obj : {
11
- default: obj
12
- };
13
- }
14
9
  function parseObjectStyles(styles) {
15
10
  if (!Array.isArray(styles)) {
16
11
  return parseObjectStyles([
@@ -21,7 +16,7 @@ function parseObjectStyles(styles) {
21
16
  return (0, _postcss).default([
22
17
  (0, _postcssNested).default({
23
18
  bubble: [
24
- 'screen'
19
+ "screen"
25
20
  ]
26
21
  }),
27
22
  ]).process(style, {
@@ -29,3 +24,8 @@ function parseObjectStyles(styles) {
29
24
  }).root.nodes;
30
25
  });
31
26
  }
27
+ function _interopRequireDefault(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }