tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce

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 (148) hide show
  1. package/CHANGELOG.md +380 -1
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +10 -5
  11. package/lib/cli.js +311 -213
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +11 -1
  14. package/lib/corePlugins.js +1895 -1773
  15. package/lib/css/preflight.css +19 -13
  16. package/lib/featureFlags.js +22 -16
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +187 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +40 -24
  24. package/lib/lib/expandApplyAtRules.js +414 -157
  25. package/lib/lib/expandTailwindAtRules.js +156 -151
  26. package/lib/lib/generateRules.js +402 -68
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +45 -36
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/regex.js +53 -0
  31. package/lib/lib/resolveDefaultsAtRules.js +105 -90
  32. package/lib/lib/setupContextUtils.js +416 -291
  33. package/lib/lib/setupTrackingContext.js +60 -56
  34. package/lib/lib/sharedState.js +38 -15
  35. package/lib/lib/substituteScreenAtRules.js +9 -6
  36. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  37. package/lib/postcss-plugins/nesting/index.js +17 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  39. package/lib/processTailwindFeatures.js +21 -9
  40. package/lib/public/colors.js +244 -248
  41. package/lib/public/resolve-config.js +5 -5
  42. package/lib/util/buildMediaQuery.js +13 -24
  43. package/lib/util/cloneDeep.js +1 -1
  44. package/lib/util/cloneNodes.js +12 -1
  45. package/lib/util/color.js +43 -32
  46. package/lib/util/createPlugin.js +1 -2
  47. package/lib/util/createUtilityPlugin.js +13 -17
  48. package/lib/util/dataTypes.js +114 -74
  49. package/lib/util/defaults.js +6 -0
  50. package/lib/util/escapeClassName.js +5 -5
  51. package/lib/util/escapeCommas.js +1 -1
  52. package/lib/util/flattenColorPalette.js +2 -4
  53. package/lib/util/formatVariantSelector.js +194 -0
  54. package/lib/util/getAllConfigs.js +13 -5
  55. package/lib/util/hashConfig.js +5 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +1 -1
  58. package/lib/util/isValidArbitraryValue.js +64 -0
  59. package/lib/util/log.js +35 -19
  60. package/lib/util/nameClass.js +7 -6
  61. package/lib/util/negateValue.js +5 -3
  62. package/lib/util/normalizeConfig.js +233 -0
  63. package/lib/util/normalizeScreens.js +59 -0
  64. package/lib/util/parseAnimationValue.js +56 -56
  65. package/lib/util/parseBoxShadowValue.js +76 -0
  66. package/lib/util/parseDependency.js +32 -32
  67. package/lib/util/parseObjectStyles.js +6 -6
  68. package/lib/util/pluginUtils.js +67 -170
  69. package/lib/util/prefixSelector.js +4 -7
  70. package/lib/util/resolveConfig.js +123 -133
  71. package/lib/util/resolveConfigPath.js +17 -18
  72. package/lib/util/responsive.js +6 -6
  73. package/lib/util/splitAtTopLevelOnly.js +72 -0
  74. package/lib/util/toColorValue.js +1 -2
  75. package/lib/util/toPath.js +6 -1
  76. package/lib/util/transformThemeValue.js +42 -34
  77. package/lib/util/validateConfig.js +21 -0
  78. package/lib/util/withAlphaVariable.js +19 -19
  79. package/nesting/index.js +2 -12
  80. package/package.json +41 -42
  81. package/peers/index.js +11539 -10859
  82. package/plugin.d.ts +11 -0
  83. package/plugin.js +2 -1
  84. package/resolveConfig.js +2 -1
  85. package/scripts/create-plugin-list.js +2 -2
  86. package/scripts/generate-types.js +52 -0
  87. package/src/cli-peer-dependencies.js +7 -1
  88. package/src/cli.js +174 -41
  89. package/src/corePluginList.js +1 -1
  90. package/src/corePlugins.js +641 -596
  91. package/src/css/preflight.css +19 -13
  92. package/src/featureFlags.js +16 -10
  93. package/src/index.js +14 -6
  94. package/src/lib/cacheInvalidation.js +52 -0
  95. package/src/lib/collapseAdjacentRules.js +21 -2
  96. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  97. package/src/lib/defaultExtractor.js +192 -0
  98. package/src/lib/detectNesting.js +22 -3
  99. package/src/lib/evaluateTailwindFunctions.js +24 -7
  100. package/src/lib/expandApplyAtRules.js +442 -154
  101. package/src/lib/expandTailwindAtRules.js +91 -65
  102. package/src/lib/generateRules.js +409 -43
  103. package/src/lib/normalizeTailwindDirectives.js +10 -3
  104. package/src/lib/partitionApplyAtRules.js +52 -0
  105. package/src/lib/regex.js +74 -0
  106. package/src/lib/resolveDefaultsAtRules.js +74 -53
  107. package/src/lib/setupContextUtils.js +388 -208
  108. package/src/lib/setupTrackingContext.js +15 -12
  109. package/src/lib/sharedState.js +42 -7
  110. package/src/lib/substituteScreenAtRules.js +6 -3
  111. package/src/postcss-plugins/nesting/README.md +42 -0
  112. package/src/postcss-plugins/nesting/index.js +13 -0
  113. package/src/postcss-plugins/nesting/plugin.js +80 -0
  114. package/src/processTailwindFeatures.js +17 -2
  115. package/src/public/colors.js +4 -9
  116. package/src/util/buildMediaQuery.js +14 -18
  117. package/src/util/cloneNodes.js +14 -1
  118. package/src/util/color.js +31 -14
  119. package/src/util/createUtilityPlugin.js +2 -2
  120. package/src/util/dataTypes.js +56 -16
  121. package/src/util/defaults.js +6 -0
  122. package/src/util/formatVariantSelector.js +213 -0
  123. package/src/util/getAllConfigs.js +7 -0
  124. package/src/util/isValidArbitraryValue.js +61 -0
  125. package/src/util/log.js +23 -22
  126. package/src/util/nameClass.js +2 -2
  127. package/src/util/negateValue.js +4 -2
  128. package/src/util/normalizeConfig.js +262 -0
  129. package/src/util/normalizeScreens.js +45 -0
  130. package/src/util/parseBoxShadowValue.js +72 -0
  131. package/src/util/pluginUtils.js +51 -147
  132. package/src/util/prefixSelector.js +7 -8
  133. package/src/util/resolveConfig.js +108 -79
  134. package/src/util/splitAtTopLevelOnly.js +71 -0
  135. package/src/util/toPath.js +23 -1
  136. package/src/util/transformThemeValue.js +24 -7
  137. package/src/util/validateConfig.js +13 -0
  138. package/stubs/defaultConfig.stub.js +157 -94
  139. package/stubs/simpleConfig.stub.js +0 -1
  140. package/types/config.d.ts +325 -0
  141. package/types/generated/.gitkeep +0 -0
  142. package/types/generated/colors.d.ts +276 -0
  143. package/types/generated/corePluginList.d.ts +1 -0
  144. package/types/index.d.ts +1 -0
  145. package/types.d.ts +1 -0
  146. package/lib/lib/setupWatchingContext.js +0 -284
  147. package/nesting/plugin.js +0 -41
  148. package/src/lib/setupWatchingContext.js +0 -306
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.normalizeConfig = normalizeConfig;
6
+ var _log = _interopRequireWildcard(require("./log"));
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
+ function normalizeConfig(config) {
29
+ // Quick structure validation
30
+ /**
31
+ * type FilePath = string
32
+ * type RawFile = { raw: string, extension?: string }
33
+ * type ExtractorFn = (content: string) => Array<string>
34
+ * type TransformerFn = (content: string) => string
35
+ *
36
+ * type Content =
37
+ * | Array<FilePath | RawFile>
38
+ * | {
39
+ * files: Array<FilePath | RawFile>,
40
+ * extract?: ExtractorFn | { [extension: string]: ExtractorFn }
41
+ * transform?: TransformerFn | { [extension: string]: TransformerFn }
42
+ * }
43
+ */ let valid = (()=>{
44
+ // `config.purge` should not exist anymore
45
+ if (config.purge) {
46
+ return false;
47
+ }
48
+ // `config.content` should exist
49
+ if (!config.content) {
50
+ return false;
51
+ }
52
+ // `config.content` should be an object or an array
53
+ if (!Array.isArray(config.content) && !(typeof config.content === "object" && config.content !== null)) {
54
+ return false;
55
+ }
56
+ // When `config.content` is an array, it should consist of FilePaths or RawFiles
57
+ if (Array.isArray(config.content)) {
58
+ return config.content.every((path)=>{
59
+ // `path` can be a string
60
+ if (typeof path === "string") return true;
61
+ // `path` can be an object { raw: string, extension?: string }
62
+ // `raw` must be a string
63
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
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") {
66
+ return false;
67
+ }
68
+ return true;
69
+ });
70
+ }
71
+ // When `config.content` is an object
72
+ if (typeof config.content === "object" && config.content !== null) {
73
+ // Only `files`, `extract` and `transform` can exist in `config.content`
74
+ if (Object.keys(config.content).some((key)=>![
75
+ "files",
76
+ "extract",
77
+ "transform"
78
+ ].includes(key)
79
+ )) {
80
+ return false;
81
+ }
82
+ // `config.content.files` should exist of FilePaths or RawFiles
83
+ if (Array.isArray(config.content.files)) {
84
+ if (!config.content.files.every((path)=>{
85
+ // `path` can be a string
86
+ if (typeof path === "string") return true;
87
+ // `path` can be an object { raw: string, extension?: string }
88
+ // `raw` must be a string
89
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
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") {
92
+ return false;
93
+ }
94
+ return true;
95
+ })) {
96
+ return false;
97
+ }
98
+ // `config.content.extract` is optional, and can be a Function or a Record<String, Function>
99
+ if (typeof config.content.extract === "object") {
100
+ for (let value of Object.values(config.content.extract)){
101
+ if (typeof value !== "function") {
102
+ return false;
103
+ }
104
+ }
105
+ } else if (!(config.content.extract === undefined || typeof config.content.extract === "function")) {
106
+ return false;
107
+ }
108
+ // `config.content.transform` is optional, and can be a Function or a Record<String, Function>
109
+ if (typeof config.content.transform === "object") {
110
+ for (let value of Object.values(config.content.transform)){
111
+ if (typeof value !== "function") {
112
+ return false;
113
+ }
114
+ }
115
+ } else if (!(config.content.transform === undefined || typeof config.content.transform === "function")) {
116
+ return false;
117
+ }
118
+ }
119
+ return true;
120
+ }
121
+ return false;
122
+ })();
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",
128
+ ]);
129
+ }
130
+ // Normalize the `safelist`
131
+ config.safelist = (()=>{
132
+ var ref;
133
+ let { content , purge , safelist } = config;
134
+ if (Array.isArray(safelist)) return safelist;
135
+ if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return content.safelist;
136
+ if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return purge.safelist;
137
+ if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return purge.options.safelist;
138
+ return [];
139
+ })();
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",
146
+ ]);
147
+ config.prefix = "";
148
+ } else {
149
+ var _prefix;
150
+ config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : "";
151
+ }
152
+ // Normalize the `content`
153
+ config.content = {
154
+ files: (()=>{
155
+ let { content , purge } = config;
156
+ if (Array.isArray(purge)) return purge;
157
+ if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
158
+ if (Array.isArray(content)) return content;
159
+ if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
160
+ if (Array.isArray(content === null || content === void 0 ? void 0 : content.files)) return content.files;
161
+ return [];
162
+ })(),
163
+ extract: (()=>{
164
+ let extract = (()=>{
165
+ var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9;
166
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.extract) return config.purge.extract;
167
+ if ((ref1 = config.content) === null || ref1 === void 0 ? void 0 : ref1.extract) return config.content.extract;
168
+ if ((ref2 = config.purge) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.extract) === null || ref3 === void 0 ? void 0 : ref3.DEFAULT) return config.purge.extract.DEFAULT;
169
+ if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.extract) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.extract.DEFAULT;
170
+ if ((ref6 = config.purge) === null || ref6 === void 0 ? void 0 : (ref7 = ref6.options) === null || ref7 === void 0 ? void 0 : ref7.extractors) return config.purge.options.extractors;
171
+ if ((ref8 = config.content) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.options) === null || ref9 === void 0 ? void 0 : ref9.extractors) return config.content.options.extractors;
172
+ return {};
173
+ })();
174
+ let extractors = {};
175
+ let defaultExtractor = (()=>{
176
+ var ref, ref10, ref11, ref12;
177
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
178
+ return config.purge.options.defaultExtractor;
179
+ }
180
+ if ((ref11 = config.content) === null || ref11 === void 0 ? void 0 : (ref12 = ref11.options) === null || ref12 === void 0 ? void 0 : ref12.defaultExtractor) {
181
+ return config.content.options.defaultExtractor;
182
+ }
183
+ return undefined;
184
+ })();
185
+ if (defaultExtractor !== undefined) {
186
+ extractors.DEFAULT = defaultExtractor;
187
+ }
188
+ // Functions
189
+ if (typeof extract === "function") {
190
+ extractors.DEFAULT = extract;
191
+ } else if (Array.isArray(extract)) {
192
+ for (let { extensions , extractor } of extract !== null && extract !== void 0 ? extract : []){
193
+ for (let extension of extensions){
194
+ extractors[extension] = extractor;
195
+ }
196
+ }
197
+ } else if (typeof extract === "object" && extract !== null) {
198
+ Object.assign(extractors, extract);
199
+ }
200
+ return extractors;
201
+ })(),
202
+ transform: (()=>{
203
+ let transform = (()=>{
204
+ var ref, ref13, ref14, ref15, ref16, ref17;
205
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
206
+ if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
207
+ if ((ref14 = config.purge) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.transform) === null || ref15 === void 0 ? void 0 : ref15.DEFAULT) return config.purge.transform.DEFAULT;
208
+ if ((ref16 = config.content) === null || ref16 === void 0 ? void 0 : (ref17 = ref16.transform) === null || ref17 === void 0 ? void 0 : ref17.DEFAULT) return config.content.transform.DEFAULT;
209
+ return {};
210
+ })();
211
+ let transformers = {};
212
+ if (typeof transform === "function") {
213
+ transformers.DEFAULT = transform;
214
+ }
215
+ if (typeof transform === "object" && transform !== null) {
216
+ Object.assign(transformers, transform);
217
+ }
218
+ return transformers;
219
+ })()
220
+ };
221
+ // Validate globs to prevent bogus globs.
222
+ // E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
223
+ for (let file of config.content.files){
224
+ if (typeof file === "string" && /{([^,]*?)}/g.test(file)) {
225
+ _log.default.warn("invalid-glob-braces", [
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.`
228
+ ]);
229
+ break;
230
+ }
231
+ }
232
+ return config;
233
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.normalizeScreens = normalizeScreens;
6
+ function normalizeScreens(screens, root = true) {
7
+ if (Array.isArray(screens)) {
8
+ return screens.map((screen)=>{
9
+ if (root && Array.isArray(screen)) {
10
+ throw new Error("The tuple syntax is not supported for `screens`.");
11
+ }
12
+ if (typeof screen === "string") {
13
+ return {
14
+ name: screen.toString(),
15
+ values: [
16
+ {
17
+ min: screen,
18
+ max: undefined
19
+ }
20
+ ]
21
+ };
22
+ }
23
+ let [name, options] = screen;
24
+ name = name.toString();
25
+ if (typeof options === "string") {
26
+ return {
27
+ name,
28
+ values: [
29
+ {
30
+ min: options,
31
+ max: undefined
32
+ }
33
+ ]
34
+ };
35
+ }
36
+ if (Array.isArray(options)) {
37
+ return {
38
+ name,
39
+ values: options.map((option)=>resolveValue(option)
40
+ )
41
+ };
42
+ }
43
+ return {
44
+ name,
45
+ values: [
46
+ resolveValue(options)
47
+ ]
48
+ };
49
+ });
50
+ }
51
+ return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {}), false);
52
+ }
53
+ function resolveValue({ "min-width": _minWidth , min =_minWidth , max , raw } = {}) {
54
+ return {
55
+ min,
56
+ max,
57
+ raw
58
+ };
59
+ }
@@ -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+)$/;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.parseBoxShadowValue = parseBoxShadowValue;
6
+ exports.formatBoxShadowValue = formatBoxShadowValue;
7
+ var _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
8
+ let KEYWORDS = new Set([
9
+ "inset",
10
+ "inherit",
11
+ "initial",
12
+ "revert",
13
+ "unset"
14
+ ]);
15
+ let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
16
+ ;
17
+ let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
18
+ function parseBoxShadowValue(input) {
19
+ let shadows = Array.from((0, _splitAtTopLevelOnly).splitAtTopLevelOnly(input, ","));
20
+ return shadows.map((shadow)=>{
21
+ let value = shadow.trim();
22
+ let result = {
23
+ raw: value
24
+ };
25
+ let parts = value.split(SPACE);
26
+ let seen = new Set();
27
+ for (let part of parts){
28
+ // Reset index, since the regex is stateful.
29
+ LENGTH.lastIndex = 0;
30
+ // Keyword
31
+ if (!seen.has("KEYWORD") && KEYWORDS.has(part)) {
32
+ result.keyword = part;
33
+ seen.add("KEYWORD");
34
+ } else if (LENGTH.test(part)) {
35
+ if (!seen.has("X")) {
36
+ result.x = part;
37
+ seen.add("X");
38
+ } else if (!seen.has("Y")) {
39
+ result.y = part;
40
+ seen.add("Y");
41
+ } else if (!seen.has("BLUR")) {
42
+ result.blur = part;
43
+ seen.add("BLUR");
44
+ } else if (!seen.has("SPREAD")) {
45
+ result.spread = part;
46
+ seen.add("SPREAD");
47
+ }
48
+ } else {
49
+ if (!result.color) {
50
+ result.color = part;
51
+ } else {
52
+ if (!result.unknown) result.unknown = [];
53
+ result.unknown.push(part);
54
+ }
55
+ }
56
+ }
57
+ // Check if valid
58
+ result.valid = result.x !== undefined && result.y !== undefined;
59
+ return result;
60
+ });
61
+ }
62
+ function formatBoxShadowValue(shadows) {
63
+ return shadows.map((shadow)=>{
64
+ if (!shadow.valid) {
65
+ return shadow.raw;
66
+ }
67
+ return [
68
+ shadow.keyword,
69
+ shadow.x,
70
+ shadow.y,
71
+ shadow.blur,
72
+ shadow.spread,
73
+ shadow.color
74
+ ].filter(Boolean).join(" ");
75
+ }).join(", ");
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
+ }