tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4

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 (108) hide show
  1. package/lib/cli/build/deps.js +34 -18
  2. package/lib/cli/build/index.js +45 -12
  3. package/lib/cli/build/plugin.js +273 -90
  4. package/lib/cli/build/utils.js +56 -24
  5. package/lib/cli/build/watching.js +156 -38
  6. package/lib/cli/help/index.js +61 -16
  7. package/lib/cli/index.js +121 -62
  8. package/lib/cli/init/index.js +47 -23
  9. package/lib/cli-peer-dependencies.js +23 -13
  10. package/lib/cli.js +5 -1
  11. package/lib/corePluginList.js +7 -4
  12. package/lib/corePlugins.js +855 -386
  13. package/lib/featureFlags.js +43 -18
  14. package/lib/lib/cacheInvalidation.js +78 -30
  15. package/lib/lib/collapseAdjacentRules.js +46 -23
  16. package/lib/lib/collapseDuplicateDeclarations.js +70 -27
  17. package/lib/lib/content.js +134 -41
  18. package/lib/lib/defaultExtractor.js +201 -96
  19. package/lib/lib/detectNesting.js +38 -12
  20. package/lib/lib/evaluateTailwindFunctions.js +192 -103
  21. package/lib/lib/expandApplyAtRules.js +488 -181
  22. package/lib/lib/expandTailwindAtRules.js +240 -70
  23. package/lib/lib/findAtConfigPath.js +34 -15
  24. package/lib/lib/generateRules.js +775 -353
  25. package/lib/lib/getModuleDependencies.js +67 -29
  26. package/lib/lib/load-config.js +27 -17
  27. package/lib/lib/normalizeTailwindDirectives.js +73 -27
  28. package/lib/lib/offsets.js +227 -62
  29. package/lib/lib/partitionApplyAtRules.js +53 -29
  30. package/lib/lib/regex.js +50 -28
  31. package/lib/lib/remap-bitfield.js +86 -9
  32. package/lib/lib/resolveDefaultsAtRules.js +123 -53
  33. package/lib/lib/setupContextUtils.js +1117 -584
  34. package/lib/lib/setupTrackingContext.js +149 -58
  35. package/lib/lib/sharedState.js +71 -23
  36. package/lib/lib/substituteScreenAtRules.js +19 -9
  37. package/lib/oxide/cli/build/deps.js +46 -23
  38. package/lib/oxide/cli/build/index.js +44 -12
  39. package/lib/oxide/cli/build/plugin.js +271 -89
  40. package/lib/oxide/cli/build/utils.js +55 -24
  41. package/lib/oxide/cli/build/watching.js +153 -36
  42. package/lib/oxide/cli/help/index.js +60 -16
  43. package/lib/oxide/cli/index.js +128 -67
  44. package/lib/oxide/cli/init/index.js +40 -19
  45. package/lib/oxide/cli.js +3 -2
  46. package/lib/plugin.js +58 -31
  47. package/lib/postcss-plugins/nesting/index.js +13 -7
  48. package/lib/postcss-plugins/nesting/plugin.js +65 -20
  49. package/lib/processTailwindFeatures.js +41 -10
  50. package/lib/public/colors.js +25 -16
  51. package/lib/public/create-plugin.js +11 -6
  52. package/lib/public/default-config.js +12 -6
  53. package/lib/public/default-theme.js +12 -6
  54. package/lib/public/load-config.js +9 -5
  55. package/lib/public/resolve-config.js +10 -6
  56. package/lib/util/applyImportantSelector.js +28 -17
  57. package/lib/util/bigSign.js +9 -6
  58. package/lib/util/buildMediaQuery.js +19 -10
  59. package/lib/util/cloneDeep.js +19 -9
  60. package/lib/util/cloneNodes.js +29 -14
  61. package/lib/util/color.js +87 -47
  62. package/lib/util/colorNames.js +752 -0
  63. package/lib/util/configurePlugins.js +18 -9
  64. package/lib/util/createPlugin.js +17 -8
  65. package/lib/util/createUtilityPlugin.js +30 -16
  66. package/lib/util/dataTypes.js +189 -38
  67. package/lib/util/defaults.js +21 -9
  68. package/lib/util/escapeClassName.js +15 -9
  69. package/lib/util/escapeCommas.js +9 -6
  70. package/lib/util/flattenColorPalette.js +11 -7
  71. package/lib/util/formatVariantSelector.js +209 -60
  72. package/lib/util/getAllConfigs.js +44 -35
  73. package/lib/util/hashConfig.js +12 -8
  74. package/lib/util/isKeyframeRule.js +10 -7
  75. package/lib/util/isPlainObject.js +14 -9
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
  77. package/lib/util/log.js +20 -9
  78. package/lib/util/nameClass.js +31 -10
  79. package/lib/util/negateValue.js +28 -10
  80. package/lib/util/normalizeConfig.js +242 -63
  81. package/lib/util/normalizeScreens.js +145 -70
  82. package/lib/util/parseAnimationValue.js +64 -14
  83. package/lib/util/parseBoxShadowValue.js +63 -14
  84. package/lib/util/parseDependency.js +39 -13
  85. package/lib/util/parseGlob.js +25 -8
  86. package/lib/util/parseObjectStyles.js +29 -18
  87. package/lib/util/pluginUtils.js +196 -77
  88. package/lib/util/prefixSelector.js +31 -12
  89. package/lib/util/pseudoElements.js +116 -34
  90. package/lib/util/removeAlphaVariables.js +23 -8
  91. package/lib/util/resolveConfig.js +224 -105
  92. package/lib/util/resolveConfigPath.js +45 -15
  93. package/lib/util/responsive.js +10 -6
  94. package/lib/util/splitAtTopLevelOnly.js +46 -10
  95. package/lib/util/tap.js +11 -7
  96. package/lib/util/toColorValue.js +10 -7
  97. package/lib/util/toPath.js +28 -8
  98. package/lib/util/transformThemeValue.js +49 -14
  99. package/lib/util/validateConfig.js +25 -15
  100. package/lib/util/validateFormalSyntax.js +14 -6
  101. package/lib/util/withAlphaVariable.js +54 -30
  102. package/package.json +18 -22
  103. package/peers/index.js +57849 -43101
  104. package/src/lib/expandTailwindAtRules.js +1 -1
  105. package/src/lib/setupTrackingContext.js +1 -1
  106. package/src/util/color.js +1 -1
  107. package/src/util/colorNames.js +150 -0
  108. package/src/util/pseudoElements.js +4 -4
@@ -1,62 +1,179 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), Object.defineProperty(exports, "createWatcher", {
5
- enumerable: !0,
6
- get: ()=>createWatcher
3
+ value: true
7
4
  });
8
- const _chokidar = _interopRequireDefault(require("chokidar")), _fs = _interopRequireDefault(require("fs")), _micromatch = _interopRequireDefault(require("micromatch")), _normalizePath = _interopRequireDefault(require("normalize-path")), _path = _interopRequireDefault(require("path")), _utils = require("./utils");
9
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "createWatcher", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createWatcher;
9
+ }
10
+ });
11
+ const _chokidar = /*#__PURE__*/ _interop_require_default(require("chokidar"));
12
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
13
+ const _micromatch = /*#__PURE__*/ _interop_require_default(require("micromatch"));
14
+ const _normalizepath = /*#__PURE__*/ _interop_require_default(require("normalize-path"));
15
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
16
+ const _utils = require("./utils");
17
+ function _interop_require_default(obj) {
10
18
  return obj && obj.__esModule ? obj : {
11
19
  default: obj
12
20
  };
13
21
  }
14
22
  function createWatcher(args, { state , rebuild }) {
15
- let _timer, _reject, shouldPoll = args["--poll"], shouldCoalesceWriteEvents = shouldPoll || "win32" === process.platform, watcher = _chokidar.default.watch([], {
16
- atomic: !0,
23
+ let shouldPoll = args["--poll"];
24
+ let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
25
+ // Polling interval in milliseconds
26
+ // Used only when polling or coalescing add/change events on Windows
27
+ let pollInterval = 10;
28
+ let watcher = _chokidar.default.watch([], {
29
+ // Force checking for atomic writes in all situations
30
+ // This causes chokidar to wait up to 100ms for a file to re-added after it's been unlinked
31
+ // This only works when watching directories though
32
+ atomic: true,
17
33
  usePolling: shouldPoll,
18
- interval: shouldPoll ? 10 : void 0,
19
- ignoreInitial: !0,
20
- awaitWriteFinish: !!shouldCoalesceWriteEvents && {
34
+ interval: shouldPoll ? pollInterval : undefined,
35
+ ignoreInitial: true,
36
+ awaitWriteFinish: shouldCoalesceWriteEvents ? {
21
37
  stabilityThreshold: 50,
22
- pollInterval: 10
23
- }
24
- }), chain = Promise.resolve(), changedContent = [], pendingRebuilds = new Set();
25
- async function rebuildAndContinue() {
38
+ pollInterval: pollInterval
39
+ } : false
40
+ });
41
+ // A queue of rebuilds, file reads, etc… to run
42
+ let chain = Promise.resolve();
43
+ /**
44
+ * A list of files that have been changed since the last rebuild
45
+ *
46
+ * @type {{file: string, content: () => Promise<string>, extension: string}[]}
47
+ */ let changedContent = [];
48
+ /**
49
+ * A list of files for which a rebuild has already been queued.
50
+ * This is used to prevent duplicate rebuilds when multiple events are fired for the same file.
51
+ * The rebuilt file is cleared from this list when it's associated rebuild has _started_
52
+ * This is because if the file is changed during a rebuild it won't trigger a new rebuild which it should
53
+ **/ let pendingRebuilds = new Set();
54
+ let _timer;
55
+ let _reject;
56
+ /**
57
+ * Rebuilds the changed files and resolves when the rebuild is
58
+ * complete regardless of whether it was successful or not
59
+ */ async function rebuildAndContinue() {
26
60
  let changes = changedContent.splice(0);
27
- return 0 === changes.length ? Promise.resolve() : (changes.forEach((change)=>pendingRebuilds.delete(change.file)), rebuild(changes).then(()=>{}, ()=>{}));
61
+ // There are no changes to rebuild so we can just do nothing
62
+ if (changes.length === 0) {
63
+ return Promise.resolve();
64
+ }
65
+ // Clear all pending rebuilds for the about-to-be-built files
66
+ changes.forEach((change)=>pendingRebuilds.delete(change.file));
67
+ // Resolve the promise even when the rebuild fails
68
+ return rebuild(changes).then(()=>{}, ()=>{});
28
69
  }
29
- function recordChangedFile(file, content = null, skipPendingCheck = !1) {
30
- return (file = _path.default.resolve(file), pendingRebuilds.has(file) && !skipPendingCheck) ? Promise.resolve() : (pendingRebuilds.add(file), changedContent.push({
70
+ /**
71
+ *
72
+ * @param {*} file
73
+ * @param {(() => Promise<string>) | null} content
74
+ * @param {boolean} skipPendingCheck
75
+ * @returns {Promise<void>}
76
+ */ function recordChangedFile(file, content = null, skipPendingCheck = false) {
77
+ file = _path.default.resolve(file);
78
+ // Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
79
+ // In that case rebuild has already been queued by rename, so can be skipped in change
80
+ if (pendingRebuilds.has(file) && !skipPendingCheck) {
81
+ return Promise.resolve();
82
+ }
83
+ // Mark that a rebuild of this file is going to happen
84
+ // It MUST happen synchronously before the rebuild is queued for this to be effective
85
+ pendingRebuilds.add(file);
86
+ changedContent.push({
31
87
  file,
32
- content: null != content ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
88
+ content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
33
89
  extension: _path.default.extname(file).slice(1)
34
- }), _timer && (clearTimeout(_timer), _reject()), chain = (chain = chain.then(()=>new Promise((resolve, reject)=>{
35
- _timer = setTimeout(resolve, 10), _reject = reject;
36
- }))).then(rebuildAndContinue, rebuildAndContinue));
90
+ });
91
+ if (_timer) {
92
+ clearTimeout(_timer);
93
+ _reject();
94
+ }
95
+ // If a rebuild is already in progress we don't want to start another one until the 10ms timer has expired
96
+ chain = chain.then(()=>new Promise((resolve, reject)=>{
97
+ _timer = setTimeout(resolve, 10);
98
+ _reject = reject;
99
+ }));
100
+ // Resolves once this file has been rebuilt (or the rebuild for this file has failed)
101
+ // This queues as many rebuilds as there are changed files
102
+ // But those rebuilds happen after some delay
103
+ // And will immediately resolve if there are no changes
104
+ chain = chain.then(rebuildAndContinue, rebuildAndContinue);
105
+ return chain;
37
106
  }
38
- return watcher.on("change", (file)=>recordChangedFile(file)), watcher.on("add", (file)=>recordChangedFile(file)), watcher.on("unlink", (file)=>{
39
- file = (0, _normalizePath.default)(file), _micromatch.default.some([
107
+ watcher.on("change", (file)=>recordChangedFile(file));
108
+ watcher.on("add", (file)=>recordChangedFile(file));
109
+ // Restore watching any files that are "removed"
110
+ // 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)
111
+ // TODO: An an optimization we should allow removal when the config changes
112
+ watcher.on("unlink", (file)=>{
113
+ file = (0, _normalizepath.default)(file);
114
+ // Only re-add the file if it's not covered by a dynamic pattern
115
+ if (!_micromatch.default.some([
40
116
  file
41
- ], state.contentPatterns.dynamic) || watcher.add(file);
42
- }), watcher.on("raw", (evt, filePath, meta)=>{
43
- if ("rename" !== evt) return;
117
+ ], state.contentPatterns.dynamic)) {
118
+ watcher.add(file);
119
+ }
120
+ });
121
+ // Some applications such as Visual Studio (but not VS Code)
122
+ // will only fire a rename event for atomic writes and not a change event
123
+ // This is very likely a chokidar bug but it's one we need to work around
124
+ // We treat this as a change event and rebuild the CSS
125
+ watcher.on("raw", (evt, filePath, meta)=>{
126
+ if (evt !== "rename") {
127
+ return;
128
+ }
44
129
  let watchedPath = meta.watchedPath;
45
- filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.join(watchedPath, filePath), !_micromatch.default.some([
130
+ // Watched path might be the file itself
131
+ // Or the directory it is in
132
+ filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.join(watchedPath, filePath);
133
+ // Skip this event since the files it is for does not match any of the registered content globs
134
+ if (!_micromatch.default.some([
46
135
  filePath
47
- ], state.contentPatterns.all) || pendingRebuilds.has(filePath) || (pendingRebuilds.add(filePath), (async function() {
136
+ ], state.contentPatterns.all)) {
137
+ return;
138
+ }
139
+ // Skip since we've already queued a rebuild for this file that hasn't happened yet
140
+ if (pendingRebuilds.has(filePath)) {
141
+ return;
142
+ }
143
+ // We'll go ahead and add the file to the pending rebuilds list here
144
+ // It'll be removed when the rebuild starts unless the read fails
145
+ // which will be taken care of as well
146
+ pendingRebuilds.add(filePath);
147
+ async function enqueue() {
48
148
  try {
149
+ // We need to read the file as early as possible outside of the chain
150
+ // because it may be gone by the time we get to it. doing the read
151
+ // immediately increases the chance that the file is still there
49
152
  let content = await (0, _utils.readFileWithRetries)(_path.default.resolve(filePath));
50
- if (void 0 === content) return;
51
- await recordChangedFile(filePath, ()=>content, !0);
52
- } catch {}
53
- })().then(()=>{
153
+ if (content === undefined) {
154
+ return;
155
+ }
156
+ // This will push the rebuild onto the chain
157
+ // We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
158
+ // This is because the order of events and timing is different on Linux
159
+ // @ts-ignore: TypeScript isn't picking up that content is a string here
160
+ await recordChangedFile(filePath, ()=>content, true);
161
+ } catch {
162
+ // If reading the file fails, it's was probably a deleted temporary file
163
+ // So we can ignore it and no rebuild is needed
164
+ }
165
+ }
166
+ enqueue().then(()=>{
167
+ // If the file read fails we still need to make sure the file isn't stuck in the pending rebuilds list
54
168
  pendingRebuilds.delete(filePath);
55
- }));
56
- }), {
169
+ });
170
+ });
171
+ return {
57
172
  fswatcher: watcher,
58
173
  refreshWatchedFiles () {
59
- watcher.add(Array.from(state.contextDependencies)), watcher.add(Array.from(state.configBag.dependencies)), watcher.add(state.contentPatterns.all);
174
+ watcher.add(Array.from(state.contextDependencies));
175
+ watcher.add(Array.from(state.configBag.dependencies));
176
+ watcher.add(state.contentPatterns.all);
60
177
  }
61
178
  };
62
179
  }
@@ -1,28 +1,72 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), Object.defineProperty(exports, "help", {
5
- enumerable: !0,
6
- get: ()=>help
3
+ value: true
7
4
  });
8
- const _packageJson = function(obj) {
5
+ Object.defineProperty(exports, "help", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return help;
9
+ }
10
+ });
11
+ const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../../../package.json"));
12
+ function _interop_require_default(obj) {
9
13
  return obj && obj.__esModule ? obj : {
10
14
  default: obj
11
15
  };
12
- }(require("../../../../package.json"));
16
+ }
13
17
  function help({ message , usage , commands , options }) {
14
- if (console.log(), console.log(`${_packageJson.default.name} v${_packageJson.default.version}`), message) for (let msg of (console.log(), message.split("\n")))console.log(msg);
15
- if (usage && usage.length > 0) for (let example of (console.log(), console.log("Usage:"), usage))console.log(" ".repeat(2), example);
16
- if (commands && commands.length > 0) for (let command of (console.log(), console.log("Commands:"), commands))console.log(" ".repeat(2), command);
18
+ let indent = 2;
19
+ // Render header
20
+ console.log();
21
+ console.log(`${_packagejson.default.name} v${_packagejson.default.version}`);
22
+ // Render message
23
+ if (message) {
24
+ console.log();
25
+ for (let msg of message.split("\n")){
26
+ console.log(msg);
27
+ }
28
+ }
29
+ // Render usage
30
+ if (usage && usage.length > 0) {
31
+ console.log();
32
+ console.log("Usage:");
33
+ for (let example of usage){
34
+ console.log(" ".repeat(indent), example);
35
+ }
36
+ }
37
+ // Render commands
38
+ if (commands && commands.length > 0) {
39
+ console.log();
40
+ console.log("Commands:");
41
+ for (let command of commands){
42
+ console.log(" ".repeat(indent), command);
43
+ }
44
+ }
45
+ // Render options
17
46
  if (options) {
18
47
  let groupedOptions = {};
19
- for (let [key, value] of Object.entries(options))"object" == typeof value ? groupedOptions[key] = {
20
- ...value,
21
- flags: [
22
- key
23
- ]
24
- } : groupedOptions[value].flags.push(key);
25
- for (let { flags , description , deprecated } of (console.log(), console.log("Options:"), Object.values(groupedOptions)))deprecated || (1 === flags.length ? console.log(" ".repeat(6), flags.slice().reverse().join(", ").padEnd(20, " "), description) : console.log(" ".repeat(2), flags.slice().reverse().join(", ").padEnd(24, " "), description));
48
+ for (let [key, value] of Object.entries(options)){
49
+ if (typeof value === "object") {
50
+ groupedOptions[key] = {
51
+ ...value,
52
+ flags: [
53
+ key
54
+ ]
55
+ };
56
+ } else {
57
+ groupedOptions[value].flags.push(key);
58
+ }
59
+ }
60
+ console.log();
61
+ console.log("Options:");
62
+ for (let { flags , description , deprecated } of Object.values(groupedOptions)){
63
+ if (deprecated) continue;
64
+ if (flags.length === 1) {
65
+ console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
66
+ } else {
67
+ console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
68
+ }
69
+ }
26
70
  }
27
71
  console.log();
28
72
  }
@@ -1,29 +1,48 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: !0
4
+ value: true
5
5
  });
6
- const _path = _interopRequireDefault(require("path")), _arg = _interopRequireDefault(require("arg")), _fs = _interopRequireDefault(require("fs")), _build = require("./build"), _help = require("./help"), _init = require("./init");
7
- function _interopRequireDefault(obj) {
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
+ const _build = require("./build");
10
+ const _help = require("./help");
11
+ const _init = require("./init");
12
+ function _interop_require_default(obj) {
8
13
  return obj && obj.__esModule ? obj : {
9
14
  default: obj
10
15
  };
11
16
  }
17
+ // ---
18
+ function oneOf(...options) {
19
+ return Object.assign((value = true)=>{
20
+ for (let option of options){
21
+ let parsed = option(value);
22
+ if (parsed === value) {
23
+ return parsed;
24
+ }
25
+ }
26
+ throw new Error("...");
27
+ }, {
28
+ manualParsing: true
29
+ });
30
+ }
12
31
  let commands = {
13
32
  init: {
14
33
  run: _init.init,
15
34
  args: {
16
35
  "--esm": {
17
36
  type: Boolean,
18
- description: "Initialize configuration file as ESM"
37
+ description: `Initialize configuration file as ESM`
19
38
  },
20
39
  "--ts": {
21
40
  type: Boolean,
22
- description: "Initialize configuration file as TypeScript"
41
+ description: `Initialize configuration file as TypeScript`
23
42
  },
24
43
  "--full": {
25
44
  type: Boolean,
26
- description: "Include the default values for all options in the generated configuration file"
45
+ description: `Include the default values for all options in the generated configuration file`
27
46
  },
28
47
  "-f": "--full"
29
48
  }
@@ -40,17 +59,7 @@ let commands = {
40
59
  description: "Output file"
41
60
  },
42
61
  "--watch": {
43
- type: function(...options) {
44
- return Object.assign((value = !0)=>{
45
- for (let option of options){
46
- let parsed = option(value);
47
- if (parsed === value) return parsed;
48
- }
49
- throw Error("...");
50
- }, {
51
- manualParsing: !0
52
- });
53
- }(String, Boolean),
62
+ type: oneOf(String, Boolean),
54
63
  description: "Watch for changes and rebuild as needed"
55
64
  },
56
65
  "--poll": {
@@ -77,77 +86,129 @@ let commands = {
77
86
  "-p": "--poll"
78
87
  }
79
88
  }
80
- }, sharedFlags = {
89
+ };
90
+ let sharedFlags = {
81
91
  "--help": {
82
92
  type: Boolean,
83
93
  description: "Display usage information"
84
94
  },
85
95
  "-h": "--help"
86
96
  };
87
- process.stdout.isTTY && (void 0 === process.argv[2] || process.argv.slice(2).every((flag)=>void 0 !== sharedFlags[flag])) && ((0, _help.help)({
88
- usage: [
89
- "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
90
- "tailwindcss init [--full] [options...]"
91
- ],
92
- commands: Object.keys(commands).filter((command)=>"build" !== command).map((command)=>`${command} [options]`),
93
- options: {
94
- ...commands.build.args,
95
- ...sharedFlags
97
+ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
98
+ (0, _help.help)({
99
+ usage: [
100
+ "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
101
+ "tailwindcss init [--full] [options...]"
102
+ ],
103
+ commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
104
+ options: {
105
+ ...commands.build.args,
106
+ ...sharedFlags
107
+ }
108
+ });
109
+ process.exit(0);
110
+ }
111
+ let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
112
+ if (commands[command] === undefined) {
113
+ if (_fs.default.existsSync(_path.default.resolve(command))) {
114
+ // TODO: Deprecate this in future versions
115
+ // Check if non-existing command, might be a file.
116
+ command = "build";
117
+ } else {
118
+ (0, _help.help)({
119
+ message: `Invalid command: ${command}`,
120
+ usage: [
121
+ "tailwindcss <command> [options]"
122
+ ],
123
+ commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
124
+ options: sharedFlags
125
+ });
126
+ process.exit(1);
96
127
  }
97
- }), process.exit(0));
98
- let command = ((arg = "")=>arg.startsWith("-") ? void 0 : arg)(process.argv[2]) || "build";
99
- void 0 === commands[command] && (_fs.default.existsSync(_path.default.resolve(command)) ? command = "build" : ((0, _help.help)({
100
- message: `Invalid command: ${command}`,
101
- usage: [
102
- "tailwindcss <command> [options]"
103
- ],
104
- commands: Object.keys(commands).filter((command)=>"build" !== command).map((command)=>`${command} [options]`),
105
- options: sharedFlags
106
- }), process.exit(1)));
107
- let { args: flags , run } = commands[command], args = (()=>{
128
+ }
129
+ // Execute command
130
+ let { args: flags , run } = commands[command];
131
+ let args = (()=>{
108
132
  try {
109
133
  let result = (0, _arg.default)(Object.fromEntries(Object.entries({
110
134
  ...flags,
111
135
  ...sharedFlags
112
136
  }).filter(([_key, value])=>{
113
137
  var _value_type;
114
- return !(null == value ? void 0 : null === (_value_type = value.type) || void 0 === _value_type ? void 0 : _value_type.manualParsing);
138
+ return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
115
139
  }).map(([key, value])=>[
116
140
  key,
117
- "object" == typeof value ? value.type : value
141
+ typeof value === "object" ? value.type : value
118
142
  ])), {
119
- permissive: !0
143
+ permissive: true
120
144
  });
121
- for(let i = result._.length - 1; i >= 0; --i){
122
- let flag = result._[i];
145
+ // Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
146
+ for(let i = result["_"].length - 1; i >= 0; --i){
147
+ let flag = result["_"][i];
123
148
  if (!flag.startsWith("-")) continue;
124
- let [flagName, flagValue] = flag.split("="), handler = flags[flagName];
125
- for(; "string" == typeof handler;)flagName = handler, handler = flags[handler];
149
+ let [flagName, flagValue] = flag.split("=");
150
+ let handler = flags[flagName];
151
+ // Resolve flagName & handler
152
+ while(typeof handler === "string"){
153
+ flagName = handler;
154
+ handler = flags[handler];
155
+ }
126
156
  if (!handler) continue;
127
- let args = [], offset = i + 1;
128
- if (void 0 === flagValue) {
129
- for(; result._[offset] && !result._[offset].startsWith("-");)args.push(result._[offset++]);
130
- result._.splice(i, 1 + args.length), flagValue = 0 === args.length ? void 0 : 1 === args.length ? args[0] : args;
131
- } else result._.splice(i, 1);
157
+ let args = [];
158
+ let offset = i + 1;
159
+ // --flag value syntax was used so we need to pull `value` from `args`
160
+ if (flagValue === undefined) {
161
+ // Parse args for current flag
162
+ while(result["_"][offset] && !result["_"][offset].startsWith("-")){
163
+ args.push(result["_"][offset++]);
164
+ }
165
+ // Cleanup manually parsed flags + args
166
+ result["_"].splice(i, 1 + args.length);
167
+ // No args were provided, use default value defined in handler
168
+ // One arg was provided, use that directly
169
+ // Multiple args were provided so pass them all in an array
170
+ flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
171
+ } else {
172
+ // Remove the whole flag from the args array
173
+ result["_"].splice(i, 1);
174
+ }
175
+ // Set the resolved value in the `result` object
132
176
  result[flagName] = handler.type(flagValue, flagName);
133
177
  }
134
- return result._[0] !== command && result._.unshift(command), result;
178
+ // Ensure that the `command` is always the first argument in the `args`.
179
+ // This is important so that we don't have to check if a default command
180
+ // (build) was used or not from within each plugin.
181
+ //
182
+ // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
183
+ // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
184
+ if (result["_"][0] !== command) {
185
+ result["_"].unshift(command);
186
+ }
187
+ return result;
135
188
  } catch (err) {
136
- throw "ARG_UNKNOWN_OPTION" === err.code && ((0, _help.help)({
137
- message: err.message,
138
- usage: [
139
- "tailwindcss <command> [options]"
140
- ],
141
- options: sharedFlags
142
- }), process.exit(1)), err;
189
+ if (err.code === "ARG_UNKNOWN_OPTION") {
190
+ (0, _help.help)({
191
+ message: err.message,
192
+ usage: [
193
+ "tailwindcss <command> [options]"
194
+ ],
195
+ options: sharedFlags
196
+ });
197
+ process.exit(1);
198
+ }
199
+ throw err;
143
200
  }
144
201
  })();
145
- args["--help"] && ((0, _help.help)({
146
- options: {
147
- ...flags,
148
- ...sharedFlags
149
- },
150
- usage: [
151
- `tailwindcss ${command} [options]`
152
- ]
153
- }), process.exit(0)), run(args);
202
+ if (args["--help"]) {
203
+ (0, _help.help)({
204
+ options: {
205
+ ...flags,
206
+ ...sharedFlags
207
+ },
208
+ usage: [
209
+ `tailwindcss ${command} [options]`
210
+ ]
211
+ });
212
+ process.exit(0);
213
+ }
214
+ run(args);
@@ -1,31 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), Object.defineProperty(exports, "init", {
5
- enumerable: !0,
6
- get: ()=>init
3
+ value: true
7
4
  });
8
- const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path"));
9
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "init", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return init;
9
+ }
10
+ });
11
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ function _interop_require_default(obj) {
10
14
  return obj && obj.__esModule ? obj : {
11
15
  default: obj
12
16
  };
13
17
  }
18
+ function isESM() {
19
+ const pkgPath = _path.default.resolve("./package.json");
20
+ try {
21
+ let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
22
+ return pkg.type && pkg.type === "module";
23
+ } catch (err) {
24
+ return false;
25
+ }
26
+ }
14
27
  function init(args) {
28
+ let messages = [];
29
+ let isProjectESM = args["--ts"] || args["--esm"] || isESM();
30
+ let syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs";
31
+ let extension = args["--ts"] ? "ts" : "js";
15
32
  var _args___;
16
- let messages = [], isProjectESM = args["--ts"] || args["--esm"] || function() {
17
- let pkgPath = _path.default.resolve("./package.json");
18
- try {
19
- let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
20
- return pkg.type && "module" === pkg.type;
21
- } catch (err) {
22
- return !1;
33
+ let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./tailwind.config.${extension}`);
34
+ if (_fs.default.existsSync(tailwindConfigLocation)) {
35
+ messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
36
+ } else {
37
+ let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../../stubs/config.simple.js"), "utf8");
38
+ let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../../stubs/tailwind.config.${syntax}`), "utf8");
39
+ // Change colors import
40
+ stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
41
+ // Replace contents of {ts,js,cjs} file with the stub {simple,full}.
42
+ stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n";
43
+ _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
44
+ messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
45
+ }
46
+ if (messages.length > 0) {
47
+ console.log();
48
+ for (let message of messages){
49
+ console.log(message);
23
50
  }
24
- }(), syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs", extension = args["--ts"] ? "ts" : "js", tailwindConfigLocation = _path.default.resolve(null !== (_args___ = args._[1]) && void 0 !== _args___ ? _args___ : `./tailwind.config.${extension}`);
25
- if (_fs.default.existsSync(tailwindConfigLocation)) messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
26
- else {
27
- let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../../stubs/config.simple.js"), "utf8"), stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../../stubs/tailwind.config.${syntax}`), "utf8");
28
- stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors"), stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n", _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8"), messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
29
51
  }
30
- if (messages.length > 0) for (let message of (console.log(), messages))console.log(message);
31
52
  }
package/lib/oxide/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), require("./cli/index");
3
+ value: true
4
+ });
5
+ require("./cli/index");