tailwindcss 0.0.0-insiders.c8b2b9a → 0.0.0-insiders.c8bf2d4

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