tailwindcss 0.0.0-insiders.ea139f2 → 0.0.0-insiders.ea4e1cd

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 (236) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +15 -7
  3. package/colors.d.ts +3 -0
  4. package/colors.js +2 -1
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultConfig.js +2 -1
  7. package/defaultTheme.d.ts +4 -0
  8. package/defaultTheme.js +2 -1
  9. package/lib/cli/build/deps.js +62 -0
  10. package/lib/cli/build/index.js +54 -0
  11. package/lib/cli/build/plugin.js +378 -0
  12. package/lib/cli/build/utils.js +88 -0
  13. package/lib/cli/build/watching.js +182 -0
  14. package/lib/cli/help/index.js +73 -0
  15. package/lib/cli/index.js +230 -0
  16. package/lib/cli/init/index.js +63 -0
  17. package/lib/cli-peer-dependencies.js +28 -7
  18. package/lib/cli.js +4 -703
  19. package/lib/corePluginList.js +12 -3
  20. package/lib/corePlugins.js +2373 -1863
  21. package/lib/css/preflight.css +10 -8
  22. package/lib/featureFlags.js +49 -26
  23. package/lib/index.js +1 -31
  24. package/lib/lib/cacheInvalidation.js +92 -0
  25. package/lib/lib/collapseAdjacentRules.js +30 -10
  26. package/lib/lib/collapseDuplicateDeclarations.js +60 -4
  27. package/lib/lib/content.js +181 -0
  28. package/lib/lib/defaultExtractor.js +243 -0
  29. package/lib/lib/detectNesting.js +21 -10
  30. package/lib/lib/evaluateTailwindFunctions.js +115 -50
  31. package/lib/lib/expandApplyAtRules.js +467 -161
  32. package/lib/lib/expandTailwindAtRules.js +160 -133
  33. package/lib/lib/findAtConfigPath.js +46 -0
  34. package/lib/lib/generateRules.js +553 -200
  35. package/lib/lib/getModuleDependencies.js +88 -37
  36. package/lib/lib/load-config.js +42 -0
  37. package/lib/lib/normalizeTailwindDirectives.js +46 -33
  38. package/lib/lib/offsets.js +306 -0
  39. package/lib/lib/partitionApplyAtRules.js +58 -0
  40. package/lib/lib/regex.js +74 -0
  41. package/lib/lib/remap-bitfield.js +89 -0
  42. package/lib/lib/resolveDefaultsAtRules.js +98 -58
  43. package/lib/lib/setupContextUtils.js +773 -321
  44. package/lib/lib/setupTrackingContext.js +70 -75
  45. package/lib/lib/sharedState.js +78 -10
  46. package/lib/lib/substituteScreenAtRules.js +14 -10
  47. package/lib/oxide/cli/build/deps.js +89 -0
  48. package/lib/oxide/cli/build/index.js +53 -0
  49. package/lib/oxide/cli/build/plugin.js +375 -0
  50. package/lib/oxide/cli/build/utils.js +87 -0
  51. package/lib/oxide/cli/build/watching.js +179 -0
  52. package/lib/oxide/cli/help/index.js +72 -0
  53. package/lib/oxide/cli/index.js +214 -0
  54. package/lib/oxide/cli/init/index.js +52 -0
  55. package/lib/oxide/cli.js +5 -0
  56. package/lib/oxide/postcss-plugin.js +2 -0
  57. package/lib/plugin.js +98 -0
  58. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  59. package/lib/postcss-plugins/nesting/index.js +21 -0
  60. package/lib/postcss-plugins/nesting/plugin.js +89 -0
  61. package/lib/processTailwindFeatures.js +39 -26
  62. package/lib/public/colors.js +272 -246
  63. package/lib/public/create-plugin.js +9 -5
  64. package/lib/public/default-config.js +10 -6
  65. package/lib/public/default-theme.js +10 -6
  66. package/lib/public/load-config.js +12 -0
  67. package/lib/public/resolve-config.js +11 -6
  68. package/lib/util/applyImportantSelector.js +36 -0
  69. package/lib/util/bigSign.js +6 -1
  70. package/lib/util/buildMediaQuery.js +13 -6
  71. package/lib/util/cloneDeep.js +9 -6
  72. package/lib/util/cloneNodes.js +23 -3
  73. package/lib/util/color.js +70 -38
  74. package/lib/util/colorNames.js +752 -0
  75. package/lib/util/configurePlugins.js +7 -2
  76. package/lib/util/createPlugin.js +8 -6
  77. package/lib/util/createUtilityPlugin.js +16 -16
  78. package/lib/util/dataTypes.js +173 -108
  79. package/lib/util/defaults.js +14 -3
  80. package/lib/util/escapeClassName.js +13 -8
  81. package/lib/util/escapeCommas.js +7 -2
  82. package/lib/util/flattenColorPalette.js +11 -12
  83. package/lib/util/formatVariantSelector.js +228 -151
  84. package/lib/util/getAllConfigs.js +33 -12
  85. package/lib/util/hashConfig.js +9 -4
  86. package/lib/util/isKeyframeRule.js +7 -2
  87. package/lib/util/isPlainObject.js +7 -2
  88. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  89. package/lib/util/log.js +27 -13
  90. package/lib/util/nameClass.js +27 -10
  91. package/lib/util/negateValue.js +25 -8
  92. package/lib/util/normalizeConfig.js +139 -65
  93. package/lib/util/normalizeScreens.js +131 -11
  94. package/lib/util/parseAnimationValue.js +44 -40
  95. package/lib/util/parseBoxShadowValue.js +34 -23
  96. package/lib/util/parseDependency.js +39 -55
  97. package/lib/util/parseGlob.js +36 -0
  98. package/lib/util/parseObjectStyles.js +15 -10
  99. package/lib/util/pluginUtils.js +159 -69
  100. package/lib/util/prefixSelector.js +30 -12
  101. package/lib/util/pseudoElements.js +229 -0
  102. package/lib/util/removeAlphaVariables.js +31 -0
  103. package/lib/util/resolveConfig.js +97 -75
  104. package/lib/util/resolveConfigPath.js +30 -12
  105. package/lib/util/responsive.js +11 -6
  106. package/lib/util/splitAtTopLevelOnly.js +51 -0
  107. package/lib/util/tap.js +6 -1
  108. package/lib/util/toColorValue.js +7 -3
  109. package/lib/util/toPath.js +26 -3
  110. package/lib/util/transformThemeValue.js +40 -30
  111. package/lib/util/validateConfig.js +37 -0
  112. package/lib/util/validateFormalSyntax.js +26 -0
  113. package/lib/util/withAlphaVariable.js +27 -15
  114. package/loadConfig.d.ts +4 -0
  115. package/loadConfig.js +2 -0
  116. package/nesting/index.js +2 -12
  117. package/package.json +66 -57
  118. package/peers/index.js +75964 -55560
  119. package/plugin.d.ts +11 -0
  120. package/plugin.js +2 -1
  121. package/resolveConfig.d.ts +12 -0
  122. package/resolveConfig.js +2 -1
  123. package/scripts/generate-types.js +105 -0
  124. package/scripts/release-channel.js +18 -0
  125. package/scripts/release-notes.js +21 -0
  126. package/scripts/swap-engines.js +40 -0
  127. package/scripts/type-utils.js +27 -0
  128. package/src/cli/build/deps.js +56 -0
  129. package/src/cli/build/index.js +49 -0
  130. package/src/cli/build/plugin.js +444 -0
  131. package/src/cli/build/utils.js +76 -0
  132. package/src/cli/build/watching.js +229 -0
  133. package/src/cli/help/index.js +70 -0
  134. package/src/cli/index.js +216 -0
  135. package/src/cli/init/index.js +79 -0
  136. package/src/cli-peer-dependencies.js +7 -1
  137. package/src/cli.js +4 -765
  138. package/src/corePluginList.js +1 -1
  139. package/src/corePlugins.js +786 -306
  140. package/src/css/preflight.css +10 -8
  141. package/src/featureFlags.js +21 -5
  142. package/src/index.js +1 -34
  143. package/src/lib/cacheInvalidation.js +52 -0
  144. package/src/lib/collapseAdjacentRules.js +21 -2
  145. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  146. package/src/lib/content.js +208 -0
  147. package/src/lib/defaultExtractor.js +217 -0
  148. package/src/lib/detectNesting.js +9 -1
  149. package/src/lib/evaluateTailwindFunctions.js +79 -8
  150. package/src/lib/expandApplyAtRules.js +515 -153
  151. package/src/lib/expandTailwindAtRules.js +115 -86
  152. package/src/lib/findAtConfigPath.js +48 -0
  153. package/src/lib/generateRules.js +545 -147
  154. package/src/lib/getModuleDependencies.js +70 -30
  155. package/src/lib/load-config.ts +31 -0
  156. package/src/lib/normalizeTailwindDirectives.js +7 -1
  157. package/src/lib/offsets.js +373 -0
  158. package/src/lib/partitionApplyAtRules.js +52 -0
  159. package/src/lib/regex.js +74 -0
  160. package/src/lib/remap-bitfield.js +82 -0
  161. package/src/lib/resolveDefaultsAtRules.js +59 -17
  162. package/src/lib/setupContextUtils.js +701 -175
  163. package/src/lib/setupTrackingContext.js +51 -62
  164. package/src/lib/sharedState.js +58 -7
  165. package/src/oxide/cli/build/deps.ts +91 -0
  166. package/src/oxide/cli/build/index.ts +47 -0
  167. package/src/oxide/cli/build/plugin.ts +442 -0
  168. package/src/oxide/cli/build/utils.ts +74 -0
  169. package/src/oxide/cli/build/watching.ts +225 -0
  170. package/src/oxide/cli/help/index.ts +69 -0
  171. package/src/oxide/cli/index.ts +204 -0
  172. package/src/oxide/cli/init/index.ts +59 -0
  173. package/src/oxide/cli.ts +1 -0
  174. package/src/oxide/postcss-plugin.ts +1 -0
  175. package/src/plugin.js +107 -0
  176. package/src/postcss-plugins/nesting/README.md +42 -0
  177. package/src/postcss-plugins/nesting/index.js +13 -0
  178. package/src/postcss-plugins/nesting/plugin.js +80 -0
  179. package/src/processTailwindFeatures.js +12 -2
  180. package/src/public/colors.js +22 -0
  181. package/src/public/default-config.js +1 -1
  182. package/src/public/default-theme.js +2 -2
  183. package/src/public/load-config.js +2 -0
  184. package/src/util/applyImportantSelector.js +27 -0
  185. package/src/util/buildMediaQuery.js +5 -3
  186. package/src/util/cloneNodes.js +19 -2
  187. package/src/util/color.js +44 -12
  188. package/src/util/colorNames.js +150 -0
  189. package/src/util/dataTypes.js +51 -16
  190. package/src/util/defaults.js +6 -0
  191. package/src/util/formatVariantSelector.js +264 -144
  192. package/src/util/getAllConfigs.js +21 -2
  193. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  194. package/src/util/log.js +11 -7
  195. package/src/util/nameClass.js +4 -0
  196. package/src/util/negateValue.js +11 -3
  197. package/src/util/normalizeConfig.js +57 -5
  198. package/src/util/normalizeScreens.js +105 -7
  199. package/src/util/parseBoxShadowValue.js +4 -3
  200. package/src/util/parseDependency.js +37 -42
  201. package/src/util/parseGlob.js +24 -0
  202. package/src/util/pluginUtils.js +123 -24
  203. package/src/util/prefixSelector.js +30 -10
  204. package/src/util/pseudoElements.js +170 -0
  205. package/src/util/removeAlphaVariables.js +24 -0
  206. package/src/util/resolveConfig.js +74 -26
  207. package/src/util/resolveConfigPath.js +12 -1
  208. package/src/util/splitAtTopLevelOnly.js +52 -0
  209. package/src/util/toPath.js +23 -1
  210. package/src/util/transformThemeValue.js +13 -3
  211. package/src/util/validateConfig.js +26 -0
  212. package/src/util/validateFormalSyntax.js +34 -0
  213. package/src/util/withAlphaVariable.js +1 -1
  214. package/stubs/.gitignore +1 -0
  215. package/stubs/.prettierrc.json +6 -0
  216. package/stubs/{defaultConfig.stub.js → config.full.js} +206 -166
  217. package/stubs/postcss.config.js +6 -0
  218. package/stubs/tailwind.config.cjs +2 -0
  219. package/stubs/tailwind.config.js +2 -0
  220. package/stubs/tailwind.config.ts +3 -0
  221. package/types/config.d.ts +368 -0
  222. package/types/generated/.gitkeep +0 -0
  223. package/types/generated/colors.d.ts +298 -0
  224. package/types/generated/corePluginList.d.ts +1 -0
  225. package/types/generated/default-theme.d.ts +371 -0
  226. package/types/index.d.ts +7 -0
  227. package/CHANGELOG.md +0 -1843
  228. package/lib/constants.js +0 -37
  229. package/lib/lib/setupWatchingContext.js +0 -288
  230. package/nesting/plugin.js +0 -41
  231. package/scripts/install-integrations.js +0 -27
  232. package/scripts/rebuildFixtures.js +0 -68
  233. package/src/constants.js +0 -17
  234. package/src/lib/setupWatchingContext.js +0 -311
  235. /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
  236. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/lib/cli.js CHANGED
@@ -1,706 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var _indexJs = require("../peers/index.js");
4
- var _chokidar = _interopRequireDefault(require("chokidar"));
5
- var _path = _interopRequireDefault(require("path"));
6
- var _arg = _interopRequireDefault(require("arg"));
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config"));
9
- var _cosmiconfig = require("cosmiconfig");
10
- var _plugins // Little bit scary, looking at private/internal API
11
- = _interopRequireDefault(require("postcss-load-config/src/plugins"));
12
- var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
13
- var _resolveConfig = _interopRequireDefault(require("../resolveConfig"));
14
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
15
- var _getModuleDependencies = _interopRequireDefault(require("./lib/getModuleDependencies"));
16
- var _log = _interopRequireDefault(require("./util/log"));
17
- var _packageJson = _interopRequireDefault(require("../package.json"));
18
- var _normalizePath = _interopRequireDefault(require("normalize-path"));
19
- function _interopRequireDefault(obj) {
20
- return obj && obj.__esModule ? obj : {
21
- default: obj
22
- };
23
- }
24
- let env = {
25
- DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0'
26
- };
27
- // ---
28
- function indentRecursive(node, indent = 0) {
29
- node.each && node.each((child, i)=>{
30
- if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes('\n')) {
31
- child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`;
32
- }
33
- child.raws.after = `\n${' '.repeat(indent)}`;
34
- indentRecursive(child, indent + 1);
35
- });
36
- }
37
- function formatNodes(root) {
38
- indentRecursive(root);
39
- if (root.first) {
40
- root.first.raws.before = '';
41
- }
42
- }
43
- function help({ message , usage , commands , options }) {
44
- let indent = 2;
45
- // Render header
46
- console.log();
47
- console.log(`${_packageJson.default.name} v${_packageJson.default.version}`);
48
- // Render message
49
- if (message) {
50
- console.log();
51
- for (let msg of message.split('\n')){
52
- console.log(msg);
53
- }
54
- }
55
- // Render usage
56
- if (usage && usage.length > 0) {
57
- console.log();
58
- console.log('Usage:');
59
- for (let example of usage){
60
- console.log(' '.repeat(indent), example);
61
- }
62
- }
63
- // Render commands
64
- if (commands && commands.length > 0) {
65
- console.log();
66
- console.log('Commands:');
67
- for (let command of commands){
68
- console.log(' '.repeat(indent), command);
69
- }
70
- }
71
- // Render options
72
- if (options) {
73
- let groupedOptions = {
74
- };
75
- for (let [key, value] of Object.entries(options)){
76
- if (typeof value === 'object') {
77
- groupedOptions[key] = {
78
- ...value,
79
- flags: [
80
- key
81
- ]
82
- };
83
- } else {
84
- groupedOptions[value].flags.push(key);
85
- }
86
- }
87
- console.log();
88
- console.log('Options:');
89
- for (let { flags , description , deprecated } of Object.values(groupedOptions)){
90
- if (deprecated) continue;
91
- if (flags.length === 1) {
92
- console.log(' '.repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(', ').padEnd(20, ' '), description);
93
- } else {
94
- console.log(' '.repeat(indent), flags.slice().reverse().join(', ').padEnd(24, ' '), description);
95
- }
96
- }
97
- }
98
- console.log();
99
- }
100
- function oneOf(...options) {
101
- return Object.assign((value = true)=>{
102
- for (let option of options){
103
- let parsed = option(value);
104
- if (parsed === value) {
105
- return parsed;
106
- }
107
- }
108
- throw new Error('...');
109
- }, {
110
- manualParsing: true
111
- });
112
- }
113
- let commands1 = {
114
- init: {
115
- run: init,
116
- args: {
117
- '--full': {
118
- type: Boolean,
119
- description: 'Initialize a full `tailwind.config.js` file'
120
- },
121
- '--postcss': {
122
- type: Boolean,
123
- description: 'Initialize a `postcss.config.js` file'
124
- },
125
- '-f': '--full',
126
- '-p': '--postcss'
127
- }
128
- },
129
- build: {
130
- run: build,
131
- args: {
132
- '--input': {
133
- type: String,
134
- description: 'Input file'
135
- },
136
- '--output': {
137
- type: String,
138
- description: 'Output file'
139
- },
140
- '--watch': {
141
- type: Boolean,
142
- description: 'Watch for changes and rebuild as needed'
143
- },
144
- '--content': {
145
- type: String,
146
- description: 'Content paths to use for removing unused classes'
147
- },
148
- '--purge': {
149
- type: String,
150
- deprecated: true
151
- },
152
- '--postcss': {
153
- type: oneOf(String, Boolean),
154
- description: 'Load custom PostCSS configuration'
155
- },
156
- '--minify': {
157
- type: Boolean,
158
- description: 'Minify the output'
159
- },
160
- '--config': {
161
- type: String,
162
- description: 'Path to a custom config file'
163
- },
164
- '--no-autoprefixer': {
165
- type: Boolean,
166
- description: 'Disable autoprefixer'
167
- },
168
- '-c': '--config',
169
- '-i': '--input',
170
- '-o': '--output',
171
- '-m': '--minify',
172
- '-w': '--watch'
173
- }
174
- }
175
- };
176
- let sharedFlags = {
177
- '--help': {
178
- type: Boolean,
179
- description: 'Display usage information'
180
- },
181
- '-h': '--help'
182
- };
183
- if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined
184
- ))) {
185
- help({
186
- usage: [
187
- 'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
188
- 'tailwindcss init [--full] [--postcss] [options...]',
189
- ],
190
- commands: Object.keys(commands1).filter((command)=>command !== 'build'
191
- ).map((command)=>`${command} [options]`
192
- ),
193
- options: {
194
- ...commands1.build.args,
195
- ...sharedFlags
196
- }
197
- });
198
- process.exit(0);
199
- }
200
- let command1 = ((arg = '')=>arg.startsWith('-') ? undefined : arg
201
- )(process.argv[2]) || 'build';
202
- if (commands1[command1] === undefined) {
203
- if (_fs.default.existsSync(_path.default.resolve(command1))) {
204
- // TODO: Deprecate this in future versions
205
- // Check if non-existing command, might be a file.
206
- command1 = 'build';
207
- } else {
208
- help({
209
- message: `Invalid command: ${command1}`,
210
- usage: [
211
- 'tailwindcss <command> [options]'
212
- ],
213
- commands: Object.keys(commands1).filter((command)=>command !== 'build'
214
- ).map((command)=>`${command} [options]`
215
- ),
216
- options: sharedFlags
217
- });
218
- process.exit(1);
219
- }
220
- }
221
- // Execute command
222
- let { args: flags1 , run } = commands1[command1];
223
- let args1 = (()=>{
224
- try {
225
- let result = (0, _arg).default(Object.fromEntries(Object.entries({
226
- ...flags1,
227
- ...sharedFlags
228
- }).filter(([_key, value])=>{
229
- var ref;
230
- return !(value === null || value === void 0 ? void 0 : (ref = value.type) === null || ref === void 0 ? void 0 : ref.manualParsing);
231
- }).map(([key, value])=>[
232
- key,
233
- typeof value === 'object' ? value.type : value
234
- ]
235
- )), {
236
- permissive: true
237
- });
238
- // Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
239
- for(let i = result['_'].length - 1; i >= 0; --i){
240
- let flag = result['_'][i];
241
- if (!flag.startsWith('-')) continue;
242
- let flagName = flag;
243
- let handler = flags1[flag];
244
- // Resolve flagName & handler
245
- while(typeof handler === 'string'){
246
- flagName = handler;
247
- handler = flags1[handler];
248
- }
249
- if (!handler) continue;
250
- let args = [];
251
- let offset = i + 1;
252
- // Parse args for current flag
253
- while(result['_'][offset] && !result['_'][offset].startsWith('-')){
254
- args.push(result['_'][offset++]);
255
- }
256
- // Cleanup manually parsed flags + args
257
- result['_'].splice(i, 1 + args.length);
258
- // Set the resolved value in the `result` object
259
- result[flagName] = handler.type(args.length === 0 ? undefined : args.length === 1 ? args[0] : args, flagName);
260
- }
261
- // Ensure that the `command` is always the first argument in the `args`.
262
- // This is important so that we don't have to check if a default command
263
- // (build) was used or not from within each plugin.
264
- //
265
- // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
266
- // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
267
- if (result['_'][0] !== command1) {
268
- result['_'].unshift(command1);
269
- }
270
- return result;
271
- } catch (err) {
272
- if (err.code === 'ARG_UNKNOWN_OPTION') {
273
- help({
274
- message: err.message,
275
- usage: [
276
- 'tailwindcss <command> [options]'
277
- ],
278
- options: sharedFlags
279
- });
280
- process.exit(1);
281
- }
282
- throw err;
283
- }
284
- })();
285
- if (args1['--help']) {
286
- help({
287
- options: {
288
- ...flags1,
289
- ...sharedFlags
290
- },
291
- usage: [
292
- `tailwindcss ${command1} [options]`
293
- ]
294
- });
295
- process.exit(0);
296
- }
297
- run();
298
- // ---
299
- function init() {
300
- let messages = [];
301
- var ref;
302
- let tailwindConfigLocation = _path.default.resolve((ref = args1['_'][1]) !== null && ref !== void 0 ? ref : './tailwind.config.js');
303
- if (_fs.default.existsSync(tailwindConfigLocation)) {
304
- messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
305
- } else {
306
- let stubFile = _fs.default.readFileSync(args1['--full'] ? _path.default.resolve(__dirname, '../stubs/defaultConfig.stub.js') : _path.default.resolve(__dirname, '../stubs/simpleConfig.stub.js'), 'utf8');
307
- // Change colors import
308
- stubFile = stubFile.replace('../colors', 'tailwindcss/colors');
309
- _fs.default.writeFileSync(tailwindConfigLocation, stubFile, 'utf8');
310
- messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
311
- }
312
- if (args1['--postcss']) {
313
- let postcssConfigLocation = _path.default.resolve('./postcss.config.js');
314
- if (_fs.default.existsSync(postcssConfigLocation)) {
315
- messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
316
- } else {
317
- let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, '../stubs/defaultPostCssConfig.stub.js'), 'utf8');
318
- _fs.default.writeFileSync(postcssConfigLocation, stubFile, 'utf8');
319
- messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
320
- }
321
- }
322
- if (messages.length > 0) {
323
- console.log();
324
- for (let message of messages){
325
- console.log(message);
326
- }
327
- }
328
- }
329
- async function build() {
330
- let input = args1['--input'];
331
- let output = args1['--output'];
332
- let shouldWatch = args1['--watch'];
333
- let includePostCss = args1['--postcss'];
334
- // TODO: Deprecate this in future versions
335
- if (!input && args1['_'][1]) {
336
- console.error('[deprecation] Running tailwindcss without -i, please provide an input file.');
337
- input = args1['--input'] = args1['_'][1];
338
- }
339
- if (input && !_fs.default.existsSync(input = _path.default.resolve(input))) {
340
- console.error(`Specified input file ${args1['--input']} does not exist.`);
341
- process.exit(9);
342
- }
343
- if (args1['--config'] && !_fs.default.existsSync(args1['--config'] = _path.default.resolve(args1['--config']))) {
344
- console.error(`Specified config file ${args1['--config']} does not exist.`);
345
- process.exit(9);
346
- }
347
- let configPath = args1['--config'] ? args1['--config'] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
348
- )(_path.default.resolve('./tailwind.config.js'));
349
- async function loadPostCssPlugins() {
350
- let customPostCssPath = typeof args1['--postcss'] === 'string' ? args1['--postcss'] : undefined;
351
- let { plugins: configPlugins } = customPostCssPath ? await (async ()=>{
352
- let file = _path.default.resolve(customPostCssPath);
353
- // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.0.1/src/index.js
354
- let { config ={
355
- } } = await (0, _cosmiconfig).cosmiconfig('postcss').load(file);
356
- if (typeof config === 'function') {
357
- config = config();
358
- } else {
359
- config = Object.assign({
360
- }, config);
361
- }
362
- if (!config.plugins) {
363
- config.plugins = [];
364
- }
365
- return {
366
- plugins: (0, _plugins).default(config, file)
367
- };
368
- })() : await (0, _postcssLoadConfig).default();
369
- let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
370
- if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
371
- return true;
372
- }
373
- if (typeof plugin === 'object' && plugin !== null && plugin.postcssPlugin === 'tailwindcss') {
374
- return true;
375
- }
376
- return false;
377
- });
378
- let beforePlugins = configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx);
379
- let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
380
- return [
381
- beforePlugins,
382
- afterPlugins
383
- ];
384
- }
385
- function resolveConfig() {
386
- let config = configPath ? require(configPath) : {
387
- };
388
- let resolvedConfig = (0, _resolveConfig).default(config);
389
- if (args1['--purge']) {
390
- _log.default.warn('purge-flag-deprecated', [
391
- 'The `--purge` flag has been deprecated.',
392
- 'Please use `--content` instead.',
393
- ]);
394
- if (!args1['--content']) {
395
- args1['--content'] = args1['--purge'];
396
- }
397
- }
398
- if (args1['--content']) {
399
- resolvedConfig.content.files = args1['--content'].split(/(?<!{[^}]+),/);
400
- }
401
- return resolvedConfig;
402
- }
403
- function extractFileGlobs(config) {
404
- return config.content.files.filter((file)=>{
405
- // Strings in this case are files / globs. If it is something else,
406
- // like an object it's probably a raw content object. But this object
407
- // is not watchable, so let's remove it.
408
- return typeof file === 'string';
409
- }).map((glob)=>(0, _normalizePath).default(glob)
410
- );
411
- }
412
- function extractRawContent(config) {
413
- return config.content.files.filter((file)=>{
414
- return typeof file === 'object' && file !== null;
415
- });
416
- }
417
- function getChangedContent(config) {
418
- let changedContent = [];
419
- // Resolve globs from the content config
420
- let globs = extractFileGlobs(config);
421
- let files = _fastGlob.default.sync(globs);
422
- for (let file of files){
423
- changedContent.push({
424
- content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
425
- extension: _path.default.extname(file).slice(1)
426
- });
427
- }
428
- // Resolve raw content in the tailwind config
429
- for (let { raw: content , extension ='html' } of extractRawContent(config)){
430
- changedContent.push({
431
- content,
432
- extension
433
- });
434
- }
435
- return changedContent;
436
- }
437
- async function buildOnce() {
438
- let config = resolveConfig();
439
- let changedContent = getChangedContent(config);
440
- let tailwindPlugin = ()=>{
441
- return {
442
- postcssPlugin: 'tailwindcss',
443
- Once (root, { result }) {
444
- (0, _processTailwindFeatures).default(({ createContext })=>{
445
- return ()=>{
446
- return createContext(config, changedContent);
447
- };
448
- })(root, result);
449
- }
450
- };
451
- };
452
- tailwindPlugin.postcss = true;
453
- let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
454
- [],
455
- []
456
- ];
457
- let plugins = [
458
- ...beforePlugins,
459
- tailwindPlugin,
460
- !args1['--minify'] && formatNodes,
461
- ...afterPlugins,
462
- !args1['--no-autoprefixer'] && (()=>{
463
- // Try to load a local `autoprefixer` version first
464
- try {
465
- return require('autoprefixer');
466
- } catch {
467
- }
468
- return (0, _indexJs).lazyAutoprefixer();
469
- })(),
470
- args1['--minify'] && (()=>{
471
- let options = {
472
- preset: [
473
- 'default',
474
- {
475
- cssDeclarationSorter: false
476
- }
477
- ]
478
- };
479
- // Try to load a local `cssnano` version first
480
- try {
481
- return require('cssnano');
482
- } catch {
483
- }
484
- return (0, _indexJs).lazyCssnano()(options);
485
- })(),
486
- ].filter(Boolean);
487
- let processor = (0, _indexJs).postcss(plugins);
488
- function processCSS(css) {
489
- let start = process.hrtime.bigint();
490
- return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
491
- recursive: true
492
- }) : null
493
- ).then(()=>processor.process(css, {
494
- from: input,
495
- to: output
496
- })
497
- ).then((result)=>{
498
- if (!output) {
499
- return process.stdout.write(result.css);
500
- }
501
- return Promise.all([
502
- _fs.default.promises.writeFile(output, result.css, ()=>true
503
- ),
504
- result.map && _fs.default.writeFile(output + '.map', result.map.toString(), ()=>true
505
- ),
506
- ].filter(Boolean));
507
- }).then(()=>{
508
- let end = process.hrtime.bigint();
509
- console.error();
510
- console.error('Done in', (end - start) / BigInt(1000000) + 'ms.');
511
- });
512
- }
513
- let css1 = input ? _fs.default.readFileSync(_path.default.resolve(input), 'utf8') : '@tailwind base; @tailwind components; @tailwind utilities';
514
- return processCSS(css1);
515
- }
516
- let context = null;
517
- async function startWatcher() {
518
- let changedContent = [];
519
- let configDependencies = [];
520
- let contextDependencies = new Set();
521
- let watcher = null;
522
- function refreshConfig() {
523
- env.DEBUG && console.time('Module dependencies');
524
- for (let file1 of configDependencies){
525
- delete require.cache[require.resolve(file1)];
526
- }
527
- if (configPath) {
528
- configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
529
- );
530
- for (let dependency of configDependencies){
531
- contextDependencies.add(dependency);
532
- }
533
- }
534
- env.DEBUG && console.timeEnd('Module dependencies');
535
- return resolveConfig();
536
- }
537
- let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
538
- [],
539
- []
540
- ];
541
- let plugins = [
542
- ...beforePlugins,
543
- '__TAILWIND_PLUGIN_POSITION__',
544
- !args1['--minify'] && formatNodes,
545
- ...afterPlugins,
546
- !args1['--no-autoprefixer'] && (()=>{
547
- // Try to load a local `autoprefixer` version first
548
- try {
549
- return require('autoprefixer');
550
- } catch {
551
- }
552
- return (0, _indexJs).lazyAutoprefixer();
553
- })(),
554
- args1['--minify'] && (()=>{
555
- let options = {
556
- preset: [
557
- 'default',
558
- {
559
- cssDeclarationSorter: false
560
- }
561
- ]
562
- };
563
- // Try to load a local `cssnano` version first
564
- try {
565
- return require('cssnano');
566
- } catch {
567
- }
568
- return (0, _indexJs).lazyCssnano()(options);
569
- })(),
570
- ].filter(Boolean);
571
- async function rebuild(config) {
572
- env.DEBUG && console.time('Finished in');
573
- let tailwindPlugin = ()=>{
574
- return {
575
- postcssPlugin: 'tailwindcss',
576
- Once (root, { result }) {
577
- env.DEBUG && console.time('Compiling CSS');
578
- (0, _processTailwindFeatures).default(({ createContext })=>{
579
- console.error();
580
- console.error('Rebuilding...');
581
- return ()=>{
582
- if (context !== null) {
583
- context.changedContent = changedContent.splice(0);
584
- return context;
585
- }
586
- env.DEBUG && console.time('Creating context');
587
- context = createContext(config, changedContent.splice(0));
588
- env.DEBUG && console.timeEnd('Creating context');
589
- return context;
590
- };
591
- })(root, result);
592
- env.DEBUG && console.timeEnd('Compiling CSS');
593
- }
594
- };
595
- };
596
- tailwindPlugin.postcss = true;
597
- let tailwindPluginIdx = plugins.indexOf('__TAILWIND_PLUGIN_POSITION__');
598
- let copy = plugins.slice();
599
- copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
600
- let processor = (0, _indexJs).postcss(copy);
601
- function processCSS(css) {
602
- let start = process.hrtime.bigint();
603
- return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
604
- recursive: true
605
- }) : null
606
- ).then(()=>processor.process(css, {
607
- from: input,
608
- to: output
609
- })
610
- ).then(async (result)=>{
611
- for (let message of result.messages){
612
- if (message.type === 'dependency') {
613
- contextDependencies.add(message.file);
614
- }
615
- }
616
- watcher.add([
617
- ...contextDependencies
618
- ]);
619
- if (!output) {
620
- return process.stdout.write(result.css);
621
- }
622
- await Promise.all([
623
- _fs.default.promises.writeFile(output, result.css, ()=>true
624
- ),
625
- result.map && _fs.default.writeFile(output + '.map', result.map.toString(), ()=>true
626
- ),
627
- ].filter(Boolean));
628
- }).then(()=>{
629
- let end = process.hrtime.bigint();
630
- console.error('Done in', (end - start) / BigInt(1000000) + 'ms.');
631
- }).catch((err)=>{
632
- if (err.name === 'CssSyntaxError') {
633
- console.error(err.toString());
634
- } else {
635
- console.error(err);
636
- }
637
- });
638
- }
639
- let css2 = input ? _fs.default.readFileSync(_path.default.resolve(input), 'utf8') : '@tailwind base; @tailwind components; @tailwind utilities';
640
- let result1 = await processCSS(css2);
641
- env.DEBUG && console.timeEnd('Finished in');
642
- return result1;
643
- }
644
- let config1 = refreshConfig(configPath);
645
- if (input) {
646
- contextDependencies.add(_path.default.resolve(input));
647
- }
648
- watcher = _chokidar.default.watch([
649
- ...contextDependencies,
650
- ...extractFileGlobs(config1)
651
- ], {
652
- ignoreInitial: true,
653
- awaitWriteFinish: process.platform === 'win32' ? {
654
- stabilityThreshold: 50,
655
- pollInterval: 10
656
- } : false
657
- });
658
- let chain = Promise.resolve();
659
- watcher.on('change', async (file)=>{
660
- if (contextDependencies.has(file)) {
661
- env.DEBUG && console.time('Resolve config');
662
- context = null;
663
- config1 = refreshConfig(configPath);
664
- env.DEBUG && console.timeEnd('Resolve config');
665
- env.DEBUG && console.time('Watch new files');
666
- let globs = extractFileGlobs(config1);
667
- watcher.add(configDependencies);
668
- watcher.add(globs);
669
- env.DEBUG && console.timeEnd('Watch new files');
670
- chain = chain.then(async ()=>{
671
- changedContent.push(...getChangedContent(config1));
672
- await rebuild(config1);
673
- });
674
- } else {
675
- chain = chain.then(async ()=>{
676
- changedContent.push({
677
- content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
678
- extension: _path.default.extname(file).slice(1)
679
- });
680
- await rebuild(config1);
681
- });
682
- }
683
- });
684
- watcher.on('add', async (file)=>{
685
- chain = chain.then(async ()=>{
686
- changedContent.push({
687
- content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
688
- extension: _path.default.extname(file).slice(1)
689
- });
690
- await rebuild(config1);
691
- });
692
- });
693
- chain = chain.then(()=>{
694
- changedContent.push(...getChangedContent(config1));
695
- return rebuild(config1);
696
- });
697
- }
698
- if (shouldWatch) {
699
- /* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.on('end', ()=>process.exit(0)
700
- );
701
- process.stdin.resume();
702
- startWatcher();
703
- } else {
704
- buildOnce();
705
- }
3
+ if (false) {
4
+ module.exports = require("./oxide/cli");
5
+ } else {
6
+ module.exports = require("./cli/index");
706
7
  }