tailwindcss 0.0.0-insiders.ed61821 → 0.0.0-insiders.ed8ff92

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