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