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
@@ -0,0 +1,178 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createWatcher", {
7
+ enumerable: true,
8
+ get: ()=>createWatcher
9
+ });
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) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ function createWatcher(args, { state , rebuild }) {
22
+ let shouldPoll = args["--poll"];
23
+ let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
24
+ // Polling interval in milliseconds
25
+ // Used only when polling or coalescing add/change events on Windows
26
+ let pollInterval = 10;
27
+ let watcher = _chokidar.default.watch([], {
28
+ // Force checking for atomic writes in all situations
29
+ // This causes chokidar to wait up to 100ms for a file to re-added after it's been unlinked
30
+ // This only works when watching directories though
31
+ atomic: true,
32
+ usePolling: shouldPoll,
33
+ interval: shouldPoll ? pollInterval : undefined,
34
+ ignoreInitial: true,
35
+ awaitWriteFinish: shouldCoalesceWriteEvents ? {
36
+ stabilityThreshold: 50,
37
+ pollInterval: pollInterval
38
+ } : false
39
+ });
40
+ // A queue of rebuilds, file reads, etc… to run
41
+ let chain = Promise.resolve();
42
+ /**
43
+ * A list of files that have been changed since the last rebuild
44
+ *
45
+ * @type {{file: string, content: () => Promise<string>, extension: string}[]}
46
+ */ let changedContent = [];
47
+ /**
48
+ * A list of files for which a rebuild has already been queued.
49
+ * This is used to prevent duplicate rebuilds when multiple events are fired for the same file.
50
+ * The rebuilt file is cleared from this list when it's associated rebuild has _started_
51
+ * This is because if the file is changed during a rebuild it won't trigger a new rebuild which it should
52
+ **/ let pendingRebuilds = new Set();
53
+ let _timer;
54
+ let _reject;
55
+ /**
56
+ * Rebuilds the changed files and resolves when the rebuild is
57
+ * complete regardless of whether it was successful or not
58
+ */ async function rebuildAndContinue() {
59
+ let changes = changedContent.splice(0);
60
+ // There are no changes to rebuild so we can just do nothing
61
+ if (changes.length === 0) {
62
+ return Promise.resolve();
63
+ }
64
+ // Clear all pending rebuilds for the about-to-be-built files
65
+ changes.forEach((change)=>pendingRebuilds.delete(change.file));
66
+ // Resolve the promise even when the rebuild fails
67
+ return rebuild(changes).then(()=>{}, ()=>{});
68
+ }
69
+ /**
70
+ *
71
+ * @param {*} file
72
+ * @param {(() => Promise<string>) | null} content
73
+ * @param {boolean} skipPendingCheck
74
+ * @returns {Promise<void>}
75
+ */ function recordChangedFile(file, content = null, skipPendingCheck = false) {
76
+ file = _path.default.resolve(file);
77
+ // Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
78
+ // In that case rebuild has already been queued by rename, so can be skipped in change
79
+ if (pendingRebuilds.has(file) && !skipPendingCheck) {
80
+ return Promise.resolve();
81
+ }
82
+ // Mark that a rebuild of this file is going to happen
83
+ // It MUST happen synchronously before the rebuild is queued for this to be effective
84
+ pendingRebuilds.add(file);
85
+ changedContent.push({
86
+ file,
87
+ content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
88
+ extension: _path.default.extname(file).slice(1)
89
+ });
90
+ if (_timer) {
91
+ clearTimeout(_timer);
92
+ _reject();
93
+ }
94
+ // If a rebuild is already in progress we don't want to start another one until the 10ms timer has expired
95
+ chain = chain.then(()=>new Promise((resolve, reject)=>{
96
+ _timer = setTimeout(resolve, 10);
97
+ _reject = reject;
98
+ }));
99
+ // Resolves once this file has been rebuilt (or the rebuild for this file has failed)
100
+ // This queues as many rebuilds as there are changed files
101
+ // But those rebuilds happen after some delay
102
+ // And will immediately resolve if there are no changes
103
+ chain = chain.then(rebuildAndContinue, rebuildAndContinue);
104
+ return chain;
105
+ }
106
+ watcher.on("change", (file)=>recordChangedFile(file));
107
+ watcher.on("add", (file)=>recordChangedFile(file));
108
+ // Restore watching any files that are "removed"
109
+ // 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
+ // TODO: An an optimization we should allow removal when the config changes
111
+ watcher.on("unlink", (file)=>{
112
+ file = (0, _normalizePath.default)(file);
113
+ // Only re-add the file if it's not covered by a dynamic pattern
114
+ if (!_micromatch.default.some([
115
+ file
116
+ ], state.contentPatterns.dynamic)) {
117
+ watcher.add(file);
118
+ }
119
+ });
120
+ // Some applications such as Visual Studio (but not VS Code)
121
+ // will only fire a rename event for atomic writes and not a change event
122
+ // This is very likely a chokidar bug but it's one we need to work around
123
+ // We treat this as a change event and rebuild the CSS
124
+ watcher.on("raw", (evt, filePath, meta)=>{
125
+ if (evt !== "rename") {
126
+ return;
127
+ }
128
+ let watchedPath = meta.watchedPath;
129
+ // Watched path might be the file itself
130
+ // Or the directory it is in
131
+ filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.join(watchedPath, filePath);
132
+ // Skip this event since the files it is for does not match any of the registered content globs
133
+ if (!_micromatch.default.some([
134
+ filePath
135
+ ], state.contentPatterns.all)) {
136
+ return;
137
+ }
138
+ // Skip since we've already queued a rebuild for this file that hasn't happened yet
139
+ if (pendingRebuilds.has(filePath)) {
140
+ return;
141
+ }
142
+ // We'll go ahead and add the file to the pending rebuilds list here
143
+ // It'll be removed when the rebuild starts unless the read fails
144
+ // which will be taken care of as well
145
+ pendingRebuilds.add(filePath);
146
+ async function enqueue() {
147
+ try {
148
+ // We need to read the file as early as possible outside of the chain
149
+ // because it may be gone by the time we get to it. doing the read
150
+ // immediately increases the chance that the file is still there
151
+ let content = await (0, _utilsJs.readFileWithRetries)(_path.default.resolve(filePath));
152
+ if (content === undefined) {
153
+ return;
154
+ }
155
+ // This will push the rebuild onto the chain
156
+ // We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
157
+ // This is because the order of events and timing is different on Linux
158
+ // @ts-ignore: TypeScript isn't picking up that content is a string here
159
+ await recordChangedFile(filePath, ()=>content, true);
160
+ } catch {
161
+ // If reading the file fails, it's was probably a deleted temporary file
162
+ // So we can ignore it and no rebuild is needed
163
+ }
164
+ }
165
+ enqueue().then(()=>{
166
+ // If the file read fails we still need to make sure the file isn't stuck in the pending rebuilds list
167
+ pendingRebuilds.delete(filePath);
168
+ });
169
+ });
170
+ return {
171
+ fswatcher: watcher,
172
+ refreshWatchedFiles () {
173
+ watcher.add(Array.from(state.contextDependencies));
174
+ watcher.add(Array.from(state.configDependencies));
175
+ watcher.add(state.contentPatterns.all);
176
+ }
177
+ };
178
+ }
@@ -0,0 +1,71 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "help", {
7
+ enumerable: true,
8
+ get: ()=>help
9
+ });
10
+ const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../../package.json"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function help({ message , usage , commands , options }) {
17
+ let indent = 2;
18
+ // Render header
19
+ console.log();
20
+ console.log(`${_packageJson.default.name} v${_packageJson.default.version}`);
21
+ // Render message
22
+ if (message) {
23
+ console.log();
24
+ for (let msg of message.split("\n")){
25
+ console.log(msg);
26
+ }
27
+ }
28
+ // Render usage
29
+ if (usage && usage.length > 0) {
30
+ console.log();
31
+ console.log("Usage:");
32
+ for (let example of usage){
33
+ console.log(" ".repeat(indent), example);
34
+ }
35
+ }
36
+ // Render commands
37
+ if (commands && commands.length > 0) {
38
+ console.log();
39
+ console.log("Commands:");
40
+ for (let command of commands){
41
+ console.log(" ".repeat(indent), command);
42
+ }
43
+ }
44
+ // Render options
45
+ if (options) {
46
+ let groupedOptions = {};
47
+ for (let [key, value] of Object.entries(options)){
48
+ if (typeof value === "object") {
49
+ groupedOptions[key] = {
50
+ ...value,
51
+ flags: [
52
+ key
53
+ ]
54
+ };
55
+ } else {
56
+ groupedOptions[value].flags.push(key);
57
+ }
58
+ }
59
+ console.log();
60
+ console.log("Options:");
61
+ for (let { flags , description , deprecated } of Object.values(groupedOptions)){
62
+ if (deprecated) continue;
63
+ if (flags.length === 1) {
64
+ console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
65
+ } else {
66
+ console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
67
+ }
68
+ }
69
+ }
70
+ console.log();
71
+ }
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
7
+ const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
8
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
9
+ const _build = require("./build");
10
+ const _help = require("./help");
11
+ const _init = require("./init");
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
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
+ function oneOf(...options) {
35
+ return Object.assign((value = true)=>{
36
+ for (let option of options){
37
+ let parsed = option(value);
38
+ if (parsed === value) {
39
+ return parsed;
40
+ }
41
+ }
42
+ throw new Error("...");
43
+ }, {
44
+ manualParsing: true
45
+ });
46
+ }
47
+ let commands = {
48
+ init: {
49
+ run: _init.init,
50
+ args: {
51
+ "--full": {
52
+ type: Boolean,
53
+ description: `Initialize a full \`${configs.tailwind}\` file`
54
+ },
55
+ "--postcss": {
56
+ type: Boolean,
57
+ description: `Initialize a \`${configs.postcss}\` file`
58
+ },
59
+ "-f": "--full",
60
+ "-p": "--postcss"
61
+ }
62
+ },
63
+ build: {
64
+ run: _build.build,
65
+ args: {
66
+ "--input": {
67
+ type: String,
68
+ description: "Input file"
69
+ },
70
+ "--output": {
71
+ type: String,
72
+ description: "Output file"
73
+ },
74
+ "--watch": {
75
+ type: oneOf(String, Boolean),
76
+ description: "Watch for changes and rebuild as needed"
77
+ },
78
+ "--poll": {
79
+ type: Boolean,
80
+ description: "Use polling instead of filesystem events when watching"
81
+ },
82
+ "--content": {
83
+ type: String,
84
+ description: "Content paths to use for removing unused classes"
85
+ },
86
+ "--purge": {
87
+ type: String,
88
+ deprecated: true
89
+ },
90
+ "--postcss": {
91
+ type: oneOf(String, Boolean),
92
+ description: "Load custom PostCSS configuration"
93
+ },
94
+ "--minify": {
95
+ type: Boolean,
96
+ description: "Minify the output"
97
+ },
98
+ "--config": {
99
+ type: String,
100
+ description: "Path to a custom config file"
101
+ },
102
+ "--no-autoprefixer": {
103
+ type: Boolean,
104
+ description: "Disable autoprefixer"
105
+ },
106
+ "-c": "--config",
107
+ "-i": "--input",
108
+ "-o": "--output",
109
+ "-m": "--minify",
110
+ "-w": "--watch",
111
+ "-p": "--poll"
112
+ }
113
+ }
114
+ };
115
+ let sharedFlags = {
116
+ "--help": {
117
+ type: Boolean,
118
+ description: "Display usage information"
119
+ },
120
+ "-h": "--help"
121
+ };
122
+ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
123
+ (0, _help.help)({
124
+ usage: [
125
+ "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
126
+ "tailwindcss init [--full] [--postcss] [options...]"
127
+ ],
128
+ commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
129
+ options: {
130
+ ...commands.build.args,
131
+ ...sharedFlags
132
+ }
133
+ });
134
+ process.exit(0);
135
+ }
136
+ let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
137
+ if (commands[command] === undefined) {
138
+ if (_fs.default.existsSync(_path.default.resolve(command))) {
139
+ // TODO: Deprecate this in future versions
140
+ // Check if non-existing command, might be a file.
141
+ command = "build";
142
+ } else {
143
+ (0, _help.help)({
144
+ message: `Invalid command: ${command}`,
145
+ usage: [
146
+ "tailwindcss <command> [options]"
147
+ ],
148
+ commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
149
+ options: sharedFlags
150
+ });
151
+ process.exit(1);
152
+ }
153
+ }
154
+ // Execute command
155
+ let { args: flags , run } = commands[command];
156
+ let args = (()=>{
157
+ try {
158
+ let result = (0, _arg.default)(Object.fromEntries(Object.entries({
159
+ ...flags,
160
+ ...sharedFlags
161
+ }).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);
164
+ }).map(([key, value])=>[
165
+ key,
166
+ typeof value === "object" ? value.type : value
167
+ ])), {
168
+ permissive: true
169
+ });
170
+ // 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("=");
175
+ let handler = flags[flagName];
176
+ // Resolve flagName & handler
177
+ while(typeof handler === "string"){
178
+ flagName = handler;
179
+ handler = flags[handler];
180
+ }
181
+ if (!handler) continue;
182
+ let args = [];
183
+ let offset = i + 1;
184
+ // --flag value syntax was used so we need to pull `value` from `args`
185
+ if (flagValue === undefined) {
186
+ // Parse args for current flag
187
+ while(result["_"][offset] && !result["_"][offset].startsWith("-")){
188
+ args.push(result["_"][offset++]);
189
+ }
190
+ // Cleanup manually parsed flags + args
191
+ result["_"].splice(i, 1 + args.length);
192
+ // No args were provided, use default value defined in handler
193
+ // One arg was provided, use that directly
194
+ // Multiple args were provided so pass them all in an array
195
+ flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
196
+ } else {
197
+ // Remove the whole flag from the args array
198
+ result["_"].splice(i, 1);
199
+ }
200
+ // Set the resolved value in the `result` object
201
+ result[flagName] = handler.type(flagValue, flagName);
202
+ }
203
+ // Ensure that the `command` is always the first argument in the `args`.
204
+ // This is important so that we don't have to check if a default command
205
+ // (build) was used or not from within each plugin.
206
+ //
207
+ // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
208
+ // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
209
+ if (result["_"][0] !== command) {
210
+ result["_"].unshift(command);
211
+ }
212
+ return result;
213
+ } catch (err) {
214
+ if (err.code === "ARG_UNKNOWN_OPTION") {
215
+ (0, _help.help)({
216
+ message: err.message,
217
+ usage: [
218
+ "tailwindcss <command> [options]"
219
+ ],
220
+ options: sharedFlags
221
+ });
222
+ process.exit(1);
223
+ }
224
+ throw err;
225
+ }
226
+ })();
227
+ if (args["--help"]) {
228
+ (0, _help.help)({
229
+ options: {
230
+ ...flags,
231
+ ...sharedFlags
232
+ },
233
+ usage: [
234
+ `tailwindcss ${command} [options]`
235
+ ]
236
+ });
237
+ process.exit(0);
238
+ }
239
+ run(args, configs);
@@ -0,0 +1,46 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "init", {
7
+ enumerable: true,
8
+ get: ()=>init
9
+ });
10
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function init(args, configs) {
18
+ let messages = [];
19
+ var _args___;
20
+ let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./${configs.tailwind}`);
21
+ if (_fs.default.existsSync(tailwindConfigLocation)) {
22
+ messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
23
+ } else {
24
+ let stubFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/defaultConfig.stub.js") : _path.default.resolve(__dirname, "../../../stubs/simpleConfig.stub.js"), "utf8");
25
+ // Change colors import
26
+ stubFile = stubFile.replace("../colors", "tailwindcss/colors");
27
+ _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
28
+ messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
29
+ }
30
+ if (args["--postcss"]) {
31
+ let postcssConfigLocation = _path.default.resolve(`./${configs.postcss}`);
32
+ if (_fs.default.existsSync(postcssConfigLocation)) {
33
+ messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
34
+ } else {
35
+ let stubFile1 = _fs.default.readFileSync(_path.default.resolve(__dirname, "../../../stubs/defaultPostCssConfig.stub.js"), "utf8");
36
+ _fs.default.writeFileSync(postcssConfigLocation, stubFile1, "utf8");
37
+ messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
38
+ }
39
+ }
40
+ if (messages.length > 0) {
41
+ console.log();
42
+ for (let message of messages){
43
+ console.log(message);
44
+ }
45
+ }
46
+ }
@@ -2,14 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.lazyAutoprefixer = lazyAutoprefixer;
6
- exports.lazyCssnano = lazyCssnano;
7
- exports.postcss = void 0;
8
- let postcss = require('postcss');
9
- exports.postcss = postcss;
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ lazyPostcss: ()=>lazyPostcss,
13
+ lazyPostcssImport: ()=>lazyPostcssImport,
14
+ lazyAutoprefixer: ()=>lazyAutoprefixer,
15
+ lazyCssnano: ()=>lazyCssnano
16
+ });
17
+ function lazyPostcss() {
18
+ return require("postcss");
19
+ }
20
+ function lazyPostcssImport() {
21
+ return require("postcss-import");
22
+ }
10
23
  function lazyAutoprefixer() {
11
- return require('autoprefixer');
24
+ return require("autoprefixer");
12
25
  }
13
26
  function lazyCssnano() {
14
- return require('cssnano');
27
+ return require("cssnano");
15
28
  }