tailwindcss 3.3.2 → 3.3.4
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 +50 -1
- package/lib/cli/build/plugin.js +2 -2
- package/lib/cli/build/watching.js +1 -1
- package/lib/corePlugins.js +11 -7
- package/lib/css/preflight.css +9 -0
- package/lib/lib/defaultExtractor.js +16 -22
- package/lib/lib/evaluateTailwindFunctions.js +5 -3
- package/lib/lib/expandApplyAtRules.js +6 -0
- package/lib/lib/expandTailwindAtRules.js +20 -6
- package/lib/lib/generateRules.js +34 -24
- package/lib/lib/setupContextUtils.js +53 -33
- package/lib/lib/setupTrackingContext.js +2 -1
- package/lib/oxide/cli/build/plugin.js +2 -2
- package/lib/plugin.js +3 -3
- package/lib/processTailwindFeatures.js +2 -2
- package/lib/util/color.js +1 -1
- package/lib/util/dataTypes.js +100 -16
- package/lib/util/formatVariantSelector.js +10 -3
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/pseudoElements.js +18 -34
- 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 +5 -6
- package/peers/index.js +701 -617
- package/src/cli/build/plugin.js +2 -2
- package/src/cli/build/watching.js +1 -1
- package/src/corePlugins.js +13 -7
- package/src/css/preflight.css +9 -0
- package/src/featureFlags.js +0 -1
- package/src/lib/defaultExtractor.js +12 -13
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +7 -0
- package/src/lib/expandTailwindAtRules.js +20 -6
- package/src/lib/generateRules.js +34 -25
- package/src/lib/setupContextUtils.js +50 -35
- package/src/lib/setupTrackingContext.js +1 -3
- package/src/oxide/cli/build/plugin.ts +2 -2
- package/src/plugin.js +3 -3
- package/src/processTailwindFeatures.js +3 -2
- package/src/util/color.js +1 -1
- package/src/util/dataTypes.js +101 -18
- package/src/util/formatVariantSelector.js +11 -3
- package/src/util/isPlainObject.js +1 -1
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +14 -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 +1 -0
- package/types/config.d.ts +6 -6
- package/types/generated/default-theme.d.ts +1 -0
- package/types/index.d.ts +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
- Nothing yet!
|
|
11
11
|
|
|
12
|
+
## [3.3.4] - 2023-10-24
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Improve normalisation of `calc()`-like functions ([#11686](https://github.com/tailwindlabs/tailwindcss/pull/11686))
|
|
17
|
+
- Skip `calc()` normalisation in nested `theme()` calls ([#11705](https://github.com/tailwindlabs/tailwindcss/pull/11705))
|
|
18
|
+
- Fix incorrectly generated CSS when using square brackets inside arbitrary properties ([#11709](https://github.com/tailwindlabs/tailwindcss/pull/11709))
|
|
19
|
+
- Make `content` optional for presets in TypeScript types ([#11730](https://github.com/tailwindlabs/tailwindcss/pull/11730))
|
|
20
|
+
- Handle variable colors that have variable fallback values ([#12049](https://github.com/tailwindlabs/tailwindcss/pull/12049))
|
|
21
|
+
- Batch reading content files to prevent `too many open files` error ([#12079](https://github.com/tailwindlabs/tailwindcss/pull/12079))
|
|
22
|
+
- Skip over classes inside `:not(…)` when nested in an at-rule ([#12105](https://github.com/tailwindlabs/tailwindcss/pull/12105))
|
|
23
|
+
- Update types to work with `Node16` module resolution ([#12097](https://github.com/tailwindlabs/tailwindcss/pull/12097))
|
|
24
|
+
- Don’t crash when important and parent selectors are equal in `@apply` ([#12112](https://github.com/tailwindlabs/tailwindcss/pull/12112))
|
|
25
|
+
- Eliminate irrelevant rules when applying variants ([#12113](https://github.com/tailwindlabs/tailwindcss/pull/12113))
|
|
26
|
+
- Improve RegEx parser, reduce possibilities as the key for arbitrary properties ([#12121](https://github.com/tailwindlabs/tailwindcss/pull/12121))
|
|
27
|
+
- Fix sorting of utilities that share multiple candidates ([#12173](https://github.com/tailwindlabs/tailwindcss/pull/12173))
|
|
28
|
+
- Ensure variants with arbitrary values and a modifier are correctly matched in the RegEx based parser ([#12179](https://github.com/tailwindlabs/tailwindcss/pull/12179))
|
|
29
|
+
- Fix crash when watching renamed files on FreeBSD ([#12193](https://github.com/tailwindlabs/tailwindcss/pull/12193))
|
|
30
|
+
- Allow plugins from a parent document to be used in an iframe ([#12208](https://github.com/tailwindlabs/tailwindcss/pull/12208))
|
|
31
|
+
- Add types for `tailwindcss/nesting` ([#12269](https://github.com/tailwindlabs/tailwindcss/pull/12269))
|
|
32
|
+
- Bump `jiti`, `fast-glob`, and `browserlist` dependencies ([#11550](https://github.com/tailwindlabs/tailwindcss/pull/11550))
|
|
33
|
+
- Improve automatic `var` injection for properties that accept a `<dashed-ident>` ([#12236](https://github.com/tailwindlabs/tailwindcss/pull/12236))
|
|
34
|
+
|
|
35
|
+
## [3.3.3] - 2023-07-13
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- Fix issue where some pseudo-element variants generated the wrong selector ([#10943](https://github.com/tailwindlabs/tailwindcss/pull/10943), [#10962](https://github.com/tailwindlabs/tailwindcss/pull/10962), [#11111](https://github.com/tailwindlabs/tailwindcss/pull/11111))
|
|
40
|
+
- Make font settings propagate into buttons, inputs, etc. ([#10940](https://github.com/tailwindlabs/tailwindcss/pull/10940))
|
|
41
|
+
- Fix parsing of `theme()` inside `calc()` when there are no spaces around operators ([#11157](https://github.com/tailwindlabs/tailwindcss/pull/11157))
|
|
42
|
+
- Ensure `repeating-conic-gradient` is detected as an image ([#11180](https://github.com/tailwindlabs/tailwindcss/pull/11180))
|
|
43
|
+
- Move unknown pseudo-elements outside of `:is` by default ([#11345](https://github.com/tailwindlabs/tailwindcss/pull/11345))
|
|
44
|
+
- Escape animation names when prefixes contain special characters ([#11470](https://github.com/tailwindlabs/tailwindcss/pull/11470))
|
|
45
|
+
- Don't prefix arbitrary classes in `group` and `peer` variants ([#11454](https://github.com/tailwindlabs/tailwindcss/pull/11454))
|
|
46
|
+
- Sort classes using position of first matching rule ([#11504](https://github.com/tailwindlabs/tailwindcss/pull/11504))
|
|
47
|
+
- Allow variant to be an at-rule without a prelude ([#11589](https://github.com/tailwindlabs/tailwindcss/pull/11589))
|
|
48
|
+
- Make PostCSS plugin async to improve performance ([#11548](https://github.com/tailwindlabs/tailwindcss/pull/11548))
|
|
49
|
+
- Don’t error when a config file is missing ([f97759f](https://github.com/tailwindlabs/tailwindcss/commit/f97759f808d15ace66647b1405744fcf95a392e5))
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- Add `aria-busy` utility ([#10966](https://github.com/tailwindlabs/tailwindcss/pull/10966))
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Reset padding for `<dialog>` elements in preflight ([#11069](https://github.com/tailwindlabs/tailwindcss/pull/11069))
|
|
58
|
+
|
|
12
59
|
## [3.3.2] - 2023-04-25
|
|
13
60
|
|
|
14
61
|
### Fixed
|
|
@@ -2236,7 +2283,9 @@ No release notes
|
|
|
2236
2283
|
|
|
2237
2284
|
- Everything!
|
|
2238
2285
|
|
|
2239
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.3.
|
|
2286
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.3.4...HEAD
|
|
2287
|
+
[3.3.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.3.3...v3.3.4
|
|
2288
|
+
[3.3.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.3.2...v3.3.3
|
|
2240
2289
|
[3.3.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.3.1...v3.3.2
|
|
2241
2290
|
[3.3.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.3.0...v3.3.1
|
|
2242
2291
|
[3.3.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.7...v3.3.0
|
package/lib/cli/build/plugin.js
CHANGED
|
@@ -245,9 +245,9 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
245
245
|
let tailwindPlugin = ()=>{
|
|
246
246
|
return {
|
|
247
247
|
postcssPlugin: "tailwindcss",
|
|
248
|
-
Once (root, { result }) {
|
|
248
|
+
async Once (root, { result }) {
|
|
249
249
|
_sharedState.env.DEBUG && console.time("Compiling CSS");
|
|
250
|
-
(0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
250
|
+
await (0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
251
251
|
console.error();
|
|
252
252
|
console.error("Rebuilding...");
|
|
253
253
|
return ()=>{
|
|
@@ -126,7 +126,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
126
126
|
// This is very likely a chokidar bug but it's one we need to work around
|
|
127
127
|
// We treat this as a change event and rebuild the CSS
|
|
128
128
|
watcher.on("raw", (evt, filePath, meta)=>{
|
|
129
|
-
if (evt !== "rename") {
|
|
129
|
+
if (evt !== "rename" || filePath === null) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
let watchedPath = meta.watchedPath;
|
package/lib/corePlugins.js
CHANGED
|
@@ -35,6 +35,7 @@ const _parseBoxShadowValue = require("./util/parseBoxShadowValue");
|
|
|
35
35
|
const _removeAlphaVariables = require("./util/removeAlphaVariables");
|
|
36
36
|
const _featureFlags = require("./featureFlags");
|
|
37
37
|
const _dataTypes = require("./util/dataTypes");
|
|
38
|
+
const _setupContextUtils = require("./lib/setupContextUtils");
|
|
38
39
|
function _interop_require_default(obj) {
|
|
39
40
|
return obj && obj.__esModule ? obj : {
|
|
40
41
|
default: obj
|
|
@@ -135,7 +136,7 @@ let variantPlugins = {
|
|
|
135
136
|
return "&::after";
|
|
136
137
|
});
|
|
137
138
|
},
|
|
138
|
-
pseudoClassVariants: ({ addVariant , matchVariant , config })=>{
|
|
139
|
+
pseudoClassVariants: ({ addVariant , matchVariant , config , prefix })=>{
|
|
139
140
|
let pseudoVariants = [
|
|
140
141
|
// Positional
|
|
141
142
|
[
|
|
@@ -216,17 +217,17 @@ let variantPlugins = {
|
|
|
216
217
|
}
|
|
217
218
|
let variants = {
|
|
218
219
|
group: (_, { modifier })=>modifier ? [
|
|
219
|
-
`:merge(.group\\/${(0, _escapeClassName.default)(modifier)})`,
|
|
220
|
+
`:merge(${prefix(".group")}\\/${(0, _escapeClassName.default)(modifier)})`,
|
|
220
221
|
" &"
|
|
221
222
|
] : [
|
|
222
|
-
`:merge(.group)`,
|
|
223
|
+
`:merge(${prefix(".group")})`,
|
|
223
224
|
" &"
|
|
224
225
|
],
|
|
225
226
|
peer: (_, { modifier })=>modifier ? [
|
|
226
|
-
`:merge(.peer\\/${(0, _escapeClassName.default)(modifier)})`,
|
|
227
|
+
`:merge(${prefix(".peer")}\\/${(0, _escapeClassName.default)(modifier)})`,
|
|
227
228
|
" ~ &"
|
|
228
229
|
] : [
|
|
229
|
-
`:merge(.peer)`,
|
|
230
|
+
`:merge(${prefix(".peer")})`,
|
|
230
231
|
" ~ &"
|
|
231
232
|
]
|
|
232
233
|
};
|
|
@@ -255,7 +256,10 @@ let variantPlugins = {
|
|
|
255
256
|
// result.replace(/&(\S+)?/g, (_, pseudo = '') => a + pseudo + b)
|
|
256
257
|
return result.slice(0, start) + a + result.slice(start + 1, end) + b + result.slice(end);
|
|
257
258
|
}, {
|
|
258
|
-
values: Object.fromEntries(pseudoVariants)
|
|
259
|
+
values: Object.fromEntries(pseudoVariants),
|
|
260
|
+
[_setupContextUtils.INTERNAL_FEATURES]: {
|
|
261
|
+
respectPrefix: false
|
|
262
|
+
}
|
|
259
263
|
});
|
|
260
264
|
}
|
|
261
265
|
},
|
|
@@ -1283,7 +1287,7 @@ let corePlugins = {
|
|
|
1283
1287
|
});
|
|
1284
1288
|
},
|
|
1285
1289
|
animation: ({ matchUtilities , theme , config })=>{
|
|
1286
|
-
let prefixName = (name)
|
|
1290
|
+
let prefixName = (name)=>(0, _escapeClassName.default)(config("prefix") + name);
|
|
1287
1291
|
var _theme;
|
|
1288
1292
|
let keyframes = Object.fromEntries(Object.entries((_theme = theme("keyframes")) !== null && _theme !== void 0 ? _theme : {}).map(([key, value])=>{
|
|
1289
1293
|
return [
|
package/lib/css/preflight.css
CHANGED
|
@@ -163,6 +163,8 @@ optgroup,
|
|
|
163
163
|
select,
|
|
164
164
|
textarea {
|
|
165
165
|
font-family: inherit; /* 1 */
|
|
166
|
+
font-feature-settings: inherit; /* 1 */
|
|
167
|
+
font-variation-settings: inherit; /* 1 */
|
|
166
168
|
font-size: 100%; /* 1 */
|
|
167
169
|
font-weight: inherit; /* 1 */
|
|
168
170
|
line-height: inherit; /* 1 */
|
|
@@ -300,6 +302,13 @@ menu {
|
|
|
300
302
|
padding: 0;
|
|
301
303
|
}
|
|
302
304
|
|
|
305
|
+
/*
|
|
306
|
+
Reset default styling for dialogs.
|
|
307
|
+
*/
|
|
308
|
+
dialog {
|
|
309
|
+
padding: 0;
|
|
310
|
+
}
|
|
311
|
+
|
|
303
312
|
/*
|
|
304
313
|
Prevent resizing textareas horizontally by default.
|
|
305
314
|
*/
|
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "defaultExtractor", {
|
|
|
8
8
|
return defaultExtractor;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _featureFlags = require("../featureFlags");
|
|
12
11
|
const _regex = /*#__PURE__*/ _interop_require_wildcard(require("./regex"));
|
|
13
12
|
function _getRequireWildcardCache(nodeInterop) {
|
|
14
13
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -57,17 +56,15 @@ function defaultExtractor(context) {
|
|
|
57
56
|
/** @type {(string|string)[]} */ let results = [];
|
|
58
57
|
for (let pattern of patterns){
|
|
59
58
|
var _content_match;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
];
|
|
59
|
+
for (let result of (_content_match = content.match(pattern)) !== null && _content_match !== void 0 ? _content_match : []){
|
|
60
|
+
results.push(clipAtBalancedParens(result));
|
|
61
|
+
}
|
|
64
62
|
}
|
|
65
|
-
return results
|
|
63
|
+
return results;
|
|
66
64
|
};
|
|
67
65
|
}
|
|
68
66
|
function* buildRegExps(context) {
|
|
69
67
|
let separator = context.tailwindConfig.separator;
|
|
70
|
-
let variantGroupingEnabled = (0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping");
|
|
71
68
|
let prefix = context.tailwindConfig.prefix !== "" ? _regex.optional(_regex.pattern([
|
|
72
69
|
/-?/,
|
|
73
70
|
_regex.escape(context.tailwindConfig.prefix)
|
|
@@ -79,7 +76,7 @@ function* buildRegExps(context) {
|
|
|
79
76
|
// This is a targeted fix to continue to allow theme()
|
|
80
77
|
// with square brackets to work in arbitrary properties
|
|
81
78
|
// while fixing a problem with the regex matching too much
|
|
82
|
-
/\[[^\s:'"
|
|
79
|
+
/\[[^\s:'"`\]]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
|
|
83
80
|
// Utilities
|
|
84
81
|
_regex.pattern([
|
|
85
82
|
// Utility Name / Group Name
|
|
@@ -115,6 +112,11 @@ function* buildRegExps(context) {
|
|
|
115
112
|
/@\[[^\s"'`]+\](\/[^\s"'`]+)?/,
|
|
116
113
|
separator
|
|
117
114
|
]),
|
|
115
|
+
// With variant modifier (e.g.: group-[..]/modifier)
|
|
116
|
+
_regex.pattern([
|
|
117
|
+
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]\/\w+/,
|
|
118
|
+
separator
|
|
119
|
+
]),
|
|
118
120
|
_regex.pattern([
|
|
119
121
|
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
|
|
120
122
|
separator
|
|
@@ -126,6 +128,11 @@ function* buildRegExps(context) {
|
|
|
126
128
|
]),
|
|
127
129
|
// With quotes allowed
|
|
128
130
|
_regex.any([
|
|
131
|
+
// With variant modifier (e.g.: group-[..]/modifier)
|
|
132
|
+
_regex.pattern([
|
|
133
|
+
/([^\s"'`\[\\]+-)?\[[^\s`]+\]\/\w+/,
|
|
134
|
+
separator
|
|
135
|
+
]),
|
|
129
136
|
_regex.pattern([
|
|
130
137
|
/([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
|
|
131
138
|
separator
|
|
@@ -145,20 +152,7 @@ function* buildRegExps(context) {
|
|
|
145
152
|
// Important (optional)
|
|
146
153
|
/!?/,
|
|
147
154
|
prefix,
|
|
148
|
-
|
|
149
|
-
// Or any of those things but grouped separated by commas
|
|
150
|
-
_regex.pattern([
|
|
151
|
-
/\(/,
|
|
152
|
-
utility,
|
|
153
|
-
_regex.zeroOrMore([
|
|
154
|
-
/,/,
|
|
155
|
-
utility
|
|
156
|
-
]),
|
|
157
|
-
/\)/
|
|
158
|
-
]),
|
|
159
|
-
// Arbitrary properties, constrained utilities, arbitrary values, etc…
|
|
160
|
-
utility
|
|
161
|
-
]) : utility
|
|
155
|
+
utility
|
|
162
156
|
]);
|
|
163
157
|
}
|
|
164
158
|
// 5. Inner matches
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
const _dlv = /*#__PURE__*/ _interop_require_default(require("dlv"));
|
|
12
12
|
const _didyoumean = /*#__PURE__*/ _interop_require_default(require("didyoumean"));
|
|
13
13
|
const _transformThemeValue = /*#__PURE__*/ _interop_require_default(require("../util/transformThemeValue"));
|
|
14
|
-
const
|
|
14
|
+
const _index = /*#__PURE__*/ _interop_require_default(require("../value-parser/index"));
|
|
15
15
|
const _normalizeScreens = require("../util/normalizeScreens");
|
|
16
16
|
const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
|
|
17
17
|
const _toPath = require("../util/toPath");
|
|
@@ -121,7 +121,7 @@ function extractArgs(node, vNodes, functions) {
|
|
|
121
121
|
if (vNode.type === "div" && vNode.value === ",") {
|
|
122
122
|
args.push("");
|
|
123
123
|
} else {
|
|
124
|
-
args[args.length - 1] +=
|
|
124
|
+
args[args.length - 1] += _index.default.stringify(vNode);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
return args;
|
|
@@ -135,7 +135,9 @@ function resolveVNode(node, vNode, functions) {
|
|
|
135
135
|
return vNode;
|
|
136
136
|
}
|
|
137
137
|
function resolveFunctions(node, input, functions) {
|
|
138
|
-
|
|
138
|
+
let hasAnyFn = Object.keys(functions).some((fn)=>input.includes(`${fn}(`));
|
|
139
|
+
if (!hasAnyFn) return input;
|
|
140
|
+
return (0, _index.default)(input).walk((vNode)=>{
|
|
139
141
|
resolveVNode(node, vNode, functions);
|
|
140
142
|
}).toString();
|
|
141
143
|
}
|
|
@@ -482,6 +482,12 @@ function processApply(root, context, localCache) {
|
|
|
482
482
|
// We do *not* want to do this for user CSS that happens to be structured the same
|
|
483
483
|
let isGenerated = parent.raws.tailwind !== undefined;
|
|
484
484
|
let parentSelector = isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0 ? parent.selector.slice(importantSelector.length) : parent.selector;
|
|
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
|
+
}
|
|
485
491
|
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate);
|
|
486
492
|
// And then re-add it if it was removed
|
|
487
493
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
@@ -124,7 +124,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
124
124
|
return returnValue;
|
|
125
125
|
}
|
|
126
126
|
function expandTailwindAtRules(context) {
|
|
127
|
-
return (root)=>{
|
|
127
|
+
return async (root)=>{
|
|
128
128
|
let layerNodes = {
|
|
129
129
|
base: null,
|
|
130
130
|
components: null,
|
|
@@ -165,11 +165,25 @@ function expandTailwindAtRules(context) {
|
|
|
165
165
|
// getClassCandidatesOxide(file, transformer(content), extractor, candidates, seen)
|
|
166
166
|
// }
|
|
167
167
|
} else {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
/** @type {[item: {file?: string, content?: string}, meta: {transformer: any, extractor: any}][]} */ let regexParserContent = [];
|
|
169
|
+
for (let item of context.changedContent){
|
|
170
|
+
let transformer = getTransformer(context.tailwindConfig, item.extension);
|
|
171
|
+
let extractor = getExtractor(context, item.extension);
|
|
172
|
+
regexParserContent.push([
|
|
173
|
+
item,
|
|
174
|
+
{
|
|
175
|
+
transformer,
|
|
176
|
+
extractor
|
|
177
|
+
}
|
|
178
|
+
]);
|
|
179
|
+
}
|
|
180
|
+
const BATCH_SIZE = 500;
|
|
181
|
+
for(let i = 0; i < regexParserContent.length; i += BATCH_SIZE){
|
|
182
|
+
let batch = regexParserContent.slice(i, i + BATCH_SIZE);
|
|
183
|
+
await Promise.all(batch.map(async ([{ file , content }, { transformer , extractor }])=>{
|
|
184
|
+
content = file ? await _fs.default.promises.readFile(file, "utf8") : content;
|
|
185
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
186
|
+
}));
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
env.DEBUG && console.timeEnd("Reading changed files");
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -231,12 +231,12 @@ function applyVariant(variant, matches, context) {
|
|
|
231
231
|
// group[:hover] (`-` is missing)
|
|
232
232
|
let match = /(.)(-?)\[(.*)\]/g.exec(variant);
|
|
233
233
|
if (match) {
|
|
234
|
-
let [, char,
|
|
234
|
+
let [, char, separator, value] = match;
|
|
235
235
|
// @-[200px] case
|
|
236
|
-
if (char === "@" &&
|
|
236
|
+
if (char === "@" && separator === "-") return [];
|
|
237
237
|
// group[:hover] case
|
|
238
|
-
if (char !== "@" &&
|
|
239
|
-
variant = variant.replace(`${
|
|
238
|
+
if (char !== "@" && separator === "") return [];
|
|
239
|
+
variant = variant.replace(`${separator}[${value}]`, "");
|
|
240
240
|
args.value = value;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -259,9 +259,17 @@ function applyVariant(variant, matches, context) {
|
|
|
259
259
|
context.variantMap.set(variant, records);
|
|
260
260
|
}
|
|
261
261
|
if (context.variantMap.has(variant)) {
|
|
262
|
+
var _context_variantOptions_get;
|
|
262
263
|
let isArbitraryVariant = isArbitraryValue(variant);
|
|
264
|
+
var _context_variantOptions_get_INTERNAL_FEATURES;
|
|
265
|
+
let internalFeatures = (_context_variantOptions_get_INTERNAL_FEATURES = (_context_variantOptions_get = context.variantOptions.get(variant)) === null || _context_variantOptions_get === void 0 ? void 0 : _context_variantOptions_get[_setupContextUtils.INTERNAL_FEATURES]) !== null && _context_variantOptions_get_INTERNAL_FEATURES !== void 0 ? _context_variantOptions_get_INTERNAL_FEATURES : {};
|
|
263
266
|
let variantFunctionTuples = context.variantMap.get(variant).slice();
|
|
264
267
|
let result = [];
|
|
268
|
+
let respectPrefix = (()=>{
|
|
269
|
+
if (isArbitraryVariant) return false;
|
|
270
|
+
if (internalFeatures.respectPrefix === false) return false;
|
|
271
|
+
return true;
|
|
272
|
+
})();
|
|
265
273
|
for (let [meta, rule] of matches){
|
|
266
274
|
// Don't generate variants for user css
|
|
267
275
|
if (meta.layer === "user") {
|
|
@@ -318,7 +326,7 @@ function applyVariant(variant, matches, context) {
|
|
|
318
326
|
format (selectorFormat) {
|
|
319
327
|
collectedFormats.push({
|
|
320
328
|
format: selectorFormat,
|
|
321
|
-
|
|
329
|
+
respectPrefix
|
|
322
330
|
});
|
|
323
331
|
},
|
|
324
332
|
args
|
|
@@ -344,7 +352,7 @@ function applyVariant(variant, matches, context) {
|
|
|
344
352
|
if (typeof ruleWithVariant === "string") {
|
|
345
353
|
collectedFormats.push({
|
|
346
354
|
format: ruleWithVariant,
|
|
347
|
-
|
|
355
|
+
respectPrefix
|
|
348
356
|
});
|
|
349
357
|
}
|
|
350
358
|
if (ruleWithVariant === null) {
|
|
@@ -383,7 +391,7 @@ function applyVariant(variant, matches, context) {
|
|
|
383
391
|
// format: .foo &
|
|
384
392
|
collectedFormats.push({
|
|
385
393
|
format: modified.replace(rebuiltBase, "&"),
|
|
386
|
-
|
|
394
|
+
respectPrefix
|
|
387
395
|
});
|
|
388
396
|
rule.selector = before;
|
|
389
397
|
});
|
|
@@ -492,7 +500,9 @@ function extractArbitraryProperty(classCandidate, context) {
|
|
|
492
500
|
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
493
501
|
return null;
|
|
494
502
|
}
|
|
495
|
-
let normalized = (0, _dataTypes.normalize)(value
|
|
503
|
+
let normalized = (0, _dataTypes.normalize)(value, {
|
|
504
|
+
property
|
|
505
|
+
});
|
|
496
506
|
if (!isParsableCssValue(property, normalized)) {
|
|
497
507
|
return null;
|
|
498
508
|
}
|
|
@@ -570,7 +580,7 @@ function* recordCandidates(matches, classCandidate) {
|
|
|
570
580
|
yield match;
|
|
571
581
|
}
|
|
572
582
|
}
|
|
573
|
-
function* resolveMatches(candidate, context
|
|
583
|
+
function* resolveMatches(candidate, context) {
|
|
574
584
|
let separator = context.tailwindConfig.separator;
|
|
575
585
|
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
|
|
576
586
|
let important = false;
|
|
@@ -578,14 +588,6 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
578
588
|
important = true;
|
|
579
589
|
classCandidate = classCandidate.slice(1);
|
|
580
590
|
}
|
|
581
|
-
if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
|
|
582
|
-
if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
|
|
583
|
-
let base = variants.slice().reverse().join(separator);
|
|
584
|
-
for (let part of (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
|
|
585
|
-
yield* resolveMatches(base + separator + part, context, original);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
591
|
// TODO: Reintroduce this in ways that doesn't break on false positives
|
|
590
592
|
// function sortAgainst(toSort, against) {
|
|
591
593
|
// return toSort.slice().sort((a, z) => {
|
|
@@ -745,8 +747,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
745
747
|
// Apply final format selector
|
|
746
748
|
match = applyFinalFormat(match, {
|
|
747
749
|
context,
|
|
748
|
-
candidate
|
|
749
|
-
original
|
|
750
|
+
candidate
|
|
750
751
|
});
|
|
751
752
|
// Skip rules with invalid selectors
|
|
752
753
|
// This will cause the candidate to be added to the "not class"
|
|
@@ -758,7 +759,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
758
759
|
}
|
|
759
760
|
}
|
|
760
761
|
}
|
|
761
|
-
function applyFinalFormat(match, { context , candidate
|
|
762
|
+
function applyFinalFormat(match, { context , candidate }) {
|
|
762
763
|
if (!match[0].collectedFormats) {
|
|
763
764
|
return match;
|
|
764
765
|
}
|
|
@@ -791,10 +792,17 @@ function applyFinalFormat(match, { context , candidate , original }) {
|
|
|
791
792
|
return;
|
|
792
793
|
}
|
|
793
794
|
try {
|
|
794
|
-
|
|
795
|
-
candidate
|
|
795
|
+
let selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
|
|
796
|
+
candidate,
|
|
796
797
|
context
|
|
797
798
|
});
|
|
799
|
+
// Finalize Selector determined that this candidate is irrelevant
|
|
800
|
+
// TODO: This elimination should happen earlier so this never happens
|
|
801
|
+
if (selector === null) {
|
|
802
|
+
rule.remove();
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
rule.selector = selector;
|
|
798
806
|
} catch {
|
|
799
807
|
// If this selector is invalid we also want to skip it
|
|
800
808
|
// But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
|
|
@@ -835,7 +843,7 @@ function getImportantStrategy(important) {
|
|
|
835
843
|
};
|
|
836
844
|
}
|
|
837
845
|
}
|
|
838
|
-
function generateRules(candidates, context) {
|
|
846
|
+
function generateRules(candidates, context, isSorting = false) {
|
|
839
847
|
let allRules = [];
|
|
840
848
|
let strategy = getImportantStrategy(context.tailwindConfig.important);
|
|
841
849
|
for (let candidate of candidates){
|
|
@@ -866,9 +874,11 @@ function generateRules(candidates, context) {
|
|
|
866
874
|
container.walkRules(strategy);
|
|
867
875
|
rule = container.nodes[0];
|
|
868
876
|
}
|
|
877
|
+
// Note: We have to clone rules during sorting
|
|
878
|
+
// so we eliminate some shared mutable state
|
|
869
879
|
let newEntry = [
|
|
870
880
|
sort,
|
|
871
|
-
rule
|
|
881
|
+
isSorting ? rule.clone() : rule
|
|
872
882
|
];
|
|
873
883
|
rules.add(newEntry);
|
|
874
884
|
context.ruleCache.add(newEntry);
|
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
INTERNAL_FEATURES: function() {
|
|
13
|
+
return INTERNAL_FEATURES;
|
|
14
|
+
},
|
|
12
15
|
isValidVariantFormatString: function() {
|
|
13
16
|
return isValidVariantFormatString;
|
|
14
17
|
},
|
|
@@ -92,6 +95,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
92
95
|
}
|
|
93
96
|
return newObj;
|
|
94
97
|
}
|
|
98
|
+
const INTERNAL_FEATURES = Symbol();
|
|
95
99
|
const VARIANT_TYPES = {
|
|
96
100
|
AddVariant: Symbol.for("ADD_VARIANT"),
|
|
97
101
|
MatchVariant: Symbol.for("MATCH_VARIANT")
|
|
@@ -197,39 +201,41 @@ function getClasses(selector, mutate) {
|
|
|
197
201
|
});
|
|
198
202
|
return parser.transformSync(selector);
|
|
199
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Ignore everything inside a :not(...). This allows you to write code like
|
|
206
|
+
* `div:not(.foo)`. If `.foo` is never found in your code, then we used to
|
|
207
|
+
* not generated it. But now we will ignore everything inside a `:not`, so
|
|
208
|
+
* that it still gets generated.
|
|
209
|
+
*
|
|
210
|
+
* @param {selectorParser.Root} selectors
|
|
211
|
+
*/ function ignoreNot(selectors) {
|
|
212
|
+
selectors.walkPseudos((pseudo)=>{
|
|
213
|
+
if (pseudo.value === ":not") {
|
|
214
|
+
pseudo.remove();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
200
218
|
function extractCandidates(node, state = {
|
|
201
219
|
containsNonOnDemandable: false
|
|
202
220
|
}, depth = 0) {
|
|
203
221
|
let classes = [];
|
|
204
|
-
|
|
222
|
+
let selectors = [];
|
|
205
223
|
if (node.type === "rule") {
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
224
|
+
// Handle normal rules
|
|
225
|
+
selectors.push(...node.selectors);
|
|
226
|
+
} else if (node.type === "atrule") {
|
|
227
|
+
// Handle at-rules (which contains nested rules)
|
|
228
|
+
node.walkRules((rule)=>selectors.push(...rule.selectors));
|
|
229
|
+
}
|
|
230
|
+
for (let selector of selectors){
|
|
231
|
+
let classCandidates = getClasses(selector, ignoreNot);
|
|
232
|
+
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
233
|
+
if (classCandidates.length === 0) {
|
|
234
|
+
state.containsNonOnDemandable = true;
|
|
216
235
|
}
|
|
217
|
-
for (let
|
|
218
|
-
|
|
219
|
-
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
220
|
-
if (classCandidates.length === 0) {
|
|
221
|
-
state.containsNonOnDemandable = true;
|
|
222
|
-
}
|
|
223
|
-
for (let classCandidate of classCandidates){
|
|
224
|
-
classes.push(classCandidate);
|
|
225
|
-
}
|
|
236
|
+
for (let classCandidate of classCandidates){
|
|
237
|
+
classes.push(classCandidate);
|
|
226
238
|
}
|
|
227
|
-
} else if (node.type === "atrule") {
|
|
228
|
-
node.walkRules((rule)=>{
|
|
229
|
-
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
|
|
230
|
-
classes.push(classCandidate);
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
239
|
}
|
|
234
240
|
if (depth === 0) {
|
|
235
241
|
return [
|
|
@@ -270,11 +276,14 @@ function parseVariant(variant) {
|
|
|
270
276
|
if (!str.startsWith("@")) {
|
|
271
277
|
return ({ format })=>format(str);
|
|
272
278
|
}
|
|
273
|
-
let [, name, params] = /@(
|
|
274
|
-
|
|
279
|
+
let [, name, params] = /@(\S*)( .+|[({].*)?/g.exec(str);
|
|
280
|
+
var _params_trim;
|
|
281
|
+
return ({ wrap })=>{
|
|
282
|
+
return wrap(_postcss.default.atRule({
|
|
275
283
|
name,
|
|
276
|
-
params: params.trim()
|
|
284
|
+
params: (_params_trim = params === null || params === void 0 ? void 0 : params.trim()) !== null && _params_trim !== void 0 ? _params_trim : ""
|
|
277
285
|
}));
|
|
286
|
+
};
|
|
278
287
|
}).reverse();
|
|
279
288
|
return (api)=>{
|
|
280
289
|
for (let fn of fns){
|
|
@@ -920,11 +929,15 @@ function registerPlugins(plugins, context) {
|
|
|
920
929
|
]));
|
|
921
930
|
// Sort all classes in order
|
|
922
931
|
// Non-tailwind classes won't be generated and will be left as `null`
|
|
923
|
-
let rules = (0, _generateRules.generateRules)(new Set(sorted), context);
|
|
932
|
+
let rules = (0, _generateRules.generateRules)(new Set(sorted), context, true);
|
|
924
933
|
rules = context.offsets.sort(rules);
|
|
925
934
|
let idx = BigInt(parasiteUtilities.length);
|
|
926
935
|
for (const [, rule] of rules){
|
|
927
|
-
|
|
936
|
+
let candidate = rule.raws.tailwind.candidate;
|
|
937
|
+
var _sortedClassNames_get;
|
|
938
|
+
// When multiple rules match a candidate
|
|
939
|
+
// always take the position of the first one
|
|
940
|
+
sortedClassNames.set(candidate, (_sortedClassNames_get = sortedClassNames.get(candidate)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : idx++);
|
|
928
941
|
}
|
|
929
942
|
return classes.map((className)=>{
|
|
930
943
|
var _sortedClassNames_get;
|
|
@@ -1095,13 +1108,20 @@ function registerPlugins(plugins, context) {
|
|
|
1095
1108
|
}
|
|
1096
1109
|
var _options_values1;
|
|
1097
1110
|
let isArbitraryVariant = !(value in ((_options_values1 = options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {}));
|
|
1111
|
+
var _options_INTERNAL_FEATURES;
|
|
1112
|
+
let internalFeatures = (_options_INTERNAL_FEATURES = options[INTERNAL_FEATURES]) !== null && _options_INTERNAL_FEATURES !== void 0 ? _options_INTERNAL_FEATURES : {};
|
|
1113
|
+
let respectPrefix = (()=>{
|
|
1114
|
+
if (isArbitraryVariant) return false;
|
|
1115
|
+
if (internalFeatures.respectPrefix === false) return false;
|
|
1116
|
+
return true;
|
|
1117
|
+
})();
|
|
1098
1118
|
formatStrings = formatStrings.map((format)=>format.map((str)=>({
|
|
1099
1119
|
format: str,
|
|
1100
|
-
|
|
1120
|
+
respectPrefix
|
|
1101
1121
|
})));
|
|
1102
1122
|
manualFormatStrings = manualFormatStrings.map((format)=>({
|
|
1103
1123
|
format,
|
|
1104
|
-
|
|
1124
|
+
respectPrefix
|
|
1105
1125
|
}));
|
|
1106
1126
|
let opts = {
|
|
1107
1127
|
candidate,
|
|
@@ -83,8 +83,9 @@ function getTailwindConfig(configOrPath) {
|
|
|
83
83
|
newDeps
|
|
84
84
|
];
|
|
85
85
|
}
|
|
86
|
+
var _configOrPath_config, _ref;
|
|
86
87
|
// It's a plain object, not a path
|
|
87
|
-
let newConfig = (0, _resolveconfig.default)(configOrPath
|
|
88
|
+
let newConfig = (0, _resolveconfig.default)((_ref = (_configOrPath_config = configOrPath === null || configOrPath === void 0 ? void 0 : configOrPath.config) !== null && _configOrPath_config !== void 0 ? _configOrPath_config : configOrPath) !== null && _ref !== void 0 ? _ref : {});
|
|
88
89
|
newConfig = (0, _validateConfig.validateConfig)(newConfig);
|
|
89
90
|
return [
|
|
90
91
|
newConfig,
|