tailwindcss 3.1.5 → 3.1.8
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 +36 -8
- package/README.md +6 -3
- 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 +194 -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 +38 -35
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +75 -44
- package/lib/lib/expandApplyAtRules.js +50 -42
- package/lib/lib/expandTailwindAtRules.js +153 -150
- package/lib/lib/generateRules.js +81 -73
- 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 +109 -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 +21 -14
- 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 +56 -53
- 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 +10 -10
- package/peers/index.js +950 -825
- package/resolveConfig.d.ts +3 -0
- package/src/lib/evaluateTailwindFunctions.js +41 -15
- package/src/lib/expandApplyAtRules.js +6 -0
- package/src/lib/generateRules.js +6 -5
- package/src/lib/setupContextUtils.js +4 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/resolveConfig.js +1 -1
|
@@ -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`
|
|
@@ -800,7 +812,7 @@ function registerPlugins(plugins, context) {
|
|
|
800
812
|
]);
|
|
801
813
|
context.getClassOrder = function getClassOrder(classes) {
|
|
802
814
|
let sortedClassNames = new Map();
|
|
803
|
-
for (let [sort, rule] of (0, _generateRules
|
|
815
|
+
for (let [sort, rule] of (0, _generateRules.generateRules)(new Set(classes), context)){
|
|
804
816
|
if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue;
|
|
805
817
|
sortedClassNames.set(rule.raws.tailwind.candidate, sort);
|
|
806
818
|
}
|
|
@@ -829,9 +841,9 @@ function registerPlugins(plugins, context) {
|
|
|
829
841
|
let negativeClasses = [];
|
|
830
842
|
var ref;
|
|
831
843
|
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
832
|
-
output.push((0, _nameClass
|
|
833
|
-
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue
|
|
834
|
-
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}`));
|
|
835
847
|
}
|
|
836
848
|
}
|
|
837
849
|
output.push(...negativeClasses);
|
|
@@ -860,13 +872,13 @@ function createContext(tailwindConfig, changedContent = [], root = _postcss.defa
|
|
|
860
872
|
registerPlugins(resolvedPlugins, context);
|
|
861
873
|
return context;
|
|
862
874
|
}
|
|
863
|
-
let contextMap =
|
|
864
|
-
let configContextMap =
|
|
865
|
-
let contextSourcesMap =
|
|
875
|
+
let contextMap = _sharedState.contextMap;
|
|
876
|
+
let configContextMap = _sharedState.configContextMap;
|
|
877
|
+
let contextSourcesMap = _sharedState.contextSourcesMap;
|
|
866
878
|
function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
|
|
867
879
|
let sourcePath = result.opts.from;
|
|
868
880
|
let isConfigFile = userConfigPath !== null;
|
|
869
|
-
|
|
881
|
+
_sharedState.env.DEBUG && console.log("Source path:", sourcePath);
|
|
870
882
|
let existingContext;
|
|
871
883
|
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
872
884
|
existingContext = contextMap.get(sourcePath);
|
|
@@ -876,7 +888,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
876
888
|
contextMap.set(sourcePath, context);
|
|
877
889
|
existingContext = context;
|
|
878
890
|
}
|
|
879
|
-
let cssDidChange = (0, _cacheInvalidationJs
|
|
891
|
+
let cssDidChange = (0, _cacheInvalidationJs.hasContentChanged)(sourcePath, root);
|
|
880
892
|
// If there's already a context in the cache and we don't need to
|
|
881
893
|
// reset the context, return the cached context.
|
|
882
894
|
if (existingContext) {
|
|
@@ -901,9 +913,9 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
901
913
|
contextSourcesMap.get(oldContext).delete(sourcePath);
|
|
902
914
|
if (contextSourcesMap.get(oldContext).size === 0) {
|
|
903
915
|
contextSourcesMap.delete(oldContext);
|
|
904
|
-
for (let [
|
|
905
|
-
if (
|
|
906
|
-
configContextMap.delete(
|
|
916
|
+
for (let [tailwindConfigHash1, context1] of configContextMap){
|
|
917
|
+
if (context1 === oldContext) {
|
|
918
|
+
configContextMap.delete(tailwindConfigHash1);
|
|
907
919
|
}
|
|
908
920
|
}
|
|
909
921
|
for (let disposable of oldContext.disposables.splice(0)){
|
|
@@ -912,21 +924,21 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
912
924
|
}
|
|
913
925
|
}
|
|
914
926
|
}
|
|
915
|
-
|
|
916
|
-
let
|
|
927
|
+
_sharedState.env.DEBUG && console.log("Setting up new context...");
|
|
928
|
+
let context2 = createContext(tailwindConfig, [], root);
|
|
917
929
|
trackModified([
|
|
918
930
|
...contextDependencies
|
|
919
|
-
], getFileModifiedMap(
|
|
931
|
+
], getFileModifiedMap(context2));
|
|
920
932
|
// ---
|
|
921
933
|
// Update all context tracking state
|
|
922
|
-
configContextMap.set(tailwindConfigHash,
|
|
923
|
-
contextMap.set(sourcePath,
|
|
924
|
-
if (!contextSourcesMap.has(
|
|
925
|
-
contextSourcesMap.set(
|
|
934
|
+
configContextMap.set(tailwindConfigHash, context2);
|
|
935
|
+
contextMap.set(sourcePath, context2);
|
|
936
|
+
if (!contextSourcesMap.has(context2)) {
|
|
937
|
+
contextSourcesMap.set(context2, new Set());
|
|
926
938
|
}
|
|
927
|
-
contextSourcesMap.get(
|
|
939
|
+
contextSourcesMap.get(context2).add(sourcePath);
|
|
928
940
|
return [
|
|
929
|
-
|
|
941
|
+
context2,
|
|
930
942
|
true
|
|
931
943
|
];
|
|
932
944
|
}
|
|
@@ -2,71 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// the context even if they change. We may want to think about `@layer`
|
|
27
|
-
// being part of this trigger too, but it's tough because it's impossible
|
|
28
|
-
// for a layer in one file to end up in the actual @tailwind rule in
|
|
29
|
-
// another file since independent sources are effectively isolated.
|
|
30
|
-
if (tailwindDirectives.size > 0) {
|
|
31
|
-
// Add current css file as a context dependencies.
|
|
32
|
-
contextDependencies.add(result.opts.from);
|
|
33
|
-
// Add all css @import dependencies as context dependencies.
|
|
34
|
-
for (let message of result.messages){
|
|
35
|
-
if (message.type === "dependency") {
|
|
36
|
-
contextDependencies.add(message.file);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
let [context] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
41
|
-
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
42
|
-
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
43
|
-
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
44
|
-
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
45
|
-
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
46
|
-
// in another file since independent sources are effectively isolated.
|
|
47
|
-
if (tailwindDirectives.size > 0) {
|
|
48
|
-
let fileModifiedMap = (0, _setupContextUtils).getFileModifiedMap(context);
|
|
49
|
-
// Add template paths as postcss dependencies.
|
|
50
|
-
for (let fileOrGlob of candidateFiles){
|
|
51
|
-
let dependency = (0, _parseDependency).default(fileOrGlob);
|
|
52
|
-
if (dependency) {
|
|
53
|
-
registerDependency(dependency);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
for (let changedContent of resolvedChangedContent(context, candidateFiles, fileModifiedMap)){
|
|
57
|
-
context.changedContent.push(changedContent);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
for (let file of configDependencies){
|
|
61
|
-
registerDependency({
|
|
62
|
-
type: "dependency",
|
|
63
|
-
file
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return context;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}
|
|
5
|
+
Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
|
|
6
|
+
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
7
|
+
// source path), or set up a new one (including setting up watchers and registering
|
|
8
|
+
// plugins) then return it
|
|
9
|
+
"default", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: ()=>setupTrackingContext
|
|
12
|
+
});
|
|
13
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
14
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
15
|
+
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
16
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
17
|
+
const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
|
|
18
|
+
const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
|
|
19
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../lib/getModuleDependencies"));
|
|
20
|
+
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
|
|
21
|
+
const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
|
|
22
|
+
const _sharedState = require("./sharedState");
|
|
23
|
+
const _setupContextUtils = require("./setupContextUtils");
|
|
24
|
+
const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
|
|
25
|
+
const _validateConfigJs = require("../util/validateConfig.js");
|
|
70
26
|
function _interopRequireDefault(obj) {
|
|
71
27
|
return obj && obj.__esModule ? obj : {
|
|
72
28
|
default: obj
|
|
@@ -80,15 +36,15 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
80
36
|
if (candidateFilesCache.has(context)) {
|
|
81
37
|
return candidateFilesCache.get(context);
|
|
82
38
|
}
|
|
83
|
-
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === "string").map((contentPath)=>(0, _normalizePath
|
|
39
|
+
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === "string").map((contentPath)=>(0, _normalizePath.default)(contentPath));
|
|
84
40
|
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
85
41
|
}
|
|
86
42
|
// Get the config object based on a path
|
|
87
43
|
function getTailwindConfig(configOrPath) {
|
|
88
|
-
let userConfigPath = (0, _resolveConfigPath
|
|
44
|
+
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
89
45
|
if (userConfigPath !== null) {
|
|
90
46
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
91
|
-
let newDeps = (0, _getModuleDependencies
|
|
47
|
+
let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map((dep)=>dep.file);
|
|
92
48
|
let modified = false;
|
|
93
49
|
let newModified = new Map();
|
|
94
50
|
for (let file of newDeps){
|
|
@@ -111,9 +67,9 @@ function getTailwindConfig(configOrPath) {
|
|
|
111
67
|
for (let file1 of newDeps){
|
|
112
68
|
delete require.cache[file1];
|
|
113
69
|
}
|
|
114
|
-
let newConfig = (0, _resolveConfig
|
|
115
|
-
newConfig = (0, _validateConfigJs
|
|
116
|
-
let newHash = (0, _hashConfig
|
|
70
|
+
let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
|
|
71
|
+
newConfig = (0, _validateConfigJs.validateConfig)(newConfig);
|
|
72
|
+
let newHash = (0, _hashConfig.default)(newConfig);
|
|
117
73
|
configPathCache.set(userConfigPath, [
|
|
118
74
|
newConfig,
|
|
119
75
|
newHash,
|
|
@@ -128,12 +84,12 @@ function getTailwindConfig(configOrPath) {
|
|
|
128
84
|
];
|
|
129
85
|
}
|
|
130
86
|
// It's a plain object, not a path
|
|
131
|
-
let
|
|
132
|
-
|
|
87
|
+
let newConfig1 = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
|
|
88
|
+
newConfig1 = (0, _validateConfigJs.validateConfig)(newConfig1);
|
|
133
89
|
return [
|
|
134
|
-
|
|
90
|
+
newConfig1,
|
|
135
91
|
null,
|
|
136
|
-
(0, _hashConfig
|
|
92
|
+
(0, _hashConfig.default)(newConfig1),
|
|
137
93
|
[]
|
|
138
94
|
];
|
|
139
95
|
}
|
|
@@ -167,3 +123,54 @@ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
|
167
123
|
_sharedState.env.DEBUG && console.timeEnd("Finding changed files");
|
|
168
124
|
return changedFiles;
|
|
169
125
|
}
|
|
126
|
+
function setupTrackingContext(configOrPath) {
|
|
127
|
+
return ({ tailwindDirectives , registerDependency })=>{
|
|
128
|
+
return (root, result)=>{
|
|
129
|
+
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
130
|
+
let contextDependencies = new Set(configDependencies);
|
|
131
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS
|
|
132
|
+
// file or its dependencies to be dependencies of the context. Can reuse
|
|
133
|
+
// the context even if they change. We may want to think about `@layer`
|
|
134
|
+
// being part of this trigger too, but it's tough because it's impossible
|
|
135
|
+
// for a layer in one file to end up in the actual @tailwind rule in
|
|
136
|
+
// another file since independent sources are effectively isolated.
|
|
137
|
+
if (tailwindDirectives.size > 0) {
|
|
138
|
+
// Add current css file as a context dependencies.
|
|
139
|
+
contextDependencies.add(result.opts.from);
|
|
140
|
+
// Add all css @import dependencies as context dependencies.
|
|
141
|
+
for (let message of result.messages){
|
|
142
|
+
if (message.type === "dependency") {
|
|
143
|
+
contextDependencies.add(message.file);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
let [context] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
148
|
+
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
149
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
150
|
+
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
151
|
+
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
152
|
+
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
153
|
+
// in another file since independent sources are effectively isolated.
|
|
154
|
+
if (tailwindDirectives.size > 0) {
|
|
155
|
+
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
156
|
+
// Add template paths as postcss dependencies.
|
|
157
|
+
for (let fileOrGlob of candidateFiles){
|
|
158
|
+
let dependency = (0, _parseDependency.default)(fileOrGlob);
|
|
159
|
+
if (dependency) {
|
|
160
|
+
registerDependency(dependency);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
for (let changedContent of resolvedChangedContent(context, candidateFiles, fileModifiedMap)){
|
|
164
|
+
context.changedContent.push(changedContent);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
for (let file of configDependencies){
|
|
168
|
+
registerDependency({
|
|
169
|
+
type: "dependency",
|
|
170
|
+
file
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return context;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
}
|