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
|
@@ -1,177 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "createWatcher", {
|
|
5
|
+
enumerable: !0,
|
|
7
6
|
get: ()=>createWatcher
|
|
8
7
|
});
|
|
9
|
-
const _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
|
-
|
|
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 ?
|
|
33
|
-
ignoreInitial:
|
|
34
|
-
awaitWriteFinish: shouldCoalesceWriteEvents
|
|
18
|
+
interval: shouldPoll ? 10 : void 0,
|
|
19
|
+
ignoreInitial: !0,
|
|
20
|
+
awaitWriteFinish: !!shouldCoalesceWriteEvents && {
|
|
35
21
|
stabilityThreshold: 50,
|
|
36
|
-
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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:
|
|
32
|
+
content: null != content ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
|
|
87
33
|
extension: _path.default.extname(file).slice(1)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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:
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "help", {
|
|
5
|
+
enumerable: !0,
|
|
7
6
|
get: ()=>help
|
|
8
7
|
});
|
|
9
|
-
const _packageJson =
|
|
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
|
|
17
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
}
|
package/lib/oxide/cli/index.js
CHANGED
|
@@ -1,48 +1,29 @@
|
|
|
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
|
-
// ---
|
|
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:
|
|
18
|
+
description: "Initialize configuration file as ESM"
|
|
38
19
|
},
|
|
39
20
|
"--ts": {
|
|
40
21
|
type: Boolean,
|
|
41
|
-
description:
|
|
22
|
+
description: "Initialize configuration file as TypeScript"
|
|
42
23
|
},
|
|
43
24
|
"--full": {
|
|
44
25
|
type: Boolean,
|
|
45
|
-
description:
|
|
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:
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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 !(
|
|
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
|
|
117
|
+
"object" == typeof value ? value.type : value
|
|
142
118
|
])), {
|
|
143
|
-
permissive:
|
|
119
|
+
permissive: !0
|
|
144
120
|
});
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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:
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "init", {
|
|
5
|
+
enumerable: !0,
|
|
7
6
|
get: ()=>init
|
|
8
7
|
});
|
|
9
|
-
const _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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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