tailwindcss 0.0.0-insiders.dddaded → 0.0.0-insiders.de00a62
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 +17 -9
- package/lib/cli/build/index.js +10 -8
- package/lib/cli/build/plugin.js +31 -29
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +13 -11
- 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 +8 -2
- package/lib/corePlugins.js +211 -48
- package/lib/css/preflight.css +24 -8
- 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 +51 -14
- package/lib/lib/defaultExtractor.js +38 -28
- package/lib/lib/detectNesting.js +3 -1
- package/lib/lib/evaluateTailwindFunctions.js +20 -16
- package/lib/lib/expandApplyAtRules.js +41 -33
- package/lib/lib/expandTailwindAtRules.js +38 -19
- package/lib/lib/findAtConfigPath.js +6 -4
- package/lib/lib/generateRules.js +83 -55
- package/lib/lib/getModuleDependencies.js +10 -8
- package/lib/lib/load-config.js +18 -5
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +58 -7
- 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 +27 -21
- package/lib/lib/setupContextUtils.js +143 -94
- package/lib/lib/setupTrackingContext.js +27 -24
- package/lib/lib/sharedState.js +28 -24
- 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 +25 -23
- 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 +9 -9
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +8 -6
- package/lib/processTailwindFeatures.js +16 -14
- 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 +7 -5
- 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 +36 -14
- package/lib/util/color.js +11 -7
- 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 +180 -31
- 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 +36 -21
- 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 +4 -2
- 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 -5
- 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 +43 -18
- package/lib/util/prefixSelector.js +6 -4
- package/lib/util/pseudoElements.js +24 -35
- 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 +5 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/nesting/index.d.ts +4 -0
- package/package.json +31 -36
- package/peers/index.js +65266 -48224
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/src/cli/build/plugin.js +7 -7
- package/src/cli/build/watching.js +1 -1
- package/src/cli.js +1 -1
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +165 -29
- package/src/css/preflight.css +24 -8
- package/src/featureFlags.js +3 -8
- package/src/index.js +1 -5
- package/src/lib/content.js +42 -1
- package/src/lib/defaultExtractor.js +30 -17
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +7 -0
- package/src/lib/expandTailwindAtRules.js +26 -9
- package/src/lib/generateRules.js +50 -26
- package/src/lib/load-config.ts +8 -0
- package/src/lib/offsets.js +61 -2
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +77 -38
- package/src/lib/setupTrackingContext.js +2 -4
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +7 -7
- package/src/plugin.js +4 -4
- package/src/processTailwindFeatures.js +3 -2
- package/src/util/cloneNodes.js +35 -14
- package/src/util/color.js +2 -2
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +143 -18
- package/src/util/formatVariantSelector.js +11 -3
- package/src/util/isPlainObject.js +1 -1
- package/src/util/pluginUtils.js +17 -5
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +18 -17
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/config.full.js +86 -14
- package/types/config.d.ts +17 -9
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +35 -9
- package/types/index.d.ts +7 -3
package/lib/lib/content.js
CHANGED
|
@@ -10,28 +10,62 @@ 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 _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
|
|
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"));
|
|
21
24
|
const _parseGlob = require("../util/parseGlob");
|
|
22
25
|
const _sharedState = require("./sharedState");
|
|
23
|
-
function
|
|
26
|
+
function _interop_require_default(obj) {
|
|
24
27
|
return obj && obj.__esModule ? obj : {
|
|
25
28
|
default: obj
|
|
26
29
|
};
|
|
27
30
|
}
|
|
31
|
+
/*!
|
|
32
|
+
* Modified version of normalize-path, original license below
|
|
33
|
+
*
|
|
34
|
+
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
|
35
|
+
*
|
|
36
|
+
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
37
|
+
* Released under the MIT License.
|
|
38
|
+
*/ function normalizePath(path) {
|
|
39
|
+
if (typeof path !== "string") {
|
|
40
|
+
throw new TypeError("expected path to be a string");
|
|
41
|
+
}
|
|
42
|
+
if (path === "\\" || path === "/") return "/";
|
|
43
|
+
var len = path.length;
|
|
44
|
+
if (len <= 1) return path;
|
|
45
|
+
// ensure that win32 namespaces has two leading slashes, so that the path is
|
|
46
|
+
// handled properly by the win32 version of path.parse() after being normalized
|
|
47
|
+
// https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
|
|
48
|
+
var prefix = "";
|
|
49
|
+
if (len > 4 && path[3] === "\\") {
|
|
50
|
+
var ch = path[2];
|
|
51
|
+
if ((ch === "?" || ch === ".") && path.slice(0, 2) === "\\\\") {
|
|
52
|
+
path = path.slice(2);
|
|
53
|
+
prefix = "//";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Modified part: instead of purely splitting on `\\` and `/`, we split on
|
|
57
|
+
// `/` and `\\` that is _not_ followed by any of the following characters: ()[]
|
|
58
|
+
// This is to ensure that we keep the escaping of brackets and parentheses
|
|
59
|
+
let segs = path.split(/[/\\]+(?![\(\)\[\]])/);
|
|
60
|
+
return prefix + segs.join("/");
|
|
61
|
+
}
|
|
28
62
|
function parseCandidateFiles(context, tailwindConfig) {
|
|
29
63
|
let files = tailwindConfig.content.files;
|
|
30
64
|
// Normalize the file globs
|
|
31
65
|
files = files.filter((filePath)=>typeof filePath === "string");
|
|
32
|
-
files = files.map(
|
|
66
|
+
files = files.map(normalizePath);
|
|
33
67
|
// Split into included and excluded globs
|
|
34
|
-
let tasks =
|
|
68
|
+
let tasks = _fastglob.default.generateTasks(files);
|
|
35
69
|
/** @type {ContentPath[]} */ let included = [];
|
|
36
70
|
/** @type {ContentPath[]} */ let excluded = [];
|
|
37
71
|
for (const task of tasks){
|
|
@@ -56,6 +90,9 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
56
90
|
* @param {boolean} ignore
|
|
57
91
|
* @returns {ContentPath}
|
|
58
92
|
*/ function parseFilePath(filePath, ignore) {
|
|
93
|
+
// Escape special characters in the file path such as: ()[]
|
|
94
|
+
// But only if the special character isn't already escaped
|
|
95
|
+
filePath = filePath.replace(/(?<!\\)([\[\]\(\)])/g, "\\$1");
|
|
59
96
|
let contentPath = {
|
|
60
97
|
original: filePath,
|
|
61
98
|
base: filePath,
|
|
@@ -63,7 +100,7 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
63
100
|
pattern: filePath,
|
|
64
101
|
glob: null
|
|
65
102
|
};
|
|
66
|
-
if ((0,
|
|
103
|
+
if ((0, _isglob.default)(filePath)) {
|
|
67
104
|
Object.assign(contentPath, (0, _parseGlob.parseGlob)(filePath));
|
|
68
105
|
}
|
|
69
106
|
return contentPath;
|
|
@@ -77,10 +114,10 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
77
114
|
// Afaik, this technically shouldn't be needed but there's probably
|
|
78
115
|
// some internal, direct path matching with a normalized path in
|
|
79
116
|
// a package which can't handle mixed directory separators
|
|
80
|
-
let base = (
|
|
117
|
+
let base = normalizePath(contentPath.base);
|
|
81
118
|
// If the user's file path contains any special characters (like parens) for instance fast-glob
|
|
82
119
|
// is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this
|
|
83
|
-
base =
|
|
120
|
+
base = _fastglob.default.escapePath(base);
|
|
84
121
|
contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base;
|
|
85
122
|
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern;
|
|
86
123
|
return contentPath;
|
|
@@ -158,7 +195,7 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
158
195
|
let mTimesToCommit = new Map();
|
|
159
196
|
let changedFiles = new Set();
|
|
160
197
|
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
161
|
-
let files =
|
|
198
|
+
let files = _fastglob.default.sync(paths, {
|
|
162
199
|
absolute: true
|
|
163
200
|
});
|
|
164
201
|
for (let file of files){
|
|
@@ -4,10 +4,11 @@ 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
|
-
const
|
|
10
|
-
const _regex = /*#__PURE__*/ _interopRequireWildcard(require("./regex"));
|
|
11
|
+
const _regex = /*#__PURE__*/ _interop_require_wildcard(require("./regex"));
|
|
11
12
|
function _getRequireWildcardCache(nodeInterop) {
|
|
12
13
|
if (typeof WeakMap !== "function") return null;
|
|
13
14
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -16,7 +17,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
16
17
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
17
18
|
})(nodeInterop);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
20
21
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
21
22
|
return obj;
|
|
22
23
|
}
|
|
@@ -55,17 +56,15 @@ function defaultExtractor(context) {
|
|
|
55
56
|
/** @type {(string|string)[]} */ let results = [];
|
|
56
57
|
for (let pattern of patterns){
|
|
57
58
|
var _content_match;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
];
|
|
59
|
+
for (let result of (_content_match = content.match(pattern)) !== null && _content_match !== void 0 ? _content_match : []){
|
|
60
|
+
results.push(clipAtBalancedParens(result));
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
|
-
return results
|
|
63
|
+
return results;
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
function* buildRegExps(context) {
|
|
67
67
|
let separator = context.tailwindConfig.separator;
|
|
68
|
-
let variantGroupingEnabled = (0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping");
|
|
69
68
|
let prefix = context.tailwindConfig.prefix !== "" ? _regex.optional(_regex.pattern([
|
|
70
69
|
/-?/,
|
|
71
70
|
_regex.escape(context.tailwindConfig.prefix)
|
|
@@ -77,16 +76,25 @@ function* buildRegExps(context) {
|
|
|
77
76
|
// This is a targeted fix to continue to allow theme()
|
|
78
77
|
// with square brackets to work in arbitrary properties
|
|
79
78
|
// while fixing a problem with the regex matching too much
|
|
80
|
-
/\[[^\s:'"
|
|
79
|
+
/\[[^\s:'"`\]]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
|
|
81
80
|
// Utilities
|
|
82
81
|
_regex.pattern([
|
|
83
82
|
// Utility Name / Group Name
|
|
84
|
-
|
|
83
|
+
_regex.any([
|
|
84
|
+
/-?(?:\w+)/,
|
|
85
|
+
// This is here to make sure @container supports everything that other utilities do
|
|
86
|
+
/@(?:\w+)/
|
|
87
|
+
]),
|
|
85
88
|
// Normal/Arbitrary values
|
|
86
89
|
_regex.optional(_regex.any([
|
|
87
90
|
_regex.pattern([
|
|
88
91
|
// Arbitrary values
|
|
89
|
-
|
|
92
|
+
_regex.any([
|
|
93
|
+
/-(?:\w+-)*\['[^\s]+'\]/,
|
|
94
|
+
/-(?:\w+-)*\["[^\s]+"\]/,
|
|
95
|
+
/-(?:\w+-)*\[`[^\s]+`\]/,
|
|
96
|
+
/-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s:\[\]]+\]/
|
|
97
|
+
]),
|
|
90
98
|
// Not immediately followed by an `{[(`
|
|
91
99
|
/(?![{([]])/,
|
|
92
100
|
// optionally followed by an opacity modifier
|
|
@@ -94,7 +102,12 @@ function* buildRegExps(context) {
|
|
|
94
102
|
]),
|
|
95
103
|
_regex.pattern([
|
|
96
104
|
// Arbitrary values
|
|
97
|
-
|
|
105
|
+
_regex.any([
|
|
106
|
+
/-(?:\w+-)*\['[^\s]+'\]/,
|
|
107
|
+
/-(?:\w+-)*\["[^\s]+"\]/,
|
|
108
|
+
/-(?:\w+-)*\[`[^\s]+`\]/,
|
|
109
|
+
/-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s\[\]]+\]/
|
|
110
|
+
]),
|
|
98
111
|
// Not immediately followed by an `{[(`
|
|
99
112
|
/(?![{([]])/,
|
|
100
113
|
// optionally followed by an opacity modifier
|
|
@@ -113,6 +126,11 @@ function* buildRegExps(context) {
|
|
|
113
126
|
/@\[[^\s"'`]+\](\/[^\s"'`]+)?/,
|
|
114
127
|
separator
|
|
115
128
|
]),
|
|
129
|
+
// With variant modifier (e.g.: group-[..]/modifier)
|
|
130
|
+
_regex.pattern([
|
|
131
|
+
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]\/\w+/,
|
|
132
|
+
separator
|
|
133
|
+
]),
|
|
116
134
|
_regex.pattern([
|
|
117
135
|
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
|
|
118
136
|
separator
|
|
@@ -124,6 +142,11 @@ function* buildRegExps(context) {
|
|
|
124
142
|
]),
|
|
125
143
|
// With quotes allowed
|
|
126
144
|
_regex.any([
|
|
145
|
+
// With variant modifier (e.g.: group-[..]/modifier)
|
|
146
|
+
_regex.pattern([
|
|
147
|
+
/([^\s"'`\[\\]+-)?\[[^\s`]+\]\/\w+/,
|
|
148
|
+
separator
|
|
149
|
+
]),
|
|
127
150
|
_regex.pattern([
|
|
128
151
|
/([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
|
|
129
152
|
separator
|
|
@@ -143,20 +166,7 @@ function* buildRegExps(context) {
|
|
|
143
166
|
// Important (optional)
|
|
144
167
|
/!?/,
|
|
145
168
|
prefix,
|
|
146
|
-
|
|
147
|
-
// Or any of those things but grouped separated by commas
|
|
148
|
-
_regex.pattern([
|
|
149
|
-
/\(/,
|
|
150
|
-
utility,
|
|
151
|
-
_regex.zeroOrMore([
|
|
152
|
-
/,/,
|
|
153
|
-
utility
|
|
154
|
-
]),
|
|
155
|
-
/\)/
|
|
156
|
-
]),
|
|
157
|
-
// Arbitrary properties, constrained utilities, arbitrary values, etc…
|
|
158
|
-
utility
|
|
159
|
-
]) : utility
|
|
169
|
+
utility
|
|
160
170
|
]);
|
|
161
171
|
}
|
|
162
172
|
// 5. Inner matches
|
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 _index = /*#__PURE__*/ _interop_require_default(require("../value-parser/index"));
|
|
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] += _index.default.stringify(vNode);
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
return args;
|
|
@@ -133,7 +135,9 @@ function resolveVNode(node, vNode, functions) {
|
|
|
133
135
|
return vNode;
|
|
134
136
|
}
|
|
135
137
|
function resolveFunctions(node, input, functions) {
|
|
136
|
-
|
|
138
|
+
let hasAnyFn = Object.keys(functions).some((fn)=>input.includes(`${fn}(`));
|
|
139
|
+
if (!hasAnyFn) return input;
|
|
140
|
+
return (0, _index.default)(input).walk((vNode)=>{
|
|
137
141
|
resolveVNode(node, vNode, functions);
|
|
138
142
|
}).toString();
|
|
139
143
|
}
|
|
@@ -4,15 +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");
|
|
15
|
-
function
|
|
17
|
+
function _interop_require_default(obj) {
|
|
16
18
|
return obj && obj.__esModule ? obj : {
|
|
17
19
|
default: obj
|
|
18
20
|
};
|
|
@@ -25,7 +27,7 @@ function _interopRequireDefault(obj) {
|
|
|
25
27
|
]
|
|
26
28
|
});
|
|
27
29
|
container.walkRules((rule)=>{
|
|
28
|
-
(0,
|
|
30
|
+
(0, _postcssselectorparser.default)((selectors)=>{
|
|
29
31
|
selectors.walkClasses((classSelector)=>{
|
|
30
32
|
let parentSelector = classSelector.parent.toString();
|
|
31
33
|
let classes = groups.get(parentSelector);
|
|
@@ -42,7 +44,7 @@ function _interopRequireDefault(obj) {
|
|
|
42
44
|
groups: normalizedGroups
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
|
-
let selectorExtractor = (0,
|
|
47
|
+
let selectorExtractor = (0, _postcssselectorparser.default)();
|
|
46
48
|
/**
|
|
47
49
|
* @param {string} ruleSelectors
|
|
48
50
|
*/ function extractSelectors(ruleSelectors) {
|
|
@@ -311,11 +313,11 @@ function processApply(root, context, localCache) {
|
|
|
311
313
|
// Sort tag names before class names (but only sort each group (separated by a combinator)
|
|
312
314
|
// separately and not in total)
|
|
313
315
|
// This happens when replacing `.bar` in `.foo.bar` with a tag like `section`
|
|
314
|
-
for (let
|
|
316
|
+
for (let sel of replaced){
|
|
315
317
|
let groups = [
|
|
316
318
|
[]
|
|
317
319
|
];
|
|
318
|
-
for (let node of
|
|
320
|
+
for (let node of sel.nodes){
|
|
319
321
|
if (node.type === "combinator") {
|
|
320
322
|
groups.push(node);
|
|
321
323
|
groups.push([]);
|
|
@@ -324,7 +326,7 @@ function processApply(root, context, localCache) {
|
|
|
324
326
|
last.push(node);
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
|
-
|
|
329
|
+
sel.nodes = [];
|
|
328
330
|
for (let group of groups){
|
|
329
331
|
if (Array.isArray(group)) {
|
|
330
332
|
group.sort((a, b)=>{
|
|
@@ -340,7 +342,7 @@ function processApply(root, context, localCache) {
|
|
|
340
342
|
return 0;
|
|
341
343
|
});
|
|
342
344
|
}
|
|
343
|
-
|
|
345
|
+
sel.nodes = sel.nodes.concat(group);
|
|
344
346
|
}
|
|
345
347
|
}
|
|
346
348
|
sel.replaceWith(...replaced);
|
|
@@ -358,15 +360,15 @@ function processApply(root, context, localCache) {
|
|
|
358
360
|
candidates,
|
|
359
361
|
apply.source
|
|
360
362
|
]);
|
|
361
|
-
let [
|
|
363
|
+
let [applyCandidates, important] = extractApplyCandidates(apply.params);
|
|
362
364
|
if (apply.parent.type === "atrule") {
|
|
363
365
|
if (apply.parent.name === "screen") {
|
|
364
366
|
let screenType = apply.parent.params;
|
|
365
|
-
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.`);
|
|
366
368
|
}
|
|
367
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}.`);
|
|
368
370
|
}
|
|
369
|
-
for (let applyCandidate of
|
|
371
|
+
for (let applyCandidate of applyCandidates){
|
|
370
372
|
if ([
|
|
371
373
|
prefix(context, "group"),
|
|
372
374
|
prefix(context, "peer")
|
|
@@ -385,16 +387,16 @@ function processApply(root, context, localCache) {
|
|
|
385
387
|
]);
|
|
386
388
|
}
|
|
387
389
|
}
|
|
388
|
-
for (let [parent, [
|
|
390
|
+
for (let [parent, [candidates, atApplySource]] of perParentApplies){
|
|
389
391
|
let siblings = [];
|
|
390
|
-
for (let [
|
|
392
|
+
for (let [applyCandidate, important, rules] of candidates){
|
|
391
393
|
let potentialApplyCandidates = [
|
|
392
|
-
|
|
394
|
+
applyCandidate,
|
|
393
395
|
...extractBaseCandidates([
|
|
394
|
-
|
|
396
|
+
applyCandidate
|
|
395
397
|
], context.tailwindConfig.separator)
|
|
396
398
|
];
|
|
397
|
-
for (let [meta, node] of
|
|
399
|
+
for (let [meta, node] of rules){
|
|
398
400
|
let parentClasses = extractClasses(parent);
|
|
399
401
|
let nodeClasses = extractClasses(node);
|
|
400
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`
|
|
@@ -425,20 +427,20 @@ function processApply(root, context, localCache) {
|
|
|
425
427
|
nodeClasses = nodeClasses.concat(extractBaseCandidates(nodeClasses, context.tailwindConfig.separator));
|
|
426
428
|
let intersects = parentClasses.some((selector)=>nodeClasses.includes(selector));
|
|
427
429
|
if (intersects) {
|
|
428
|
-
throw node.error(`You cannot \`@apply\` the \`${
|
|
430
|
+
throw node.error(`You cannot \`@apply\` the \`${applyCandidate}\` utility here because it creates a circular dependency.`);
|
|
429
431
|
}
|
|
430
|
-
let
|
|
432
|
+
let root = _postcss.default.root({
|
|
431
433
|
nodes: [
|
|
432
434
|
node.clone()
|
|
433
435
|
]
|
|
434
436
|
});
|
|
435
437
|
// Make sure every node in the entire tree points back at the @apply rule that generated it
|
|
436
|
-
|
|
438
|
+
root.walk((node)=>{
|
|
437
439
|
node.source = atApplySource;
|
|
438
440
|
});
|
|
439
441
|
let canRewriteSelector = node.type !== "atrule" || node.type === "atrule" && node.name !== "keyframes";
|
|
440
442
|
if (canRewriteSelector) {
|
|
441
|
-
|
|
443
|
+
root.walkRules((rule)=>{
|
|
442
444
|
// Let's imagine you have the following structure:
|
|
443
445
|
//
|
|
444
446
|
// .foo {
|
|
@@ -470,7 +472,7 @@ function processApply(root, context, localCache) {
|
|
|
470
472
|
// would have replaced this with something that didn't exist and
|
|
471
473
|
// therefore it removed the selector altogether. In this specific
|
|
472
474
|
// case it would result in `{}` instead of `.something-unrelated {}`
|
|
473
|
-
if (!extractClasses(rule).some((candidate)=>candidate ===
|
|
475
|
+
if (!extractClasses(rule).some((candidate)=>candidate === applyCandidate)) {
|
|
474
476
|
rule.remove();
|
|
475
477
|
return;
|
|
476
478
|
}
|
|
@@ -480,29 +482,35 @@ function processApply(root, context, localCache) {
|
|
|
480
482
|
// We do *not* want to do this for user CSS that happens to be structured the same
|
|
481
483
|
let isGenerated = parent.raws.tailwind !== undefined;
|
|
482
484
|
let parentSelector = isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0 ? parent.selector.slice(importantSelector.length) : parent.selector;
|
|
483
|
-
|
|
485
|
+
// If the selector becomes empty after replacing the important selector
|
|
486
|
+
// This means that it's the same as the parent selector and we don't want to replace it
|
|
487
|
+
// Otherwise we'll crash
|
|
488
|
+
if (parentSelector === "") {
|
|
489
|
+
parentSelector = parent.selector;
|
|
490
|
+
}
|
|
491
|
+
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate);
|
|
484
492
|
// And then re-add it if it was removed
|
|
485
493
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
486
494
|
rule.selector = (0, _applyImportantSelector.applyImportantSelector)(rule.selector, importantSelector);
|
|
487
495
|
}
|
|
488
496
|
rule.walkDecls((d)=>{
|
|
489
|
-
d.important = meta.important ||
|
|
497
|
+
d.important = meta.important || important;
|
|
490
498
|
});
|
|
491
499
|
// Move pseudo elements to the end of the selector (if necessary)
|
|
492
|
-
let selector = (0,
|
|
500
|
+
let selector = (0, _postcssselectorparser.default)().astSync(rule.selector);
|
|
493
501
|
selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
|
|
494
502
|
rule.selector = selector.toString();
|
|
495
503
|
});
|
|
496
504
|
}
|
|
497
505
|
// It could be that the node we were inserted was removed because the class didn't match
|
|
498
506
|
// If that was the *only* rule in the parent, then we have nothing add so we skip it
|
|
499
|
-
if (!
|
|
507
|
+
if (!root.nodes[0]) {
|
|
500
508
|
continue;
|
|
501
509
|
}
|
|
502
510
|
// Insert it
|
|
503
511
|
siblings.push([
|
|
504
512
|
meta.sort,
|
|
505
|
-
|
|
513
|
+
root.nodes[0]
|
|
506
514
|
]);
|
|
507
515
|
}
|
|
508
516
|
}
|
|
@@ -511,13 +519,13 @@ function processApply(root, context, localCache) {
|
|
|
511
519
|
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
|
|
512
520
|
parent.after(nodes);
|
|
513
521
|
}
|
|
514
|
-
for (let
|
|
522
|
+
for (let apply of applies){
|
|
515
523
|
// If there are left-over declarations, just remove the @apply
|
|
516
|
-
if (
|
|
517
|
-
|
|
524
|
+
if (apply.parent.nodes.length > 1) {
|
|
525
|
+
apply.remove();
|
|
518
526
|
} else {
|
|
519
527
|
// The node is empty, drop the full node
|
|
520
|
-
|
|
528
|
+
apply.parent.remove();
|
|
521
529
|
}
|
|
522
530
|
}
|
|
523
531
|
// Do it again, in case we have other `@apply` rules
|