tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.ca7b10e

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 (179) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +18 -11
  3. package/dist/chunk-7MHEDNEU.mjs +1 -0
  4. package/dist/chunk-AZANAYY2.mjs +1 -0
  5. package/dist/chunk-YTVGJJD3.mjs +12 -0
  6. package/dist/colors-b_6i0Oi7.d.ts +295 -0
  7. package/dist/colors.d.mts +295 -0
  8. package/dist/colors.d.ts +5 -0
  9. package/dist/colors.js +1 -0
  10. package/dist/colors.mjs +1 -0
  11. package/dist/default-theme.d.mts +1147 -0
  12. package/dist/default-theme.d.ts +1147 -0
  13. package/dist/default-theme.js +1 -0
  14. package/dist/default-theme.mjs +1 -0
  15. package/dist/flatten-color-palette.d.mts +6 -0
  16. package/dist/flatten-color-palette.d.ts +6 -0
  17. package/dist/flatten-color-palette.js +1 -0
  18. package/dist/flatten-color-palette.mjs +1 -0
  19. package/dist/lib.d.mts +264 -0
  20. package/dist/lib.d.ts +3 -0
  21. package/dist/lib.js +33 -0
  22. package/dist/lib.mjs +22 -0
  23. package/dist/plugin.d.mts +11 -0
  24. package/dist/plugin.d.ts +104 -0
  25. package/dist/plugin.js +1 -0
  26. package/dist/plugin.mjs +1 -0
  27. package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
  28. package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
  29. package/dist/types-B254mqw1.d.mts +98 -0
  30. package/index.css +866 -0
  31. package/package.json +73 -100
  32. package/preflight.css +375 -0
  33. package/theme.css +453 -0
  34. package/CHANGELOG.md +0 -1758
  35. package/base.css +0 -1
  36. package/colors.js +0 -1
  37. package/components.css +0 -1
  38. package/defaultConfig.js +0 -1
  39. package/defaultTheme.js +0 -1
  40. package/lib/cli-peer-dependencies.js +0 -15
  41. package/lib/cli.js +0 -707
  42. package/lib/constants.js +0 -37
  43. package/lib/corePluginList.js +0 -169
  44. package/lib/corePlugins.js +0 -3525
  45. package/lib/css/LICENSE +0 -25
  46. package/lib/css/preflight.css +0 -354
  47. package/lib/featureFlags.js +0 -57
  48. package/lib/index.js +0 -32
  49. package/lib/lib/collapseAdjacentRules.js +0 -41
  50. package/lib/lib/detectNesting.js +0 -19
  51. package/lib/lib/evaluateTailwindFunctions.js +0 -167
  52. package/lib/lib/expandApplyAtRules.js +0 -228
  53. package/lib/lib/expandTailwindAtRules.js +0 -257
  54. package/lib/lib/generateRules.js +0 -350
  55. package/lib/lib/getModuleDependencies.js +0 -48
  56. package/lib/lib/normalizeTailwindDirectives.js +0 -75
  57. package/lib/lib/resolveDefaultsAtRules.js +0 -128
  58. package/lib/lib/setupContextUtils.js +0 -791
  59. package/lib/lib/setupTrackingContext.js +0 -170
  60. package/lib/lib/setupWatchingContext.js +0 -284
  61. package/lib/lib/sharedState.js +0 -29
  62. package/lib/lib/substituteScreenAtRules.js +0 -24
  63. package/lib/processTailwindFeatures.js +0 -47
  64. package/lib/public/colors.js +0 -333
  65. package/lib/public/create-plugin.js +0 -13
  66. package/lib/public/default-config.js +0 -14
  67. package/lib/public/default-theme.js +0 -14
  68. package/lib/public/resolve-config.js +0 -19
  69. package/lib/util/bigSign.js +0 -8
  70. package/lib/util/buildMediaQuery.js +0 -31
  71. package/lib/util/cloneDeep.js +0 -19
  72. package/lib/util/cloneNodes.js +0 -14
  73. package/lib/util/color.js +0 -84
  74. package/lib/util/configurePlugins.js +0 -18
  75. package/lib/util/createPlugin.js +0 -30
  76. package/lib/util/createUtilityPlugin.js +0 -53
  77. package/lib/util/dataTypes.js +0 -202
  78. package/lib/util/defaults.js +0 -16
  79. package/lib/util/escapeClassName.js +0 -19
  80. package/lib/util/escapeCommas.js +0 -8
  81. package/lib/util/flattenColorPalette.js +0 -19
  82. package/lib/util/getAllConfigs.js +0 -29
  83. package/lib/util/hashConfig.js +0 -16
  84. package/lib/util/isKeyframeRule.js +0 -8
  85. package/lib/util/isPlainObject.js +0 -12
  86. package/lib/util/log.js +0 -35
  87. package/lib/util/nameClass.js +0 -31
  88. package/lib/util/negateValue.js +0 -17
  89. package/lib/util/parseAnimationValue.js +0 -89
  90. package/lib/util/parseDependency.js +0 -63
  91. package/lib/util/parseObjectStyles.js +0 -31
  92. package/lib/util/pluginUtils.js +0 -282
  93. package/lib/util/prefixSelector.js +0 -23
  94. package/lib/util/resolveConfig.js +0 -293
  95. package/lib/util/resolveConfigPath.js +0 -52
  96. package/lib/util/responsive.js +0 -19
  97. package/lib/util/tap.js +0 -9
  98. package/lib/util/toColorValue.js +0 -9
  99. package/lib/util/toPath.js +0 -9
  100. package/lib/util/transformThemeValue.js +0 -53
  101. package/lib/util/withAlphaVariable.js +0 -67
  102. package/nesting/README.md +0 -42
  103. package/nesting/index.js +0 -12
  104. package/nesting/plugin.js +0 -41
  105. package/peers/index.js +0 -77111
  106. package/plugin.js +0 -1
  107. package/prettier.config.js +0 -19
  108. package/resolveConfig.js +0 -1
  109. package/screens.css +0 -1
  110. package/scripts/create-plugin-list.js +0 -10
  111. package/scripts/install-integrations.js +0 -27
  112. package/scripts/rebuildFixtures.js +0 -68
  113. package/src/cli-peer-dependencies.js +0 -9
  114. package/src/cli.js +0 -762
  115. package/src/constants.js +0 -17
  116. package/src/corePluginList.js +0 -1
  117. package/src/corePlugins.js +0 -2382
  118. package/src/css/LICENSE +0 -25
  119. package/src/css/preflight.css +0 -354
  120. package/src/featureFlags.js +0 -48
  121. package/src/index.js +0 -34
  122. package/src/lib/collapseAdjacentRules.js +0 -39
  123. package/src/lib/detectNesting.js +0 -20
  124. package/src/lib/evaluateTailwindFunctions.js +0 -195
  125. package/src/lib/expandApplyAtRules.js +0 -251
  126. package/src/lib/expandTailwindAtRules.js +0 -266
  127. package/src/lib/generateRules.js +0 -320
  128. package/src/lib/getModuleDependencies.js +0 -39
  129. package/src/lib/normalizeTailwindDirectives.js +0 -77
  130. package/src/lib/resolveDefaultsAtRules.js +0 -125
  131. package/src/lib/setupContextUtils.js +0 -775
  132. package/src/lib/setupTrackingContext.js +0 -184
  133. package/src/lib/setupWatchingContext.js +0 -306
  134. package/src/lib/sharedState.js +0 -13
  135. package/src/lib/substituteScreenAtRules.js +0 -16
  136. package/src/processTailwindFeatures.js +0 -43
  137. package/src/public/colors.js +0 -305
  138. package/src/public/create-plugin.js +0 -2
  139. package/src/public/default-config.js +0 -4
  140. package/src/public/default-theme.js +0 -4
  141. package/src/public/resolve-config.js +0 -7
  142. package/src/util/bigSign.js +0 -3
  143. package/src/util/buildMediaQuery.js +0 -24
  144. package/src/util/cloneDeep.js +0 -11
  145. package/src/util/cloneNodes.js +0 -11
  146. package/src/util/color.js +0 -56
  147. package/src/util/configurePlugins.js +0 -23
  148. package/src/util/createPlugin.js +0 -27
  149. package/src/util/createUtilityPlugin.js +0 -37
  150. package/src/util/dataTypes.js +0 -216
  151. package/src/util/defaults.js +0 -11
  152. package/src/util/escapeClassName.js +0 -8
  153. package/src/util/escapeCommas.js +0 -3
  154. package/src/util/flattenColorPalette.js +0 -13
  155. package/src/util/getAllConfigs.js +0 -19
  156. package/src/util/hashConfig.js +0 -5
  157. package/src/util/isKeyframeRule.js +0 -3
  158. package/src/util/isPlainObject.js +0 -8
  159. package/src/util/log.js +0 -28
  160. package/src/util/nameClass.js +0 -26
  161. package/src/util/negateValue.js +0 -14
  162. package/src/util/parseAnimationValue.js +0 -68
  163. package/src/util/parseDependency.js +0 -49
  164. package/src/util/parseObjectStyles.js +0 -19
  165. package/src/util/pluginUtils.js +0 -288
  166. package/src/util/prefixSelector.js +0 -15
  167. package/src/util/resolveConfig.js +0 -282
  168. package/src/util/resolveConfigPath.js +0 -55
  169. package/src/util/responsive.js +0 -10
  170. package/src/util/tap.js +0 -4
  171. package/src/util/toColorValue.js +0 -3
  172. package/src/util/toPath.js +0 -4
  173. package/src/util/transformThemeValue.js +0 -37
  174. package/src/util/withAlphaVariable.js +0 -49
  175. package/stubs/defaultConfig.stub.js +0 -890
  176. package/stubs/defaultPostCssConfig.stub.js +0 -6
  177. package/stubs/simpleConfig.stub.js +0 -8
  178. package/tailwind.css +0 -5
  179. package/variants.css +0 -1
@@ -1,184 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
-
4
- import fastGlob from 'fast-glob'
5
- import LRU from 'quick-lru'
6
- import normalizePath from 'normalize-path'
7
-
8
- import hash from '../util/hashConfig'
9
- import getModuleDependencies from '../lib/getModuleDependencies'
10
-
11
- import resolveConfig from '../public/resolve-config'
12
-
13
- import resolveConfigPath from '../util/resolveConfigPath'
14
-
15
- import { env } from './sharedState'
16
-
17
- import { getContext, getFileModifiedMap } from './setupContextUtils'
18
- import parseDependency from '../util/parseDependency'
19
-
20
- let configPathCache = new LRU({ maxSize: 100 })
21
-
22
- let candidateFilesCache = new WeakMap()
23
-
24
- function getCandidateFiles(context, tailwindConfig) {
25
- if (candidateFilesCache.has(context)) {
26
- return candidateFilesCache.get(context)
27
- }
28
-
29
- let candidateFiles = tailwindConfig.content.content
30
- .filter((item) => typeof item === 'string')
31
- .map((contentPath) => normalizePath(contentPath))
32
-
33
- return candidateFilesCache.set(context, candidateFiles).get(context)
34
- }
35
-
36
- // Get the config object based on a path
37
- function getTailwindConfig(configOrPath) {
38
- let userConfigPath = resolveConfigPath(configOrPath)
39
-
40
- if (userConfigPath !== null) {
41
- let [prevConfig, prevConfigHash, prevDeps, prevModified] =
42
- configPathCache.get(userConfigPath) || []
43
-
44
- let newDeps = getModuleDependencies(userConfigPath).map((dep) => dep.file)
45
-
46
- let modified = false
47
- let newModified = new Map()
48
- for (let file of newDeps) {
49
- let time = fs.statSync(file).mtimeMs
50
- newModified.set(file, time)
51
- if (!prevModified || !prevModified.has(file) || time > prevModified.get(file)) {
52
- modified = true
53
- }
54
- }
55
-
56
- // It hasn't changed (based on timestamps)
57
- if (!modified) {
58
- return [prevConfig, userConfigPath, prevConfigHash, prevDeps]
59
- }
60
-
61
- // It has changed (based on timestamps), or first run
62
- for (let file of newDeps) {
63
- delete require.cache[file]
64
- }
65
- let newConfig = resolveConfig(require(userConfigPath))
66
- let newHash = hash(newConfig)
67
- configPathCache.set(userConfigPath, [newConfig, newHash, newDeps, newModified])
68
- return [newConfig, userConfigPath, newHash, newDeps]
69
- }
70
-
71
- // It's a plain object, not a path
72
- let newConfig = resolveConfig(
73
- configOrPath.config === undefined ? configOrPath : configOrPath.config
74
- )
75
-
76
- return [newConfig, null, hash(newConfig), []]
77
- }
78
-
79
- function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
80
- let changedContent = context.tailwindConfig.content.content
81
- .filter((item) => typeof item.raw === 'string')
82
- .concat(context.tailwindConfig.content.safelist)
83
- .concat(context.safelist())
84
- .map(({ raw, extension }) => ({ content: raw, extension }))
85
-
86
- for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)) {
87
- let content = fs.readFileSync(changedFile, 'utf8')
88
- let extension = path.extname(changedFile).slice(1)
89
- changedContent.push({ content, extension })
90
- }
91
- return changedContent
92
- }
93
-
94
- function resolveChangedFiles(candidateFiles, fileModifiedMap) {
95
- let changedFiles = new Set()
96
- env.DEBUG && console.time('Finding changed files')
97
- let files = fastGlob.sync(candidateFiles)
98
- for (let file of files) {
99
- let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity
100
- let modified = fs.statSync(file).mtimeMs
101
-
102
- if (modified > prevModified) {
103
- changedFiles.add(file)
104
- fileModifiedMap.set(file, modified)
105
- }
106
- }
107
- env.DEBUG && console.timeEnd('Finding changed files')
108
- return changedFiles
109
- }
110
-
111
- // DISABLE_TOUCH = TRUE
112
-
113
- // Retrieve an existing context from cache if possible (since contexts are unique per
114
- // source path), or set up a new one (including setting up watchers and registering
115
- // plugins) then return it
116
- export default function setupTrackingContext(configOrPath) {
117
- return ({ tailwindDirectives, registerDependency }) => {
118
- return (root, result) => {
119
- let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] =
120
- getTailwindConfig(configOrPath)
121
-
122
- let contextDependencies = new Set(configDependencies)
123
-
124
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
125
- // to be dependencies of the context. Can reuse the context even if they change.
126
- // We may want to think about `@layer` being part of this trigger too, but it's tough
127
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
128
- // in another file since independent sources are effectively isolated.
129
- if (tailwindDirectives.size > 0) {
130
- // Add current css file as a context dependencies.
131
- contextDependencies.add(result.opts.from)
132
-
133
- // Add all css @import dependencies as context dependencies.
134
- for (let message of result.messages) {
135
- if (message.type === 'dependency') {
136
- contextDependencies.add(message.file)
137
- }
138
- }
139
- }
140
-
141
- let [context] = getContext(
142
- root,
143
- result,
144
- tailwindConfig,
145
- userConfigPath,
146
- tailwindConfigHash,
147
- contextDependencies
148
- )
149
-
150
- let candidateFiles = getCandidateFiles(context, tailwindConfig)
151
-
152
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
153
- // to be dependencies of the context. Can reuse the context even if they change.
154
- // We may want to think about `@layer` being part of this trigger too, but it's tough
155
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
156
- // in another file since independent sources are effectively isolated.
157
- if (tailwindDirectives.size > 0) {
158
- let fileModifiedMap = getFileModifiedMap(context)
159
-
160
- // Add template paths as postcss dependencies.
161
- for (let fileOrGlob of candidateFiles) {
162
- let dependency = parseDependency(fileOrGlob)
163
- if (dependency) {
164
- registerDependency(dependency)
165
- }
166
- }
167
-
168
- for (let changedContent of resolvedChangedContent(
169
- context,
170
- candidateFiles,
171
- fileModifiedMap
172
- )) {
173
- context.changedContent.push(changedContent)
174
- }
175
- }
176
-
177
- for (let file of configDependencies) {
178
- registerDependency({ type: 'dependency', file })
179
- }
180
-
181
- return context
182
- }
183
- }
184
- }
@@ -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 '../public/resolve-config'
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(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
- .concat(context.safelist())
192
- .map(({ raw, extension }) => ({ content: raw, extension }))
193
-
194
- for (let changedFile of resolveChangedFiles(context, candidateFiles)) {
195
- let content = fs.readFileSync(changedFile, 'utf8')
196
- let extension = path.extname(changedFile).slice(1)
197
- changedContent.push({ content, extension })
198
- }
199
- return changedContent
200
- }
201
-
202
- let scannedContentCache = new WeakMap()
203
-
204
- function resolveChangedFiles(context, candidateFiles) {
205
- let changedFiles = new Set()
206
-
207
- // If we're not set up and watching files ourselves, we need to do
208
- // the work of grabbing all of the template files for candidate
209
- // detection.
210
- if (!scannedContentCache.has(context)) {
211
- let files = fastGlob.sync(candidateFiles)
212
- for (let file of files) {
213
- changedFiles.add(file)
214
- }
215
- scannedContentCache.set(context, true)
216
- }
217
-
218
- return changedFiles
219
- }
220
-
221
- // DISABLE_TOUCH = FALSE
222
-
223
- // Retrieve an existing context from cache if possible (since contexts are unique per
224
- // source path), or set up a new one (including setting up watchers and registering
225
- // plugins) then return it
226
- export default function setupWatchingContext(configOrPath) {
227
- return ({ tailwindDirectives, registerDependency }) => {
228
- return (root, result) => {
229
- let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] =
230
- getTailwindConfig(configOrPath)
231
-
232
- let contextDependencies = new Set(configDependencies)
233
-
234
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
235
- // to be dependencies of the context. Can reuse the context even if they change.
236
- // We may want to think about `@layer` being part of this trigger too, but it's tough
237
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
238
- // in another file since independent sources are effectively isolated.
239
- if (tailwindDirectives.size > 0) {
240
- // Add current css file as a context dependencies.
241
- contextDependencies.add(result.opts.from)
242
-
243
- // Add all css @import dependencies as context dependencies.
244
- for (let message of result.messages) {
245
- if (message.type === 'dependency') {
246
- contextDependencies.add(message.file)
247
- }
248
- }
249
- }
250
-
251
- let [context, isNewContext] = getContext(
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
- }
@@ -1,13 +0,0 @@
1
- import LRU from 'quick-lru'
2
-
3
- export const env = {
4
- TAILWIND_MODE: process.env.TAILWIND_MODE,
5
- NODE_ENV: process.env.NODE_ENV,
6
- DEBUG: process.env.DEBUG !== undefined,
7
- TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
8
- TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR,
9
- }
10
- export const contextMap = new Map()
11
- export const configContextMap = new Map()
12
- export const contextSourcesMap = new Map()
13
- export const contentMatchCache = new LRU({ maxSize: 25000 })
@@ -1,16 +0,0 @@
1
- import buildMediaQuery from '../util/buildMediaQuery'
2
-
3
- export default function ({ tailwindConfig: { theme } }) {
4
- return function (css) {
5
- css.walkAtRules('screen', (atRule) => {
6
- const screen = atRule.params
7
-
8
- if (!theme.screens?.hasOwnProperty?.(screen)) {
9
- throw atRule.error(`No \`${screen}\` screen found.`)
10
- }
11
-
12
- atRule.name = 'media'
13
- atRule.params = buildMediaQuery(theme.screens[screen])
14
- })
15
- }
16
- }
@@ -1,43 +0,0 @@
1
- import normalizeTailwindDirectives from './lib/normalizeTailwindDirectives'
2
- import expandTailwindAtRules from './lib/expandTailwindAtRules'
3
- import expandApplyAtRules from './lib/expandApplyAtRules'
4
- import evaluateTailwindFunctions from './lib/evaluateTailwindFunctions'
5
- import substituteScreenAtRules from './lib/substituteScreenAtRules'
6
- import resolveDefaultsAtRules from './lib/resolveDefaultsAtRules'
7
- import collapseAdjacentRules from './lib/collapseAdjacentRules'
8
- import detectNesting from './lib/detectNesting'
9
- import { createContext } from './lib/setupContextUtils'
10
-
11
- export default function processTailwindFeatures(setupContext) {
12
- return function (root, result) {
13
- let tailwindDirectives = normalizeTailwindDirectives(root)
14
-
15
- let context = setupContext({
16
- tailwindDirectives,
17
- registerDependency(dependency) {
18
- result.messages.push({
19
- plugin: 'tailwindcss',
20
- parent: result.opts.from,
21
- ...dependency,
22
- })
23
- },
24
- createContext(tailwindConfig, changedContent) {
25
- return createContext(tailwindConfig, changedContent, root)
26
- },
27
- })(root, result)
28
-
29
- if (context.tailwindConfig.separator === '-') {
30
- throw new Error(
31
- "The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
32
- )
33
- }
34
-
35
- detectNesting(context)(root, result)
36
- expandTailwindAtRules(context)(root, result)
37
- expandApplyAtRules(context)(root, result)
38
- evaluateTailwindFunctions(context)(root, result)
39
- substituteScreenAtRules(context)(root, result)
40
- resolveDefaultsAtRules(context)(root, result)
41
- collapseAdjacentRules(context)(root, result)
42
- }
43
- }