tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-insiders.b2e3cf2

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