tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21

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 (120) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/README.md +1 -1
  3. package/colors.js +1 -304
  4. package/defaultConfig.js +1 -4
  5. package/defaultTheme.js +1 -4
  6. package/lib/cli-peer-dependencies.js +4 -9
  7. package/lib/cli.js +646 -705
  8. package/lib/constants.js +15 -15
  9. package/lib/corePluginList.js +174 -4
  10. package/lib/corePlugins.js +3637 -2934
  11. package/lib/css/preflight.css +14 -1
  12. package/lib/featureFlags.js +44 -44
  13. package/lib/index.js +25 -24
  14. package/lib/lib/collapseAdjacentRules.js +33 -35
  15. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  16. package/lib/lib/detectNesting.js +34 -0
  17. package/lib/lib/evaluateTailwindFunctions.js +134 -155
  18. package/lib/lib/expandApplyAtRules.js +183 -200
  19. package/lib/lib/expandTailwindAtRules.js +219 -232
  20. package/lib/lib/generateRules.js +478 -311
  21. package/lib/lib/getModuleDependencies.js +36 -41
  22. package/lib/lib/normalizeTailwindDirectives.js +66 -58
  23. package/lib/lib/resolveDefaultsAtRules.js +110 -90
  24. package/lib/lib/setupContextUtils.js +740 -580
  25. package/lib/lib/setupTrackingContext.js +142 -162
  26. package/lib/lib/setupWatchingContext.js +235 -278
  27. package/lib/lib/sharedState.js +7 -17
  28. package/lib/lib/substituteScreenAtRules.js +22 -26
  29. package/lib/processTailwindFeatures.js +38 -44
  30. package/lib/public/colors.js +329 -0
  31. package/lib/public/create-plugin.js +13 -0
  32. package/lib/public/default-config.js +14 -0
  33. package/lib/public/default-theme.js +14 -0
  34. package/lib/public/resolve-config.js +19 -0
  35. package/lib/util/bigSign.js +3 -5
  36. package/lib/util/buildMediaQuery.js +15 -31
  37. package/lib/util/cloneDeep.js +14 -13
  38. package/lib/util/cloneNodes.js +9 -13
  39. package/lib/util/color.js +69 -59
  40. package/lib/util/configurePlugins.js +13 -14
  41. package/lib/util/createPlugin.js +21 -24
  42. package/lib/util/createUtilityPlugin.js +47 -45
  43. package/lib/util/dataTypes.js +231 -0
  44. package/lib/util/defaults.js +10 -14
  45. package/lib/util/escapeClassName.js +12 -14
  46. package/lib/util/escapeCommas.js +3 -5
  47. package/lib/util/flattenColorPalette.js +14 -10
  48. package/lib/util/formatVariantSelector.js +186 -0
  49. package/lib/util/getAllConfigs.js +23 -16
  50. package/lib/util/hashConfig.js +10 -10
  51. package/lib/util/isKeyframeRule.js +3 -5
  52. package/lib/util/isPlainObject.js +7 -10
  53. package/lib/util/isValidArbitraryValue.js +64 -0
  54. package/lib/util/log.js +39 -30
  55. package/lib/util/nameClass.js +23 -23
  56. package/lib/util/negateValue.js +14 -15
  57. package/lib/util/normalizeConfig.js +208 -0
  58. package/lib/util/normalizeScreens.js +58 -0
  59. package/lib/util/parseAnimationValue.js +82 -53
  60. package/lib/util/parseBoxShadowValue.js +77 -0
  61. package/lib/util/parseDependency.js +49 -60
  62. package/lib/util/parseObjectStyles.js +23 -20
  63. package/lib/util/pluginUtils.js +153 -285
  64. package/lib/util/prefixSelector.js +14 -16
  65. package/lib/util/resolveConfig.js +194 -249
  66. package/lib/util/resolveConfigPath.js +38 -45
  67. package/lib/util/responsive.js +12 -11
  68. package/lib/util/tap.js +4 -6
  69. package/lib/util/toColorValue.js +4 -5
  70. package/lib/util/toPath.js +4 -6
  71. package/lib/util/transformThemeValue.js +57 -26
  72. package/lib/util/withAlphaVariable.js +56 -54
  73. package/package.json +27 -37
  74. package/peers/index.js +73099 -84294
  75. package/plugin.js +1 -3
  76. package/resolveConfig.js +1 -7
  77. package/scripts/create-plugin-list.js +2 -2
  78. package/src/cli.js +27 -18
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +2124 -1968
  81. package/src/css/preflight.css +14 -1
  82. package/src/featureFlags.js +12 -6
  83. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  84. package/src/lib/detectNesting.js +39 -0
  85. package/src/lib/evaluateTailwindFunctions.js +5 -2
  86. package/src/lib/expandTailwindAtRules.js +24 -32
  87. package/src/lib/generateRules.js +230 -20
  88. package/src/lib/normalizeTailwindDirectives.js +3 -2
  89. package/src/lib/resolveDefaultsAtRules.js +46 -30
  90. package/src/lib/setupContextUtils.js +275 -113
  91. package/src/lib/setupTrackingContext.js +9 -8
  92. package/src/lib/setupWatchingContext.js +12 -7
  93. package/src/lib/sharedState.js +1 -4
  94. package/src/lib/substituteScreenAtRules.js +6 -3
  95. package/src/processTailwindFeatures.js +8 -1
  96. package/src/public/colors.js +300 -0
  97. package/src/public/create-plugin.js +2 -0
  98. package/src/public/default-config.js +4 -0
  99. package/src/public/default-theme.js +4 -0
  100. package/src/public/resolve-config.js +7 -0
  101. package/src/util/buildMediaQuery.js +14 -18
  102. package/src/util/createUtilityPlugin.js +2 -11
  103. package/src/util/dataTypes.js +246 -0
  104. package/src/util/formatVariantSelector.js +196 -0
  105. package/src/util/isValidArbitraryValue.js +61 -0
  106. package/src/util/log.js +18 -21
  107. package/src/util/nameClass.js +10 -6
  108. package/src/util/negateValue.js +4 -2
  109. package/src/util/normalizeConfig.js +249 -0
  110. package/src/util/normalizeScreens.js +42 -0
  111. package/src/util/parseAnimationValue.js +7 -1
  112. package/src/util/parseBoxShadowValue.js +71 -0
  113. package/src/util/parseDependency.js +4 -0
  114. package/src/util/pluginUtils.js +101 -204
  115. package/src/util/prefixSelector.js +1 -4
  116. package/src/util/resolveConfig.js +12 -65
  117. package/src/util/transformThemeValue.js +22 -7
  118. package/src/util/withAlphaVariable.js +13 -8
  119. package/stubs/defaultConfig.stub.js +163 -97
  120. package/stubs/simpleConfig.stub.js +0 -1
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.normalizeConfig = normalizeConfig;
6
+ var _log = _interopRequireDefault(require("./log"));
7
+ function _interopRequireDefault(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
+ function normalizeConfig(config) {
13
+ // Quick structure validation
14
+ /**
15
+ * type FilePath = string
16
+ * type RawFile = { raw: string, extension?: string }
17
+ * type ExtractorFn = (content: string) => Array<string>
18
+ * type TransformerFn = (content: string) => string
19
+ *
20
+ * type Content =
21
+ * | Array<FilePath | RawFile>
22
+ * | {
23
+ * files: Array<FilePath | RawFile>,
24
+ * extract?: ExtractorFn | { [extension: string]: ExtractorFn }
25
+ * transform?: TransformerFn | { [extension: string]: TransformerFn }
26
+ * }
27
+ */ let valid = (()=>{
28
+ // `config.purge` should not exist anymore
29
+ if (config.purge) {
30
+ return false;
31
+ }
32
+ // `config.content` should exist
33
+ if (!config.content) {
34
+ return false;
35
+ }
36
+ // `config.content` should be an object or an array
37
+ if (!Array.isArray(config.content) && !(typeof config.content === 'object' && config.content !== null)) {
38
+ return false;
39
+ }
40
+ // When `config.content` is an array, it should consist of FilePaths or RawFiles
41
+ if (Array.isArray(config.content)) {
42
+ return config.content.every((path)=>{
43
+ // `path` can be a string
44
+ if (typeof path === 'string') return true;
45
+ // `path` can be an object { raw: string, extension?: string }
46
+ // `raw` must be a string
47
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== 'string') return false;
48
+ // `extension` (if provided) should also be a string
49
+ if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== 'string') {
50
+ return false;
51
+ }
52
+ return true;
53
+ });
54
+ }
55
+ // When `config.content` is an object
56
+ if (typeof config.content === 'object' && config.content !== null) {
57
+ // Only `files`, `extract` and `transform` can exist in `config.content`
58
+ if (Object.keys(config.content).some((key)=>![
59
+ 'files',
60
+ 'extract',
61
+ 'transform'
62
+ ].includes(key)
63
+ )) {
64
+ return false;
65
+ }
66
+ // `config.content.files` should exist of FilePaths or RawFiles
67
+ if (Array.isArray(config.content.files)) {
68
+ if (!config.content.files.every((path)=>{
69
+ // `path` can be a string
70
+ if (typeof path === 'string') return true;
71
+ // `path` can be an object { raw: string, extension?: string }
72
+ // `raw` must be a string
73
+ if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== 'string') return false;
74
+ // `extension` (if provided) should also be a string
75
+ if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== 'string') {
76
+ return false;
77
+ }
78
+ return true;
79
+ })) {
80
+ return false;
81
+ }
82
+ // `config.content.extract` is optional, and can be a Function or a Record<String, Function>
83
+ if (typeof config.content.extract === 'object') {
84
+ for (let value of Object.values(config.content.extract)){
85
+ if (typeof value !== 'function') {
86
+ return false;
87
+ }
88
+ }
89
+ } else if (!(config.content.extract === undefined || typeof config.content.extract === 'function')) {
90
+ return false;
91
+ }
92
+ // `config.content.transform` is optional, and can be a Function or a Record<String, Function>
93
+ if (typeof config.content.transform === 'object') {
94
+ for (let value of Object.values(config.content.transform)){
95
+ if (typeof value !== 'function') {
96
+ return false;
97
+ }
98
+ }
99
+ } else if (!(config.content.transform === undefined || typeof config.content.transform === 'function')) {
100
+ return false;
101
+ }
102
+ }
103
+ return true;
104
+ }
105
+ return false;
106
+ })();
107
+ if (!valid) {
108
+ _log.default.warn('purge-deprecation', [
109
+ 'The `purge`/`content` options have changed in Tailwind CSS v3.0.',
110
+ 'Update your configuration file to eliminate this warning.'
111
+ ]);
112
+ }
113
+ // Normalize the `safelist`
114
+ config.safelist = (()=>{
115
+ var ref;
116
+ let { content , purge , safelist } = config;
117
+ if (Array.isArray(safelist)) return safelist;
118
+ if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return content.safelist;
119
+ if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return purge.safelist;
120
+ 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;
121
+ return [];
122
+ })();
123
+ // Normalize prefix option
124
+ if (typeof config.prefix === 'function') {
125
+ _log.default.warn('prefix-function', [
126
+ 'As of Tailwind CSS v3.0, `prefix` cannot be a function.',
127
+ 'Update `prefix` in your configuration to be a string to eliminate this warning.'
128
+ ]);
129
+ config.prefix = '';
130
+ } else {
131
+ var _prefix;
132
+ config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : '';
133
+ }
134
+ // Normalize the `content`
135
+ config.content = {
136
+ files: (()=>{
137
+ let { content , purge } = config;
138
+ if (Array.isArray(purge)) return purge;
139
+ if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
140
+ if (Array.isArray(content)) return content;
141
+ if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
142
+ if (Array.isArray(content === null || content === void 0 ? void 0 : content.files)) return content.files;
143
+ return [];
144
+ })(),
145
+ extract: (()=>{
146
+ let extract = (()=>{
147
+ var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9;
148
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.extract) return config.purge.extract;
149
+ if ((ref1 = config.content) === null || ref1 === void 0 ? void 0 : ref1.extract) return config.content.extract;
150
+ 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;
151
+ 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;
152
+ 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;
153
+ 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;
154
+ return {
155
+ };
156
+ })();
157
+ let extractors = {
158
+ };
159
+ let defaultExtractor = (()=>{
160
+ var ref, ref10, ref11, ref12;
161
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
162
+ return config.purge.options.defaultExtractor;
163
+ }
164
+ if ((ref11 = config.content) === null || ref11 === void 0 ? void 0 : (ref12 = ref11.options) === null || ref12 === void 0 ? void 0 : ref12.defaultExtractor) {
165
+ return config.content.options.defaultExtractor;
166
+ }
167
+ return undefined;
168
+ })();
169
+ if (defaultExtractor !== undefined) {
170
+ extractors.DEFAULT = defaultExtractor;
171
+ }
172
+ // Functions
173
+ if (typeof extract === 'function') {
174
+ extractors.DEFAULT = extract;
175
+ } else if (Array.isArray(extract)) {
176
+ for (let { extensions , extractor } of extract !== null && extract !== void 0 ? extract : []){
177
+ for (let extension of extensions){
178
+ extractors[extension] = extractor;
179
+ }
180
+ }
181
+ } else if (typeof extract === 'object' && extract !== null) {
182
+ Object.assign(extractors, extract);
183
+ }
184
+ return extractors;
185
+ })(),
186
+ transform: (()=>{
187
+ let transform = (()=>{
188
+ var ref, ref13, ref14, ref15, ref16, ref17;
189
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
190
+ if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
191
+ 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;
192
+ 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;
193
+ return {
194
+ };
195
+ })();
196
+ let transformers = {
197
+ };
198
+ if (typeof transform === 'function') {
199
+ transformers.DEFAULT = transform;
200
+ }
201
+ if (typeof transform === 'object' && transform !== null) {
202
+ Object.assign(transformers, transform);
203
+ }
204
+ return transformers;
205
+ })()
206
+ };
207
+ return config;
208
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.normalizeScreens = normalizeScreens;
6
+ function normalizeScreens(screens) {
7
+ if (Array.isArray(screens)) {
8
+ return screens.map((screen)=>{
9
+ if (typeof screen === 'string') {
10
+ return {
11
+ name: screen.toString(),
12
+ values: [
13
+ {
14
+ min: screen,
15
+ max: undefined
16
+ }
17
+ ]
18
+ };
19
+ }
20
+ let [name, options] = screen;
21
+ name = name.toString();
22
+ if (typeof options === 'string') {
23
+ return {
24
+ name,
25
+ values: [
26
+ {
27
+ min: options,
28
+ max: undefined
29
+ }
30
+ ]
31
+ };
32
+ }
33
+ if (Array.isArray(options)) {
34
+ return {
35
+ name,
36
+ values: options.map((option)=>resolveValue(option)
37
+ )
38
+ };
39
+ }
40
+ return {
41
+ name,
42
+ values: [
43
+ resolveValue(options)
44
+ ]
45
+ };
46
+ });
47
+ }
48
+ return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {
49
+ }));
50
+ }
51
+ function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {
52
+ }) {
53
+ return {
54
+ min,
55
+ max,
56
+ raw
57
+ };
58
+ }
@@ -1,60 +1,89 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = parseAnimationValue;
7
- const DIRECTIONS = new Set(['normal', 'reverse', 'alternate', 'alternate-reverse']);
8
- const PLAY_STATES = new Set(['running', 'paused']);
9
- const FILL_MODES = new Set(['none', 'forwards', 'backwards', 'both']);
10
- const ITERATION_COUNTS = new Set(['infinite']);
11
- const TIMINGS = new Set(['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'step-start', 'step-end']);
12
- const TIMING_FNS = ['cubic-bezier', 'steps'];
13
- const COMMA = /\,(?![^(]*\))/g; // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
14
-
15
- const SPACE = /\ +(?![^(]*\))/g; // Similar to the one above, but with spaces instead.
16
-
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
+ ;
17
42
  const TIME = /^(-?[\d.]+m?s)$/;
18
43
  const DIGIT = /^(\d+)$/;
19
-
20
44
  function parseAnimationValue(input) {
21
- let animations = input.split(COMMA);
22
- return animations.map(animation => {
23
- let value = animation.trim();
24
- let result = {
25
- value
26
- };
27
- let parts = value.split(SPACE);
28
- let seen = new Set();
29
-
30
- for (let part of parts) {
31
- if (!seen.has('DIRECTIONS') && DIRECTIONS.has(part)) {
32
- result.direction = part;
33
- seen.add('DIRECTIONS');
34
- } else if (!seen.has('PLAY_STATES') && PLAY_STATES.has(part)) {
35
- result.playState = part;
36
- seen.add('PLAY_STATES');
37
- } else if (!seen.has('FILL_MODES') && FILL_MODES.has(part)) {
38
- result.fillMode = part;
39
- seen.add('FILL_MODES');
40
- } else if (!seen.has('ITERATION_COUNTS') && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
41
- result.iterationCount = part;
42
- seen.add('ITERATION_COUNTS');
43
- } else if (!seen.has('TIMING_FUNCTION') && TIMINGS.has(part)) {
44
- result.timingFunction = part;
45
- seen.add('TIMING_FUNCTION');
46
- } else if (!seen.has('TIMING_FUNCTION') && TIMING_FNS.some(f => part.startsWith(`${f}(`))) {
47
- result.timingFunction = part;
48
- seen.add('TIMING_FUNCTION');
49
- } else if (!seen.has('DURATION') && TIME.test(part)) {
50
- result.duration = part;
51
- seen.add('DURATION');
52
- } else if (!seen.has('DELAY') && TIME.test(part)) {
53
- result.delay = part;
54
- seen.add('DELAY');
55
- } else result.name = part;
56
- }
57
-
58
- return result;
59
- });
60
- }
45
+ let animations = input.split(COMMA);
46
+ return animations.map((animation)=>{
47
+ let value = animation.trim();
48
+ let result = {
49
+ value
50
+ };
51
+ let parts = value.split(SPACE);
52
+ let seen = new Set();
53
+ for (let part of parts){
54
+ if (!seen.has('DIRECTIONS') && DIRECTIONS.has(part)) {
55
+ result.direction = part;
56
+ seen.add('DIRECTIONS');
57
+ } else if (!seen.has('PLAY_STATES') && PLAY_STATES.has(part)) {
58
+ result.playState = part;
59
+ seen.add('PLAY_STATES');
60
+ } else if (!seen.has('FILL_MODES') && FILL_MODES.has(part)) {
61
+ result.fillMode = part;
62
+ seen.add('FILL_MODES');
63
+ } else if (!seen.has('ITERATION_COUNTS') && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
64
+ result.iterationCount = part;
65
+ seen.add('ITERATION_COUNTS');
66
+ } else if (!seen.has('TIMING_FUNCTION') && TIMINGS.has(part)) {
67
+ result.timingFunction = part;
68
+ seen.add('TIMING_FUNCTION');
69
+ } else if (!seen.has('TIMING_FUNCTION') && TIMING_FNS.some((f)=>part.startsWith(`${f}(`)
70
+ )) {
71
+ result.timingFunction = part;
72
+ seen.add('TIMING_FUNCTION');
73
+ } else if (!seen.has('DURATION') && TIME.test(part)) {
74
+ result.duration = part;
75
+ seen.add('DURATION');
76
+ } else if (!seen.has('DELAY') && TIME.test(part)) {
77
+ result.delay = part;
78
+ seen.add('DELAY');
79
+ } else if (!seen.has('NAME')) {
80
+ result.name = part;
81
+ seen.add('NAME');
82
+ } else {
83
+ if (!result.unknown) result.unknown = [];
84
+ result.unknown.push(part);
85
+ }
86
+ }
87
+ return result;
88
+ });
89
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.parseBoxShadowValue = parseBoxShadowValue;
6
+ exports.formatBoxShadowValue = formatBoxShadowValue;
7
+ let KEYWORDS = new Set([
8
+ 'inset',
9
+ 'inherit',
10
+ 'initial',
11
+ 'revert',
12
+ 'unset'
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
+ let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
+ ;
18
+ let LENGTH = /^-?(\d+)(.*?)$/g;
19
+ function parseBoxShadowValue(input) {
20
+ let shadows = input.split(COMMA);
21
+ return shadows.map((shadow)=>{
22
+ let value = shadow.trim();
23
+ let result = {
24
+ raw: value
25
+ };
26
+ let parts = value.split(SPACE);
27
+ let seen = new Set();
28
+ for (let part of parts){
29
+ // Reset index, since the regex is stateful.
30
+ LENGTH.lastIndex = 0;
31
+ // Keyword
32
+ if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
33
+ result.keyword = part;
34
+ seen.add('KEYWORD');
35
+ } else if (LENGTH.test(part)) {
36
+ if (!seen.has('X')) {
37
+ result.x = part;
38
+ seen.add('X');
39
+ } else if (!seen.has('Y')) {
40
+ result.y = part;
41
+ seen.add('Y');
42
+ } else if (!seen.has('BLUR')) {
43
+ result.blur = part;
44
+ seen.add('BLUR');
45
+ } else if (!seen.has('SPREAD')) {
46
+ result.spread = part;
47
+ seen.add('SPREAD');
48
+ }
49
+ } else {
50
+ if (!result.color) {
51
+ result.color = part;
52
+ } else {
53
+ if (!result.unknown) result.unknown = [];
54
+ result.unknown.push(part);
55
+ }
56
+ }
57
+ }
58
+ // Check if valid
59
+ result.valid = result.x !== undefined && result.y !== undefined;
60
+ return result;
61
+ });
62
+ }
63
+ function formatBoxShadowValue(shadows) {
64
+ return shadows.map((shadow)=>{
65
+ if (!shadow.valid) {
66
+ return shadow.raw;
67
+ }
68
+ return [
69
+ shadow.keyword,
70
+ shadow.x,
71
+ shadow.y,
72
+ shadow.blur,
73
+ shadow.spread,
74
+ shadow.color
75
+ ].filter(Boolean).join(' ');
76
+ }).join(', ');
77
+ }
@@ -1,74 +1,63 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = parseDependency;
7
-
8
6
  var _isGlob = _interopRequireDefault(require("is-glob"));
9
-
10
7
  var _globParent = _interopRequireDefault(require("glob-parent"));
11
-
12
8
  var _path = _interopRequireDefault(require("path"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
16
14
  // Based on `glob-base`
17
15
  // https://github.com/micromatch/glob-base/blob/master/index.js
18
16
  function parseGlob(pattern) {
19
- let glob = pattern;
20
- let base = (0, _globParent.default)(pattern);
21
-
22
- if (base !== '.') {
23
- glob = pattern.substr(base.length);
24
-
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
+ }
25
28
  if (glob.charAt(0) === '/') {
26
- glob = glob.substr(1);
29
+ glob = glob.substr(1);
27
30
  }
28
- }
29
-
30
- if (glob.substr(0, 2) === './') {
31
- glob = glob.substr(2);
32
- }
33
-
34
- if (glob.charAt(0) === '/') {
35
- glob = glob.substr(1);
36
- }
37
-
38
- return {
39
- base,
40
- glob
41
- };
31
+ return {
32
+ base,
33
+ glob
34
+ };
42
35
  }
43
-
44
36
  function parseDependency(normalizedFileOrGlob) {
45
- let message;
46
-
47
- if ((0, _isGlob.default)(normalizedFileOrGlob)) {
48
- let {
49
- base,
50
- glob
51
- } = parseGlob(normalizedFileOrGlob);
52
- message = {
53
- type: 'dir-dependency',
54
- dir: _path.default.resolve(base),
55
- glob
56
- };
57
- } else {
58
- message = {
59
- type: 'dependency',
60
- file: _path.default.resolve(normalizedFileOrGlob)
61
- };
62
- } // rollup-plugin-postcss does not support dir-dependency messages
63
- // but directories can be watched in the same way as files
64
-
65
-
66
- if (message.type === 'dir-dependency' && process.env.ROLLUP_WATCH === 'true') {
67
- message = {
68
- type: 'dependency',
69
- file: message.dir
70
- };
71
- }
72
-
73
- return message;
74
- }
37
+ if (normalizedFileOrGlob.startsWith('!')) {
38
+ return null;
39
+ }
40
+ let message;
41
+ if ((0, _isGlob).default(normalizedFileOrGlob)) {
42
+ let { base , glob } = parseGlob(normalizedFileOrGlob);
43
+ message = {
44
+ type: 'dir-dependency',
45
+ dir: _path.default.resolve(base),
46
+ glob
47
+ };
48
+ } else {
49
+ message = {
50
+ type: 'dependency',
51
+ file: _path.default.resolve(normalizedFileOrGlob)
52
+ };
53
+ }
54
+ // rollup-plugin-postcss does not support dir-dependency messages
55
+ // but directories can be watched in the same way as files
56
+ if (message.type === 'dir-dependency' && process.env.ROLLUP_WATCH === 'true') {
57
+ message = {
58
+ type: 'dependency',
59
+ file: message.dir
60
+ };
61
+ }
62
+ return message;
63
+ }
@@ -1,28 +1,31 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = parseObjectStyles;
7
-
8
6
  var _postcss = _interopRequireDefault(require("postcss"));
9
-
10
7
  var _postcssNested = _interopRequireDefault(require("postcss-nested"));
11
-
12
8
  var _postcssJs = _interopRequireDefault(require("postcss-js"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
16
14
  function parseObjectStyles(styles) {
17
- if (!Array.isArray(styles)) {
18
- return parseObjectStyles([styles]);
19
- }
20
-
21
- return styles.flatMap(style => {
22
- return (0, _postcss.default)([(0, _postcssNested.default)({
23
- bubble: ['screen']
24
- })]).process(style, {
25
- parser: _postcssJs.default
26
- }).root.nodes;
27
- });
28
- }
15
+ if (!Array.isArray(styles)) {
16
+ return parseObjectStyles([
17
+ styles
18
+ ]);
19
+ }
20
+ return styles.flatMap((style)=>{
21
+ return (0, _postcss).default([
22
+ (0, _postcssNested).default({
23
+ bubble: [
24
+ 'screen'
25
+ ]
26
+ }),
27
+ ]).process(style, {
28
+ parser: _postcssJs.default
29
+ }).root.nodes;
30
+ });
31
+ }