tailwindcss 0.0.0-insiders.fda68f7 → 0.0.0-oxide.6bf5e56

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 (195) hide show
  1. package/CHANGELOG.md +603 -2
  2. package/LICENSE +1 -2
  3. package/README.md +14 -6
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -304
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -4
  8. package/defaultTheme.d.ts +4 -0
  9. package/defaultTheme.js +2 -4
  10. package/lib/cli/build/deps.js +54 -0
  11. package/lib/cli/build/index.js +48 -0
  12. package/lib/cli/build/plugin.js +367 -0
  13. package/lib/cli/build/utils.js +78 -0
  14. package/lib/cli/build/watching.js +178 -0
  15. package/lib/cli/help/index.js +71 -0
  16. package/lib/cli/index.js +18 -0
  17. package/lib/cli/init/index.js +46 -0
  18. package/lib/cli/shared.js +13 -0
  19. package/lib/cli-peer-dependencies.js +22 -14
  20. package/lib/cli.js +217 -743
  21. package/lib/constants.js +41 -34
  22. package/lib/corePluginList.js +178 -5
  23. package/lib/corePlugins.js +3879 -2941
  24. package/lib/css/preflight.css +22 -9
  25. package/lib/featureFlags.js +61 -50
  26. package/lib/index.js +45 -28
  27. package/lib/lib/cacheInvalidation.js +90 -0
  28. package/lib/lib/collapseAdjacentRules.js +52 -36
  29. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  30. package/lib/lib/content.js +176 -0
  31. package/lib/lib/defaultExtractor.js +236 -0
  32. package/lib/lib/detectNesting.js +37 -0
  33. package/lib/lib/evaluateTailwindFunctions.js +203 -161
  34. package/lib/lib/expandApplyAtRules.js +502 -221
  35. package/lib/lib/expandTailwindAtRules.js +258 -243
  36. package/lib/lib/findAtConfigPath.js +44 -0
  37. package/lib/lib/generateRules.js +775 -320
  38. package/lib/lib/getModuleDependencies.js +44 -46
  39. package/lib/lib/normalizeTailwindDirectives.js +79 -60
  40. package/lib/lib/offsets.js +217 -0
  41. package/lib/lib/partitionApplyAtRules.js +56 -0
  42. package/lib/lib/regex.js +60 -0
  43. package/lib/lib/resolveDefaultsAtRules.js +150 -94
  44. package/lib/lib/setupContextUtils.js +1146 -599
  45. package/lib/lib/setupTrackingContext.js +129 -177
  46. package/lib/lib/sharedState.js +53 -21
  47. package/lib/lib/substituteScreenAtRules.js +26 -28
  48. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  49. package/lib/postcss-plugins/nesting/index.js +19 -0
  50. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  51. package/lib/processTailwindFeatures.js +58 -53
  52. package/lib/public/colors.js +331 -0
  53. package/lib/public/create-plugin.js +15 -0
  54. package/lib/public/default-config.js +16 -0
  55. package/lib/public/default-theme.js +16 -0
  56. package/lib/public/resolve-config.js +22 -0
  57. package/lib/util/bigSign.js +7 -6
  58. package/lib/util/buildMediaQuery.js +21 -32
  59. package/lib/util/cloneDeep.js +16 -14
  60. package/lib/util/cloneNodes.js +29 -15
  61. package/lib/util/color.js +90 -66
  62. package/lib/util/configurePlugins.js +17 -15
  63. package/lib/util/createPlugin.js +23 -26
  64. package/lib/util/createUtilityPlugin.js +46 -46
  65. package/lib/util/dataTypes.js +242 -0
  66. package/lib/util/defaults.js +20 -15
  67. package/lib/util/escapeClassName.js +18 -17
  68. package/lib/util/escapeCommas.js +7 -6
  69. package/lib/util/flattenColorPalette.js +13 -12
  70. package/lib/util/formatVariantSelector.js +285 -0
  71. package/lib/util/getAllConfigs.js +44 -18
  72. package/lib/util/hashConfig.js +15 -12
  73. package/lib/util/isKeyframeRule.js +7 -6
  74. package/lib/util/isPlainObject.js +11 -11
  75. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  76. package/lib/util/log.js +52 -33
  77. package/lib/util/nameClass.js +37 -26
  78. package/lib/util/negateValue.js +31 -17
  79. package/lib/util/normalizeConfig.js +281 -0
  80. package/lib/util/normalizeScreens.js +170 -0
  81. package/lib/util/parseAnimationValue.js +85 -54
  82. package/lib/util/parseBoxShadowValue.js +84 -0
  83. package/lib/util/parseDependency.js +41 -70
  84. package/lib/util/parseGlob.js +34 -0
  85. package/lib/util/parseObjectStyles.js +30 -24
  86. package/lib/util/pluginUtils.js +252 -287
  87. package/lib/util/prefixSelector.js +20 -20
  88. package/lib/util/removeAlphaVariables.js +29 -0
  89. package/lib/util/resolveConfig.js +221 -256
  90. package/lib/util/resolveConfigPath.js +43 -48
  91. package/lib/util/responsive.js +18 -14
  92. package/lib/util/splitAtTopLevelOnly.js +43 -0
  93. package/lib/util/tap.js +8 -7
  94. package/lib/util/toColorValue.js +7 -6
  95. package/lib/util/toPath.js +27 -8
  96. package/lib/util/transformThemeValue.js +67 -28
  97. package/lib/util/validateConfig.js +24 -0
  98. package/lib/util/validateFormalSyntax.js +24 -0
  99. package/lib/util/withAlphaVariable.js +67 -57
  100. package/nesting/index.js +2 -12
  101. package/package.json +60 -65
  102. package/peers/index.js +76445 -84221
  103. package/plugin.d.ts +11 -0
  104. package/plugin.js +1 -2
  105. package/resolveConfig.d.ts +12 -0
  106. package/resolveConfig.js +2 -7
  107. package/scripts/create-plugin-list.js +2 -2
  108. package/scripts/generate-types.js +105 -0
  109. package/scripts/release-channel.js +18 -0
  110. package/scripts/release-notes.js +21 -0
  111. package/scripts/type-utils.js +27 -0
  112. package/src/cli/build/deps.js +56 -0
  113. package/src/cli/build/index.js +49 -0
  114. package/src/cli/build/plugin.js +439 -0
  115. package/src/cli/build/utils.js +76 -0
  116. package/src/cli/build/watching.js +227 -0
  117. package/src/cli/help/index.js +70 -0
  118. package/src/cli/index.js +3 -0
  119. package/src/cli/init/index.js +50 -0
  120. package/src/cli/shared.js +6 -0
  121. package/src/cli-peer-dependencies.js +7 -1
  122. package/src/cli.js +50 -575
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +2405 -1948
  125. package/src/css/preflight.css +22 -9
  126. package/src/featureFlags.js +26 -10
  127. package/src/index.js +19 -6
  128. package/src/lib/cacheInvalidation.js +52 -0
  129. package/src/lib/collapseAdjacentRules.js +21 -2
  130. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  131. package/src/lib/content.js +212 -0
  132. package/src/lib/defaultExtractor.js +211 -0
  133. package/src/lib/detectNesting.js +39 -0
  134. package/src/lib/evaluateTailwindFunctions.js +84 -10
  135. package/src/lib/expandApplyAtRules.js +508 -153
  136. package/src/lib/expandTailwindAtRules.js +130 -104
  137. package/src/lib/findAtConfigPath.js +48 -0
  138. package/src/lib/generateRules.js +596 -70
  139. package/src/lib/normalizeTailwindDirectives.js +10 -3
  140. package/src/lib/offsets.js +270 -0
  141. package/src/lib/partitionApplyAtRules.js +52 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/resolveDefaultsAtRules.js +105 -47
  144. package/src/lib/setupContextUtils.js +828 -196
  145. package/src/lib/setupTrackingContext.js +19 -54
  146. package/src/lib/sharedState.js +45 -7
  147. package/src/lib/substituteScreenAtRules.js +6 -3
  148. package/src/postcss-plugins/nesting/README.md +42 -0
  149. package/src/postcss-plugins/nesting/index.js +13 -0
  150. package/src/postcss-plugins/nesting/plugin.js +80 -0
  151. package/src/processTailwindFeatures.js +19 -2
  152. package/src/public/colors.js +300 -0
  153. package/src/public/create-plugin.js +2 -0
  154. package/src/public/default-config.js +4 -0
  155. package/src/public/default-theme.js +4 -0
  156. package/src/public/resolve-config.js +7 -0
  157. package/src/util/buildMediaQuery.js +14 -16
  158. package/src/util/cloneNodes.js +19 -2
  159. package/src/util/color.js +31 -14
  160. package/src/util/createUtilityPlugin.js +2 -11
  161. package/src/util/dataTypes.js +256 -0
  162. package/src/util/defaults.js +6 -0
  163. package/src/util/formatVariantSelector.js +319 -0
  164. package/src/util/getAllConfigs.js +19 -0
  165. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  166. package/src/util/log.js +23 -22
  167. package/src/util/nameClass.js +14 -6
  168. package/src/util/negateValue.js +15 -5
  169. package/src/util/normalizeConfig.js +300 -0
  170. package/src/util/normalizeScreens.js +140 -0
  171. package/src/util/parseAnimationValue.js +7 -1
  172. package/src/util/parseBoxShadowValue.js +72 -0
  173. package/src/util/parseDependency.js +37 -38
  174. package/src/util/parseGlob.js +24 -0
  175. package/src/util/pluginUtils.js +216 -197
  176. package/src/util/prefixSelector.js +7 -8
  177. package/src/util/removeAlphaVariables.js +24 -0
  178. package/src/util/resolveConfig.js +86 -91
  179. package/src/util/splitAtTopLevelOnly.js +45 -0
  180. package/src/util/toPath.js +23 -1
  181. package/src/util/transformThemeValue.js +33 -8
  182. package/src/util/validateConfig.js +13 -0
  183. package/src/util/validateFormalSyntax.js +34 -0
  184. package/src/util/withAlphaVariable.js +14 -9
  185. package/stubs/defaultConfig.stub.js +186 -117
  186. package/stubs/simpleConfig.stub.js +1 -1
  187. package/types/config.d.ts +362 -0
  188. package/types/generated/.gitkeep +0 -0
  189. package/types/generated/colors.d.ts +276 -0
  190. package/types/generated/corePluginList.d.ts +1 -0
  191. package/types/generated/default-theme.d.ts +342 -0
  192. package/types/index.d.ts +7 -0
  193. package/lib/lib/setupWatchingContext.js +0 -331
  194. package/nesting/plugin.js +0 -41
  195. package/src/lib/setupWatchingContext.js +0 -306
package/nesting/plugin.js DELETED
@@ -1,41 +0,0 @@
1
- let postcss = require('postcss')
2
- let postcssNested = require('postcss-nested')
3
-
4
- module.exports = function nesting(opts = postcssNested) {
5
- return (root, result) => {
6
- root.walkAtRules('screen', (rule) => {
7
- rule.name = 'media'
8
- rule.params = `screen(${rule.params})`
9
- })
10
-
11
- root.walkAtRules('apply', (rule) => {
12
- rule.before(postcss.decl({ prop: '__apply', value: rule.params, source: rule.source }))
13
- rule.remove()
14
- })
15
-
16
- let plugin = (() => {
17
- if (typeof opts === 'function') {
18
- return opts
19
- }
20
-
21
- if (typeof opts === 'string') {
22
- return require(opts)
23
- }
24
-
25
- if (Object.keys(opts).length <= 0) {
26
- return postcssNested
27
- }
28
-
29
- throw new Error('tailwindcss/nesting should be loaded with a nesting plugin.')
30
- })()
31
-
32
- postcss([plugin]).process(root, result.opts).sync()
33
-
34
- root.walkDecls('__apply', (decl) => {
35
- decl.before(postcss.atRule({ name: 'apply', params: decl.value, source: decl.source }))
36
- decl.remove()
37
- })
38
-
39
- return root
40
- }
41
- }
@@ -1,306 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
-
4
- import tmp from 'tmp'
5
- import chokidar from 'chokidar'
6
- import fastGlob from 'fast-glob'
7
- import LRU from 'quick-lru'
8
- import normalizePath from 'normalize-path'
9
-
10
- import hash from '../util/hashConfig'
11
- import log from '../util/log'
12
- import getModuleDependencies from '../lib/getModuleDependencies'
13
- import resolveConfig from '../../resolveConfig'
14
- import resolveConfigPath from '../util/resolveConfigPath'
15
- import { getContext } from './setupContextUtils'
16
-
17
- // This is used to trigger rebuilds. Just updating the timestamp
18
- // is significantly faster than actually writing to the file (10x).
19
-
20
- function touch(filename) {
21
- let time = new Date()
22
-
23
- try {
24
- fs.utimesSync(filename, time, time)
25
- } catch (err) {
26
- fs.closeSync(fs.openSync(filename, 'w'))
27
- }
28
- }
29
-
30
- let watchers = new WeakMap()
31
-
32
- function getWatcher(context) {
33
- if (watchers.has(context)) {
34
- return watchers.get(context)
35
- }
36
-
37
- return null
38
- }
39
-
40
- function setWatcher(context, watcher) {
41
- return watchers.set(context, watcher)
42
- }
43
-
44
- let touchFiles = new WeakMap()
45
-
46
- function getTouchFile(context) {
47
- if (touchFiles.has(context)) {
48
- return touchFiles.get(context)
49
- }
50
-
51
- return null
52
- }
53
-
54
- function setTouchFile(context, touchFile) {
55
- return touchFiles.set(context, touchFile)
56
- }
57
-
58
- let configPaths = new WeakMap()
59
-
60
- function getConfigPath(context, configOrPath) {
61
- if (!configPaths.has(context)) {
62
- configPaths.set(context, resolveConfigPath(configOrPath))
63
- }
64
-
65
- return configPaths.get(context)
66
- }
67
-
68
- function rebootWatcher(context, configPath, configDependencies, candidateFiles) {
69
- let touchFile = getTouchFile(context)
70
-
71
- if (touchFile === null) {
72
- touchFile = tmp.fileSync().name
73
- setTouchFile(context, touchFile)
74
- touch(touchFile)
75
- }
76
-
77
- let watcher = getWatcher(context)
78
-
79
- Promise.resolve(watcher ? watcher.close() : null).then(() => {
80
- log.info([
81
- 'Tailwind CSS is watching for changes...',
82
- 'https://tailwindcss.com/docs/just-in-time-mode#watch-mode-and-one-off-builds',
83
- ])
84
-
85
- watcher = chokidar.watch([...candidateFiles, ...configDependencies], {
86
- ignoreInitial: true,
87
- })
88
-
89
- setWatcher(context, watcher)
90
-
91
- watcher.on('add', (file) => {
92
- let changedFile = path.resolve('.', file)
93
- let content = fs.readFileSync(changedFile, 'utf8')
94
- let extension = path.extname(changedFile).slice(1)
95
- context.changedContent.push({ content, extension })
96
- touch(touchFile)
97
- })
98
-
99
- watcher.on('change', (file) => {
100
- // If it was a config dependency, touch the config file to trigger a new context.
101
- // This is not really that clean of a solution but it's the fastest, because we
102
- // can do a very quick check on each build to see if the config has changed instead
103
- // of having to get all of the module dependencies and check every timestamp each
104
- // time.
105
- if (configDependencies.has(file)) {
106
- for (let dependency of configDependencies) {
107
- delete require.cache[require.resolve(dependency)]
108
- }
109
- touch(configPath)
110
- } else {
111
- let changedFile = path.resolve('.', file)
112
- let content = fs.readFileSync(changedFile, 'utf8')
113
- let extension = path.extname(changedFile).slice(1)
114
- context.changedContent.push({ content, extension })
115
- touch(touchFile)
116
- }
117
- })
118
-
119
- watcher.on('unlink', (file) => {
120
- // Touch the config file if any of the dependencies are deleted.
121
- if (configDependencies.has(file)) {
122
- for (let dependency of configDependencies) {
123
- delete require.cache[require.resolve(dependency)]
124
- }
125
- touch(configPath)
126
- }
127
- })
128
- })
129
- }
130
-
131
- let configPathCache = new LRU({ maxSize: 100 })
132
-
133
- let configDependenciesCache = new WeakMap()
134
-
135
- function getConfigDependencies(context) {
136
- if (!configDependenciesCache.has(context)) {
137
- configDependenciesCache.set(context, new Set())
138
- }
139
-
140
- return configDependenciesCache.get(context)
141
- }
142
-
143
- let candidateFilesCache = new WeakMap()
144
-
145
- function getCandidateFiles(context, tailwindConfig) {
146
- if (candidateFilesCache.has(context)) {
147
- return candidateFilesCache.get(context)
148
- }
149
-
150
- let candidateFiles = tailwindConfig.content.content
151
- .filter((item) => typeof item === 'string')
152
- .map((contentPath) => normalizePath(path.resolve(contentPath)))
153
-
154
- return candidateFilesCache.set(context, candidateFiles).get(context)
155
- }
156
-
157
- // Get the config object based on a path
158
- function getTailwindConfig(configOrPath) {
159
- let userConfigPath = resolveConfigPath(configOrPath)
160
-
161
- if (userConfigPath !== null) {
162
- let [prevConfig, prevModified = -Infinity, prevConfigHash] =
163
- configPathCache.get(userConfigPath) || []
164
- let modified = fs.statSync(userConfigPath).mtimeMs
165
-
166
- // It hasn't changed (based on timestamp)
167
- if (modified <= prevModified) {
168
- return [prevConfig, userConfigPath, prevConfigHash, [userConfigPath]]
169
- }
170
-
171
- // It has changed (based on timestamp), or first run
172
- delete require.cache[userConfigPath]
173
- let newConfig = resolveConfig(require(userConfigPath))
174
- let newHash = hash(newConfig)
175
- configPathCache.set(userConfigPath, [newConfig, modified, newHash])
176
- return [newConfig, userConfigPath, newHash, [userConfigPath]]
177
- }
178
-
179
- // It's a plain object, not a path
180
- let newConfig = resolveConfig(
181
- configOrPath.config === undefined ? configOrPath : configOrPath.config
182
- )
183
-
184
- return [newConfig, null, hash(newConfig), []]
185
- }
186
-
187
- function resolvedChangedContent(context, candidateFiles) {
188
- let changedContent = context.tailwindConfig.content.content
189
- .filter((item) => typeof item.raw === 'string')
190
- .concat(context.tailwindConfig.content.safelist)
191
- .map(({ raw, extension }) => ({ content: raw, extension }))
192
-
193
- for (let changedFile of resolveChangedFiles(context, candidateFiles)) {
194
- let content = fs.readFileSync(changedFile, 'utf8')
195
- let extension = path.extname(changedFile).slice(1)
196
- changedContent.push({ content, extension })
197
- }
198
- return changedContent
199
- }
200
-
201
- let scannedContentCache = new WeakMap()
202
-
203
- function resolveChangedFiles(context, candidateFiles) {
204
- let changedFiles = new Set()
205
-
206
- // If we're not set up and watching files ourselves, we need to do
207
- // the work of grabbing all of the template files for candidate
208
- // detection.
209
- if (!scannedContentCache.has(context)) {
210
- let files = fastGlob.sync(candidateFiles)
211
- for (let file of files) {
212
- changedFiles.add(file)
213
- }
214
- scannedContentCache.set(context, true)
215
- }
216
-
217
- return changedFiles
218
- }
219
-
220
- // DISABLE_TOUCH = FALSE
221
-
222
- // Retrieve an existing context from cache if possible (since contexts are unique per
223
- // source path), or set up a new one (including setting up watchers and registering
224
- // plugins) then return it
225
- export default function setupWatchingContext(configOrPath) {
226
- return ({ tailwindDirectives, registerDependency }) => {
227
- return (root, result) => {
228
- let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] =
229
- getTailwindConfig(configOrPath)
230
-
231
- let contextDependencies = new Set(configDependencies)
232
-
233
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
234
- // to be dependencies of the context. Can reuse the context even if they change.
235
- // We may want to think about `@layer` being part of this trigger too, but it's tough
236
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
237
- // in another file since independent sources are effectively isolated.
238
- if (tailwindDirectives.size > 0) {
239
- // Add current css file as a context dependencies.
240
- contextDependencies.add(result.opts.from)
241
-
242
- // Add all css @import dependencies as context dependencies.
243
- for (let message of result.messages) {
244
- if (message.type === 'dependency') {
245
- contextDependencies.add(message.file)
246
- }
247
- }
248
- }
249
-
250
- let [context, isNewContext] = getContext(
251
- tailwindDirectives,
252
- root,
253
- result,
254
- tailwindConfig,
255
- userConfigPath,
256
- tailwindConfigHash,
257
- contextDependencies
258
- )
259
-
260
- let candidateFiles = getCandidateFiles(context, tailwindConfig)
261
- let contextConfigDependencies = getConfigDependencies(context)
262
-
263
- for (let file of configDependencies) {
264
- registerDependency({ type: 'dependency', file })
265
- }
266
-
267
- context.disposables.push((oldContext) => {
268
- let watcher = getWatcher(oldContext)
269
- if (watcher !== null) {
270
- watcher.close()
271
- }
272
- })
273
-
274
- let configPath = getConfigPath(context, configOrPath)
275
-
276
- if (configPath !== null) {
277
- for (let dependency of getModuleDependencies(configPath)) {
278
- if (dependency.file === configPath) {
279
- continue
280
- }
281
-
282
- contextConfigDependencies.add(dependency.file)
283
- }
284
- }
285
-
286
- if (isNewContext) {
287
- rebootWatcher(context, configPath, contextConfigDependencies, candidateFiles)
288
- }
289
-
290
- // Register our temp file as a dependency — we write to this file
291
- // to trigger rebuilds.
292
- let touchFile = getTouchFile(context)
293
- if (touchFile) {
294
- registerDependency({ type: 'dependency', file: touchFile })
295
- }
296
-
297
- if (tailwindDirectives.size > 0) {
298
- for (let changedContent of resolvedChangedContent(context, candidateFiles)) {
299
- context.changedContent.push(changedContent)
300
- }
301
- }
302
-
303
- return context
304
- }
305
- }
306
- }