tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.759a8c2
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 +34 -18
- package/lib/cli/build/index.js +45 -12
- package/lib/cli/build/plugin.js +273 -90
- package/lib/cli/build/utils.js +56 -24
- package/lib/cli/build/watching.js +156 -38
- package/lib/cli/help/index.js +61 -16
- package/lib/cli/index.js +121 -62
- package/lib/cli/init/index.js +47 -23
- package/lib/cli-peer-dependencies.js +23 -13
- package/lib/cli.js +5 -1
- package/lib/corePluginList.js +7 -4
- package/lib/corePlugins.js +855 -386
- package/lib/featureFlags.js +43 -18
- package/lib/lib/cacheInvalidation.js +78 -30
- package/lib/lib/collapseAdjacentRules.js +46 -23
- package/lib/lib/collapseDuplicateDeclarations.js +70 -27
- package/lib/lib/content.js +134 -41
- package/lib/lib/defaultExtractor.js +201 -96
- package/lib/lib/detectNesting.js +38 -12
- package/lib/lib/evaluateTailwindFunctions.js +192 -103
- package/lib/lib/expandApplyAtRules.js +488 -181
- package/lib/lib/expandTailwindAtRules.js +240 -70
- package/lib/lib/findAtConfigPath.js +34 -15
- package/lib/lib/generateRules.js +775 -353
- package/lib/lib/getModuleDependencies.js +67 -29
- package/lib/lib/load-config.js +27 -17
- package/lib/lib/normalizeTailwindDirectives.js +73 -27
- package/lib/lib/offsets.js +227 -62
- package/lib/lib/partitionApplyAtRules.js +53 -29
- package/lib/lib/regex.js +50 -28
- package/lib/lib/remap-bitfield.js +86 -9
- package/lib/lib/resolveDefaultsAtRules.js +123 -53
- package/lib/lib/setupContextUtils.js +1117 -584
- package/lib/lib/setupTrackingContext.js +149 -58
- package/lib/lib/sharedState.js +71 -23
- package/lib/lib/substituteScreenAtRules.js +19 -9
- package/lib/oxide/cli/build/deps.js +46 -23
- package/lib/oxide/cli/build/index.js +44 -12
- package/lib/oxide/cli/build/plugin.js +271 -89
- package/lib/oxide/cli/build/utils.js +55 -24
- package/lib/oxide/cli/build/watching.js +153 -36
- package/lib/oxide/cli/help/index.js +60 -16
- package/lib/oxide/cli/index.js +128 -67
- package/lib/oxide/cli/init/index.js +40 -19
- package/lib/oxide/cli.js +3 -2
- package/lib/plugin.js +58 -31
- package/lib/postcss-plugins/nesting/index.js +13 -7
- package/lib/postcss-plugins/nesting/plugin.js +65 -20
- package/lib/processTailwindFeatures.js +41 -10
- package/lib/public/colors.js +25 -16
- package/lib/public/create-plugin.js +11 -6
- package/lib/public/default-config.js +12 -6
- package/lib/public/default-theme.js +12 -6
- package/lib/public/load-config.js +9 -5
- package/lib/public/resolve-config.js +10 -6
- package/lib/util/applyImportantSelector.js +28 -17
- package/lib/util/bigSign.js +9 -6
- package/lib/util/buildMediaQuery.js +19 -10
- package/lib/util/cloneDeep.js +19 -9
- package/lib/util/cloneNodes.js +29 -14
- package/lib/util/color.js +87 -47
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +18 -9
- package/lib/util/createPlugin.js +17 -8
- package/lib/util/createUtilityPlugin.js +30 -16
- package/lib/util/dataTypes.js +189 -38
- package/lib/util/defaults.js +21 -9
- package/lib/util/escapeClassName.js +15 -9
- package/lib/util/escapeCommas.js +9 -6
- package/lib/util/flattenColorPalette.js +11 -7
- package/lib/util/formatVariantSelector.js +209 -60
- package/lib/util/getAllConfigs.js +44 -35
- package/lib/util/hashConfig.js +12 -8
- package/lib/util/isKeyframeRule.js +10 -7
- package/lib/util/isPlainObject.js +14 -9
- package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
- package/lib/util/log.js +20 -9
- package/lib/util/nameClass.js +31 -10
- package/lib/util/negateValue.js +28 -10
- package/lib/util/normalizeConfig.js +242 -63
- package/lib/util/normalizeScreens.js +145 -70
- package/lib/util/parseAnimationValue.js +64 -14
- package/lib/util/parseBoxShadowValue.js +63 -14
- package/lib/util/parseDependency.js +39 -13
- package/lib/util/parseGlob.js +25 -8
- package/lib/util/parseObjectStyles.js +29 -18
- package/lib/util/pluginUtils.js +196 -77
- package/lib/util/prefixSelector.js +31 -12
- package/lib/util/pseudoElements.js +116 -34
- package/lib/util/removeAlphaVariables.js +23 -8
- package/lib/util/resolveConfig.js +224 -105
- package/lib/util/resolveConfigPath.js +45 -15
- package/lib/util/responsive.js +10 -6
- package/lib/util/splitAtTopLevelOnly.js +46 -10
- package/lib/util/tap.js +11 -7
- package/lib/util/toColorValue.js +10 -7
- package/lib/util/toPath.js +28 -8
- package/lib/util/transformThemeValue.js +49 -14
- package/lib/util/validateConfig.js +25 -15
- package/lib/util/validateFormalSyntax.js +14 -6
- package/lib/util/withAlphaVariable.js +54 -30
- package/package.json +18 -22
- package/peers/index.js +57849 -43101
- package/src/lib/expandTailwindAtRules.js +1 -1
- package/src/lib/setupTrackingContext.js +1 -1
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/pseudoElements.js +4 -4
|
@@ -1,41 +1,122 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
}), Object.defineProperty(exports, "createProcessor", {
|
|
5
|
-
enumerable: !0,
|
|
6
|
-
get: ()=>createProcessor
|
|
3
|
+
value: true
|
|
7
4
|
});
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
Object.defineProperty(exports, "createProcessor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createProcessor;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
|
+
const _postcssloadconfig = /*#__PURE__*/ _interop_require_default(require("postcss-load-config"));
|
|
14
|
+
const _lilconfig = require("lilconfig");
|
|
15
|
+
const _plugins = /*#__PURE__*/ _interop_require_default(require("postcss-load-config/src/plugins" // Little bit scary, looking at private/internal API
|
|
16
|
+
));
|
|
17
|
+
const _options = /*#__PURE__*/ _interop_require_default(require("postcss-load-config/src/options" // Little bit scary, looking at private/internal API
|
|
18
|
+
));
|
|
19
|
+
const _processTailwindFeatures = /*#__PURE__*/ _interop_require_default(require("../../../processTailwindFeatures"));
|
|
20
|
+
const _deps = require("./deps");
|
|
21
|
+
const _utils = require("./utils");
|
|
22
|
+
const _sharedState = require("../../../lib/sharedState");
|
|
23
|
+
const _resolveConfig = /*#__PURE__*/ _interop_require_default(require("../../../../resolveConfig"));
|
|
24
|
+
const _content = require("../../../lib/content");
|
|
25
|
+
const _watching = require("./watching");
|
|
26
|
+
const _fastglob = /*#__PURE__*/ _interop_require_default(require("fast-glob"));
|
|
27
|
+
const _findAtConfigPath = require("../../../lib/findAtConfigPath");
|
|
28
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../../../util/log"));
|
|
29
|
+
const _loadconfig = require("../../../lib/load-config");
|
|
30
|
+
const _getModuleDependencies = /*#__PURE__*/ _interop_require_default(require("../../../lib/getModuleDependencies"));
|
|
31
|
+
function _interop_require_default(obj) {
|
|
10
32
|
return obj && obj.__esModule ? obj : {
|
|
11
33
|
default: obj
|
|
12
34
|
};
|
|
13
35
|
}
|
|
14
|
-
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {string} [customPostCssPath ]
|
|
39
|
+
* @returns
|
|
40
|
+
*/ async function loadPostCssPlugins(customPostCssPath) {
|
|
15
41
|
let config = customPostCssPath ? await (async ()=>{
|
|
16
|
-
let file = _path.default.resolve(customPostCssPath)
|
|
17
|
-
|
|
42
|
+
let file = _path.default.resolve(customPostCssPath);
|
|
43
|
+
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
let { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
|
|
46
|
+
if (typeof config === "function") {
|
|
47
|
+
config = config();
|
|
48
|
+
} else {
|
|
49
|
+
config = Object.assign({}, config);
|
|
50
|
+
}
|
|
51
|
+
if (!config.plugins) {
|
|
52
|
+
config.plugins = [];
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
18
55
|
file,
|
|
19
56
|
plugins: (0, _plugins.default)(config, file),
|
|
20
57
|
options: (0, _options.default)(config, file)
|
|
21
58
|
};
|
|
22
|
-
})() : await (0,
|
|
59
|
+
})() : await (0, _postcssloadconfig.default)();
|
|
60
|
+
let configPlugins = config.plugins;
|
|
61
|
+
let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
|
|
62
|
+
if (typeof plugin === "function" && plugin.name === "tailwindcss") {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (typeof plugin === "object" && plugin !== null && plugin.postcssPlugin === "tailwindcss") {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
70
|
+
let beforePlugins = configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx);
|
|
71
|
+
let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
|
|
23
72
|
return [
|
|
24
|
-
|
|
25
|
-
|
|
73
|
+
beforePlugins,
|
|
74
|
+
afterPlugins,
|
|
26
75
|
config.options
|
|
27
76
|
];
|
|
28
77
|
}
|
|
78
|
+
function loadBuiltinPostcssPlugins() {
|
|
79
|
+
let postcss = (0, _deps.loadPostcss)();
|
|
80
|
+
let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
|
|
81
|
+
return [
|
|
82
|
+
[
|
|
83
|
+
(root)=>{
|
|
84
|
+
root.walkAtRules("import", (rule)=>{
|
|
85
|
+
if (rule.params.slice(1).startsWith("tailwindcss/")) {
|
|
86
|
+
rule.after(postcss.comment({
|
|
87
|
+
text: IMPORT_COMMENT + rule.params
|
|
88
|
+
}));
|
|
89
|
+
rule.remove();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
(0, _deps.loadPostcssImport)(),
|
|
94
|
+
(root)=>{
|
|
95
|
+
root.walkComments((rule)=>{
|
|
96
|
+
if (rule.text.startsWith(IMPORT_COMMENT)) {
|
|
97
|
+
rule.after(postcss.atRule({
|
|
98
|
+
name: "import",
|
|
99
|
+
params: rule.text.replace(IMPORT_COMMENT, "")
|
|
100
|
+
}));
|
|
101
|
+
rule.remove();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
[],
|
|
107
|
+
{}
|
|
108
|
+
];
|
|
109
|
+
}
|
|
29
110
|
let state = {
|
|
30
|
-
context: null,
|
|
31
|
-
watcher: null,
|
|
32
|
-
changedContent: [],
|
|
33
|
-
configBag: null,
|
|
111
|
+
/** @type {any} */ context: null,
|
|
112
|
+
/** @type {ReturnType<typeof createWatcher> | null} */ watcher: null,
|
|
113
|
+
/** @type {{content: string, extension: string}[]} */ changedContent: [],
|
|
114
|
+
/** @type {{config: Config, dependencies: Set<string>, dispose: Function } | null} */ configBag: null,
|
|
34
115
|
contextDependencies: new Set(),
|
|
35
|
-
contentPaths: [],
|
|
116
|
+
/** @type {import('../../lib/content.js').ContentPath[]} */ contentPaths: [],
|
|
36
117
|
refreshContentPaths () {
|
|
37
118
|
var _this_context;
|
|
38
|
-
this.contentPaths = (0, _content.parseCandidateFiles)(this.context,
|
|
119
|
+
this.contentPaths = (0, _content.parseCandidateFiles)(this.context, (_this_context = this.context) === null || _this_context === void 0 ? void 0 : _this_context.tailwindConfig);
|
|
39
120
|
},
|
|
40
121
|
get config () {
|
|
41
122
|
return this.context.tailwindConfig;
|
|
@@ -43,103 +124,165 @@ let state = {
|
|
|
43
124
|
get contentPatterns () {
|
|
44
125
|
return {
|
|
45
126
|
all: this.contentPaths.map((contentPath)=>contentPath.pattern),
|
|
46
|
-
dynamic: this.contentPaths.filter((contentPath)=>
|
|
127
|
+
dynamic: this.contentPaths.filter((contentPath)=>contentPath.glob !== undefined).map((contentPath)=>contentPath.pattern)
|
|
47
128
|
};
|
|
48
129
|
},
|
|
49
130
|
loadConfig (configPath, content) {
|
|
50
|
-
this.watcher && configPath
|
|
51
|
-
|
|
52
|
-
|
|
131
|
+
if (this.watcher && configPath) {
|
|
132
|
+
this.refreshConfigDependencies();
|
|
133
|
+
}
|
|
134
|
+
let config = (0, _loadconfig.loadConfig)(configPath);
|
|
135
|
+
let dependencies = (0, _getModuleDependencies.default)(configPath);
|
|
136
|
+
this.configBag = {
|
|
53
137
|
config,
|
|
54
138
|
dependencies,
|
|
55
139
|
dispose () {
|
|
56
|
-
for (let file of dependencies)
|
|
140
|
+
for (let file of dependencies){
|
|
141
|
+
delete require.cache[require.resolve(file)];
|
|
142
|
+
}
|
|
57
143
|
}
|
|
58
|
-
}
|
|
144
|
+
};
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
this.configBag.config = (0, _resolveConfig.default)(this.configBag.config, {
|
|
59
147
|
content: {
|
|
60
148
|
files: []
|
|
61
149
|
}
|
|
62
|
-
})
|
|
150
|
+
});
|
|
151
|
+
// Override content files if `--content` has been passed explicitly
|
|
152
|
+
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
153
|
+
this.configBag.config.content.files = content;
|
|
154
|
+
}
|
|
155
|
+
return this.configBag.config;
|
|
63
156
|
},
|
|
64
157
|
refreshConfigDependencies (configPath) {
|
|
65
158
|
var _this_configBag;
|
|
66
|
-
_sharedState.env.DEBUG && console.time("Module dependencies")
|
|
159
|
+
_sharedState.env.DEBUG && console.time("Module dependencies");
|
|
160
|
+
(_this_configBag = this.configBag) === null || _this_configBag === void 0 ? void 0 : _this_configBag.dispose();
|
|
161
|
+
_sharedState.env.DEBUG && console.timeEnd("Module dependencies");
|
|
67
162
|
},
|
|
68
163
|
readContentPaths () {
|
|
69
164
|
let content = [];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
165
|
+
// Resolve globs from the content config
|
|
166
|
+
// TODO: When we make the postcss plugin async-capable this can become async
|
|
167
|
+
let files = _fastglob.default.sync(this.contentPatterns.all);
|
|
168
|
+
for (let file of files){
|
|
169
|
+
if (true) {
|
|
170
|
+
content.push({
|
|
171
|
+
file,
|
|
172
|
+
extension: _path.default.extname(file).slice(1)
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
content.push({
|
|
176
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
177
|
+
extension: _path.default.extname(file).slice(1)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Resolve raw content in the tailwind config
|
|
182
|
+
let rawContent = this.config.content.files.filter((file)=>{
|
|
183
|
+
return file !== null && typeof file === "object";
|
|
77
184
|
});
|
|
185
|
+
for (let { raw: htmlContent , extension ="html" } of rawContent){
|
|
186
|
+
content.push({
|
|
187
|
+
content: htmlContent,
|
|
188
|
+
extension
|
|
189
|
+
});
|
|
190
|
+
}
|
|
78
191
|
return content;
|
|
79
192
|
},
|
|
80
193
|
getContext ({ createContext , cliConfigPath , root , result , content }) {
|
|
81
|
-
|
|
82
|
-
|
|
194
|
+
if (this.context) {
|
|
195
|
+
this.context.changedContent = this.changedContent.splice(0);
|
|
196
|
+
return this.context;
|
|
197
|
+
}
|
|
83
198
|
_sharedState.env.DEBUG && console.time("Searching for config");
|
|
84
|
-
|
|
85
|
-
|
|
199
|
+
var _findAtConfigPath1;
|
|
200
|
+
let configPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : cliConfigPath;
|
|
201
|
+
_sharedState.env.DEBUG && console.timeEnd("Searching for config");
|
|
202
|
+
_sharedState.env.DEBUG && console.time("Loading config");
|
|
86
203
|
let config = this.loadConfig(configPath, content);
|
|
87
|
-
|
|
204
|
+
_sharedState.env.DEBUG && console.timeEnd("Loading config");
|
|
205
|
+
_sharedState.env.DEBUG && console.time("Creating context");
|
|
206
|
+
this.context = createContext(config, []);
|
|
207
|
+
Object.assign(this.context, {
|
|
88
208
|
userConfigPath: configPath
|
|
89
|
-
})
|
|
209
|
+
});
|
|
210
|
+
_sharedState.env.DEBUG && console.timeEnd("Creating context");
|
|
211
|
+
_sharedState.env.DEBUG && console.time("Resolving content paths");
|
|
212
|
+
this.refreshContentPaths();
|
|
213
|
+
_sharedState.env.DEBUG && console.timeEnd("Resolving content paths");
|
|
214
|
+
if (this.watcher) {
|
|
215
|
+
_sharedState.env.DEBUG && console.time("Watch new files");
|
|
216
|
+
this.watcher.refreshWatchedFiles();
|
|
217
|
+
_sharedState.env.DEBUG && console.timeEnd("Watch new files");
|
|
218
|
+
}
|
|
219
|
+
for (let file of this.readContentPaths()){
|
|
220
|
+
this.context.changedContent.push(file);
|
|
221
|
+
}
|
|
90
222
|
return this.context;
|
|
91
223
|
}
|
|
92
224
|
};
|
|
93
225
|
async function createProcessor(args, cliConfigPath) {
|
|
94
|
-
var _args_content
|
|
95
|
-
let postcss,
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
],
|
|
115
|
-
[],
|
|
116
|
-
{}
|
|
117
|
-
]);
|
|
118
|
-
args["--purge"] && (_log.default.warn("purge-flag-deprecated", [
|
|
119
|
-
"The `--purge` flag has been deprecated.",
|
|
120
|
-
"Please use `--content` instead."
|
|
121
|
-
]), args["--content"] || (args["--content"] = args["--purge"]));
|
|
122
|
-
let content = null !== (_args_content_split = null === (_args_content = args["--content"]) || void 0 === _args_content ? void 0 : _args_content.split(/(?<!{[^}]+),/)) && void 0 !== _args_content_split ? _args_content_split : [], tailwindPlugin = ()=>({
|
|
226
|
+
var _args_content;
|
|
227
|
+
let postcss = (0, _deps.loadPostcss)();
|
|
228
|
+
let input = args["--input"];
|
|
229
|
+
let output = args["--output"];
|
|
230
|
+
let includePostCss = args["--postcss"];
|
|
231
|
+
let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
|
|
232
|
+
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : loadBuiltinPostcssPlugins();
|
|
233
|
+
if (args["--purge"]) {
|
|
234
|
+
_log.default.warn("purge-flag-deprecated", [
|
|
235
|
+
"The `--purge` flag has been deprecated.",
|
|
236
|
+
"Please use `--content` instead."
|
|
237
|
+
]);
|
|
238
|
+
if (!args["--content"]) {
|
|
239
|
+
args["--content"] = args["--purge"];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
var _args_content_split;
|
|
243
|
+
let content = (_args_content_split = (_args_content = args["--content"]) === null || _args_content === void 0 ? void 0 : _args_content.split(/(?<!{[^}]+),/)) !== null && _args_content_split !== void 0 ? _args_content_split : [];
|
|
244
|
+
let tailwindPlugin = ()=>{
|
|
245
|
+
return {
|
|
123
246
|
postcssPlugin: "tailwindcss",
|
|
124
247
|
Once (root, { result }) {
|
|
125
|
-
_sharedState.env.DEBUG && console.time("Compiling CSS")
|
|
248
|
+
_sharedState.env.DEBUG && console.time("Compiling CSS");
|
|
249
|
+
(0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
250
|
+
console.error();
|
|
251
|
+
console.error("Rebuilding...");
|
|
252
|
+
return ()=>{
|
|
253
|
+
return state.getContext({
|
|
126
254
|
createContext,
|
|
127
255
|
cliConfigPath,
|
|
128
256
|
root,
|
|
129
257
|
result,
|
|
130
258
|
content
|
|
131
|
-
})
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
})(root, result);
|
|
262
|
+
_sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
|
|
132
263
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
tailwindPlugin.postcss = true;
|
|
267
|
+
let plugins = [
|
|
136
268
|
...beforePlugins,
|
|
137
269
|
tailwindPlugin,
|
|
138
270
|
!args["--minify"] && _utils.formatNodes,
|
|
139
271
|
...afterPlugins
|
|
140
|
-
].filter(Boolean)
|
|
272
|
+
].filter(Boolean);
|
|
273
|
+
/** @type {import('postcss').Processor} */ // @ts-ignore
|
|
274
|
+
let processor = postcss(plugins);
|
|
141
275
|
async function readInput() {
|
|
142
|
-
|
|
276
|
+
// Piping in data, let's drain the stdin
|
|
277
|
+
if (input === "-") {
|
|
278
|
+
return (0, _utils.drainStdin)();
|
|
279
|
+
}
|
|
280
|
+
// Input file has been provided
|
|
281
|
+
if (input) {
|
|
282
|
+
return _fs.default.promises.readFile(_path.default.resolve(input), "utf8");
|
|
283
|
+
}
|
|
284
|
+
// No input file provided, fallback to default atrules
|
|
285
|
+
return "@tailwind base; @tailwind components; @tailwind utilities";
|
|
143
286
|
}
|
|
144
287
|
async function build() {
|
|
145
288
|
let start = process.hrtime.bigint();
|
|
@@ -148,9 +291,21 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
148
291
|
from: input,
|
|
149
292
|
to: output
|
|
150
293
|
})).then((result)=>(0, _deps.lightningcss)(!!args["--minify"], result)).then((result)=>{
|
|
151
|
-
if (!state.watcher)
|
|
152
|
-
|
|
153
|
-
|
|
294
|
+
if (!state.watcher) {
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
_sharedState.env.DEBUG && console.time("Recording PostCSS dependencies");
|
|
298
|
+
for (let message of result.messages){
|
|
299
|
+
if (message.type === "dependency") {
|
|
300
|
+
state.contextDependencies.add(message.file);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
_sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies");
|
|
304
|
+
// TODO: This needs to be in a different spot
|
|
305
|
+
_sharedState.env.DEBUG && console.time("Watch new files");
|
|
306
|
+
state.watcher.refreshWatchedFiles();
|
|
307
|
+
_sharedState.env.DEBUG && console.timeEnd("Watch new files");
|
|
308
|
+
return result;
|
|
154
309
|
}).then((result)=>{
|
|
155
310
|
if (!output) {
|
|
156
311
|
process.stdout.write(result.css);
|
|
@@ -162,32 +317,59 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
162
317
|
]);
|
|
163
318
|
}).then(()=>{
|
|
164
319
|
let end = process.hrtime.bigint();
|
|
165
|
-
console.error()
|
|
320
|
+
console.error();
|
|
321
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
166
322
|
}).then(()=>{}, (err)=>{
|
|
167
|
-
|
|
168
|
-
|
|
323
|
+
// TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
|
|
324
|
+
// that were collected before the error occurred
|
|
325
|
+
// The result is not stored on the error so we have to store it externally
|
|
326
|
+
// and pull the messages off of it here somehow
|
|
327
|
+
// This results in a less than ideal DX because the watcher will not pick up
|
|
328
|
+
// changes to imported CSS if one of them caused an error during the initial build
|
|
329
|
+
// If you fix it and then save the main CSS file so there's no error
|
|
330
|
+
// The watcher will start watching the imported CSS files and will be
|
|
331
|
+
// resilient to future errors.
|
|
332
|
+
if (state.watcher) {
|
|
333
|
+
console.error(err);
|
|
334
|
+
} else {
|
|
335
|
+
return Promise.reject(err);
|
|
336
|
+
}
|
|
169
337
|
});
|
|
170
338
|
}
|
|
171
|
-
|
|
339
|
+
/**
|
|
340
|
+
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
341
|
+
*/ async function parseChanges(changes) {
|
|
172
342
|
return Promise.all(changes.map(async (change)=>({
|
|
173
343
|
content: await change.content(),
|
|
174
344
|
extension: change.extension
|
|
175
345
|
})));
|
|
176
346
|
}
|
|
177
|
-
|
|
347
|
+
if (input !== undefined && input !== "-") {
|
|
348
|
+
state.contextDependencies.add(_path.default.resolve(input));
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
178
351
|
build,
|
|
179
352
|
watch: async ()=>{
|
|
180
353
|
state.watcher = (0, _watching.createWatcher)(args, {
|
|
181
354
|
state,
|
|
182
|
-
|
|
183
|
-
|
|
355
|
+
/**
|
|
356
|
+
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
357
|
+
*/ async rebuild (changes) {
|
|
358
|
+
let needsNewContext = changes.some((change)=>{
|
|
184
359
|
var _state_configBag;
|
|
185
|
-
return (
|
|
186
|
-
})
|
|
187
|
-
|
|
360
|
+
return ((_state_configBag = state.configBag) === null || _state_configBag === void 0 ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
|
|
361
|
+
});
|
|
362
|
+
if (needsNewContext) {
|
|
363
|
+
state.context = null;
|
|
364
|
+
} else {
|
|
365
|
+
for (let change of (await parseChanges(changes))){
|
|
366
|
+
state.changedContent.push(change);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
188
369
|
return build();
|
|
189
370
|
}
|
|
190
|
-
})
|
|
371
|
+
});
|
|
372
|
+
await build();
|
|
191
373
|
}
|
|
192
374
|
};
|
|
193
375
|
}
|
|
@@ -1,41 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value:
|
|
4
|
-
})
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
5
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
6
|
-
enumerable:
|
|
7
|
+
enumerable: true,
|
|
7
8
|
get: all[name]
|
|
8
9
|
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
indentRecursive: function() {
|
|
13
|
+
return indentRecursive;
|
|
14
|
+
},
|
|
15
|
+
formatNodes: function() {
|
|
16
|
+
return formatNodes;
|
|
17
|
+
},
|
|
18
|
+
readFileWithRetries: function() {
|
|
19
|
+
return readFileWithRetries;
|
|
20
|
+
},
|
|
21
|
+
drainStdin: function() {
|
|
22
|
+
return drainStdin;
|
|
23
|
+
},
|
|
24
|
+
outputFile: function() {
|
|
25
|
+
return outputFile;
|
|
26
|
+
}
|
|
15
27
|
});
|
|
16
|
-
const _fs =
|
|
17
|
-
|
|
28
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
29
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
30
|
+
function _interop_require_default(obj) {
|
|
18
31
|
return obj && obj.__esModule ? obj : {
|
|
19
32
|
default: obj
|
|
20
33
|
};
|
|
21
34
|
}
|
|
22
35
|
function indentRecursive(node, indent = 0) {
|
|
23
36
|
node.each && node.each((child, i)=>{
|
|
24
|
-
(!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n"))
|
|
37
|
+
if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n")) {
|
|
38
|
+
child.raws.before = `\n${node.type !== "rule" && i > 0 ? "\n" : ""}${" ".repeat(indent)}`;
|
|
39
|
+
}
|
|
40
|
+
child.raws.after = `\n${" ".repeat(indent)}`;
|
|
41
|
+
indentRecursive(child, indent + 1);
|
|
25
42
|
});
|
|
26
43
|
}
|
|
27
44
|
function formatNodes(root) {
|
|
28
|
-
indentRecursive(root)
|
|
45
|
+
indentRecursive(root);
|
|
46
|
+
if (root.first) {
|
|
47
|
+
root.first.raws.before = "";
|
|
48
|
+
}
|
|
29
49
|
}
|
|
30
50
|
async function readFileWithRetries(path, tries = 5) {
|
|
31
|
-
for(let n = 0; n <= tries; n++)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
for(let n = 0; n <= tries; n++){
|
|
52
|
+
try {
|
|
53
|
+
return await _fs.default.promises.readFile(path, "utf8");
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (n !== tries) {
|
|
56
|
+
if (err.code === "ENOENT" || err.code === "EBUSY") {
|
|
57
|
+
await new Promise((resolve)=>setTimeout(resolve, 10));
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
throw err;
|
|
37
62
|
}
|
|
38
|
-
throw err;
|
|
39
63
|
}
|
|
40
64
|
}
|
|
41
65
|
function drainStdin() {
|
|
@@ -43,14 +67,21 @@ function drainStdin() {
|
|
|
43
67
|
let result = "";
|
|
44
68
|
process.stdin.on("data", (chunk)=>{
|
|
45
69
|
result += chunk;
|
|
46
|
-
})
|
|
70
|
+
});
|
|
71
|
+
process.stdin.on("end", ()=>resolve(result));
|
|
72
|
+
process.stdin.on("error", (err)=>reject(err));
|
|
47
73
|
});
|
|
48
74
|
}
|
|
49
75
|
async function outputFile(file, newContents) {
|
|
50
76
|
try {
|
|
51
|
-
|
|
77
|
+
let currentContents = await _fs.default.promises.readFile(file, "utf8");
|
|
78
|
+
if (currentContents === newContents) {
|
|
79
|
+
return; // Skip writing the file
|
|
80
|
+
}
|
|
52
81
|
} catch {}
|
|
82
|
+
// Write the file
|
|
53
83
|
await _fs.default.promises.mkdir(_path.default.dirname(file), {
|
|
54
|
-
recursive:
|
|
55
|
-
})
|
|
84
|
+
recursive: true
|
|
85
|
+
});
|
|
86
|
+
await _fs.default.promises.writeFile(file, newContents, "utf8");
|
|
56
87
|
}
|