tailwindcss 3.3.0 → 3.3.2
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/CHANGELOG.md +28 -1
- package/lib/cli/build/deps.js +17 -9
- package/lib/cli/build/index.js +10 -8
- package/lib/cli/build/plugin.js +27 -25
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +12 -10
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +4 -4
- package/lib/cli/init/index.js +8 -6
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +3 -1
- package/lib/corePlugins.js +41 -35
- package/lib/featureFlags.js +14 -9
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +3 -1
- package/lib/lib/collapseDuplicateDeclarations.js +10 -8
- package/lib/lib/content.js +18 -14
- package/lib/lib/defaultExtractor.js +6 -4
- package/lib/lib/detectNesting.js +3 -1
- package/lib/lib/evaluateTailwindFunctions.js +18 -16
- package/lib/lib/expandApplyAtRules.js +39 -32
- package/lib/lib/expandTailwindAtRules.js +15 -13
- package/lib/lib/findAtConfigPath.js +6 -4
- package/lib/lib/generateRules.js +37 -31
- package/lib/lib/getModuleDependencies.js +10 -8
- package/lib/lib/load-config.js +14 -8
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +7 -5
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +3 -1
- package/lib/lib/resolveDefaultsAtRules.js +24 -20
- package/lib/lib/setupContextUtils.js +67 -57
- package/lib/lib/setupTrackingContext.js +26 -24
- package/lib/lib/sharedState.js +32 -23
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/oxide/cli/build/deps.js +16 -8
- package/lib/oxide/cli/build/index.js +6 -4
- package/lib/oxide/cli/build/plugin.js +19 -17
- package/lib/oxide/cli/build/utils.js +18 -8
- package/lib/oxide/cli/build/watching.js +10 -8
- package/lib/oxide/cli/help/index.js +6 -4
- package/lib/oxide/cli/index.js +4 -4
- package/lib/oxide/cli/init/index.js +6 -4
- package/lib/plugin.js +7 -7
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +8 -6
- package/lib/processTailwindFeatures.js +14 -12
- package/lib/public/colors.js +5 -3
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +5 -3
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +27 -13
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +3 -1
- package/lib/util/color.js +10 -6
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +5 -3
- package/lib/util/dataTypes.js +45 -15
- package/lib/util/defaults.js +6 -4
- package/lib/util/escapeClassName.js +7 -5
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +28 -106
- package/lib/util/getAllConfigs.js +6 -4
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +8 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +7 -19
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +30 -18
- package/lib/util/prefixSelector.js +6 -4
- package/lib/util/pseudoElements.js +225 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +10 -8
- package/lib/util/resolveConfigPath.js +9 -5
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +3 -1
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +16 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/package.json +30 -34
- package/peers/index.js +65828 -48819
- 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/defaultExtractor.js +1 -1
- package/src/lib/expandApplyAtRules.js +6 -0
- package/src/lib/expandTailwindAtRules.js +3 -3
- package/src/lib/load-config.ts +9 -5
- package/src/lib/setupTrackingContext.js +1 -1
- package/src/lib/sharedState.js +13 -19
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +1 -1
- package/src/util/applyImportantSelector.js +20 -12
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/formatVariantSelector.js +2 -98
- package/src/util/normalizeConfig.js +0 -17
- package/src/util/pluginUtils.js +1 -5
- package/src/util/pseudoElements.js +170 -0
- package/src/util/validateConfig.js +13 -0
- package/types/config.d.ts +1 -6
package/lib/index.js
CHANGED
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "hasContentChanged", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return hasContentChanged;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _crypto = /*#__PURE__*/
|
|
10
|
-
const _sharedState = /*#__PURE__*/
|
|
11
|
-
function
|
|
11
|
+
const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
|
12
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
|
@@ -21,7 +23,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
21
23
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
24
|
})(nodeInterop);
|
|
23
25
|
}
|
|
24
|
-
function
|
|
26
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
27
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
28
|
return obj;
|
|
27
29
|
}
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return collapseDuplicateDeclarations;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
function collapseDuplicateDeclarations() {
|
|
10
12
|
return (root)=>{
|
|
@@ -51,21 +53,21 @@ function collapseDuplicateDeclarations() {
|
|
|
51
53
|
// with the same unit but the last one in the list.
|
|
52
54
|
for (let declarations of byProperty.values()){
|
|
53
55
|
let byUnit = new Map();
|
|
54
|
-
for (let
|
|
55
|
-
let unit = resolveUnit(
|
|
56
|
+
for (let decl of declarations){
|
|
57
|
+
let unit = resolveUnit(decl.value);
|
|
56
58
|
if (unit === null) {
|
|
57
59
|
continue;
|
|
58
60
|
}
|
|
59
61
|
if (!byUnit.has(unit)) {
|
|
60
62
|
byUnit.set(unit, new Set());
|
|
61
63
|
}
|
|
62
|
-
byUnit.get(unit).add(
|
|
64
|
+
byUnit.get(unit).add(decl);
|
|
63
65
|
}
|
|
64
|
-
for (let
|
|
66
|
+
for (let declarations of byUnit.values()){
|
|
65
67
|
// Get all but the last one
|
|
66
|
-
let removableDeclarations = Array.from(
|
|
67
|
-
for (let
|
|
68
|
-
|
|
68
|
+
let removableDeclarations = Array.from(declarations).slice(0, -1);
|
|
69
|
+
for (let decl of removableDeclarations){
|
|
70
|
+
decl.remove();
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
}
|
package/lib/lib/content.js
CHANGED
|
@@ -10,17 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
parseCandidateFiles: ()
|
|
14
|
-
|
|
13
|
+
parseCandidateFiles: function() {
|
|
14
|
+
return parseCandidateFiles;
|
|
15
|
+
},
|
|
16
|
+
resolvedChangedContent: function() {
|
|
17
|
+
return resolvedChangedContent;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
|
-
const _fs = /*#__PURE__*/
|
|
17
|
-
const _path = /*#__PURE__*/
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
20
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
21
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
22
|
+
const _isglob = /*#__PURE__*/ _interop_require_default(require("is-glob"));
|
|
23
|
+
const _fastglob = /*#__PURE__*/ _interop_require_default(require("fast-glob"));
|
|
24
|
+
const _normalizepath = /*#__PURE__*/ _interop_require_default(require("normalize-path"));
|
|
21
25
|
const _parseGlob = require("../util/parseGlob");
|
|
22
26
|
const _sharedState = require("./sharedState");
|
|
23
|
-
function
|
|
27
|
+
function _interop_require_default(obj) {
|
|
24
28
|
return obj && obj.__esModule ? obj : {
|
|
25
29
|
default: obj
|
|
26
30
|
};
|
|
@@ -29,9 +33,9 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
29
33
|
let files = tailwindConfig.content.files;
|
|
30
34
|
// Normalize the file globs
|
|
31
35
|
files = files.filter((filePath)=>typeof filePath === "string");
|
|
32
|
-
files = files.map(
|
|
36
|
+
files = files.map(_normalizepath.default);
|
|
33
37
|
// Split into included and excluded globs
|
|
34
|
-
let tasks =
|
|
38
|
+
let tasks = _fastglob.default.generateTasks(files);
|
|
35
39
|
/** @type {ContentPath[]} */ let included = [];
|
|
36
40
|
/** @type {ContentPath[]} */ let excluded = [];
|
|
37
41
|
for (const task of tasks){
|
|
@@ -63,7 +67,7 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
63
67
|
pattern: filePath,
|
|
64
68
|
glob: null
|
|
65
69
|
};
|
|
66
|
-
if ((0,
|
|
70
|
+
if ((0, _isglob.default)(filePath)) {
|
|
67
71
|
Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
|
|
68
72
|
}
|
|
69
73
|
return contentPath;
|
|
@@ -77,10 +81,10 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
77
81
|
// Afaik, this technically shouldn't be needed but there's probably
|
|
78
82
|
// some internal, direct path matching with a normalized path in
|
|
79
83
|
// a package which can't handle mixed directory separators
|
|
80
|
-
let base = (0,
|
|
84
|
+
let base = (0, _normalizepath.default)(contentPath.base);
|
|
81
85
|
// If the user's file path contains any special characters (like parens) for instance fast-glob
|
|
82
86
|
// is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this
|
|
83
|
-
base =
|
|
87
|
+
base = _fastglob.default.escapePath(base);
|
|
84
88
|
contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base;
|
|
85
89
|
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern;
|
|
86
90
|
return contentPath;
|
|
@@ -158,7 +162,7 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
158
162
|
let mTimesToCommit = new Map();
|
|
159
163
|
let changedFiles = new Set();
|
|
160
164
|
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
161
|
-
let files =
|
|
165
|
+
let files = _fastglob.default.sync(paths, {
|
|
162
166
|
absolute: true
|
|
163
167
|
});
|
|
164
168
|
for (let file of files){
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "defaultExtractor", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return defaultExtractor;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _featureFlags = require("../featureFlags");
|
|
10
|
-
const _regex = /*#__PURE__*/
|
|
12
|
+
const _regex = /*#__PURE__*/ _interop_require_wildcard(require("./regex"));
|
|
11
13
|
function _getRequireWildcardCache(nodeInterop) {
|
|
12
14
|
if (typeof WeakMap !== "function") return null;
|
|
13
15
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -16,7 +18,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
16
18
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
17
19
|
})(nodeInterop);
|
|
18
20
|
}
|
|
19
|
-
function
|
|
21
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
20
22
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
21
23
|
return obj;
|
|
22
24
|
}
|
|
@@ -77,7 +79,7 @@ function* buildRegExps(context) {
|
|
|
77
79
|
// This is a targeted fix to continue to allow theme()
|
|
78
80
|
// with square brackets to work in arbitrary properties
|
|
79
81
|
// while fixing a problem with the regex matching too much
|
|
80
|
-
/\[[^\s:'"`]+:[^\s]+?\[[^\s]
|
|
82
|
+
/\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
|
|
81
83
|
// Utilities
|
|
82
84
|
_regex.pattern([
|
|
83
85
|
// Utility Name / Group Name
|
package/lib/lib/detectNesting.js
CHANGED
|
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _dlv = /*#__PURE__*/
|
|
10
|
-
const _didyoumean = /*#__PURE__*/
|
|
11
|
-
const _transformThemeValue = /*#__PURE__*/
|
|
12
|
-
const
|
|
11
|
+
const _dlv = /*#__PURE__*/ _interop_require_default(require("dlv"));
|
|
12
|
+
const _didyoumean = /*#__PURE__*/ _interop_require_default(require("didyoumean"));
|
|
13
|
+
const _transformThemeValue = /*#__PURE__*/ _interop_require_default(require("../util/transformThemeValue"));
|
|
14
|
+
const _postcssvalueparser = /*#__PURE__*/ _interop_require_default(require("postcss-value-parser"));
|
|
13
15
|
const _normalizeScreens = require("../util/normalizeScreens");
|
|
14
|
-
const _buildMediaQuery = /*#__PURE__*/
|
|
16
|
+
const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
|
|
15
17
|
const _toPath = require("../util/toPath");
|
|
16
18
|
const _withAlphaVariable = require("../util/withAlphaVariable");
|
|
17
19
|
const _pluginUtils = require("../util/pluginUtils");
|
|
18
|
-
const _log = /*#__PURE__*/
|
|
19
|
-
function
|
|
20
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
21
|
+
function _interop_require_default(obj) {
|
|
20
22
|
return obj && obj.__esModule ? obj : {
|
|
21
23
|
default: obj
|
|
22
24
|
};
|
|
@@ -86,22 +88,22 @@ function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
89
|
-
let
|
|
91
|
+
let error = `'${pathString}' was found but does not resolve to a string.`;
|
|
90
92
|
if (isObject(value)) {
|
|
91
|
-
let
|
|
93
|
+
let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
|
|
92
94
|
...pathSegments,
|
|
93
95
|
key
|
|
94
96
|
]).isValid);
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
+
if (validKeys.length) {
|
|
98
|
+
error += ` Did you mean something like '${pathToString([
|
|
97
99
|
...pathSegments,
|
|
98
|
-
|
|
100
|
+
validKeys[0]
|
|
99
101
|
])}'?`;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
return {
|
|
103
105
|
isValid: false,
|
|
104
|
-
error
|
|
106
|
+
error
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
const [themeSection] = pathSegments;
|
|
@@ -119,7 +121,7 @@ function extractArgs(node, vNodes, functions) {
|
|
|
119
121
|
if (vNode.type === "div" && vNode.value === ",") {
|
|
120
122
|
args.push("");
|
|
121
123
|
} else {
|
|
122
|
-
args[args.length - 1] +=
|
|
124
|
+
args[args.length - 1] += _postcssvalueparser.default.stringify(vNode);
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
return args;
|
|
@@ -133,7 +135,7 @@ function resolveVNode(node, vNode, functions) {
|
|
|
133
135
|
return vNode;
|
|
134
136
|
}
|
|
135
137
|
function resolveFunctions(node, input, functions) {
|
|
136
|
-
return (0,
|
|
138
|
+
return (0, _postcssvalueparser.default)(input).walk((vNode)=>{
|
|
137
139
|
resolveVNode(node, vNode, functions);
|
|
138
140
|
}).toString();
|
|
139
141
|
}
|
|
@@ -4,14 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandApplyAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _postcss = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
12
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
11
13
|
const _generateRules = require("./generateRules");
|
|
12
|
-
const _escapeClassName = /*#__PURE__*/
|
|
14
|
+
const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
|
|
13
15
|
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
14
|
-
|
|
16
|
+
const _pseudoElements = require("../util/pseudoElements");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
15
18
|
return obj && obj.__esModule ? obj : {
|
|
16
19
|
default: obj
|
|
17
20
|
};
|
|
@@ -24,7 +27,7 @@ function _interopRequireDefault(obj) {
|
|
|
24
27
|
]
|
|
25
28
|
});
|
|
26
29
|
container.walkRules((rule)=>{
|
|
27
|
-
(0,
|
|
30
|
+
(0, _postcssselectorparser.default)((selectors)=>{
|
|
28
31
|
selectors.walkClasses((classSelector)=>{
|
|
29
32
|
let parentSelector = classSelector.parent.toString();
|
|
30
33
|
let classes = groups.get(parentSelector);
|
|
@@ -41,7 +44,7 @@ function _interopRequireDefault(obj) {
|
|
|
41
44
|
groups: normalizedGroups
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
|
-
let selectorExtractor = (0,
|
|
47
|
+
let selectorExtractor = (0, _postcssselectorparser.default)();
|
|
45
48
|
/**
|
|
46
49
|
* @param {string} ruleSelectors
|
|
47
50
|
*/ function extractSelectors(ruleSelectors) {
|
|
@@ -310,11 +313,11 @@ function processApply(root, context, localCache) {
|
|
|
310
313
|
// Sort tag names before class names (but only sort each group (separated by a combinator)
|
|
311
314
|
// separately and not in total)
|
|
312
315
|
// This happens when replacing `.bar` in `.foo.bar` with a tag like `section`
|
|
313
|
-
for (let
|
|
316
|
+
for (let sel of replaced){
|
|
314
317
|
let groups = [
|
|
315
318
|
[]
|
|
316
319
|
];
|
|
317
|
-
for (let node of
|
|
320
|
+
for (let node of sel.nodes){
|
|
318
321
|
if (node.type === "combinator") {
|
|
319
322
|
groups.push(node);
|
|
320
323
|
groups.push([]);
|
|
@@ -323,7 +326,7 @@ function processApply(root, context, localCache) {
|
|
|
323
326
|
last.push(node);
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
|
-
|
|
329
|
+
sel.nodes = [];
|
|
327
330
|
for (let group of groups){
|
|
328
331
|
if (Array.isArray(group)) {
|
|
329
332
|
group.sort((a, b)=>{
|
|
@@ -339,7 +342,7 @@ function processApply(root, context, localCache) {
|
|
|
339
342
|
return 0;
|
|
340
343
|
});
|
|
341
344
|
}
|
|
342
|
-
|
|
345
|
+
sel.nodes = sel.nodes.concat(group);
|
|
343
346
|
}
|
|
344
347
|
}
|
|
345
348
|
sel.replaceWith(...replaced);
|
|
@@ -357,15 +360,15 @@ function processApply(root, context, localCache) {
|
|
|
357
360
|
candidates,
|
|
358
361
|
apply.source
|
|
359
362
|
]);
|
|
360
|
-
let [
|
|
363
|
+
let [applyCandidates, important] = extractApplyCandidates(apply.params);
|
|
361
364
|
if (apply.parent.type === "atrule") {
|
|
362
365
|
if (apply.parent.name === "screen") {
|
|
363
366
|
let screenType = apply.parent.params;
|
|
364
|
-
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${
|
|
367
|
+
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map((c)=>`${screenType}:${c}`).join(" ")} instead.`);
|
|
365
368
|
}
|
|
366
369
|
throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
|
|
367
370
|
}
|
|
368
|
-
for (let applyCandidate of
|
|
371
|
+
for (let applyCandidate of applyCandidates){
|
|
369
372
|
if ([
|
|
370
373
|
prefix(context, "group"),
|
|
371
374
|
prefix(context, "peer")
|
|
@@ -384,16 +387,16 @@ function processApply(root, context, localCache) {
|
|
|
384
387
|
]);
|
|
385
388
|
}
|
|
386
389
|
}
|
|
387
|
-
for (let [parent, [
|
|
390
|
+
for (let [parent, [candidates, atApplySource]] of perParentApplies){
|
|
388
391
|
let siblings = [];
|
|
389
|
-
for (let [
|
|
392
|
+
for (let [applyCandidate, important, rules] of candidates){
|
|
390
393
|
let potentialApplyCandidates = [
|
|
391
|
-
|
|
394
|
+
applyCandidate,
|
|
392
395
|
...extractBaseCandidates([
|
|
393
|
-
|
|
396
|
+
applyCandidate
|
|
394
397
|
], context.tailwindConfig.separator)
|
|
395
398
|
];
|
|
396
|
-
for (let [meta, node] of
|
|
399
|
+
for (let [meta, node] of rules){
|
|
397
400
|
let parentClasses = extractClasses(parent);
|
|
398
401
|
let nodeClasses = extractClasses(node);
|
|
399
402
|
// When we encounter a rule like `.dark .a, .b { … }` we only want to be left with `[.dark, .a]` if the base applyCandidate is `.a` or with `[.b]` if the base applyCandidate is `.b`
|
|
@@ -424,20 +427,20 @@ function processApply(root, context, localCache) {
|
|
|
424
427
|
nodeClasses = nodeClasses.concat(extractBaseCandidates(nodeClasses, context.tailwindConfig.separator));
|
|
425
428
|
let intersects = parentClasses.some((selector)=>nodeClasses.includes(selector));
|
|
426
429
|
if (intersects) {
|
|
427
|
-
throw node.error(`You cannot \`@apply\` the \`${
|
|
430
|
+
throw node.error(`You cannot \`@apply\` the \`${applyCandidate}\` utility here because it creates a circular dependency.`);
|
|
428
431
|
}
|
|
429
|
-
let
|
|
432
|
+
let root = _postcss.default.root({
|
|
430
433
|
nodes: [
|
|
431
434
|
node.clone()
|
|
432
435
|
]
|
|
433
436
|
});
|
|
434
437
|
// Make sure every node in the entire tree points back at the @apply rule that generated it
|
|
435
|
-
|
|
438
|
+
root.walk((node)=>{
|
|
436
439
|
node.source = atApplySource;
|
|
437
440
|
});
|
|
438
441
|
let canRewriteSelector = node.type !== "atrule" || node.type === "atrule" && node.name !== "keyframes";
|
|
439
442
|
if (canRewriteSelector) {
|
|
440
|
-
|
|
443
|
+
root.walkRules((rule)=>{
|
|
441
444
|
// Let's imagine you have the following structure:
|
|
442
445
|
//
|
|
443
446
|
// .foo {
|
|
@@ -469,7 +472,7 @@ function processApply(root, context, localCache) {
|
|
|
469
472
|
// would have replaced this with something that didn't exist and
|
|
470
473
|
// therefore it removed the selector altogether. In this specific
|
|
471
474
|
// case it would result in `{}` instead of `.something-unrelated {}`
|
|
472
|
-
if (!extractClasses(rule).some((candidate)=>candidate ===
|
|
475
|
+
if (!extractClasses(rule).some((candidate)=>candidate === applyCandidate)) {
|
|
473
476
|
rule.remove();
|
|
474
477
|
return;
|
|
475
478
|
}
|
|
@@ -479,25 +482,29 @@ function processApply(root, context, localCache) {
|
|
|
479
482
|
// We do *not* want to do this for user CSS that happens to be structured the same
|
|
480
483
|
let isGenerated = parent.raws.tailwind !== undefined;
|
|
481
484
|
let parentSelector = isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0 ? parent.selector.slice(importantSelector.length) : parent.selector;
|
|
482
|
-
rule.selector = replaceSelector(parentSelector, rule.selector,
|
|
485
|
+
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate);
|
|
483
486
|
// And then re-add it if it was removed
|
|
484
487
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
485
488
|
rule.selector = (0, _applyImportantSelector.applyImportantSelector)(rule.selector, importantSelector);
|
|
486
489
|
}
|
|
487
490
|
rule.walkDecls((d)=>{
|
|
488
|
-
d.important = meta.important ||
|
|
491
|
+
d.important = meta.important || important;
|
|
489
492
|
});
|
|
493
|
+
// Move pseudo elements to the end of the selector (if necessary)
|
|
494
|
+
let selector = (0, _postcssselectorparser.default)().astSync(rule.selector);
|
|
495
|
+
selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
|
|
496
|
+
rule.selector = selector.toString();
|
|
490
497
|
});
|
|
491
498
|
}
|
|
492
499
|
// It could be that the node we were inserted was removed because the class didn't match
|
|
493
500
|
// If that was the *only* rule in the parent, then we have nothing add so we skip it
|
|
494
|
-
if (!
|
|
501
|
+
if (!root.nodes[0]) {
|
|
495
502
|
continue;
|
|
496
503
|
}
|
|
497
504
|
// Insert it
|
|
498
505
|
siblings.push([
|
|
499
506
|
meta.sort,
|
|
500
|
-
|
|
507
|
+
root.nodes[0]
|
|
501
508
|
]);
|
|
502
509
|
}
|
|
503
510
|
}
|
|
@@ -506,13 +513,13 @@ function processApply(root, context, localCache) {
|
|
|
506
513
|
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
|
|
507
514
|
parent.after(nodes);
|
|
508
515
|
}
|
|
509
|
-
for (let
|
|
516
|
+
for (let apply of applies){
|
|
510
517
|
// If there are left-over declarations, just remove the @apply
|
|
511
|
-
if (
|
|
512
|
-
|
|
518
|
+
if (apply.parent.nodes.length > 1) {
|
|
519
|
+
apply.remove();
|
|
513
520
|
} else {
|
|
514
521
|
// The node is empty, drop the full node
|
|
515
|
-
|
|
522
|
+
apply.parent.remove();
|
|
516
523
|
}
|
|
517
524
|
}
|
|
518
525
|
// Do it again, in case we have other `@apply` rules
|
|
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandTailwindAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const _sharedState = /*#__PURE__*/
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
|
|
13
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
12
14
|
const _generateRules = require("./generateRules");
|
|
13
|
-
const _log = /*#__PURE__*/
|
|
14
|
-
const _cloneNodes = /*#__PURE__*/
|
|
15
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
16
|
+
const _cloneNodes = /*#__PURE__*/ _interop_require_default(require("../util/cloneNodes"));
|
|
15
17
|
const _defaultExtractor = require("./defaultExtractor");
|
|
16
|
-
function
|
|
18
|
+
function _interop_require_default(obj) {
|
|
17
19
|
return obj && obj.__esModule ? obj : {
|
|
18
20
|
default: obj
|
|
19
21
|
};
|
|
@@ -26,7 +28,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
26
28
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
29
|
})(nodeInterop);
|
|
28
30
|
}
|
|
29
|
-
function
|
|
31
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
30
32
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
33
|
return obj;
|
|
32
34
|
}
|
|
@@ -79,7 +81,7 @@ let extractorCache = new WeakMap();
|
|
|
79
81
|
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
80
82
|
function getClassCandidates(content, extractor, candidates, seen) {
|
|
81
83
|
if (!extractorCache.has(extractor)) {
|
|
82
|
-
extractorCache.set(extractor, new
|
|
84
|
+
extractorCache.set(extractor, new _quicklru.default({
|
|
83
85
|
maxSize: 25000
|
|
84
86
|
}));
|
|
85
87
|
}
|
|
@@ -96,8 +98,8 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
96
98
|
} else {
|
|
97
99
|
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
98
100
|
let lineMatchesSet = new Set(extractorMatches);
|
|
99
|
-
for (let
|
|
100
|
-
candidates.add(
|
|
101
|
+
for (let match of lineMatchesSet){
|
|
102
|
+
candidates.add(match);
|
|
101
103
|
}
|
|
102
104
|
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
103
105
|
}
|
|
@@ -152,7 +154,7 @@ function expandTailwindAtRules(context) {
|
|
|
152
154
|
]);
|
|
153
155
|
let seen = new Set();
|
|
154
156
|
env.DEBUG && console.time("Reading changed files");
|
|
155
|
-
if (
|
|
157
|
+
if (false) {
|
|
156
158
|
// TODO: Pass through or implement `extractor`
|
|
157
159
|
for (let candidate of require("@tailwindcss/oxide").parseCandidateStringsFromFiles(context.changedContent)){
|
|
158
160
|
candidates.add(candidate);
|
|
@@ -176,7 +178,7 @@ function expandTailwindAtRules(context) {
|
|
|
176
178
|
let classCacheCount = context.classCache.size;
|
|
177
179
|
env.DEBUG && console.time("Generate rules");
|
|
178
180
|
env.DEBUG && console.time("Sorting candidates");
|
|
179
|
-
let sortedCandidates =
|
|
181
|
+
let sortedCandidates = false ? candidates : new Set([
|
|
180
182
|
...candidates
|
|
181
183
|
].sort((a, z)=>{
|
|
182
184
|
if (a === z) return 0;
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "findAtConfigPath", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return findAtConfigPath;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
-
function
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|