tailwindcss 3.1.4 → 3.1.7
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 +37 -2
- package/defaultTheme.d.ts +2 -1
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +78 -75
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +197 -187
- package/lib/featureFlags.js +14 -7
- package/lib/index.js +9 -6
- package/lib/lib/cacheInvalidation.js +18 -15
- package/lib/lib/collapseAdjacentRules.js +14 -11
- package/lib/lib/collapseDuplicateDeclarations.js +11 -8
- package/lib/lib/defaultExtractor.js +41 -33
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +75 -44
- package/lib/lib/expandApplyAtRules.js +45 -42
- package/lib/lib/expandTailwindAtRules.js +153 -150
- package/lib/lib/generateRules.js +84 -70
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +10 -7
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +15 -7
- package/lib/lib/resolveDefaultsAtRules.js +92 -85
- package/lib/lib/setupContextUtils.js +115 -97
- package/lib/lib/setupTrackingContext.js +82 -75
- package/lib/lib/sharedState.js +15 -8
- package/lib/lib/substituteScreenAtRules.js +8 -5
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +7 -4
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +6 -4
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +5 -2
- package/lib/util/cloneDeep.js +4 -1
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +11 -3
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +5 -3
- package/lib/util/createUtilityPlugin.js +13 -10
- package/lib/util/dataTypes.js +27 -19
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +12 -9
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +23 -15
- package/lib/util/getAllConfigs.js +12 -9
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/isValidArbitraryValue.js +33 -24
- package/lib/util/log.js +12 -5
- package/lib/util/nameClass.js +16 -8
- package/lib/util/negateValue.js +4 -1
- package/lib/util/normalizeConfig.js +26 -23
- package/lib/util/normalizeScreens.js +17 -2
- package/lib/util/parseAnimationValue.js +42 -39
- package/lib/util/parseBoxShadowValue.js +12 -4
- package/lib/util/parseDependency.js +35 -32
- package/lib/util/parseObjectStyles.js +14 -11
- package/lib/util/pluginUtils.js +28 -20
- package/lib/util/prefixSelector.js +6 -3
- package/lib/util/removeAlphaVariables.js +13 -2
- package/lib/util/resolveConfig.js +55 -52
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +16 -13
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +10 -7
- package/lib/util/validateConfig.js +5 -2
- package/lib/util/withAlphaVariable.js +30 -22
- package/package.json +12 -12
- package/peers/index.js +24 -10
- package/resolveConfig.d.ts +3 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/type-utils.js +27 -0
- package/src/corePlugins.js +2 -1
- package/src/lib/defaultExtractor.js +7 -1
- package/src/lib/evaluateTailwindFunctions.js +41 -15
- package/src/lib/generateRules.js +10 -1
- package/src/lib/setupContextUtils.js +15 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/formatVariantSelector.js +3 -1
- package/types/config.d.ts +7 -5
- package/types/generated/default-theme.d.ts +331 -0
|
@@ -2,48 +2,56 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
isValidVariantFormatString: ()=>isValidVariantFormatString,
|
|
13
|
+
parseVariant: ()=>parseVariant,
|
|
14
|
+
getFileModifiedMap: ()=>getFileModifiedMap,
|
|
15
|
+
createContext: ()=>createContext,
|
|
16
|
+
getContext: ()=>getContext
|
|
17
|
+
});
|
|
18
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
19
|
+
const _url = /*#__PURE__*/ _interopRequireDefault(require("url"));
|
|
20
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
21
|
+
const _dlv = /*#__PURE__*/ _interopRequireDefault(require("dlv"));
|
|
22
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
23
|
+
const _featureFlagsJs = require("../featureFlags.js");
|
|
24
|
+
const _transformThemeValue = /*#__PURE__*/ _interopRequireDefault(require("../util/transformThemeValue"));
|
|
25
|
+
const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
|
|
26
|
+
const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
|
|
27
|
+
const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isPlainObject"));
|
|
28
|
+
const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
|
|
29
|
+
const _nameClass = /*#__PURE__*/ _interopRequireWildcard(require("../util/nameClass"));
|
|
30
|
+
const _pluginUtils = require("../util/pluginUtils");
|
|
31
|
+
const _bigSign = /*#__PURE__*/ _interopRequireDefault(require("../util/bigSign"));
|
|
32
|
+
const _corePlugins = require("../corePlugins");
|
|
33
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
34
|
+
const _toPath = require("../util/toPath");
|
|
35
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
36
|
+
const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("../util/negateValue"));
|
|
37
|
+
const _isValidArbitraryValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
38
|
+
const _generateRules = require("./generateRules");
|
|
39
|
+
const _cacheInvalidationJs = require("./cacheInvalidation.js");
|
|
32
40
|
function _interopRequireDefault(obj) {
|
|
33
41
|
return obj && obj.__esModule ? obj : {
|
|
34
42
|
default: obj
|
|
35
43
|
};
|
|
36
44
|
}
|
|
37
|
-
function _getRequireWildcardCache() {
|
|
45
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
38
46
|
if (typeof WeakMap !== "function") return null;
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
var cacheBabelInterop = new WeakMap();
|
|
48
|
+
var cacheNodeInterop = new WeakMap();
|
|
49
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
50
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
51
|
+
})(nodeInterop);
|
|
44
52
|
}
|
|
45
|
-
function _interopRequireWildcard(obj) {
|
|
46
|
-
if (obj && obj.__esModule) {
|
|
53
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
54
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
47
55
|
return obj;
|
|
48
56
|
}
|
|
49
57
|
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
@@ -51,14 +59,14 @@ function _interopRequireWildcard(obj) {
|
|
|
51
59
|
default: obj
|
|
52
60
|
};
|
|
53
61
|
}
|
|
54
|
-
var cache = _getRequireWildcardCache();
|
|
62
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
55
63
|
if (cache && cache.has(obj)) {
|
|
56
64
|
return cache.get(obj);
|
|
57
65
|
}
|
|
58
66
|
var newObj = {};
|
|
59
67
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
68
|
for(var key in obj){
|
|
61
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
69
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
62
70
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
63
71
|
if (desc && (desc.get || desc.set)) {
|
|
64
72
|
Object.defineProperty(newObj, key, desc);
|
|
@@ -75,8 +83,8 @@ function _interopRequireWildcard(obj) {
|
|
|
75
83
|
}
|
|
76
84
|
let MATCH_VARIANT = Symbol();
|
|
77
85
|
function prefix(context, selector) {
|
|
78
|
-
let
|
|
79
|
-
return typeof
|
|
86
|
+
let prefix = context.tailwindConfig.prefix;
|
|
87
|
+
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
|
|
80
88
|
}
|
|
81
89
|
function parseVariantFormatString(input) {
|
|
82
90
|
if (input.includes("{")) {
|
|
@@ -122,12 +130,12 @@ function parseStyles(styles) {
|
|
|
122
130
|
]);
|
|
123
131
|
}
|
|
124
132
|
return styles.flatMap((style)=>{
|
|
125
|
-
let isNode = !Array.isArray(style) && !(0, _isPlainObject
|
|
126
|
-
return isNode ? style : (0, _parseObjectStyles
|
|
133
|
+
let isNode = !Array.isArray(style) && !(0, _isPlainObject.default)(style);
|
|
134
|
+
return isNode ? style : (0, _parseObjectStyles.default)(style);
|
|
127
135
|
});
|
|
128
136
|
}
|
|
129
137
|
function getClasses(selector, mutate) {
|
|
130
|
-
let parser = (0, _postcssSelectorParser
|
|
138
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
131
139
|
let allClasses = [];
|
|
132
140
|
if (mutate) {
|
|
133
141
|
mutate(selectors);
|
|
@@ -187,7 +195,7 @@ function withIdentifiers(styles) {
|
|
|
187
195
|
let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
|
|
188
196
|
// If this isn't "on-demandable", assign it a universal candidate to always include it.
|
|
189
197
|
if (containsNonOnDemandableSelectors) {
|
|
190
|
-
candidates.unshift(
|
|
198
|
+
candidates.unshift(_sharedState.NOT_ON_DEMAND);
|
|
191
199
|
}
|
|
192
200
|
// However, it could be that it also contains "on-demandable" candidates.
|
|
193
201
|
// E.g.: `span, .foo {}`, in that case it should still be possible to use
|
|
@@ -226,14 +234,14 @@ function parseVariant(variant) {
|
|
|
226
234
|
}
|
|
227
235
|
function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
228
236
|
function getConfigValue(path, defaultValue) {
|
|
229
|
-
return path ? (0, _dlv
|
|
237
|
+
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
230
238
|
}
|
|
231
239
|
function applyConfiguredPrefix(selector) {
|
|
232
|
-
return (0, _prefixSelector
|
|
240
|
+
return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
|
|
233
241
|
}
|
|
234
242
|
function prefixIdentifier(identifier, options) {
|
|
235
|
-
if (identifier ===
|
|
236
|
-
return
|
|
243
|
+
if (identifier === _sharedState.NOT_ON_DEMAND) {
|
|
244
|
+
return _sharedState.NOT_ON_DEMAND;
|
|
237
245
|
}
|
|
238
246
|
if (!options.respectPrefix) {
|
|
239
247
|
return identifier;
|
|
@@ -241,20 +249,20 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
241
249
|
return context.tailwindConfig.prefix + identifier;
|
|
242
250
|
}
|
|
243
251
|
function resolveThemeValue(path, defaultValue, opts = {}) {
|
|
244
|
-
const [pathRoot, ...subPaths] = (0, _toPath
|
|
252
|
+
const [pathRoot, ...subPaths] = (0, _toPath.toPath)(path);
|
|
245
253
|
const value = getConfigValue([
|
|
246
254
|
"theme",
|
|
247
255
|
pathRoot,
|
|
248
256
|
...subPaths
|
|
249
257
|
], defaultValue);
|
|
250
|
-
return (0, _transformThemeValue
|
|
258
|
+
return (0, _transformThemeValue.default)(pathRoot)(value, opts);
|
|
251
259
|
}
|
|
252
260
|
const theme = Object.assign((path, defaultValue = undefined)=>resolveThemeValue(path, defaultValue), {
|
|
253
261
|
withAlpha: (path, opacityValue)=>resolveThemeValue(path, undefined, {
|
|
254
262
|
opacityValue
|
|
255
263
|
})
|
|
256
264
|
});
|
|
257
|
-
let
|
|
265
|
+
let api = {
|
|
258
266
|
postcss: _postcss.default,
|
|
259
267
|
prefix: applyConfiguredPrefix,
|
|
260
268
|
e: _escapeClassName.default,
|
|
@@ -312,6 +320,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
312
320
|
},
|
|
313
321
|
addComponents (components, options) {
|
|
314
322
|
let defaultOptions = {
|
|
323
|
+
preserveSource: false,
|
|
315
324
|
respectPrefix: true,
|
|
316
325
|
respectImportant: false
|
|
317
326
|
};
|
|
@@ -334,6 +343,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
334
343
|
},
|
|
335
344
|
addUtilities (utilities, options) {
|
|
336
345
|
let defaultOptions = {
|
|
346
|
+
preserveSource: false,
|
|
337
347
|
respectPrefix: true,
|
|
338
348
|
respectImportant: true
|
|
339
349
|
};
|
|
@@ -374,18 +384,18 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
374
384
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
375
385
|
let { type ="any" } = options;
|
|
376
386
|
type = [].concat(type);
|
|
377
|
-
let [value, coercedType] = (0, _pluginUtils
|
|
387
|
+
let [value, coercedType] = (0, _pluginUtils.coerceValue)(type, modifier, options, tailwindConfig);
|
|
378
388
|
if (value === undefined) {
|
|
379
389
|
return [];
|
|
380
390
|
}
|
|
381
391
|
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
382
392
|
return [];
|
|
383
393
|
}
|
|
384
|
-
if (!(0, _isValidArbitraryValue
|
|
394
|
+
if (!(0, _isValidArbitraryValue.default)(value)) {
|
|
385
395
|
return [];
|
|
386
396
|
}
|
|
387
397
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
388
|
-
[(0, _nameClass
|
|
398
|
+
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
389
399
|
}));
|
|
390
400
|
return ruleSets;
|
|
391
401
|
}
|
|
@@ -423,7 +433,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
423
433
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
424
434
|
let { type ="any" } = options;
|
|
425
435
|
type = [].concat(type);
|
|
426
|
-
let [value, coercedType] = (0, _pluginUtils
|
|
436
|
+
let [value, coercedType] = (0, _pluginUtils.coerceValue)(type, modifier, options, tailwindConfig);
|
|
427
437
|
if (value === undefined) {
|
|
428
438
|
return [];
|
|
429
439
|
}
|
|
@@ -437,11 +447,11 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
437
447
|
return [];
|
|
438
448
|
}
|
|
439
449
|
}
|
|
440
|
-
if (!(0, _isValidArbitraryValue
|
|
450
|
+
if (!(0, _isValidArbitraryValue.default)(value)) {
|
|
441
451
|
return [];
|
|
442
452
|
}
|
|
443
453
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
444
|
-
[(0, _nameClass
|
|
454
|
+
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
445
455
|
}));
|
|
446
456
|
return ruleSets;
|
|
447
457
|
}
|
|
@@ -494,20 +504,20 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
494
504
|
variantMap.set(variantName, variantFunctions);
|
|
495
505
|
}
|
|
496
506
|
};
|
|
497
|
-
if ((0, _featureFlagsJs
|
|
498
|
-
|
|
507
|
+
if ((0, _featureFlagsJs.flagEnabled)(tailwindConfig, "matchVariant")) {
|
|
508
|
+
api.matchVariant = function(variants, options) {
|
|
499
509
|
for(let variant in variants){
|
|
500
510
|
var ref;
|
|
501
511
|
for (let [k, v] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
502
|
-
|
|
512
|
+
api.addVariant(`${variant}-${k}`, variants[variant](v));
|
|
503
513
|
}
|
|
504
|
-
|
|
514
|
+
api.addVariant(variant, Object.assign(({ args })=>variants[variant](args), {
|
|
505
515
|
[MATCH_VARIANT]: true
|
|
506
516
|
}), options);
|
|
507
517
|
}
|
|
508
518
|
};
|
|
509
519
|
}
|
|
510
|
-
return
|
|
520
|
+
return api;
|
|
511
521
|
}
|
|
512
522
|
let fileModifiedMapCache = new WeakMap();
|
|
513
523
|
function getFileModifiedMap(context) {
|
|
@@ -573,19 +583,21 @@ function collectLayerPlugins(root) {
|
|
|
573
583
|
}
|
|
574
584
|
layerRule.remove();
|
|
575
585
|
} else if (layerRule.params === "components") {
|
|
576
|
-
for (let
|
|
586
|
+
for (let node1 of layerRule.nodes){
|
|
577
587
|
layerPlugins.push(function({ addComponents }) {
|
|
578
|
-
addComponents(
|
|
579
|
-
respectPrefix: false
|
|
588
|
+
addComponents(node1, {
|
|
589
|
+
respectPrefix: false,
|
|
590
|
+
preserveSource: true
|
|
580
591
|
});
|
|
581
592
|
});
|
|
582
593
|
}
|
|
583
594
|
layerRule.remove();
|
|
584
595
|
} else if (layerRule.params === "utilities") {
|
|
585
|
-
for (let
|
|
596
|
+
for (let node2 of layerRule.nodes){
|
|
586
597
|
layerPlugins.push(function({ addUtilities }) {
|
|
587
|
-
addUtilities(
|
|
588
|
-
respectPrefix: false
|
|
598
|
+
addUtilities(node2, {
|
|
599
|
+
respectPrefix: false,
|
|
600
|
+
preserveSource: true
|
|
589
601
|
});
|
|
590
602
|
});
|
|
591
603
|
}
|
|
@@ -688,14 +700,14 @@ function registerPlugins(plugins, context) {
|
|
|
688
700
|
variant,
|
|
689
701
|
bits
|
|
690
702
|
];
|
|
691
|
-
}).sort(([, a], [, z])=>(0, _bigSign
|
|
703
|
+
}).sort(([, a], [, z])=>(0, _bigSign.default)(a - z)));
|
|
692
704
|
context.minimumScreen = [
|
|
693
705
|
...context.variantOrder.values()
|
|
694
706
|
].shift();
|
|
695
707
|
// Build variantMap
|
|
696
|
-
for (let [variantName,
|
|
708
|
+
for (let [variantName, variantFunctions] of variantMap.entries()){
|
|
697
709
|
let sort = context.variantOrder.get(variantName);
|
|
698
|
-
context.variantMap.set(variantName,
|
|
710
|
+
context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
|
|
699
711
|
sort << BigInt(idx),
|
|
700
712
|
variantFunction
|
|
701
713
|
]));
|
|
@@ -704,15 +716,15 @@ function registerPlugins(plugins, context) {
|
|
|
704
716
|
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
705
717
|
if (safelist.length > 0) {
|
|
706
718
|
let checks = [];
|
|
707
|
-
for (let
|
|
708
|
-
if (typeof
|
|
719
|
+
for (let value of safelist){
|
|
720
|
+
if (typeof value === "string") {
|
|
709
721
|
context.changedContent.push({
|
|
710
|
-
content:
|
|
722
|
+
content: value,
|
|
711
723
|
extension: "html"
|
|
712
724
|
});
|
|
713
725
|
continue;
|
|
714
726
|
}
|
|
715
|
-
if (
|
|
727
|
+
if (value instanceof RegExp) {
|
|
716
728
|
_log.default.warn("root-regex", [
|
|
717
729
|
"Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
|
|
718
730
|
"Update your `safelist` configuration to eliminate this warning.",
|
|
@@ -720,7 +732,7 @@ function registerPlugins(plugins, context) {
|
|
|
720
732
|
]);
|
|
721
733
|
continue;
|
|
722
734
|
}
|
|
723
|
-
checks.push(
|
|
735
|
+
checks.push(value);
|
|
724
736
|
}
|
|
725
737
|
if (checks.length > 0) {
|
|
726
738
|
let patternMatchingCount = new Map();
|
|
@@ -730,7 +742,7 @@ function registerPlugins(plugins, context) {
|
|
|
730
742
|
let [utilName, options] = util;
|
|
731
743
|
var ref;
|
|
732
744
|
let values = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {});
|
|
733
|
-
let classes = values.map((value)=>(0, _nameClass
|
|
745
|
+
let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
|
|
734
746
|
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
735
747
|
// This is the normal negated version
|
|
736
748
|
// e.g. `-inset-1` or `-tw-inset-1`
|
|
@@ -747,6 +759,12 @@ function registerPlugins(plugins, context) {
|
|
|
747
759
|
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength)),
|
|
748
760
|
];
|
|
749
761
|
}
|
|
762
|
+
if ([].concat(options === null || options === void 0 ? void 0 : options.type).includes("color")) {
|
|
763
|
+
classes = [
|
|
764
|
+
...classes,
|
|
765
|
+
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`)),
|
|
766
|
+
];
|
|
767
|
+
}
|
|
750
768
|
return classes;
|
|
751
769
|
})() : [
|
|
752
770
|
util
|
|
@@ -794,7 +812,7 @@ function registerPlugins(plugins, context) {
|
|
|
794
812
|
]);
|
|
795
813
|
context.getClassOrder = function getClassOrder(classes) {
|
|
796
814
|
let sortedClassNames = new Map();
|
|
797
|
-
for (let [sort, rule] of (0, _generateRules
|
|
815
|
+
for (let [sort, rule] of (0, _generateRules.generateRules)(new Set(classes), context)){
|
|
798
816
|
if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue;
|
|
799
817
|
sortedClassNames.set(rule.raws.tailwind.candidate, sort);
|
|
800
818
|
}
|
|
@@ -823,9 +841,9 @@ function registerPlugins(plugins, context) {
|
|
|
823
841
|
let negativeClasses = [];
|
|
824
842
|
var ref;
|
|
825
843
|
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
826
|
-
output.push((0, _nameClass
|
|
827
|
-
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue
|
|
828
|
-
negativeClasses.push((0, _nameClass
|
|
844
|
+
output.push((0, _nameClass.formatClass)(utilName, key));
|
|
845
|
+
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue.default)(value)) {
|
|
846
|
+
negativeClasses.push((0, _nameClass.formatClass)(utilName, `-${key}`));
|
|
829
847
|
}
|
|
830
848
|
}
|
|
831
849
|
output.push(...negativeClasses);
|
|
@@ -854,13 +872,13 @@ function createContext(tailwindConfig, changedContent = [], root = _postcss.defa
|
|
|
854
872
|
registerPlugins(resolvedPlugins, context);
|
|
855
873
|
return context;
|
|
856
874
|
}
|
|
857
|
-
let contextMap =
|
|
858
|
-
let configContextMap =
|
|
859
|
-
let contextSourcesMap =
|
|
875
|
+
let contextMap = _sharedState.contextMap;
|
|
876
|
+
let configContextMap = _sharedState.configContextMap;
|
|
877
|
+
let contextSourcesMap = _sharedState.contextSourcesMap;
|
|
860
878
|
function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
|
|
861
879
|
let sourcePath = result.opts.from;
|
|
862
880
|
let isConfigFile = userConfigPath !== null;
|
|
863
|
-
|
|
881
|
+
_sharedState.env.DEBUG && console.log("Source path:", sourcePath);
|
|
864
882
|
let existingContext;
|
|
865
883
|
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
866
884
|
existingContext = contextMap.get(sourcePath);
|
|
@@ -870,7 +888,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
870
888
|
contextMap.set(sourcePath, context);
|
|
871
889
|
existingContext = context;
|
|
872
890
|
}
|
|
873
|
-
let cssDidChange = (0, _cacheInvalidationJs
|
|
891
|
+
let cssDidChange = (0, _cacheInvalidationJs.hasContentChanged)(sourcePath, root);
|
|
874
892
|
// If there's already a context in the cache and we don't need to
|
|
875
893
|
// reset the context, return the cached context.
|
|
876
894
|
if (existingContext) {
|
|
@@ -895,9 +913,9 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
895
913
|
contextSourcesMap.get(oldContext).delete(sourcePath);
|
|
896
914
|
if (contextSourcesMap.get(oldContext).size === 0) {
|
|
897
915
|
contextSourcesMap.delete(oldContext);
|
|
898
|
-
for (let [
|
|
899
|
-
if (
|
|
900
|
-
configContextMap.delete(
|
|
916
|
+
for (let [tailwindConfigHash1, context1] of configContextMap){
|
|
917
|
+
if (context1 === oldContext) {
|
|
918
|
+
configContextMap.delete(tailwindConfigHash1);
|
|
901
919
|
}
|
|
902
920
|
}
|
|
903
921
|
for (let disposable of oldContext.disposables.splice(0)){
|
|
@@ -906,21 +924,21 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
906
924
|
}
|
|
907
925
|
}
|
|
908
926
|
}
|
|
909
|
-
|
|
910
|
-
let
|
|
927
|
+
_sharedState.env.DEBUG && console.log("Setting up new context...");
|
|
928
|
+
let context2 = createContext(tailwindConfig, [], root);
|
|
911
929
|
trackModified([
|
|
912
930
|
...contextDependencies
|
|
913
|
-
], getFileModifiedMap(
|
|
931
|
+
], getFileModifiedMap(context2));
|
|
914
932
|
// ---
|
|
915
933
|
// Update all context tracking state
|
|
916
|
-
configContextMap.set(tailwindConfigHash,
|
|
917
|
-
contextMap.set(sourcePath,
|
|
918
|
-
if (!contextSourcesMap.has(
|
|
919
|
-
contextSourcesMap.set(
|
|
934
|
+
configContextMap.set(tailwindConfigHash, context2);
|
|
935
|
+
contextMap.set(sourcePath, context2);
|
|
936
|
+
if (!contextSourcesMap.has(context2)) {
|
|
937
|
+
contextSourcesMap.set(context2, new Set());
|
|
920
938
|
}
|
|
921
|
-
contextSourcesMap.get(
|
|
939
|
+
contextSourcesMap.get(context2).add(sourcePath);
|
|
922
940
|
return [
|
|
923
|
-
|
|
941
|
+
context2,
|
|
924
942
|
true
|
|
925
943
|
];
|
|
926
944
|
}
|