tailwindcss 0.0.0-insiders.fa693e5 → 0.0.0-insiders.fa9be73

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 (203) hide show
  1. package/README.md +1 -1
  2. package/index.css +5 -0
  3. package/lib/cli/build/index.js +29 -20
  4. package/lib/cli/build/plugin.js +200 -139
  5. package/lib/cli/build/utils.js +31 -21
  6. package/lib/cli/build/watching.js +26 -22
  7. package/lib/cli/help/index.js +17 -15
  8. package/lib/cli/index.js +74 -82
  9. package/lib/cli/init/index.js +30 -13
  10. package/lib/cli.js +1 -5
  11. package/lib/corePluginList.js +6 -1
  12. package/lib/corePlugins.js +1980 -1888
  13. package/lib/css/preflight.css +15 -4
  14. package/lib/featureFlags.js +36 -22
  15. package/lib/index.js +1 -5
  16. package/lib/lib/cacheInvalidation.js +10 -8
  17. package/lib/lib/collapseAdjacentRules.js +9 -7
  18. package/lib/lib/collapseDuplicateDeclarations.js +11 -9
  19. package/lib/lib/content.js +50 -20
  20. package/lib/lib/defaultExtractor.js +29 -33
  21. package/lib/lib/detectNesting.js +13 -11
  22. package/lib/lib/evaluateTailwindFunctions.js +43 -39
  23. package/lib/lib/expandApplyAtRules.js +64 -50
  24. package/lib/lib/expandTailwindAtRules.js +97 -57
  25. package/lib/lib/findAtConfigPath.js +11 -9
  26. package/lib/lib/generateRules.js +127 -113
  27. package/lib/lib/getModuleDependencies.js +85 -37
  28. package/lib/lib/handleImportAtRules.js +50 -0
  29. package/lib/lib/load-config.js +42 -0
  30. package/lib/lib/normalizeTailwindDirectives.js +26 -39
  31. package/lib/lib/offsets.js +53 -51
  32. package/lib/lib/partitionApplyAtRules.js +5 -3
  33. package/lib/lib/regex.js +26 -12
  34. package/lib/lib/remap-bitfield.js +3 -1
  35. package/lib/lib/resolveDefaultsAtRules.js +49 -45
  36. package/lib/lib/setupContextUtils.js +263 -228
  37. package/lib/lib/setupTrackingContext.js +32 -28
  38. package/lib/lib/sharedState.js +37 -36
  39. package/lib/lib/substituteScreenAtRules.js +9 -7
  40. package/lib/plugin.js +110 -44
  41. package/lib/postcss-plugins/nesting/index.js +5 -3
  42. package/lib/postcss-plugins/nesting/plugin.js +19 -17
  43. package/lib/processTailwindFeatures.js +19 -17
  44. package/lib/public/colors.js +269 -245
  45. package/lib/public/create-plugin.js +5 -3
  46. package/lib/public/default-config.js +6 -4
  47. package/lib/public/default-theme.js +6 -4
  48. package/lib/public/load-config.js +12 -0
  49. package/lib/public/resolve-config.js +6 -4
  50. package/lib/util/applyImportantSelector.js +36 -0
  51. package/lib/util/bigSign.js +3 -1
  52. package/lib/util/buildMediaQuery.js +5 -3
  53. package/lib/util/cloneDeep.js +4 -2
  54. package/lib/util/cloneNodes.js +4 -2
  55. package/lib/util/color.js +30 -26
  56. package/lib/util/colorNames.js +752 -0
  57. package/lib/util/configurePlugins.js +3 -1
  58. package/lib/util/createPlugin.js +3 -1
  59. package/lib/util/createUtilityPlugin.js +8 -6
  60. package/lib/util/dataTypes.js +210 -118
  61. package/lib/util/defaults.js +9 -7
  62. package/lib/util/escapeClassName.js +9 -7
  63. package/lib/util/escapeCommas.js +4 -2
  64. package/lib/util/flattenColorPalette.js +5 -3
  65. package/lib/util/formatVariantSelector.js +57 -137
  66. package/lib/util/getAllConfigs.js +11 -8
  67. package/lib/util/hashConfig.js +6 -4
  68. package/lib/util/isKeyframeRule.js +4 -2
  69. package/lib/util/isPlainObject.js +4 -2
  70. package/lib/util/isSyntacticallyValidPropertyValue.js +13 -11
  71. package/lib/util/log.js +31 -10
  72. package/lib/util/nameClass.js +16 -10
  73. package/lib/util/negateValue.js +11 -9
  74. package/lib/util/normalizeConfig.js +101 -69
  75. package/lib/util/normalizeScreens.js +30 -22
  76. package/lib/util/parseAnimationValue.js +41 -39
  77. package/lib/util/parseBoxShadowValue.js +24 -20
  78. package/lib/util/parseDependency.js +7 -5
  79. package/lib/util/parseGlob.js +10 -8
  80. package/lib/util/parseObjectStyles.js +10 -8
  81. package/lib/util/pluginUtils.js +54 -63
  82. package/lib/util/prefixSelector.js +9 -7
  83. package/lib/util/pseudoElements.js +209 -0
  84. package/lib/util/removeAlphaVariables.js +4 -2
  85. package/lib/util/resolveConfig.js +64 -52
  86. package/lib/util/resolveConfigPath.js +28 -12
  87. package/lib/util/responsive.js +7 -5
  88. package/lib/util/splitAtTopLevelOnly.js +12 -4
  89. package/lib/util/tap.js +3 -1
  90. package/lib/util/toColorValue.js +4 -2
  91. package/lib/util/toPath.js +5 -3
  92. package/lib/util/transformThemeValue.js +30 -28
  93. package/lib/util/validateConfig.js +31 -7
  94. package/lib/util/validateFormalSyntax.js +8 -6
  95. package/lib/util/withAlphaVariable.js +11 -7
  96. package/lib/value-parser/LICENSE +22 -0
  97. package/lib/value-parser/README.md +3 -0
  98. package/lib/value-parser/index.d.js +2 -0
  99. package/lib/value-parser/index.js +22 -0
  100. package/lib/value-parser/parse.js +259 -0
  101. package/lib/value-parser/stringify.js +38 -0
  102. package/lib/value-parser/unit.js +86 -0
  103. package/lib/value-parser/walk.js +16 -0
  104. package/loadConfig.d.ts +4 -0
  105. package/loadConfig.js +2 -0
  106. package/package.json +47 -59
  107. package/scripts/release-notes.js +1 -1
  108. package/src/cli/build/index.js +11 -7
  109. package/src/cli/build/plugin.js +96 -69
  110. package/src/cli/build/watching.js +4 -2
  111. package/src/cli/index.js +9 -26
  112. package/src/cli/init/index.js +37 -8
  113. package/src/cli.js +1 -5
  114. package/src/corePluginList.js +1 -1
  115. package/src/corePlugins.js +141 -48
  116. package/src/css/preflight.css +15 -4
  117. package/src/featureFlags.js +7 -7
  118. package/src/index.js +1 -5
  119. package/src/lib/content.js +33 -1
  120. package/src/lib/defaultExtractor.js +12 -14
  121. package/src/lib/evaluateTailwindFunctions.js +4 -1
  122. package/src/lib/expandApplyAtRules.js +15 -1
  123. package/src/lib/expandTailwindAtRules.js +73 -33
  124. package/src/lib/generateRules.js +71 -47
  125. package/src/lib/getModuleDependencies.js +70 -30
  126. package/src/lib/handleImportAtRules.js +34 -0
  127. package/src/lib/load-config.ts +31 -0
  128. package/src/lib/normalizeTailwindDirectives.js +0 -27
  129. package/src/lib/offsets.js +3 -3
  130. package/src/lib/setupContextUtils.js +64 -51
  131. package/src/lib/setupTrackingContext.js +6 -8
  132. package/src/lib/sharedState.js +10 -20
  133. package/src/plugin.js +86 -60
  134. package/src/processTailwindFeatures.js +3 -2
  135. package/src/public/colors.js +22 -0
  136. package/src/public/default-config.js +1 -1
  137. package/src/public/default-theme.js +2 -2
  138. package/src/public/load-config.js +2 -0
  139. package/src/util/applyImportantSelector.js +27 -0
  140. package/src/util/color.js +2 -2
  141. package/src/util/colorNames.js +150 -0
  142. package/src/util/dataTypes.js +75 -16
  143. package/src/util/formatVariantSelector.js +14 -102
  144. package/src/util/getAllConfigs.js +2 -2
  145. package/src/util/log.js +24 -0
  146. package/src/util/normalizeConfig.js +39 -11
  147. package/src/util/pluginUtils.js +11 -38
  148. package/src/util/prefixSelector.js +1 -0
  149. package/src/util/pseudoElements.js +167 -0
  150. package/src/util/resolveConfig.js +42 -24
  151. package/src/util/resolveConfigPath.js +12 -1
  152. package/src/util/splitAtTopLevelOnly.js +8 -1
  153. package/src/util/validateConfig.js +23 -0
  154. package/src/value-parser/LICENSE +22 -0
  155. package/src/value-parser/README.md +3 -0
  156. package/src/value-parser/index.d.ts +177 -0
  157. package/src/value-parser/index.js +28 -0
  158. package/src/value-parser/parse.js +303 -0
  159. package/src/value-parser/stringify.js +41 -0
  160. package/src/value-parser/unit.js +118 -0
  161. package/src/value-parser/walk.js +18 -0
  162. package/stubs/.gitignore +1 -0
  163. package/stubs/.prettierrc.json +6 -0
  164. package/stubs/{defaultConfig.stub.js → config.full.js} +56 -11
  165. package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
  166. package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
  167. package/stubs/postcss.config.js +5 -0
  168. package/stubs/tailwind.config.cjs +2 -0
  169. package/stubs/tailwind.config.js +2 -0
  170. package/stubs/tailwind.config.ts +3 -0
  171. package/types/config.d.ts +10 -12
  172. package/types/generated/colors.d.ts +22 -0
  173. package/types/generated/corePluginList.d.ts +1 -1
  174. package/types/generated/default-theme.d.ts +34 -1
  175. package/types/index.d.ts +7 -3
  176. package/lib/cli/build/deps.js +0 -54
  177. package/lib/cli-peer-dependencies.js +0 -28
  178. package/lib/constants.js +0 -44
  179. package/lib/oxide/cli/build/deps.js +0 -81
  180. package/lib/oxide/cli/build/index.js +0 -47
  181. package/lib/oxide/cli/build/plugin.js +0 -364
  182. package/lib/oxide/cli/build/utils.js +0 -77
  183. package/lib/oxide/cli/build/watching.js +0 -177
  184. package/lib/oxide/cli/help/index.js +0 -70
  185. package/lib/oxide/cli/index.js +0 -220
  186. package/lib/oxide/cli/init/index.js +0 -35
  187. package/lib/oxide/cli.js +0 -5
  188. package/lib/oxide/postcss-plugin.js +0 -2
  189. package/peers/index.js +0 -79461
  190. package/scripts/swap-engines.js +0 -40
  191. package/src/cli/build/deps.js +0 -56
  192. package/src/cli-peer-dependencies.js +0 -15
  193. package/src/constants.js +0 -17
  194. package/src/oxide/cli/build/deps.ts +0 -91
  195. package/src/oxide/cli/build/index.ts +0 -47
  196. package/src/oxide/cli/build/plugin.ts +0 -436
  197. package/src/oxide/cli/build/utils.ts +0 -74
  198. package/src/oxide/cli/build/watching.ts +0 -225
  199. package/src/oxide/cli/help/index.ts +0 -69
  200. package/src/oxide/cli/index.ts +0 -212
  201. package/src/oxide/cli/init/index.ts +0 -32
  202. package/src/oxide/cli.ts +0 -1
  203. package/src/oxide/postcss-plugin.ts +0 -1
@@ -10,41 +10,51 @@ function _export(target, all) {
10
10
  });
11
11
  }
12
12
  _export(exports, {
13
- indentRecursive: ()=>indentRecursive,
14
- formatNodes: ()=>formatNodes,
15
- readFileWithRetries: ()=>readFileWithRetries,
16
- drainStdin: ()=>drainStdin,
17
- outputFile: ()=>outputFile
13
+ indentRecursive: function() {
14
+ return indentRecursive;
15
+ },
16
+ formatNodes: function() {
17
+ return formatNodes;
18
+ },
19
+ readFileWithRetries: function() {
20
+ return readFileWithRetries;
21
+ },
22
+ drainStdin: function() {
23
+ return drainStdin;
24
+ },
25
+ outputFile: function() {
26
+ return outputFile;
27
+ }
18
28
  });
19
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
20
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
21
- function _interopRequireDefault(obj) {
29
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
30
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
31
+ function _interop_require_default(obj) {
22
32
  return obj && obj.__esModule ? obj : {
23
33
  default: obj
24
34
  };
25
35
  }
26
36
  function indentRecursive(node, indent = 0) {
27
37
  node.each && node.each((child, i)=>{
28
- if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n")) {
29
- child.raws.before = `\n${node.type !== "rule" && i > 0 ? "\n" : ""}${" ".repeat(indent)}`;
38
+ if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes('\n')) {
39
+ child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`;
30
40
  }
31
- child.raws.after = `\n${" ".repeat(indent)}`;
41
+ child.raws.after = `\n${' '.repeat(indent)}`;
32
42
  indentRecursive(child, indent + 1);
33
43
  });
34
44
  }
35
45
  function formatNodes(root) {
36
46
  indentRecursive(root);
37
47
  if (root.first) {
38
- root.first.raws.before = "";
48
+ root.first.raws.before = '';
39
49
  }
40
50
  }
41
51
  async function readFileWithRetries(path, tries = 5) {
42
52
  for(let n = 0; n <= tries; n++){
43
53
  try {
44
- return await _fs.default.promises.readFile(path, "utf8");
54
+ return await _fs.default.promises.readFile(path, 'utf8');
45
55
  } catch (err) {
46
56
  if (n !== tries) {
47
- if (err.code === "ENOENT" || err.code === "EBUSY") {
57
+ if (err.code === 'ENOENT' || err.code === 'EBUSY') {
48
58
  await new Promise((resolve)=>setTimeout(resolve, 10));
49
59
  continue;
50
60
  }
@@ -55,24 +65,24 @@ async function readFileWithRetries(path, tries = 5) {
55
65
  }
56
66
  function drainStdin() {
57
67
  return new Promise((resolve, reject)=>{
58
- let result = "";
59
- process.stdin.on("data", (chunk)=>{
68
+ let result = '';
69
+ process.stdin.on('data', (chunk)=>{
60
70
  result += chunk;
61
71
  });
62
- process.stdin.on("end", ()=>resolve(result));
63
- process.stdin.on("error", (err)=>reject(err));
72
+ process.stdin.on('end', ()=>resolve(result));
73
+ process.stdin.on('error', (err)=>reject(err));
64
74
  });
65
75
  }
66
76
  async function outputFile(file, newContents) {
67
77
  try {
68
- let currentContents = await _fs.default.promises.readFile(file, "utf8");
78
+ let currentContents = await _fs.default.promises.readFile(file, 'utf8');
69
79
  if (currentContents === newContents) {
70
80
  return; // Skip writing the file
71
81
  }
72
- } catch {}
82
+ } catch (e) {}
73
83
  // Write the file
74
84
  await _fs.default.promises.mkdir(_path.default.dirname(file), {
75
85
  recursive: true
76
86
  });
77
- await _fs.default.promises.writeFile(file, newContents, "utf8");
87
+ await _fs.default.promises.writeFile(file, newContents, 'utf8');
78
88
  }
@@ -5,22 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "createWatcher", {
7
7
  enumerable: true,
8
- get: ()=>createWatcher
8
+ get: function() {
9
+ return createWatcher;
10
+ }
9
11
  });
10
- const _chokidar = /*#__PURE__*/ _interopRequireDefault(require("chokidar"));
11
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
12
- const _micromatch = /*#__PURE__*/ _interopRequireDefault(require("micromatch"));
13
- const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
14
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
15
- const _utilsJs = require("./utils.js");
16
- function _interopRequireDefault(obj) {
12
+ const _chokidar = /*#__PURE__*/ _interop_require_default(require("chokidar"));
13
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
14
+ const _micromatch = /*#__PURE__*/ _interop_require_default(require("micromatch"));
15
+ const _normalizepath = /*#__PURE__*/ _interop_require_default(require("normalize-path"));
16
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
17
+ const _utils = require("./utils.js");
18
+ function _interop_require_default(obj) {
17
19
  return obj && obj.__esModule ? obj : {
18
20
  default: obj
19
21
  };
20
22
  }
21
- function createWatcher(args, { state , rebuild }) {
22
- let shouldPoll = args["--poll"];
23
- let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
23
+ function createWatcher(args, { state, rebuild }) {
24
+ let shouldPoll = args['--poll'];
25
+ let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32';
24
26
  // Polling interval in milliseconds
25
27
  // Used only when polling or coalescing add/change events on Windows
26
28
  let pollInterval = 10;
@@ -64,7 +66,9 @@ function createWatcher(args, { state , rebuild }) {
64
66
  // Clear all pending rebuilds for the about-to-be-built files
65
67
  changes.forEach((change)=>pendingRebuilds.delete(change.file));
66
68
  // Resolve the promise even when the rebuild fails
67
- return rebuild(changes).then(()=>{}, ()=>{});
69
+ return rebuild(changes).then(()=>{}, (e)=>{
70
+ console.error(e.toString());
71
+ });
68
72
  }
69
73
  /**
70
74
  *
@@ -84,7 +88,7 @@ function createWatcher(args, { state , rebuild }) {
84
88
  pendingRebuilds.add(file);
85
89
  changedContent.push({
86
90
  file,
87
- content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
91
+ content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, 'utf8'),
88
92
  extension: _path.default.extname(file).slice(1)
89
93
  });
90
94
  if (_timer) {
@@ -103,13 +107,13 @@ function createWatcher(args, { state , rebuild }) {
103
107
  chain = chain.then(rebuildAndContinue, rebuildAndContinue);
104
108
  return chain;
105
109
  }
106
- watcher.on("change", (file)=>recordChangedFile(file));
107
- watcher.on("add", (file)=>recordChangedFile(file));
110
+ watcher.on('change', (file)=>recordChangedFile(file));
111
+ watcher.on('add', (file)=>recordChangedFile(file));
108
112
  // Restore watching any files that are "removed"
109
113
  // This can happen when a file is pseudo-atomically replaced (a copy is created, overwritten, the old one is unlinked, and the new one is renamed)
110
114
  // TODO: An an optimization we should allow removal when the config changes
111
- watcher.on("unlink", (file)=>{
112
- file = (0, _normalizePath.default)(file);
115
+ watcher.on('unlink', (file)=>{
116
+ file = (0, _normalizepath.default)(file);
113
117
  // Only re-add the file if it's not covered by a dynamic pattern
114
118
  if (!_micromatch.default.some([
115
119
  file
@@ -121,8 +125,8 @@ function createWatcher(args, { state , rebuild }) {
121
125
  // will only fire a rename event for atomic writes and not a change event
122
126
  // This is very likely a chokidar bug but it's one we need to work around
123
127
  // We treat this as a change event and rebuild the CSS
124
- watcher.on("raw", (evt, filePath, meta)=>{
125
- if (evt !== "rename") {
128
+ watcher.on('raw', (evt, filePath, meta)=>{
129
+ if (evt !== 'rename') {
126
130
  return;
127
131
  }
128
132
  let watchedPath = meta.watchedPath;
@@ -148,7 +152,7 @@ function createWatcher(args, { state , rebuild }) {
148
152
  // We need to read the file as early as possible outside of the chain
149
153
  // because it may be gone by the time we get to it. doing the read
150
154
  // immediately increases the chance that the file is still there
151
- let content = await (0, _utilsJs.readFileWithRetries)(_path.default.resolve(filePath));
155
+ let content = await (0, _utils.readFileWithRetries)(_path.default.resolve(filePath));
152
156
  if (content === undefined) {
153
157
  return;
154
158
  }
@@ -157,7 +161,7 @@ function createWatcher(args, { state , rebuild }) {
157
161
  // This is because the order of events and timing is different on Linux
158
162
  // @ts-ignore: TypeScript isn't picking up that content is a string here
159
163
  await recordChangedFile(filePath, ()=>content, true);
160
- } catch {
164
+ } catch (e) {
161
165
  // If reading the file fails, it's was probably a deleted temporary file
162
166
  // So we can ignore it and no rebuild is needed
163
167
  }
@@ -171,7 +175,7 @@ function createWatcher(args, { state , rebuild }) {
171
175
  fswatcher: watcher,
172
176
  refreshWatchedFiles () {
173
177
  watcher.add(Array.from(state.contextDependencies));
174
- watcher.add(Array.from(state.configDependencies));
178
+ watcher.add(Array.from(state.configBag.dependencies));
175
179
  watcher.add(state.contentPatterns.all);
176
180
  }
177
181
  };
@@ -5,47 +5,49 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "help", {
7
7
  enumerable: true,
8
- get: ()=>help
8
+ get: function() {
9
+ return help;
10
+ }
9
11
  });
10
- const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../../package.json"));
11
- function _interopRequireDefault(obj) {
12
+ const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../../package.json"));
13
+ function _interop_require_default(obj) {
12
14
  return obj && obj.__esModule ? obj : {
13
15
  default: obj
14
16
  };
15
17
  }
16
- function help({ message , usage , commands , options }) {
18
+ function help({ message, usage, commands, options }) {
17
19
  let indent = 2;
18
20
  // Render header
19
21
  console.log();
20
- console.log(`${_packageJson.default.name} v${_packageJson.default.version}`);
22
+ console.log(`${_packagejson.default.name} v${_packagejson.default.version}`);
21
23
  // Render message
22
24
  if (message) {
23
25
  console.log();
24
- for (let msg of message.split("\n")){
26
+ for (let msg of message.split('\n')){
25
27
  console.log(msg);
26
28
  }
27
29
  }
28
30
  // Render usage
29
31
  if (usage && usage.length > 0) {
30
32
  console.log();
31
- console.log("Usage:");
33
+ console.log('Usage:');
32
34
  for (let example of usage){
33
- console.log(" ".repeat(indent), example);
35
+ console.log(' '.repeat(indent), example);
34
36
  }
35
37
  }
36
38
  // Render commands
37
39
  if (commands && commands.length > 0) {
38
40
  console.log();
39
- console.log("Commands:");
41
+ console.log('Commands:');
40
42
  for (let command of commands){
41
- console.log(" ".repeat(indent), command);
43
+ console.log(' '.repeat(indent), command);
42
44
  }
43
45
  }
44
46
  // Render options
45
47
  if (options) {
46
48
  let groupedOptions = {};
47
49
  for (let [key, value] of Object.entries(options)){
48
- if (typeof value === "object") {
50
+ if (typeof value === 'object') {
49
51
  groupedOptions[key] = {
50
52
  ...value,
51
53
  flags: [
@@ -57,13 +59,13 @@ function help({ message , usage , commands , options }) {
57
59
  }
58
60
  }
59
61
  console.log();
60
- console.log("Options:");
61
- for (let { flags , description , deprecated } of Object.values(groupedOptions)){
62
+ console.log('Options:');
63
+ for (let { flags, description, deprecated } of Object.values(groupedOptions)){
62
64
  if (deprecated) continue;
63
65
  if (flags.length === 1) {
64
- console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
66
+ console.log(' '.repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(', ').padEnd(20, ' '), description);
65
67
  } else {
66
- console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
68
+ console.log(' '.repeat(indent), flags.slice().reverse().join(', ').padEnd(24, ' '), description);
67
69
  }
68
70
  }
69
71
  }
package/lib/cli/index.js CHANGED
@@ -3,34 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
7
- const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
8
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
6
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
7
+ const _arg = /*#__PURE__*/ _interop_require_default(require("arg"));
8
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
9
9
  const _build = require("./build");
10
10
  const _help = require("./help");
11
11
  const _init = require("./init");
12
- function _interopRequireDefault(obj) {
12
+ function _interop_require_default(obj) {
13
13
  return obj && obj.__esModule ? obj : {
14
14
  default: obj
15
15
  };
16
16
  }
17
- function isESM() {
18
- const pkgPath = _path.default.resolve("./package.json");
19
- try {
20
- let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
21
- return pkg.type && pkg.type === "module";
22
- } catch (err) {
23
- return false;
24
- }
25
- }
26
- let configs = isESM() ? {
27
- tailwind: "tailwind.config.cjs",
28
- postcss: "postcss.config.cjs"
29
- } : {
30
- tailwind: "tailwind.config.js",
31
- postcss: "postcss.config.js"
32
- };
33
- // ---
34
17
  function oneOf(...options) {
35
18
  return Object.assign((value = true)=>{
36
19
  for (let option of options){
@@ -39,7 +22,7 @@ function oneOf(...options) {
39
22
  return parsed;
40
23
  }
41
24
  }
42
- throw new Error("...");
25
+ throw new Error('...');
43
26
  }, {
44
27
  manualParsing: true
45
28
  });
@@ -48,84 +31,93 @@ let commands = {
48
31
  init: {
49
32
  run: _init.init,
50
33
  args: {
51
- "--full": {
34
+ '--esm': {
35
+ type: Boolean,
36
+ description: `Initialize configuration file as ESM`
37
+ },
38
+ '--ts': {
39
+ type: Boolean,
40
+ description: `Initialize configuration file as TypeScript`
41
+ },
42
+ '--postcss': {
52
43
  type: Boolean,
53
- description: `Initialize a full \`${configs.tailwind}\` file`
44
+ description: `Initialize a \`postcss.config.js\` file`
54
45
  },
55
- "--postcss": {
46
+ '--full': {
56
47
  type: Boolean,
57
- description: `Initialize a \`${configs.postcss}\` file`
48
+ description: `Include the default values for all options in the generated configuration file`
58
49
  },
59
- "-f": "--full",
60
- "-p": "--postcss"
50
+ '-f': '--full',
51
+ '-p': '--postcss'
61
52
  }
62
53
  },
63
54
  build: {
64
55
  run: _build.build,
65
56
  args: {
66
- "--input": {
57
+ '--input': {
67
58
  type: String,
68
- description: "Input file"
59
+ description: 'Input file'
69
60
  },
70
- "--output": {
61
+ '--output': {
71
62
  type: String,
72
- description: "Output file"
63
+ description: 'Output file'
73
64
  },
74
- "--watch": {
65
+ '--watch': {
75
66
  type: oneOf(String, Boolean),
76
- description: "Watch for changes and rebuild as needed"
67
+ description: 'Watch for changes and rebuild as needed'
77
68
  },
78
- "--poll": {
69
+ '--poll': {
79
70
  type: Boolean,
80
- description: "Use polling instead of filesystem events when watching"
71
+ description: 'Use polling instead of filesystem events when watching'
81
72
  },
82
- "--content": {
73
+ '--content': {
83
74
  type: String,
84
- description: "Content paths to use for removing unused classes"
75
+ description: 'Content paths to use for removing unused classes'
85
76
  },
86
- "--purge": {
77
+ '--purge': {
87
78
  type: String,
88
79
  deprecated: true
89
80
  },
90
- "--postcss": {
81
+ '--postcss': {
91
82
  type: oneOf(String, Boolean),
92
- description: "Load custom PostCSS configuration"
83
+ description: 'Load custom PostCSS configuration'
93
84
  },
94
- "--minify": {
85
+ '--minify': {
95
86
  type: Boolean,
96
- description: "Minify the output"
87
+ description: 'Minify the output'
97
88
  },
98
- "--config": {
89
+ '--config': {
99
90
  type: String,
100
- description: "Path to a custom config file"
91
+ description: 'Path to a custom config file'
101
92
  },
102
- "--no-autoprefixer": {
93
+ '--no-autoprefixer': {
94
+ deprecated: true,
103
95
  type: Boolean,
104
- description: "Disable autoprefixer"
96
+ description: 'Disable autoprefixer'
105
97
  },
106
- "-c": "--config",
107
- "-i": "--input",
108
- "-o": "--output",
109
- "-m": "--minify",
110
- "-w": "--watch",
111
- "-p": "--poll"
98
+ '-c': '--config',
99
+ '-i': '--input',
100
+ '-o': '--output',
101
+ '-m': '--minify',
102
+ '-w': '--watch',
103
+ '-p': '--poll'
112
104
  }
113
105
  }
114
106
  };
115
107
  let sharedFlags = {
116
- "--help": {
108
+ '--help': {
117
109
  type: Boolean,
118
- description: "Display usage information"
110
+ description: 'Display usage information'
119
111
  },
120
- "-h": "--help"
112
+ '-h': '--help'
121
113
  };
122
114
  if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
123
115
  (0, _help.help)({
124
116
  usage: [
125
- "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
126
- "tailwindcss init [--full] [--postcss] [options...]"
117
+ 'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
118
+ 'tailwindcss init [--full] [--postcss] [options...]'
127
119
  ],
128
- commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
120
+ commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
129
121
  options: {
130
122
  ...commands.build.args,
131
123
  ...sharedFlags
@@ -133,48 +125,48 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
133
125
  });
134
126
  process.exit(0);
135
127
  }
136
- let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
128
+ let command = ((arg = '')=>arg.startsWith('-') ? undefined : arg)(process.argv[2]) || 'build';
137
129
  if (commands[command] === undefined) {
138
130
  if (_fs.default.existsSync(_path.default.resolve(command))) {
139
131
  // TODO: Deprecate this in future versions
140
132
  // Check if non-existing command, might be a file.
141
- command = "build";
133
+ command = 'build';
142
134
  } else {
143
135
  (0, _help.help)({
144
136
  message: `Invalid command: ${command}`,
145
137
  usage: [
146
- "tailwindcss <command> [options]"
138
+ 'tailwindcss <command> [options]'
147
139
  ],
148
- commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
140
+ commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
149
141
  options: sharedFlags
150
142
  });
151
143
  process.exit(1);
152
144
  }
153
145
  }
154
146
  // Execute command
155
- let { args: flags , run } = commands[command];
147
+ let { args: flags, run } = commands[command];
156
148
  let args = (()=>{
157
149
  try {
158
150
  let result = (0, _arg.default)(Object.fromEntries(Object.entries({
159
151
  ...flags,
160
152
  ...sharedFlags
161
153
  }).filter(([_key, value])=>{
162
- var _value_type;
163
- return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
154
+ var _value_type, _value;
155
+ return !((_value = value) === null || _value === void 0 ? void 0 : (_value_type = _value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
164
156
  }).map(([key, value])=>[
165
157
  key,
166
- typeof value === "object" ? value.type : value
158
+ typeof value === 'object' ? value.type : value
167
159
  ])), {
168
160
  permissive: true
169
161
  });
170
162
  // Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
171
- for(let i = result["_"].length - 1; i >= 0; --i){
172
- let flag = result["_"][i];
173
- if (!flag.startsWith("-")) continue;
174
- let [flagName, flagValue] = flag.split("=");
163
+ for(let i = result['_'].length - 1; i >= 0; --i){
164
+ let flag = result['_'][i];
165
+ if (!flag.startsWith('-')) continue;
166
+ let [flagName, flagValue] = flag.split('=');
175
167
  let handler = flags[flagName];
176
168
  // Resolve flagName & handler
177
- while(typeof handler === "string"){
169
+ while(typeof handler === 'string'){
178
170
  flagName = handler;
179
171
  handler = flags[handler];
180
172
  }
@@ -184,18 +176,18 @@ let args = (()=>{
184
176
  // --flag value syntax was used so we need to pull `value` from `args`
185
177
  if (flagValue === undefined) {
186
178
  // Parse args for current flag
187
- while(result["_"][offset] && !result["_"][offset].startsWith("-")){
188
- args.push(result["_"][offset++]);
179
+ while(result['_'][offset] && !result['_'][offset].startsWith('-')){
180
+ args.push(result['_'][offset++]);
189
181
  }
190
182
  // Cleanup manually parsed flags + args
191
- result["_"].splice(i, 1 + args.length);
183
+ result['_'].splice(i, 1 + args.length);
192
184
  // No args were provided, use default value defined in handler
193
185
  // One arg was provided, use that directly
194
186
  // Multiple args were provided so pass them all in an array
195
187
  flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
196
188
  } else {
197
189
  // Remove the whole flag from the args array
198
- result["_"].splice(i, 1);
190
+ result['_'].splice(i, 1);
199
191
  }
200
192
  // Set the resolved value in the `result` object
201
193
  result[flagName] = handler.type(flagValue, flagName);
@@ -206,16 +198,16 @@ let args = (()=>{
206
198
  //
207
199
  // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
208
200
  // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
209
- if (result["_"][0] !== command) {
210
- result["_"].unshift(command);
201
+ if (result['_'][0] !== command) {
202
+ result['_'].unshift(command);
211
203
  }
212
204
  return result;
213
205
  } catch (err) {
214
- if (err.code === "ARG_UNKNOWN_OPTION") {
206
+ if (err.code === 'ARG_UNKNOWN_OPTION') {
215
207
  (0, _help.help)({
216
208
  message: err.message,
217
209
  usage: [
218
- "tailwindcss <command> [options]"
210
+ 'tailwindcss <command> [options]'
219
211
  ],
220
212
  options: sharedFlags
221
213
  });
@@ -224,7 +216,7 @@ let args = (()=>{
224
216
  throw err;
225
217
  }
226
218
  })();
227
- if (args["--help"]) {
219
+ if (args['--help']) {
228
220
  (0, _help.help)({
229
221
  options: {
230
222
  ...flags,
@@ -236,4 +228,4 @@ if (args["--help"]) {
236
228
  });
237
229
  process.exit(0);
238
230
  }
239
- run(args, configs);
231
+ run(args);