tailwindcss 0.0.0-insiders.cbbfa82 → 0.0.0-insiders.cc1eec6
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/README.md +1 -1
- package/lib/cli/build/index.js +7 -3
- package/lib/cli/build/plugin.js +65 -51
- package/lib/cli/build/watching.js +4 -2
- package/lib/cli/index.js +222 -10
- package/lib/cli/init/index.js +22 -7
- package/lib/cli.js +4 -236
- package/lib/corePluginList.js +4 -0
- package/lib/corePlugins.js +319 -52
- package/lib/css/preflight.css +2 -0
- package/lib/featureFlags.js +16 -9
- package/lib/index.js +4 -46
- package/lib/lib/collapseAdjacentRules.js +2 -2
- package/lib/lib/collapseDuplicateDeclarations.js +2 -2
- package/lib/lib/content.js +16 -16
- package/lib/lib/defaultExtractor.js +10 -5
- package/lib/lib/detectNesting.js +7 -1
- package/lib/lib/evaluateTailwindFunctions.js +4 -4
- package/lib/lib/expandApplyAtRules.js +14 -3
- package/lib/lib/expandTailwindAtRules.js +34 -9
- package/lib/lib/findAtConfigPath.js +3 -3
- package/lib/lib/generateRules.js +123 -64
- package/lib/lib/getModuleDependencies.js +79 -33
- package/lib/lib/load-config.js +40 -0
- package/lib/lib/offsets.js +88 -1
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +4 -4
- package/lib/lib/setupContextUtils.js +123 -68
- package/lib/lib/setupTrackingContext.js +29 -8
- package/lib/lib/sharedState.js +25 -2
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +51 -0
- package/lib/oxide/cli/build/plugin.js +373 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +214 -0
- package/lib/oxide/cli/init/index.js +50 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/lib/postcss-plugins/nesting/plugin.js +2 -2
- package/lib/public/colors.js +44 -22
- package/lib/public/default-config.js +2 -2
- package/lib/public/default-theme.js +2 -2
- package/lib/public/load-config.js +10 -0
- package/lib/util/applyImportantSelector.js +37 -0
- package/lib/util/cloneNodes.js +2 -2
- package/lib/util/color.js +20 -6
- package/lib/util/createUtilityPlugin.js +2 -2
- package/lib/util/dataTypes.js +26 -2
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +3 -3
- package/lib/util/formatVariantSelector.js +173 -115
- package/lib/util/getAllConfigs.js +4 -4
- package/lib/util/negateValue.js +2 -2
- package/lib/util/normalizeConfig.js +21 -22
- package/lib/util/pluginUtils.js +20 -39
- package/lib/util/prefixSelector.js +22 -8
- package/lib/util/resolveConfig.js +7 -7
- package/lib/util/resolveConfigPath.js +19 -7
- package/lib/util/splitAtTopLevelOnly.js +7 -1
- package/lib/util/validateConfig.js +11 -0
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +33 -21
- package/peers/index.js +108 -173
- package/resolveConfig.d.ts +11 -2
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/index.js +7 -7
- package/src/cli/build/plugin.js +40 -30
- package/src/cli/build/watching.js +4 -2
- package/src/cli/index.js +216 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +4 -231
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +205 -29
- package/src/css/preflight.css +2 -0
- package/src/featureFlags.js +7 -0
- package/src/index.js +4 -46
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandApplyAtRules.js +14 -1
- package/src/lib/expandTailwindAtRules.js +35 -6
- package/src/lib/generateRules.js +124 -42
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +31 -0
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +99 -43
- package/src/lib/setupTrackingContext.js +35 -10
- package/src/lib/sharedState.js +30 -4
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +442 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +204 -0
- package/src/oxide/cli/init/index.ts +59 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +30 -0
- package/src/util/color.js +17 -2
- package/src/util/dataTypes.js +29 -4
- package/src/util/formatVariantSelector.js +240 -121
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +2 -1
- package/src/util/pluginUtils.js +10 -29
- package/src/util/prefixSelector.js +28 -10
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +13 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +183 -146
- package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +15 -9
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +108 -79
- package/CHANGELOG.md +0 -2339
- package/lib/cli/shared.js +0 -12
- package/lib/constants.js +0 -44
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
- package/src/constants.js +0 -17
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/lib/featureFlags.js
CHANGED
|
@@ -15,6 +15,7 @@ _export(exports, {
|
|
|
15
15
|
});
|
|
16
16
|
const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
|
|
17
17
|
const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
|
|
18
|
+
const _sharedState = require("./lib/sharedState");
|
|
18
19
|
function _interopRequireDefault(obj) {
|
|
19
20
|
return obj && obj.__esModule ? obj : {
|
|
20
21
|
default: obj
|
|
@@ -22,7 +23,13 @@ function _interopRequireDefault(obj) {
|
|
|
22
23
|
}
|
|
23
24
|
let defaults = {
|
|
24
25
|
optimizeUniversalDefaults: false,
|
|
25
|
-
generalizedModifiers: true
|
|
26
|
+
generalizedModifiers: true,
|
|
27
|
+
get disableColorOpacityUtilitiesByDefault () {
|
|
28
|
+
return _sharedState.env.OXIDE;
|
|
29
|
+
},
|
|
30
|
+
get relativeContentPathsByDefault () {
|
|
31
|
+
return _sharedState.env.OXIDE;
|
|
32
|
+
}
|
|
26
33
|
};
|
|
27
34
|
let featureFlags = {
|
|
28
35
|
future: [
|
|
@@ -38,14 +45,14 @@ let featureFlags = {
|
|
|
38
45
|
};
|
|
39
46
|
function flagEnabled(config, flag) {
|
|
40
47
|
if (featureFlags.future.includes(flag)) {
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
return config.future === "all" || ((
|
|
48
|
+
var _config_future;
|
|
49
|
+
var _config_future_flag, _ref;
|
|
50
|
+
return config.future === "all" || ((_ref = (_config_future_flag = config === null || config === void 0 ? void 0 : (_config_future = config.future) === null || _config_future === void 0 ? void 0 : _config_future[flag]) !== null && _config_future_flag !== void 0 ? _config_future_flag : defaults[flag]) !== null && _ref !== void 0 ? _ref : false);
|
|
44
51
|
}
|
|
45
52
|
if (featureFlags.experimental.includes(flag)) {
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
return config.experimental === "all" || ((
|
|
53
|
+
var _config_experimental;
|
|
54
|
+
var _config_experimental_flag, _ref1;
|
|
55
|
+
return config.experimental === "all" || ((_ref1 = (_config_experimental_flag = config === null || config === void 0 ? void 0 : (_config_experimental = config.experimental) === null || _config_experimental === void 0 ? void 0 : _config_experimental[flag]) !== null && _config_experimental_flag !== void 0 ? _config_experimental_flag : defaults[flag]) !== null && _ref1 !== void 0 ? _ref1 : false);
|
|
49
56
|
}
|
|
50
57
|
return false;
|
|
51
58
|
}
|
|
@@ -53,8 +60,8 @@ function experimentalFlagsEnabled(config) {
|
|
|
53
60
|
if (config.experimental === "all") {
|
|
54
61
|
return featureFlags.experimental;
|
|
55
62
|
}
|
|
56
|
-
var
|
|
57
|
-
return Object.keys((
|
|
63
|
+
var _config_experimental;
|
|
64
|
+
return Object.keys((_config_experimental = config === null || config === void 0 ? void 0 : config.experimental) !== null && _config_experimental !== void 0 ? _config_experimental : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]);
|
|
58
65
|
}
|
|
59
66
|
function issueFlagNotices(config) {
|
|
60
67
|
if (process.env.JEST_WORKER_ID !== undefined) {
|
package/lib/index.js
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
|
|
7
|
-
const _sharedState = require("./lib/sharedState");
|
|
8
|
-
const _findAtConfigPath = require("./lib/findAtConfigPath");
|
|
9
|
-
function _interopRequireDefault(obj) {
|
|
10
|
-
return obj && obj.__esModule ? obj : {
|
|
11
|
-
default: obj
|
|
12
|
-
};
|
|
2
|
+
if (process.env.OXIDE) {
|
|
3
|
+
module.exports = require("./oxide/postcss-plugin");
|
|
4
|
+
} else {
|
|
5
|
+
module.exports = require("./plugin");
|
|
13
6
|
}
|
|
14
|
-
module.exports = function tailwindcss(configOrPath) {
|
|
15
|
-
return {
|
|
16
|
-
postcssPlugin: "tailwindcss",
|
|
17
|
-
plugins: [
|
|
18
|
-
_sharedState.env.DEBUG && function(root) {
|
|
19
|
-
console.log("\n");
|
|
20
|
-
console.time("JIT TOTAL");
|
|
21
|
-
return root;
|
|
22
|
-
},
|
|
23
|
-
function(root, result) {
|
|
24
|
-
var ref;
|
|
25
|
-
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
26
|
-
// path for the file being processed
|
|
27
|
-
configOrPath = (ref = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && ref !== void 0 ? ref : configOrPath;
|
|
28
|
-
let context = (0, _setupTrackingContext.default)(configOrPath);
|
|
29
|
-
if (root.type === "document") {
|
|
30
|
-
let roots = root.nodes.filter((node)=>node.type === "root");
|
|
31
|
-
for (const root1 of roots){
|
|
32
|
-
if (root1.type === "root") {
|
|
33
|
-
(0, _processTailwindFeatures.default)(context)(root1, result);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
39
|
-
},
|
|
40
|
-
_sharedState.env.DEBUG && function(root) {
|
|
41
|
-
console.timeEnd("JIT TOTAL");
|
|
42
|
-
console.log("\n");
|
|
43
|
-
return root;
|
|
44
|
-
}
|
|
45
|
-
].filter(Boolean)
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
module.exports.postcss = true;
|
|
@@ -29,10 +29,10 @@ function collapseAdjacentRules() {
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
let properties = comparisonMap[node.type];
|
|
32
|
-
var
|
|
32
|
+
var _node_property, _currentRule_property;
|
|
33
33
|
if (node.type === "atrule" && node.name === "font-face") {
|
|
34
34
|
currentRule = node;
|
|
35
|
-
} else if (properties.every((property)=>((
|
|
35
|
+
} else if (properties.every((property)=>((_node_property = node[property]) !== null && _node_property !== void 0 ? _node_property : "").replace(/\s+/g, " ") === ((_currentRule_property = currentRule[property]) !== null && _currentRule_property !== void 0 ? _currentRule_property : "").replace(/\s+/g, " "))) {
|
|
36
36
|
// An AtRule may not have children (for example if we encounter duplicate @import url(…) rules)
|
|
37
37
|
if (node.nodes) {
|
|
38
38
|
currentRule.append(node.nodes);
|
|
@@ -76,8 +76,8 @@ let UNITLESS_NUMBER = Symbol("unitless-number");
|
|
|
76
76
|
function resolveUnit(input) {
|
|
77
77
|
let result = /^-?\d*.?\d+([\w%]+)?$/g.exec(input);
|
|
78
78
|
if (result) {
|
|
79
|
-
var
|
|
80
|
-
return (
|
|
79
|
+
var _result_;
|
|
80
|
+
return (_result_ = result[1]) !== null && _result_ !== void 0 ? _result_ : UNITLESS_NUMBER;
|
|
81
81
|
}
|
|
82
82
|
return null;
|
|
83
83
|
}
|
package/lib/lib/content.js
CHANGED
|
@@ -135,43 +135,43 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
135
135
|
content: raw,
|
|
136
136
|
extension
|
|
137
137
|
}));
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
let [changedFiles, mTimesToCommit] = resolveChangedFiles(candidateFiles, fileModifiedMap);
|
|
139
|
+
for (let changedFile of changedFiles){
|
|
140
140
|
let extension = _path.default.extname(changedFile).slice(1);
|
|
141
141
|
changedContent.push({
|
|
142
|
-
|
|
142
|
+
file: changedFile,
|
|
143
143
|
extension
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
return
|
|
146
|
+
return [
|
|
147
|
+
changedContent,
|
|
148
|
+
mTimesToCommit
|
|
149
|
+
];
|
|
147
150
|
}
|
|
148
151
|
/**
|
|
149
152
|
*
|
|
150
153
|
* @param {ContentPath[]} candidateFiles
|
|
151
154
|
* @param {Map<string, number>} fileModifiedMap
|
|
152
|
-
* @returns {Set<string>}
|
|
155
|
+
* @returns {[Set<string>, Map<string, number>]}
|
|
153
156
|
*/ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
154
157
|
let paths = candidateFiles.map((contentPath)=>contentPath.pattern);
|
|
158
|
+
let mTimesToCommit = new Map();
|
|
155
159
|
let changedFiles = new Set();
|
|
156
160
|
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
157
161
|
let files = _fastGlob.default.sync(paths, {
|
|
158
162
|
absolute: true
|
|
159
163
|
});
|
|
160
164
|
for (let file of files){
|
|
161
|
-
let prevModified = fileModifiedMap.
|
|
165
|
+
let prevModified = fileModifiedMap.get(file) || -Infinity;
|
|
162
166
|
let modified = _fs.default.statSync(file).mtimeMs;
|
|
163
|
-
|
|
164
|
-
// earier in the process and we want to make sure we don't miss any changes that happen
|
|
165
|
-
// when a context dependency is also a content dependency
|
|
166
|
-
// Ideally, we'd do all this tracking at one time but that is a larger refactor
|
|
167
|
-
// than we want to commit to right now, so this is a decent compromise.
|
|
168
|
-
// This should be sufficient because file modification times will be off by at least
|
|
169
|
-
// 1ms (the precision of fstat in Node) in most cases if they exist and were changed.
|
|
170
|
-
if (modified >= prevModified) {
|
|
167
|
+
if (modified > prevModified) {
|
|
171
168
|
changedFiles.add(file);
|
|
172
|
-
|
|
169
|
+
mTimesToCommit.set(file, modified);
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
_sharedState.env.DEBUG && console.timeEnd("Finding changed files");
|
|
176
|
-
return
|
|
173
|
+
return [
|
|
174
|
+
changedFiles,
|
|
175
|
+
mTimesToCommit
|
|
176
|
+
];
|
|
177
177
|
}
|
|
@@ -54,10 +54,10 @@ function defaultExtractor(context) {
|
|
|
54
54
|
*/ return (content)=>{
|
|
55
55
|
/** @type {(string|string)[]} */ let results = [];
|
|
56
56
|
for (let pattern of patterns){
|
|
57
|
-
var
|
|
57
|
+
var _content_match;
|
|
58
58
|
results = [
|
|
59
59
|
...results,
|
|
60
|
-
...(
|
|
60
|
+
...(_content_match = content.match(pattern)) !== null && _content_match !== void 0 ? _content_match : []
|
|
61
61
|
];
|
|
62
62
|
}
|
|
63
63
|
return results.filter((v)=>v !== undefined).map(clipAtBalancedParens);
|
|
@@ -71,8 +71,13 @@ function* buildRegExps(context) {
|
|
|
71
71
|
_regex.escape(context.tailwindConfig.prefix)
|
|
72
72
|
])) : "";
|
|
73
73
|
let utility = _regex.any([
|
|
74
|
-
// Arbitrary properties
|
|
75
|
-
/\[[^\s:'"`]+:[^\s]+\]/,
|
|
74
|
+
// Arbitrary properties (without square brackets)
|
|
75
|
+
/\[[^\s:'"`]+:[^\s\[\]]+\]/,
|
|
76
|
+
// Arbitrary properties with balanced square brackets
|
|
77
|
+
// This is a targeted fix to continue to allow theme()
|
|
78
|
+
// with square brackets to work in arbitrary properties
|
|
79
|
+
// while fixing a problem with the regex matching too much
|
|
80
|
+
/\[[^\s:'"`]+:[^\s]+?\[[^\s]+?\][^\s]+?\]/,
|
|
76
81
|
// Utilities
|
|
77
82
|
_regex.pattern([
|
|
78
83
|
// Utility Name / Group Name
|
|
@@ -216,7 +221,7 @@ let ALLOWED_CLASS_CHARACTERS = /[^"'`\s<>\]]+/;
|
|
|
216
221
|
// This means that there was an extra closing `]`
|
|
217
222
|
// We'll clip to just before it
|
|
218
223
|
if (depth < 0) {
|
|
219
|
-
return input.substring(0, match.index);
|
|
224
|
+
return input.substring(0, match.index - 1);
|
|
220
225
|
}
|
|
221
226
|
// We've finished balancing the brackets but there still may be characters that can be included
|
|
222
227
|
// For example in the class `text-[#336699]/[.35]`
|
package/lib/lib/detectNesting.js
CHANGED
|
@@ -6,12 +6,18 @@ Object.defineProperty(exports, "default", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>_default
|
|
8
8
|
});
|
|
9
|
+
function isRoot(node) {
|
|
10
|
+
return node.type === "root";
|
|
11
|
+
}
|
|
12
|
+
function isAtLayer(node) {
|
|
13
|
+
return node.type === "atrule" && node.name === "layer";
|
|
14
|
+
}
|
|
9
15
|
function _default(_context) {
|
|
10
16
|
return (root, result)=>{
|
|
11
17
|
let found = false;
|
|
12
18
|
root.walkAtRules("tailwind", (node)=>{
|
|
13
19
|
if (found) return false;
|
|
14
|
-
if (node.parent && node.parent
|
|
20
|
+
if (node.parent && !(isRoot(node.parent) || isAtLayer(node.parent))) {
|
|
15
21
|
found = true;
|
|
16
22
|
node.warn(result, [
|
|
17
23
|
"Nested @tailwind rules were detected, but are not supported.",
|
|
@@ -177,8 +177,8 @@ let nodeTypePropertyMap = {
|
|
|
177
177
|
alpha
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
|
-
var
|
|
181
|
-
return (
|
|
180
|
+
var _results_find;
|
|
181
|
+
return (_results_find = results.find((result)=>result.isValid)) !== null && _results_find !== void 0 ? _results_find : results[0];
|
|
182
182
|
}
|
|
183
183
|
function _default(context) {
|
|
184
184
|
let config = context.tailwindConfig;
|
|
@@ -186,9 +186,9 @@ function _default(context) {
|
|
|
186
186
|
theme: (node, path, ...defaultValue)=>{
|
|
187
187
|
let { isValid , value , error , alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
|
|
188
188
|
if (!isValid) {
|
|
189
|
-
var
|
|
189
|
+
var _parentNode_raws_tailwind;
|
|
190
190
|
let parentNode = node.parent;
|
|
191
|
-
let candidate = (
|
|
191
|
+
let candidate = (_parentNode_raws_tailwind = parentNode === null || parentNode === void 0 ? void 0 : parentNode.raws.tailwind) === null || _parentNode_raws_tailwind === void 0 ? void 0 : _parentNode_raws_tailwind.candidate;
|
|
192
192
|
if (parentNode && candidate !== undefined) {
|
|
193
193
|
// Remove this utility from any caches
|
|
194
194
|
context.markInvalidUtilityNode(parentNode);
|
|
@@ -10,6 +10,8 @@ const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
|
10
10
|
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
11
11
|
const _generateRules = require("./generateRules");
|
|
12
12
|
const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
|
|
13
|
+
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
14
|
+
const _formatVariantSelectorJs = require("../util/formatVariantSelector.js");
|
|
13
15
|
function _interopRequireDefault(obj) {
|
|
14
16
|
return obj && obj.__esModule ? obj : {
|
|
15
17
|
default: obj
|
|
@@ -139,8 +141,8 @@ function* pathToRoot(node) {
|
|
|
139
141
|
root.walkRules((rule)=>{
|
|
140
142
|
// Ignore rules generated by Tailwind
|
|
141
143
|
for (let node of pathToRoot(rule)){
|
|
142
|
-
var
|
|
143
|
-
if (((
|
|
144
|
+
var _node_raws_tailwind;
|
|
145
|
+
if (((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.layer) !== undefined) {
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
148
|
}
|
|
@@ -481,11 +483,20 @@ function processApply(root, context, localCache) {
|
|
|
481
483
|
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate1);
|
|
482
484
|
// And then re-add it if it was removed
|
|
483
485
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
484
|
-
rule.selector =
|
|
486
|
+
rule.selector = (0, _applyImportantSelector.applyImportantSelector)(rule.selector, importantSelector);
|
|
485
487
|
}
|
|
486
488
|
rule.walkDecls((d)=>{
|
|
487
489
|
d.important = meta.important || important1;
|
|
488
490
|
});
|
|
491
|
+
// Move pseudo elements to the end of the selector (if necessary)
|
|
492
|
+
let selector = (0, _postcssSelectorParser.default)().astSync(rule.selector);
|
|
493
|
+
selector.each((sel)=>{
|
|
494
|
+
let [pseudoElements] = (0, _formatVariantSelectorJs.collectPseudoElements)(sel);
|
|
495
|
+
if (pseudoElements.length > 0) {
|
|
496
|
+
sel.nodes.push(...pseudoElements.sort(_formatVariantSelectorJs.sortSelector));
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
rule.selector = selector.toString();
|
|
489
500
|
});
|
|
490
501
|
}
|
|
491
502
|
// It could be that the node we were inserted was removed because the class didn't match
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "default", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>expandTailwindAtRules
|
|
8
8
|
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
9
10
|
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
10
11
|
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
11
12
|
const _generateRules = require("./generateRules");
|
|
@@ -142,24 +143,48 @@ function expandTailwindAtRules(context) {
|
|
|
142
143
|
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
143
144
|
return root;
|
|
144
145
|
}
|
|
146
|
+
var _context_candidates;
|
|
145
147
|
// ---
|
|
146
148
|
// Find potential rules in changed files
|
|
147
149
|
let candidates = new Set([
|
|
150
|
+
...(_context_candidates = context.candidates) !== null && _context_candidates !== void 0 ? _context_candidates : [],
|
|
148
151
|
_sharedState.NOT_ON_DEMAND
|
|
149
152
|
]);
|
|
150
153
|
let seen = new Set();
|
|
151
154
|
env.DEBUG && console.time("Reading changed files");
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
let
|
|
155
|
-
|
|
155
|
+
if (env.OXIDE) {
|
|
156
|
+
// TODO: Pass through or implement `extractor`
|
|
157
|
+
for (let candidate of require("@tailwindcss/oxide").parseCandidateStringsFromFiles(context.changedContent)){
|
|
158
|
+
candidates.add(candidate);
|
|
159
|
+
}
|
|
160
|
+
// for (let { file, content, extension } of context.changedContent) {
|
|
161
|
+
// let transformer = getTransformer(context.tailwindConfig, extension)
|
|
162
|
+
// let extractor = getExtractor(context, extension)
|
|
163
|
+
// getClassCandidatesOxide(file, transformer(content), extractor, candidates, seen)
|
|
164
|
+
// }
|
|
165
|
+
} else {
|
|
166
|
+
for (let { file , content , extension } of context.changedContent){
|
|
167
|
+
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
168
|
+
let extractor = getExtractor(context, extension);
|
|
169
|
+
content = file ? _fs.default.readFileSync(file, "utf8") : content;
|
|
170
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
171
|
+
}
|
|
156
172
|
}
|
|
157
173
|
env.DEBUG && console.timeEnd("Reading changed files");
|
|
158
174
|
// ---
|
|
159
175
|
// Generate the actual CSS
|
|
160
176
|
let classCacheCount = context.classCache.size;
|
|
161
177
|
env.DEBUG && console.time("Generate rules");
|
|
162
|
-
|
|
178
|
+
env.DEBUG && console.time("Sorting candidates");
|
|
179
|
+
let sortedCandidates = env.OXIDE ? candidates : new Set([
|
|
180
|
+
...candidates
|
|
181
|
+
].sort((a, z)=>{
|
|
182
|
+
if (a === z) return 0;
|
|
183
|
+
if (a < z) return -1;
|
|
184
|
+
return 1;
|
|
185
|
+
}));
|
|
186
|
+
env.DEBUG && console.timeEnd("Sorting candidates");
|
|
187
|
+
(0, _generateRules.generateRules)(sortedCandidates, context);
|
|
163
188
|
env.DEBUG && console.timeEnd("Generate rules");
|
|
164
189
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
165
190
|
env.DEBUG && console.time("Build stylesheet");
|
|
@@ -199,8 +224,8 @@ function expandTailwindAtRules(context) {
|
|
|
199
224
|
}
|
|
200
225
|
// We do post-filtering to not alter the emitted order of the variants
|
|
201
226
|
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
202
|
-
var
|
|
203
|
-
const parentLayer = (
|
|
227
|
+
var _node_raws_tailwind;
|
|
228
|
+
const parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer;
|
|
204
229
|
if (parentLayer === "components") {
|
|
205
230
|
return layerNodes.components !== null;
|
|
206
231
|
}
|
|
@@ -221,8 +246,8 @@ function expandTailwindAtRules(context) {
|
|
|
221
246
|
}
|
|
222
247
|
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
223
248
|
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
224
|
-
var
|
|
225
|
-
return ((
|
|
249
|
+
var _node_raws_tailwind;
|
|
250
|
+
return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) === "utilities";
|
|
226
251
|
});
|
|
227
252
|
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
228
253
|
_log.default.warn("content-problems", [
|
|
@@ -17,9 +17,9 @@ function findAtConfigPath(root, result) {
|
|
|
17
17
|
let configPath = null;
|
|
18
18
|
let relativeTo = null;
|
|
19
19
|
root.walkAtRules("config", (rule)=>{
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
relativeTo = (
|
|
20
|
+
var _rule_source;
|
|
21
|
+
var _rule_source_input_file, _ref;
|
|
22
|
+
relativeTo = (_ref = (_rule_source_input_file = (_rule_source = rule.source) === null || _rule_source === void 0 ? void 0 : _rule_source.input.file) !== null && _rule_source_input_file !== void 0 ? _rule_source_input_file : result.opts.from) !== null && _ref !== void 0 ? _ref : null;
|
|
23
23
|
if (relativeTo === null) {
|
|
24
24
|
throw rule.error("The `@config` directive cannot be used without setting `from` in your PostCSS config.");
|
|
25
25
|
}
|