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,249 @@
1
+ import log from './log'
2
+
3
+ export function normalizeConfig(config) {
4
+ // Quick structure validation
5
+ /**
6
+ * type FilePath = string
7
+ * type RawFile = { raw: string, extension?: string }
8
+ * type ExtractorFn = (content: string) => Array<string>
9
+ * type TransformerFn = (content: string) => string
10
+ *
11
+ * type Content =
12
+ * | Array<FilePath | RawFile>
13
+ * | {
14
+ * files: Array<FilePath | RawFile>,
15
+ * extract?: ExtractorFn | { [extension: string]: ExtractorFn }
16
+ * transform?: TransformerFn | { [extension: string]: TransformerFn }
17
+ * }
18
+ */
19
+ let valid = (() => {
20
+ // `config.purge` should not exist anymore
21
+ if (config.purge) {
22
+ return false
23
+ }
24
+
25
+ // `config.content` should exist
26
+ if (!config.content) {
27
+ return false
28
+ }
29
+
30
+ // `config.content` should be an object or an array
31
+ if (
32
+ !Array.isArray(config.content) &&
33
+ !(typeof config.content === 'object' && config.content !== null)
34
+ ) {
35
+ return false
36
+ }
37
+
38
+ // When `config.content` is an array, it should consist of FilePaths or RawFiles
39
+ if (Array.isArray(config.content)) {
40
+ return config.content.every((path) => {
41
+ // `path` can be a string
42
+ if (typeof path === 'string') return true
43
+
44
+ // `path` can be an object { raw: string, extension?: string }
45
+ // `raw` must be a string
46
+ if (typeof path?.raw !== 'string') return false
47
+
48
+ // `extension` (if provided) should also be a string
49
+ if (path?.extension && typeof path?.extension !== 'string') {
50
+ return false
51
+ }
52
+
53
+ return true
54
+ })
55
+ }
56
+
57
+ // When `config.content` is an object
58
+ if (typeof config.content === 'object' && config.content !== null) {
59
+ // Only `files`, `extract` and `transform` can exist in `config.content`
60
+ if (
61
+ Object.keys(config.content).some((key) => !['files', 'extract', 'transform'].includes(key))
62
+ ) {
63
+ return false
64
+ }
65
+
66
+ // `config.content.files` should exist of FilePaths or RawFiles
67
+ if (Array.isArray(config.content.files)) {
68
+ if (
69
+ !config.content.files.every((path) => {
70
+ // `path` can be a string
71
+ if (typeof path === 'string') return true
72
+
73
+ // `path` can be an object { raw: string, extension?: string }
74
+ // `raw` must be a string
75
+ if (typeof path?.raw !== 'string') return false
76
+
77
+ // `extension` (if provided) should also be a string
78
+ if (path?.extension && typeof path?.extension !== 'string') {
79
+ return false
80
+ }
81
+
82
+ return true
83
+ })
84
+ ) {
85
+ return false
86
+ }
87
+
88
+ // `config.content.extract` is optional, and can be a Function or a Record<String, Function>
89
+ if (typeof config.content.extract === 'object') {
90
+ for (let value of Object.values(config.content.extract)) {
91
+ if (typeof value !== 'function') {
92
+ return false
93
+ }
94
+ }
95
+ } else if (
96
+ !(config.content.extract === undefined || typeof config.content.extract === 'function')
97
+ ) {
98
+ return false
99
+ }
100
+
101
+ // `config.content.transform` is optional, and can be a Function or a Record<String, Function>
102
+ if (typeof config.content.transform === 'object') {
103
+ for (let value of Object.values(config.content.transform)) {
104
+ if (typeof value !== 'function') {
105
+ return false
106
+ }
107
+ }
108
+ } else if (
109
+ !(
110
+ config.content.transform === undefined || typeof config.content.transform === 'function'
111
+ )
112
+ ) {
113
+ return false
114
+ }
115
+ }
116
+
117
+ return true
118
+ }
119
+
120
+ return false
121
+ })()
122
+
123
+ if (!valid) {
124
+ log.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
+ // TODO: Add https://tw.wtf/purge-deprecation
128
+ ])
129
+ }
130
+
131
+ // Normalize the `safelist`
132
+ config.safelist = (() => {
133
+ let { content, purge, safelist } = config
134
+
135
+ if (Array.isArray(safelist)) return safelist
136
+ if (Array.isArray(content?.safelist)) return content.safelist
137
+ if (Array.isArray(purge?.safelist)) return purge.safelist
138
+ if (Array.isArray(purge?.options?.safelist)) return purge.options.safelist
139
+
140
+ return []
141
+ })()
142
+
143
+ // Normalize prefix option
144
+ if (typeof config.prefix === 'function') {
145
+ log.warn('prefix-function', [
146
+ 'As of Tailwind CSS v3.0, `prefix` cannot be a function.',
147
+ 'Update `prefix` in your configuration to be a string to eliminate this warning.',
148
+ // TODO: Add https://tw.wtf/prefix-function
149
+ ])
150
+ config.prefix = ''
151
+ } else {
152
+ config.prefix = config.prefix ?? ''
153
+ }
154
+
155
+ // Normalize the `content`
156
+ config.content = {
157
+ files: (() => {
158
+ let { content, purge } = config
159
+
160
+ if (Array.isArray(purge)) return purge
161
+ if (Array.isArray(purge?.content)) return purge.content
162
+ if (Array.isArray(content)) return content
163
+ if (Array.isArray(content?.content)) return content.content
164
+ if (Array.isArray(content?.files)) return content.files
165
+
166
+ return []
167
+ })(),
168
+
169
+ extract: (() => {
170
+ let extract = (() => {
171
+ if (config.purge?.extract) return config.purge.extract
172
+ if (config.content?.extract) return config.content.extract
173
+
174
+ if (config.purge?.extract?.DEFAULT) return config.purge.extract.DEFAULT
175
+ if (config.content?.extract?.DEFAULT) return config.content.extract.DEFAULT
176
+
177
+ if (config.purge?.options?.extractors) return config.purge.options.extractors
178
+ if (config.content?.options?.extractors) return config.content.options.extractors
179
+
180
+ return {}
181
+ })()
182
+
183
+ let extractors = {}
184
+
185
+ let defaultExtractor = (() => {
186
+ if (config.purge?.options?.defaultExtractor) {
187
+ return config.purge.options.defaultExtractor
188
+ }
189
+
190
+ if (config.content?.options?.defaultExtractor) {
191
+ return config.content.options.defaultExtractor
192
+ }
193
+
194
+ return undefined
195
+ })()
196
+
197
+ if (defaultExtractor !== undefined) {
198
+ extractors.DEFAULT = defaultExtractor
199
+ }
200
+
201
+ // Functions
202
+ if (typeof extract === 'function') {
203
+ extractors.DEFAULT = extract
204
+ }
205
+
206
+ // Arrays
207
+ else if (Array.isArray(extract)) {
208
+ for (let { extensions, extractor } of extract ?? []) {
209
+ for (let extension of extensions) {
210
+ extractors[extension] = extractor
211
+ }
212
+ }
213
+ }
214
+
215
+ // Objects
216
+ else if (typeof extract === 'object' && extract !== null) {
217
+ Object.assign(extractors, extract)
218
+ }
219
+
220
+ return extractors
221
+ })(),
222
+
223
+ transform: (() => {
224
+ let transform = (() => {
225
+ if (config.purge?.transform) return config.purge.transform
226
+ if (config.content?.transform) return config.content.transform
227
+
228
+ if (config.purge?.transform?.DEFAULT) return config.purge.transform.DEFAULT
229
+ if (config.content?.transform?.DEFAULT) return config.content.transform.DEFAULT
230
+
231
+ return {}
232
+ })()
233
+
234
+ let transformers = {}
235
+
236
+ if (typeof transform === 'function') {
237
+ transformers.DEFAULT = transform
238
+ }
239
+
240
+ if (typeof transform === 'object' && transform !== null) {
241
+ Object.assign(transformers, transform)
242
+ }
243
+
244
+ return transformers
245
+ })(),
246
+ }
247
+
248
+ return config
249
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A function that normalizes the various forms that the screens object can be
3
+ * provided in.
4
+ *
5
+ * Input(s):
6
+ * - ['100px', '200px'] // Raw strings
7
+ * - { sm: '100px', md: '200px' } // Object with string values
8
+ * - { sm: { min: '100px' }, md: { max: '100px' } } // Object with object values
9
+ * - { sm: [{ min: '100px' }, { max: '200px' }] } // Object with object array (multiple values)
10
+ * - [['sm', '100px'], ['md', '200px']] // Tuple object
11
+ *
12
+ * Output(s):
13
+ * - [{ name: 'sm', values: [{ min: '100px', max: '200px' }] }] // List of objects, that contains multiple values
14
+ */
15
+ export function normalizeScreens(screens) {
16
+ if (Array.isArray(screens)) {
17
+ return screens.map((screen) => {
18
+ if (typeof screen === 'string') {
19
+ return { name: screen.toString(), values: [{ min: screen, max: undefined }] }
20
+ }
21
+
22
+ let [name, options] = screen
23
+ name = name.toString()
24
+
25
+ if (typeof options === 'string') {
26
+ return { name, values: [{ min: options, max: undefined }] }
27
+ }
28
+
29
+ if (Array.isArray(options)) {
30
+ return { name, values: options.map((option) => resolveValue(option)) }
31
+ }
32
+
33
+ return { name, values: [resolveValue(options)] }
34
+ })
35
+ }
36
+
37
+ return normalizeScreens(Object.entries(screens ?? {}))
38
+ }
39
+
40
+ function resolveValue({ 'min-width': _minWidth, min = _minWidth, max, raw } = {}) {
41
+ return { min, max, raw }
42
+ }
@@ -54,7 +54,13 @@ export default function parseAnimationValue(input) {
54
54
  } else if (!seen.has('DELAY') && TIME.test(part)) {
55
55
  result.delay = part
56
56
  seen.add('DELAY')
57
- } else result.name = part
57
+ } else if (!seen.has('NAME')) {
58
+ result.name = part
59
+ seen.add('NAME')
60
+ } else {
61
+ if (!result.unknown) result.unknown = []
62
+ result.unknown.push(part)
63
+ }
58
64
  }
59
65
 
60
66
  return result
@@ -0,0 +1,71 @@
1
+ let KEYWORDS = new Set(['inset', 'inherit', 'initial', 'revert', 'unset'])
2
+ let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
3
+ let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
4
+ let LENGTH = /^-?(\d+)(.*?)$/g
5
+
6
+ export function parseBoxShadowValue(input) {
7
+ let shadows = input.split(COMMA)
8
+ return shadows.map((shadow) => {
9
+ let value = shadow.trim()
10
+ let result = { raw: value }
11
+ let parts = value.split(SPACE)
12
+ let seen = new Set()
13
+
14
+ for (let part of parts) {
15
+ // Reset index, since the regex is stateful.
16
+ LENGTH.lastIndex = 0
17
+
18
+ // Keyword
19
+ if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
20
+ result.keyword = part
21
+ seen.add('KEYWORD')
22
+ }
23
+
24
+ // Length value
25
+ else if (LENGTH.test(part)) {
26
+ if (!seen.has('X')) {
27
+ result.x = part
28
+ seen.add('X')
29
+ } else if (!seen.has('Y')) {
30
+ result.y = part
31
+ seen.add('Y')
32
+ } else if (!seen.has('BLUR')) {
33
+ result.blur = part
34
+ seen.add('BLUR')
35
+ } else if (!seen.has('SPREAD')) {
36
+ result.spread = part
37
+ seen.add('SPREAD')
38
+ }
39
+ }
40
+
41
+ // Color or unknown
42
+ else {
43
+ if (!result.color) {
44
+ result.color = part
45
+ } else {
46
+ if (!result.unknown) result.unknown = []
47
+ result.unknown.push(part)
48
+ }
49
+ }
50
+ }
51
+
52
+ // Check if valid
53
+ result.valid = result.x !== undefined && result.y !== undefined
54
+
55
+ return result
56
+ })
57
+ }
58
+
59
+ export function formatBoxShadowValue(shadows) {
60
+ return shadows
61
+ .map((shadow) => {
62
+ if (!shadow.valid) {
63
+ return shadow.raw
64
+ }
65
+
66
+ return [shadow.keyword, shadow.x, shadow.y, shadow.blur, shadow.spread, shadow.color]
67
+ .filter(Boolean)
68
+ .join(' ')
69
+ })
70
+ .join(', ')
71
+ }
@@ -26,6 +26,10 @@ function parseGlob(pattern) {
26
26
  }
27
27
 
28
28
  export default function parseDependency(normalizedFileOrGlob) {
29
+ if (normalizedFileOrGlob.startsWith('!')) {
30
+ return null
31
+ }
32
+
29
33
  let message
30
34
 
31
35
  if (isGlob(normalizedFileOrGlob)) {