tailwindcss 3.1.7 → 3.2.0
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/README.md +12 -8
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +44 -0
- package/lib/cli/build/plugin.js +335 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +113 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +12 -0
- package/lib/cli.js +11 -590
- package/lib/corePlugins.js +332 -108
- package/lib/css/preflight.css +5 -0
- package/lib/featureFlags.js +7 -4
- package/lib/index.js +6 -1
- package/lib/lib/content.js +167 -0
- package/lib/lib/defaultExtractor.js +15 -10
- package/lib/lib/detectNesting.js +2 -2
- package/lib/lib/evaluateTailwindFunctions.js +17 -1
- package/lib/lib/expandApplyAtRules.js +71 -37
- package/lib/lib/expandTailwindAtRules.js +10 -42
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +181 -96
- package/lib/lib/normalizeTailwindDirectives.js +1 -1
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/regex.js +1 -1
- package/lib/lib/setupContextUtils.js +339 -100
- package/lib/lib/setupTrackingContext.js +5 -39
- package/lib/lib/sharedState.js +2 -0
- package/lib/public/colors.js +1 -1
- package/lib/util/buildMediaQuery.js +6 -3
- package/lib/util/configurePlugins.js +1 -1
- package/lib/util/dataTypes.js +15 -19
- package/lib/util/formatVariantSelector.js +92 -8
- package/lib/util/getAllConfigs.js +14 -3
- package/lib/util/isValidArbitraryValue.js +1 -1
- package/lib/util/nameClass.js +3 -0
- package/lib/util/negateValue.js +15 -2
- package/lib/util/normalizeConfig.js +17 -3
- package/lib/util/normalizeScreens.js +100 -3
- package/lib/util/parseAnimationValue.js +1 -1
- package/lib/util/parseBoxShadowValue.js +1 -1
- package/lib/util/parseDependency.js +33 -54
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +86 -17
- package/lib/util/resolveConfig.js +3 -3
- package/lib/util/splitAtTopLevelOnly.js +31 -81
- package/lib/util/transformThemeValue.js +9 -2
- package/lib/util/validateConfig.js +1 -1
- package/lib/util/validateFormalSyntax.js +24 -0
- package/package.json +14 -12
- package/peers/.DS_Store +0 -0
- package/peers/.svgo.yml +75 -0
- package/peers/index.js +3690 -2274
- package/peers/orders/concentric-css.json +299 -0
- package/peers/orders/smacss.json +299 -0
- package/peers/orders/source.json +295 -0
- package/plugin.d.ts +3 -3
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/src/.DS_Store +0 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +45 -0
- package/src/cli/build/plugin.js +397 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +134 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +5 -0
- package/src/cli.js +4 -696
- package/src/corePlugins.js +262 -39
- package/src/css/preflight.css +5 -0
- package/src/featureFlags.js +12 -2
- package/src/index.js +5 -0
- package/src/lib/content.js +205 -0
- package/src/lib/defaultExtractor.js +3 -0
- package/src/lib/evaluateTailwindFunctions.js +22 -1
- package/src/lib/expandApplyAtRules.js +76 -29
- package/src/lib/expandTailwindAtRules.js +8 -46
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +224 -105
- package/src/lib/offsets.js +270 -0
- package/src/lib/setupContextUtils.js +376 -89
- package/src/lib/setupTrackingContext.js +4 -45
- package/src/lib/sharedState.js +2 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/dataTypes.js +15 -17
- package/src/util/formatVariantSelector.js +113 -9
- package/src/util/getAllConfigs.js +14 -2
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +22 -2
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +1 -1
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +90 -14
- package/src/util/resolveConfig.js +2 -2
- package/src/util/splitAtTopLevelOnly.js +23 -49
- package/src/util/transformThemeValue.js +9 -1
- package/src/util/validateFormalSyntax.js +34 -0
- package/stubs/defaultConfig.stub.js +19 -3
- package/tmp.css +11 -0
- package/tmp.dependency-graph.js +2 -0
- package/tmp.in.css +3 -0
- package/tmp.js +0 -0
- package/tmp.out.css +524 -0
- package/types/config.d.ts +47 -13
- package/types/generated/default-theme.d.ts +11 -0
- package/CHANGELOG.md +0 -2222
|
@@ -20,7 +20,6 @@ const _url = /*#__PURE__*/ _interopRequireDefault(require("url"));
|
|
|
20
20
|
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
21
21
|
const _dlv = /*#__PURE__*/ _interopRequireDefault(require("dlv"));
|
|
22
22
|
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
23
|
-
const _featureFlagsJs = require("../featureFlags.js");
|
|
24
23
|
const _transformThemeValue = /*#__PURE__*/ _interopRequireDefault(require("../util/transformThemeValue"));
|
|
25
24
|
const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
|
|
26
25
|
const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
|
|
@@ -28,7 +27,6 @@ const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isP
|
|
|
28
27
|
const _escapeClassName = /*#__PURE__*/ _interopRequireDefault(require("../util/escapeClassName"));
|
|
29
28
|
const _nameClass = /*#__PURE__*/ _interopRequireWildcard(require("../util/nameClass"));
|
|
30
29
|
const _pluginUtils = require("../util/pluginUtils");
|
|
31
|
-
const _bigSign = /*#__PURE__*/ _interopRequireDefault(require("../util/bigSign"));
|
|
32
30
|
const _corePlugins = require("../corePlugins");
|
|
33
31
|
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
34
32
|
const _toPath = require("../util/toPath");
|
|
@@ -37,6 +35,9 @@ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("../util/negat
|
|
|
37
35
|
const _isValidArbitraryValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
38
36
|
const _generateRules = require("./generateRules");
|
|
39
37
|
const _cacheInvalidationJs = require("./cacheInvalidation.js");
|
|
38
|
+
const _offsetsJs = require("./offsets.js");
|
|
39
|
+
const _featureFlagsJs = require("../featureFlags.js");
|
|
40
|
+
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
40
41
|
function _interopRequireDefault(obj) {
|
|
41
42
|
return obj && obj.__esModule ? obj : {
|
|
42
43
|
default: obj
|
|
@@ -81,11 +82,36 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
81
82
|
}
|
|
82
83
|
return newObj;
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
const VARIANT_TYPES = {
|
|
86
|
+
AddVariant: Symbol.for("ADD_VARIANT"),
|
|
87
|
+
MatchVariant: Symbol.for("MATCH_VARIANT")
|
|
88
|
+
};
|
|
89
|
+
const VARIANT_INFO = {
|
|
90
|
+
Base: 1 << 0,
|
|
91
|
+
Dynamic: 1 << 1
|
|
92
|
+
};
|
|
85
93
|
function prefix(context, selector) {
|
|
86
94
|
let prefix = context.tailwindConfig.prefix;
|
|
87
95
|
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
|
|
88
96
|
}
|
|
97
|
+
function normalizeOptionTypes({ type ="any" , ...options }) {
|
|
98
|
+
let types = [].concat(type);
|
|
99
|
+
return {
|
|
100
|
+
...options,
|
|
101
|
+
types: types.map((type)=>{
|
|
102
|
+
if (Array.isArray(type)) {
|
|
103
|
+
return {
|
|
104
|
+
type: type[0],
|
|
105
|
+
...type[1]
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
type,
|
|
110
|
+
preferOnConflict: false
|
|
111
|
+
};
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
}
|
|
89
115
|
function parseVariantFormatString(input) {
|
|
90
116
|
if (input.includes("{")) {
|
|
91
117
|
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
@@ -232,7 +258,13 @@ function parseVariant(variant) {
|
|
|
232
258
|
}
|
|
233
259
|
};
|
|
234
260
|
}
|
|
235
|
-
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @param {any} tailwindConfig
|
|
264
|
+
* @param {any} context
|
|
265
|
+
* @param {object} param2
|
|
266
|
+
* @param {Offsets} param2.offsets
|
|
267
|
+
*/ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
236
268
|
function getConfigValue(path, defaultValue) {
|
|
237
269
|
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
238
270
|
}
|
|
@@ -262,6 +294,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
262
294
|
opacityValue
|
|
263
295
|
})
|
|
264
296
|
});
|
|
297
|
+
let variantIdentifier = 0;
|
|
265
298
|
let api = {
|
|
266
299
|
postcss: _postcss.default,
|
|
267
300
|
prefix: applyConfiguredPrefix,
|
|
@@ -284,7 +317,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
284
317
|
addBase (base) {
|
|
285
318
|
for (let [identifier, rule] of withIdentifiers(base)){
|
|
286
319
|
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
287
|
-
let offset = offsets.base
|
|
320
|
+
let offset = offsets.create("base");
|
|
288
321
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
289
322
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
290
323
|
}
|
|
@@ -311,7 +344,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
311
344
|
}
|
|
312
345
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
313
346
|
{
|
|
314
|
-
sort: offsets.
|
|
347
|
+
sort: offsets.create("defaults"),
|
|
315
348
|
layer: "defaults"
|
|
316
349
|
},
|
|
317
350
|
rule
|
|
@@ -333,7 +366,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
333
366
|
}
|
|
334
367
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
335
368
|
{
|
|
336
|
-
sort: offsets.components
|
|
369
|
+
sort: offsets.create("components"),
|
|
337
370
|
layer: "components",
|
|
338
371
|
options
|
|
339
372
|
},
|
|
@@ -356,7 +389,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
356
389
|
}
|
|
357
390
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
358
391
|
{
|
|
359
|
-
sort: offsets.utilities
|
|
392
|
+
sort: offsets.create("utilities"),
|
|
360
393
|
layer: "utilities",
|
|
361
394
|
options
|
|
362
395
|
},
|
|
@@ -367,13 +400,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
367
400
|
matchUtilities: function(utilities, options) {
|
|
368
401
|
let defaultOptions = {
|
|
369
402
|
respectPrefix: true,
|
|
370
|
-
respectImportant: true
|
|
403
|
+
respectImportant: true,
|
|
404
|
+
modifiers: false
|
|
371
405
|
};
|
|
372
|
-
options = {
|
|
406
|
+
options = normalizeOptionTypes({
|
|
373
407
|
...defaultOptions,
|
|
374
408
|
...options
|
|
375
|
-
};
|
|
376
|
-
let offset = offsets.utilities
|
|
409
|
+
});
|
|
410
|
+
let offset = offsets.create("utilities");
|
|
377
411
|
for(let identifier in utilities){
|
|
378
412
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
379
413
|
let rule = utilities[identifier];
|
|
@@ -382,19 +416,35 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
382
416
|
options
|
|
383
417
|
]);
|
|
384
418
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
385
|
-
let
|
|
386
|
-
type = [].concat(type);
|
|
387
|
-
let [value, coercedType] = (0, _pluginUtils.coerceValue)(type, modifier, options, tailwindConfig);
|
|
419
|
+
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
388
420
|
if (value === undefined) {
|
|
389
421
|
return [];
|
|
390
422
|
}
|
|
391
|
-
if (!
|
|
392
|
-
|
|
423
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
424
|
+
if (isOnlyPlugin) {
|
|
425
|
+
_log.default.warn([
|
|
426
|
+
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
427
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
428
|
+
]);
|
|
429
|
+
} else {
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
393
432
|
}
|
|
394
433
|
if (!(0, _isValidArbitraryValue.default)(value)) {
|
|
395
434
|
return [];
|
|
396
435
|
}
|
|
397
|
-
let
|
|
436
|
+
let extras = {
|
|
437
|
+
get modifier () {
|
|
438
|
+
if (!options.modifiers) {
|
|
439
|
+
_log.default.warn(`modifier-used-without-options-for-${identifier}`, [
|
|
440
|
+
"Your plugin must set `modifiers: true` in its options to support modifiers."
|
|
441
|
+
]);
|
|
442
|
+
}
|
|
443
|
+
return utilityModifier;
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
447
|
+
let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
|
|
398
448
|
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
399
449
|
}));
|
|
400
450
|
return ruleSets;
|
|
@@ -416,13 +466,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
416
466
|
matchComponents: function(components, options) {
|
|
417
467
|
let defaultOptions = {
|
|
418
468
|
respectPrefix: true,
|
|
419
|
-
respectImportant: false
|
|
469
|
+
respectImportant: false,
|
|
470
|
+
modifiers: false
|
|
420
471
|
};
|
|
421
|
-
options = {
|
|
472
|
+
options = normalizeOptionTypes({
|
|
422
473
|
...defaultOptions,
|
|
423
474
|
...options
|
|
424
|
-
};
|
|
425
|
-
let offset = offsets.components
|
|
475
|
+
});
|
|
476
|
+
let offset = offsets.create("components");
|
|
426
477
|
for(let identifier in components){
|
|
427
478
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
428
479
|
let rule = components[identifier];
|
|
@@ -431,17 +482,15 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
431
482
|
options
|
|
432
483
|
]);
|
|
433
484
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
434
|
-
let
|
|
435
|
-
type = [].concat(type);
|
|
436
|
-
let [value, coercedType] = (0, _pluginUtils.coerceValue)(type, modifier, options, tailwindConfig);
|
|
485
|
+
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
437
486
|
if (value === undefined) {
|
|
438
487
|
return [];
|
|
439
488
|
}
|
|
440
|
-
if (!
|
|
489
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
441
490
|
if (isOnlyPlugin) {
|
|
442
491
|
_log.default.warn([
|
|
443
492
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
444
|
-
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}
|
|
493
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
445
494
|
]);
|
|
446
495
|
} else {
|
|
447
496
|
return [];
|
|
@@ -450,7 +499,18 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
450
499
|
if (!(0, _isValidArbitraryValue.default)(value)) {
|
|
451
500
|
return [];
|
|
452
501
|
}
|
|
453
|
-
let
|
|
502
|
+
let extras = {
|
|
503
|
+
get modifier () {
|
|
504
|
+
if (!options.modifiers) {
|
|
505
|
+
_log.default.warn(`modifier-used-without-options-for-${identifier}`, [
|
|
506
|
+
"Your plugin must set `modifiers: true` in its options to support modifiers."
|
|
507
|
+
]);
|
|
508
|
+
}
|
|
509
|
+
return utilityModifier;
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
513
|
+
let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
|
|
454
514
|
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
455
515
|
}));
|
|
456
516
|
return ruleSets;
|
|
@@ -479,7 +539,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
479
539
|
modifySelectors,
|
|
480
540
|
container,
|
|
481
541
|
separator
|
|
482
|
-
},
|
|
542
|
+
}, options.type === VARIANT_TYPES.MatchVariant && {
|
|
483
543
|
args,
|
|
484
544
|
wrap,
|
|
485
545
|
format
|
|
@@ -502,21 +562,51 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
502
562
|
});
|
|
503
563
|
insertInto(variantList, variantName, options);
|
|
504
564
|
variantMap.set(variantName, variantFunctions);
|
|
565
|
+
context.variantOptions.set(variantName, options);
|
|
566
|
+
},
|
|
567
|
+
matchVariant (variant, variantFn, options) {
|
|
568
|
+
var ref;
|
|
569
|
+
// A unique identifier that "groups" these variants together.
|
|
570
|
+
// This is for internal use only which is why it is not present in the types
|
|
571
|
+
let id = (ref = options === null || options === void 0 ? void 0 : options.id) !== null && ref !== void 0 ? ref : ++variantIdentifier;
|
|
572
|
+
let isSpecial = variant === "@";
|
|
573
|
+
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
574
|
+
var ref1;
|
|
575
|
+
for (let [key, value] of Object.entries((ref1 = options === null || options === void 0 ? void 0 : options.values) !== null && ref1 !== void 0 ? ref1 : {})){
|
|
576
|
+
if (key === "DEFAULT") continue;
|
|
577
|
+
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>variantFn(value, modifiersEnabled ? {
|
|
578
|
+
modifier: args.modifier,
|
|
579
|
+
container
|
|
580
|
+
} : {
|
|
581
|
+
container
|
|
582
|
+
}), {
|
|
583
|
+
...options,
|
|
584
|
+
value,
|
|
585
|
+
id,
|
|
586
|
+
type: VARIANT_TYPES.MatchVariant,
|
|
587
|
+
variantInfo: VARIANT_INFO.Base
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
var ref2;
|
|
591
|
+
let hasDefault = "DEFAULT" in ((ref2 = options === null || options === void 0 ? void 0 : options.values) !== null && ref2 !== void 0 ? ref2 : {});
|
|
592
|
+
api.addVariant(variant, ({ args , container })=>{
|
|
593
|
+
if (args.value === _sharedState.NONE && !hasDefault) {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
return variantFn(args.value === _sharedState.NONE ? options.values.DEFAULT : args.value, modifiersEnabled ? {
|
|
597
|
+
modifier: args.modifier,
|
|
598
|
+
container
|
|
599
|
+
} : {
|
|
600
|
+
container
|
|
601
|
+
});
|
|
602
|
+
}, {
|
|
603
|
+
...options,
|
|
604
|
+
id,
|
|
605
|
+
type: VARIANT_TYPES.MatchVariant,
|
|
606
|
+
variantInfo: VARIANT_INFO.Dynamic
|
|
607
|
+
});
|
|
505
608
|
}
|
|
506
609
|
};
|
|
507
|
-
if ((0, _featureFlagsJs.flagEnabled)(tailwindConfig, "matchVariant")) {
|
|
508
|
-
api.matchVariant = function(variants, options) {
|
|
509
|
-
for(let variant in variants){
|
|
510
|
-
var ref;
|
|
511
|
-
for (let [k, v] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
512
|
-
api.addVariant(`${variant}-${k}`, variants[variant](v));
|
|
513
|
-
}
|
|
514
|
-
api.addVariant(variant, Object.assign(({ args })=>variants[variant](args), {
|
|
515
|
-
[MATCH_VARIANT]: true
|
|
516
|
-
}), options);
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
610
|
return api;
|
|
521
611
|
}
|
|
522
612
|
let fileModifiedMapCache = new WeakMap();
|
|
@@ -627,16 +717,19 @@ function resolvePlugins(context, root) {
|
|
|
627
717
|
// were historically sorted before screen/stackable variants.
|
|
628
718
|
let beforeVariants = [
|
|
629
719
|
_corePlugins.variantPlugins["pseudoElementVariants"],
|
|
630
|
-
_corePlugins.variantPlugins["pseudoClassVariants"],
|
|
720
|
+
_corePlugins.variantPlugins["pseudoClassVariants"],
|
|
721
|
+
_corePlugins.variantPlugins["ariaVariants"],
|
|
722
|
+
_corePlugins.variantPlugins["dataVariants"]
|
|
631
723
|
];
|
|
632
724
|
let afterVariants = [
|
|
725
|
+
_corePlugins.variantPlugins["supportsVariants"],
|
|
633
726
|
_corePlugins.variantPlugins["directionVariants"],
|
|
634
727
|
_corePlugins.variantPlugins["reducedMotionVariants"],
|
|
635
728
|
_corePlugins.variantPlugins["prefersContrastVariants"],
|
|
636
729
|
_corePlugins.variantPlugins["darkVariants"],
|
|
637
730
|
_corePlugins.variantPlugins["printVariant"],
|
|
638
731
|
_corePlugins.variantPlugins["screenVariants"],
|
|
639
|
-
_corePlugins.variantPlugins["orientationVariants"]
|
|
732
|
+
_corePlugins.variantPlugins["orientationVariants"]
|
|
640
733
|
];
|
|
641
734
|
return [
|
|
642
735
|
...corePluginList,
|
|
@@ -649,13 +742,9 @@ function resolvePlugins(context, root) {
|
|
|
649
742
|
function registerPlugins(plugins, context) {
|
|
650
743
|
let variantList = [];
|
|
651
744
|
let variantMap = new Map();
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
components: 0n,
|
|
656
|
-
utilities: 0n,
|
|
657
|
-
user: 0n
|
|
658
|
-
};
|
|
745
|
+
context.variantMap = variantMap;
|
|
746
|
+
let offsets = new _offsetsJs.Offsets();
|
|
747
|
+
context.offsets = offsets;
|
|
659
748
|
let classList = new Set();
|
|
660
749
|
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
661
750
|
variantList,
|
|
@@ -672,43 +761,12 @@ function registerPlugins(plugins, context) {
|
|
|
672
761
|
plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
|
|
673
762
|
}
|
|
674
763
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
offsets.defaults,
|
|
678
|
-
offsets.components,
|
|
679
|
-
offsets.utilities,
|
|
680
|
-
offsets.user,
|
|
681
|
-
]);
|
|
682
|
-
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
683
|
-
// A number one less than the top range of the highest offset area
|
|
684
|
-
// so arbitrary properties are always sorted at the end.
|
|
685
|
-
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
686
|
-
context.layerOrder = {
|
|
687
|
-
defaults: 1n << reservedBits << 0n,
|
|
688
|
-
base: 1n << reservedBits << 1n,
|
|
689
|
-
components: 1n << reservedBits << 2n,
|
|
690
|
-
utilities: 1n << reservedBits << 3n,
|
|
691
|
-
user: 1n << reservedBits << 4n
|
|
692
|
-
};
|
|
693
|
-
reservedBits += 5n;
|
|
694
|
-
let offset = 0;
|
|
695
|
-
context.variantOrder = new Map(variantList.map((variant, i)=>{
|
|
696
|
-
let variantFunctions = variantMap.get(variant).length;
|
|
697
|
-
let bits = 1n << BigInt(i + offset) << reservedBits;
|
|
698
|
-
offset += variantFunctions - 1;
|
|
699
|
-
return [
|
|
700
|
-
variant,
|
|
701
|
-
bits
|
|
702
|
-
];
|
|
703
|
-
}).sort(([, a], [, z])=>(0, _bigSign.default)(a - z)));
|
|
704
|
-
context.minimumScreen = [
|
|
705
|
-
...context.variantOrder.values()
|
|
706
|
-
].shift();
|
|
764
|
+
// Make sure to record bit masks for every variant
|
|
765
|
+
offsets.recordVariants(variantList, (variant)=>variantMap.get(variant).length);
|
|
707
766
|
// Build variantMap
|
|
708
767
|
for (let [variantName, variantFunctions] of variantMap.entries()){
|
|
709
|
-
let sort = context.variantOrder.get(variantName);
|
|
710
768
|
context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
|
|
711
|
-
|
|
769
|
+
offsets.forVariant(variantName, idx),
|
|
712
770
|
variantFunction
|
|
713
771
|
]));
|
|
714
772
|
}
|
|
@@ -728,7 +786,7 @@ function registerPlugins(plugins, context) {
|
|
|
728
786
|
_log.default.warn("root-regex", [
|
|
729
787
|
"Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
|
|
730
788
|
"Update your `safelist` configuration to eliminate this warning.",
|
|
731
|
-
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
789
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
732
790
|
]);
|
|
733
791
|
continue;
|
|
734
792
|
}
|
|
@@ -756,13 +814,13 @@ function registerPlugins(plugins, context) {
|
|
|
756
814
|
// So we add the negative after the prefix
|
|
757
815
|
classes = [
|
|
758
816
|
...classes,
|
|
759
|
-
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
|
|
817
|
+
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
|
|
760
818
|
];
|
|
761
819
|
}
|
|
762
|
-
if (
|
|
820
|
+
if (options.types.some(({ type })=>type === "color")) {
|
|
763
821
|
classes = [
|
|
764
822
|
...classes,
|
|
765
|
-
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
|
|
823
|
+
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
|
|
766
824
|
];
|
|
767
825
|
}
|
|
768
826
|
return classes;
|
|
@@ -797,33 +855,45 @@ function registerPlugins(plugins, context) {
|
|
|
797
855
|
_log.default.warn([
|
|
798
856
|
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
799
857
|
"Fix this pattern or remove it from your `safelist` configuration.",
|
|
800
|
-
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
858
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
801
859
|
]);
|
|
802
860
|
}
|
|
803
861
|
}
|
|
804
862
|
}
|
|
863
|
+
var _darkMode, ref;
|
|
864
|
+
let darkClassName = (ref = [].concat((_darkMode = context.tailwindConfig.darkMode) !== null && _darkMode !== void 0 ? _darkMode : "media")[1]) !== null && ref !== void 0 ? ref : "dark";
|
|
805
865
|
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
806
866
|
// that don't exist on their own. This will result in them "not existing" and
|
|
807
867
|
// sorting could be weird since you still require them in order to make the
|
|
808
|
-
// host
|
|
809
|
-
let parasiteUtilities =
|
|
868
|
+
// host utilities work properly. (Thanks Biology)
|
|
869
|
+
let parasiteUtilities = [
|
|
870
|
+
prefix(context, darkClassName),
|
|
810
871
|
prefix(context, "group"),
|
|
811
872
|
prefix(context, "peer")
|
|
812
|
-
]
|
|
873
|
+
];
|
|
813
874
|
context.getClassOrder = function getClassOrder(classes) {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
875
|
+
// Non-util classes won't be generated, so we default them to null
|
|
876
|
+
let sortedClassNames = new Map(classes.map((className)=>[
|
|
877
|
+
className,
|
|
878
|
+
null
|
|
879
|
+
]));
|
|
880
|
+
// Sort all classes in order
|
|
881
|
+
// Non-tailwind classes won't be generated and will be left as `null`
|
|
882
|
+
let rules = (0, _generateRules.generateRules)(new Set(classes), context);
|
|
883
|
+
rules = context.offsets.sort(rules);
|
|
884
|
+
let idx = BigInt(parasiteUtilities.length);
|
|
885
|
+
for (const [, rule] of rules){
|
|
886
|
+
sortedClassNames.set(rule.raws.tailwind.candidate, idx++);
|
|
818
887
|
}
|
|
819
888
|
return classes.map((className)=>{
|
|
820
889
|
var ref;
|
|
821
890
|
let order = (ref = sortedClassNames.get(className)) !== null && ref !== void 0 ? ref : null;
|
|
822
|
-
|
|
891
|
+
let parasiteIndex = parasiteUtilities.indexOf(className);
|
|
892
|
+
if (order === null && parasiteIndex !== -1) {
|
|
823
893
|
// This will make sure that it is at the very beginning of the
|
|
824
894
|
// `components` layer which technically means 'before any
|
|
825
895
|
// components'.
|
|
826
|
-
order =
|
|
896
|
+
order = BigInt(parasiteIndex);
|
|
827
897
|
}
|
|
828
898
|
return [
|
|
829
899
|
className,
|
|
@@ -841,6 +911,10 @@ function registerPlugins(plugins, context) {
|
|
|
841
911
|
let negativeClasses = [];
|
|
842
912
|
var ref;
|
|
843
913
|
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
914
|
+
// Ignore undefined and null values
|
|
915
|
+
if (value == null) {
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
844
918
|
output.push((0, _nameClass.formatClass)(utilName, key));
|
|
845
919
|
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue.default)(value)) {
|
|
846
920
|
negativeClasses.push((0, _nameClass.formatClass)(utilName, `-${key}`));
|
|
@@ -853,11 +927,170 @@ function registerPlugins(plugins, context) {
|
|
|
853
927
|
}
|
|
854
928
|
return output;
|
|
855
929
|
};
|
|
930
|
+
// Generate a list of available variants with meta information of the type of variant.
|
|
931
|
+
context.getVariants = function getVariants() {
|
|
932
|
+
let result = [];
|
|
933
|
+
for (let [name, options] of context.variantOptions.entries()){
|
|
934
|
+
if (options.variantInfo === VARIANT_INFO.Base) continue;
|
|
935
|
+
var _values;
|
|
936
|
+
result.push({
|
|
937
|
+
name,
|
|
938
|
+
isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
|
|
939
|
+
values: Object.keys((_values = options.values) !== null && _values !== void 0 ? _values : {}),
|
|
940
|
+
hasDash: name !== "@",
|
|
941
|
+
selectors ({ modifier , value } = {}) {
|
|
942
|
+
let candidate = "__TAILWIND_PLACEHOLDER__";
|
|
943
|
+
let rule = _postcss.default.rule({
|
|
944
|
+
selector: `.${candidate}`
|
|
945
|
+
});
|
|
946
|
+
let container = _postcss.default.root({
|
|
947
|
+
nodes: [
|
|
948
|
+
rule.clone()
|
|
949
|
+
]
|
|
950
|
+
});
|
|
951
|
+
let before = container.toString();
|
|
952
|
+
var ref;
|
|
953
|
+
let fns = ((ref = context.variantMap.get(name)) !== null && ref !== void 0 ? ref : []).flatMap(([_, fn])=>fn);
|
|
954
|
+
let formatStrings = [];
|
|
955
|
+
for (let fn of fns){
|
|
956
|
+
var ref1;
|
|
957
|
+
let localFormatStrings = [];
|
|
958
|
+
var ref2;
|
|
959
|
+
let api = {
|
|
960
|
+
args: {
|
|
961
|
+
modifier,
|
|
962
|
+
value: (ref2 = (ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[value]) !== null && ref2 !== void 0 ? ref2 : value
|
|
963
|
+
},
|
|
964
|
+
separator: context.tailwindConfig.separator,
|
|
965
|
+
modifySelectors (modifierFunction) {
|
|
966
|
+
// Run the modifierFunction over each rule
|
|
967
|
+
container.each((rule)=>{
|
|
968
|
+
if (rule.type !== "rule") {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
rule.selectors = rule.selectors.map((selector)=>{
|
|
972
|
+
return modifierFunction({
|
|
973
|
+
get className () {
|
|
974
|
+
return (0, _generateRules.getClassNameFromSelector)(selector);
|
|
975
|
+
},
|
|
976
|
+
selector
|
|
977
|
+
});
|
|
978
|
+
});
|
|
979
|
+
});
|
|
980
|
+
return container;
|
|
981
|
+
},
|
|
982
|
+
format (str) {
|
|
983
|
+
localFormatStrings.push(str);
|
|
984
|
+
},
|
|
985
|
+
wrap (wrapper) {
|
|
986
|
+
localFormatStrings.push(`@${wrapper.name} ${wrapper.params} { & }`);
|
|
987
|
+
},
|
|
988
|
+
container
|
|
989
|
+
};
|
|
990
|
+
let ruleWithVariant = fn(api);
|
|
991
|
+
if (localFormatStrings.length > 0) {
|
|
992
|
+
formatStrings.push(localFormatStrings);
|
|
993
|
+
}
|
|
994
|
+
if (Array.isArray(ruleWithVariant)) {
|
|
995
|
+
for (let variantFunction of ruleWithVariant){
|
|
996
|
+
localFormatStrings = [];
|
|
997
|
+
variantFunction(api);
|
|
998
|
+
formatStrings.push(localFormatStrings);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
// Reverse engineer the result of the `container`
|
|
1003
|
+
let manualFormatStrings = [];
|
|
1004
|
+
let after = container.toString();
|
|
1005
|
+
if (before !== after) {
|
|
1006
|
+
// Figure out all selectors
|
|
1007
|
+
container.walkRules((rule)=>{
|
|
1008
|
+
let modified = rule.selector;
|
|
1009
|
+
// Rebuild the base selector, this is what plugin authors would do
|
|
1010
|
+
// as well. E.g.: `${variant}${separator}${className}`.
|
|
1011
|
+
// However, plugin authors probably also prepend or append certain
|
|
1012
|
+
// classes, pseudos, ids, ...
|
|
1013
|
+
let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
1014
|
+
selectors.walkClasses((classNode)=>{
|
|
1015
|
+
classNode.value = `${name}${context.tailwindConfig.separator}${classNode.value}`;
|
|
1016
|
+
});
|
|
1017
|
+
}).processSync(modified);
|
|
1018
|
+
// Now that we know the original selector, the new selector, and
|
|
1019
|
+
// the rebuild part in between, we can replace the part that plugin
|
|
1020
|
+
// authors need to rebuild with `&`, and eventually store it in the
|
|
1021
|
+
// collectedFormats. Similar to what `format('...')` would do.
|
|
1022
|
+
//
|
|
1023
|
+
// E.g.:
|
|
1024
|
+
// variant: foo
|
|
1025
|
+
// selector: .markdown > p
|
|
1026
|
+
// modified (by plugin): .foo .foo\\:markdown > p
|
|
1027
|
+
// rebuiltBase (internal): .foo\\:markdown > p
|
|
1028
|
+
// format: .foo &
|
|
1029
|
+
manualFormatStrings.push(modified.replace(rebuiltBase, "&").replace(candidate, "&"));
|
|
1030
|
+
});
|
|
1031
|
+
// Figure out all atrules
|
|
1032
|
+
container.walkAtRules((atrule)=>{
|
|
1033
|
+
manualFormatStrings.push(`@${atrule.name} (${atrule.params}) { & }`);
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
var _values;
|
|
1037
|
+
let result = formatStrings.map((formatString)=>(0, _formatVariantSelector.finalizeSelector)((0, _formatVariantSelector.formatVariantSelector)("&", ...formatString), {
|
|
1038
|
+
selector: `.${candidate}`,
|
|
1039
|
+
candidate,
|
|
1040
|
+
context,
|
|
1041
|
+
isArbitraryVariant: !(value in ((_values = options.values) !== null && _values !== void 0 ? _values : {}))
|
|
1042
|
+
}).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
|
|
1043
|
+
if (manualFormatStrings.length > 0) {
|
|
1044
|
+
result.push((0, _formatVariantSelector.formatVariantSelector)("&", ...manualFormatStrings));
|
|
1045
|
+
}
|
|
1046
|
+
return result;
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
return result;
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Mark as class as retroactively invalid
|
|
1055
|
+
*
|
|
1056
|
+
*
|
|
1057
|
+
* @param {string} candidate
|
|
1058
|
+
*/ function markInvalidUtilityCandidate(context, candidate) {
|
|
1059
|
+
if (!context.classCache.has(candidate)) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
// Mark this as not being a real utility
|
|
1063
|
+
context.notClassCache.add(candidate);
|
|
1064
|
+
// Remove it from any candidate-specific caches
|
|
1065
|
+
context.classCache.delete(candidate);
|
|
1066
|
+
context.applyClassCache.delete(candidate);
|
|
1067
|
+
context.candidateRuleMap.delete(candidate);
|
|
1068
|
+
context.candidateRuleCache.delete(candidate);
|
|
1069
|
+
// Ensure the stylesheet gets rebuilt
|
|
1070
|
+
context.stylesheetCache = null;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Mark as class as retroactively invalid
|
|
1074
|
+
*
|
|
1075
|
+
* @param {import('postcss').Node} node
|
|
1076
|
+
*/ function markInvalidUtilityNode(context, node) {
|
|
1077
|
+
let candidate = node.raws.tailwind.candidate;
|
|
1078
|
+
if (!candidate) {
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
for (const entry of context.ruleCache){
|
|
1082
|
+
if (entry[1].raws.tailwind.candidate === candidate) {
|
|
1083
|
+
context.ruleCache.delete(entry);
|
|
1084
|
+
// context.postCssNodeCache.delete(node)
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
markInvalidUtilityCandidate(context, candidate);
|
|
856
1088
|
}
|
|
857
1089
|
function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
|
|
858
1090
|
let context = {
|
|
859
1091
|
disposables: [],
|
|
860
1092
|
ruleCache: new Set(),
|
|
1093
|
+
candidateRuleCache: new Map(),
|
|
861
1094
|
classCache: new Map(),
|
|
862
1095
|
applyClassCache: new Map(),
|
|
863
1096
|
notClassCache: new Set(),
|
|
@@ -866,7 +1099,10 @@ function createContext(tailwindConfig, changedContent = [], root = _postcss.defa
|
|
|
866
1099
|
tailwindConfig,
|
|
867
1100
|
changedContent: changedContent,
|
|
868
1101
|
variantMap: new Map(),
|
|
869
|
-
stylesheetCache: null
|
|
1102
|
+
stylesheetCache: null,
|
|
1103
|
+
variantOptions: new Map(),
|
|
1104
|
+
markInvalidUtilityCandidate: (candidate)=>markInvalidUtilityCandidate(context, candidate),
|
|
1105
|
+
markInvalidUtilityNode: (node)=>markInvalidUtilityNode(context, node)
|
|
870
1106
|
};
|
|
871
1107
|
let resolvedPlugins = resolvePlugins(context, root);
|
|
872
1108
|
registerPlugins(resolvedPlugins, context);
|
|
@@ -926,6 +1162,9 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
926
1162
|
}
|
|
927
1163
|
_sharedState.env.DEBUG && console.log("Setting up new context...");
|
|
928
1164
|
let context2 = createContext(tailwindConfig, [], root);
|
|
1165
|
+
Object.assign(context2, {
|
|
1166
|
+
userConfigPath
|
|
1167
|
+
});
|
|
929
1168
|
trackModified([
|
|
930
1169
|
...contextDependencies
|
|
931
1170
|
], getFileModifiedMap(context2));
|