tailwindcss 0.0.0-insiders.eeec89a → 0.0.0-insiders.eef91c9
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 +1 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +0 -3
- package/lib/cli/build/plugin.js +66 -126
- package/lib/cli/build/watching.js +2 -2
- package/lib/cli/help/index.js +2 -2
- package/lib/cli/index.js +3 -4
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +318 -185
- package/lib/css/preflight.css +20 -9
- package/lib/featureFlags.js +9 -15
- package/lib/lib/content.js +2 -28
- package/lib/lib/defaultExtractor.js +33 -25
- package/lib/lib/evaluateTailwindFunctions.js +4 -4
- package/lib/lib/expandApplyAtRules.js +19 -0
- package/lib/lib/expandTailwindAtRules.js +22 -58
- package/lib/lib/generateRules.js +47 -27
- package/lib/lib/load-config.js +18 -3
- package/lib/lib/normalizeTailwindDirectives.js +15 -0
- package/lib/lib/offsets.js +53 -4
- package/lib/lib/resolveDefaultsAtRules.js +4 -2
- package/lib/lib/setupContextUtils.js +108 -80
- package/lib/lib/setupTrackingContext.js +2 -3
- package/lib/lib/substituteScreenAtRules.js +2 -2
- package/lib/plugin.js +0 -116
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +2 -2
- package/lib/processTailwindFeatures.js +1 -3
- package/lib/public/colors.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +4 -4
- package/lib/util/createUtilityPlugin.js +2 -2
- package/lib/util/dataTypes.js +69 -6
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/formatVariantSelector.js +12 -7
- package/lib/util/getAllConfigs.js +2 -3
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/log.js +0 -17
- package/lib/util/normalizeConfig.js +28 -59
- package/lib/util/normalizeScreens.js +3 -3
- package/lib/util/pluginUtils.js +22 -7
- package/lib/util/pseudoElements.js +3 -0
- package/lib/util/resolveConfig.js +6 -10
- package/lib/util/validateConfig.js +0 -11
- package/lib/util/withAlphaVariable.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +39 -34
- package/peers/index.js +96671 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +157 -44
- package/src/css/preflight.css +20 -9
- package/src/featureFlags.js +3 -9
- package/src/lib/content.js +1 -33
- package/src/lib/defaultExtractor.js +30 -17
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +43 -22
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/color.js +1 -1
- package/src/util/dataTypes.js +78 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +21 -1
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +75 -16
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +34 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
|
@@ -49,6 +49,7 @@ const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_defaul
|
|
|
49
49
|
const _generateRules = require("./generateRules");
|
|
50
50
|
const _cacheInvalidation = require("./cacheInvalidation.js");
|
|
51
51
|
const _offsets = require("./offsets.js");
|
|
52
|
+
const _featureFlags = require("../featureFlags.js");
|
|
52
53
|
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
53
54
|
function _interop_require_default(obj) {
|
|
54
55
|
return obj && obj.__esModule ? obj : {
|
|
@@ -107,7 +108,7 @@ function prefix(context, selector) {
|
|
|
107
108
|
let prefix = context.tailwindConfig.prefix;
|
|
108
109
|
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
|
|
109
110
|
}
|
|
110
|
-
function normalizeOptionTypes({ type =
|
|
111
|
+
function normalizeOptionTypes({ type ="any" , ...options }) {
|
|
111
112
|
let types = [].concat(type);
|
|
112
113
|
return {
|
|
113
114
|
...options,
|
|
@@ -162,7 +163,7 @@ function parseVariantFormatString(input) {
|
|
|
162
163
|
parts = parts.filter((part)=>part !== "");
|
|
163
164
|
return parts;
|
|
164
165
|
}
|
|
165
|
-
function insertInto(list, value, { before =
|
|
166
|
+
function insertInto(list, value, { before =[] } = {}) {
|
|
166
167
|
before = [].concat(before);
|
|
167
168
|
if (before.length <= 0) {
|
|
168
169
|
list.push(value);
|
|
@@ -200,39 +201,41 @@ function getClasses(selector, mutate) {
|
|
|
200
201
|
});
|
|
201
202
|
return parser.transformSync(selector);
|
|
202
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Ignore everything inside a :not(...). This allows you to write code like
|
|
206
|
+
* `div:not(.foo)`. If `.foo` is never found in your code, then we used to
|
|
207
|
+
* not generated it. But now we will ignore everything inside a `:not`, so
|
|
208
|
+
* that it still gets generated.
|
|
209
|
+
*
|
|
210
|
+
* @param {selectorParser.Root} selectors
|
|
211
|
+
*/ function ignoreNot(selectors) {
|
|
212
|
+
selectors.walkPseudos((pseudo)=>{
|
|
213
|
+
if (pseudo.value === ":not") {
|
|
214
|
+
pseudo.remove();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
203
218
|
function extractCandidates(node, state = {
|
|
204
219
|
containsNonOnDemandable: false
|
|
205
220
|
}, depth = 0) {
|
|
206
221
|
let classes = [];
|
|
207
|
-
|
|
222
|
+
let selectors = [];
|
|
208
223
|
if (node.type === "rule") {
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
224
|
+
// Handle normal rules
|
|
225
|
+
selectors.push(...node.selectors);
|
|
226
|
+
} else if (node.type === "atrule") {
|
|
227
|
+
// Handle at-rules (which contains nested rules)
|
|
228
|
+
node.walkRules((rule)=>selectors.push(...rule.selectors));
|
|
229
|
+
}
|
|
230
|
+
for (let selector of selectors){
|
|
231
|
+
let classCandidates = getClasses(selector, ignoreNot);
|
|
232
|
+
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
233
|
+
if (classCandidates.length === 0) {
|
|
234
|
+
state.containsNonOnDemandable = true;
|
|
219
235
|
}
|
|
220
|
-
for (let
|
|
221
|
-
|
|
222
|
-
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
223
|
-
if (classCandidates.length === 0) {
|
|
224
|
-
state.containsNonOnDemandable = true;
|
|
225
|
-
}
|
|
226
|
-
for (let classCandidate of classCandidates){
|
|
227
|
-
classes.push(classCandidate);
|
|
228
|
-
}
|
|
236
|
+
for (let classCandidate of classCandidates){
|
|
237
|
+
classes.push(classCandidate);
|
|
229
238
|
}
|
|
230
|
-
} else if (node.type === "atrule") {
|
|
231
|
-
node.walkRules((rule)=>{
|
|
232
|
-
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
|
|
233
|
-
classes.push(classCandidate);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
239
|
}
|
|
237
240
|
if (depth === 0) {
|
|
238
241
|
return [
|
|
@@ -271,15 +274,14 @@ function parseVariant(variant) {
|
|
|
271
274
|
variant = variant.replace(/\n+/g, "").replace(/\s{1,}/g, " ").trim();
|
|
272
275
|
let fns = parseVariantFormatString(variant).map((str)=>{
|
|
273
276
|
if (!str.startsWith("@")) {
|
|
274
|
-
return ({ format
|
|
277
|
+
return ({ format })=>format(str);
|
|
275
278
|
}
|
|
276
279
|
let [, name, params] = /@(\S*)( .+|[({].*)?/g.exec(str);
|
|
277
280
|
var _params_trim;
|
|
278
|
-
return ({ wrap
|
|
279
|
-
var _params;
|
|
281
|
+
return ({ wrap })=>{
|
|
280
282
|
return wrap(_postcss.default.atRule({
|
|
281
283
|
name,
|
|
282
|
-
params: (_params_trim =
|
|
284
|
+
params: (_params_trim = params === null || params === void 0 ? void 0 : params.trim()) !== null && _params_trim !== void 0 ? _params_trim : ""
|
|
283
285
|
}));
|
|
284
286
|
};
|
|
285
287
|
}).reverse();
|
|
@@ -295,7 +297,7 @@ function parseVariant(variant) {
|
|
|
295
297
|
* @param {any} context
|
|
296
298
|
* @param {object} param2
|
|
297
299
|
* @param {Offsets} param2.offsets
|
|
298
|
-
*/ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offsets, classList
|
|
300
|
+
*/ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
299
301
|
function getConfigValue(path, defaultValue) {
|
|
300
302
|
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
301
303
|
}
|
|
@@ -440,12 +442,12 @@ function parseVariant(variant) {
|
|
|
440
442
|
prefixedIdentifier,
|
|
441
443
|
options
|
|
442
444
|
]);
|
|
443
|
-
function wrapped(modifier, { isOnlyPlugin
|
|
445
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
444
446
|
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
445
447
|
if (value === undefined) {
|
|
446
448
|
return [];
|
|
447
449
|
}
|
|
448
|
-
if (!options.types.some(({ type
|
|
450
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
449
451
|
if (isOnlyPlugin) {
|
|
450
452
|
_log.default.warn([
|
|
451
453
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
@@ -468,7 +470,8 @@ function parseVariant(variant) {
|
|
|
468
470
|
return utilityModifier;
|
|
469
471
|
}
|
|
470
472
|
};
|
|
471
|
-
let
|
|
473
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
474
|
+
let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
|
|
472
475
|
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
473
476
|
}));
|
|
474
477
|
return ruleSets;
|
|
@@ -505,12 +508,12 @@ function parseVariant(variant) {
|
|
|
505
508
|
prefixedIdentifier,
|
|
506
509
|
options
|
|
507
510
|
]);
|
|
508
|
-
function wrapped(modifier, { isOnlyPlugin
|
|
511
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
509
512
|
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
510
513
|
if (value === undefined) {
|
|
511
514
|
return [];
|
|
512
515
|
}
|
|
513
|
-
if (!options.types.some(({ type
|
|
516
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
514
517
|
if (isOnlyPlugin) {
|
|
515
518
|
_log.default.warn([
|
|
516
519
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
@@ -533,7 +536,8 @@ function parseVariant(variant) {
|
|
|
533
536
|
return utilityModifier;
|
|
534
537
|
}
|
|
535
538
|
};
|
|
536
|
-
let
|
|
539
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
540
|
+
let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
|
|
537
541
|
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
538
542
|
}));
|
|
539
543
|
return ruleSets;
|
|
@@ -557,7 +561,7 @@ function parseVariant(variant) {
|
|
|
557
561
|
if (typeof variantFunction !== "string") {
|
|
558
562
|
// Safelist public API functions
|
|
559
563
|
return (api = {})=>{
|
|
560
|
-
let { args, modifySelectors, container, separator, wrap, format
|
|
564
|
+
let { args , modifySelectors , container , separator , wrap , format } = api;
|
|
561
565
|
let result = variantFunction(Object.assign({
|
|
562
566
|
modifySelectors,
|
|
563
567
|
container,
|
|
@@ -588,19 +592,20 @@ function parseVariant(variant) {
|
|
|
588
592
|
context.variantOptions.set(variantName, options);
|
|
589
593
|
},
|
|
590
594
|
matchVariant (variant, variantFn, options) {
|
|
591
|
-
var _options, _options1, _options2;
|
|
592
595
|
var _options_id;
|
|
593
596
|
// A unique identifier that "groups" these variants together.
|
|
594
597
|
// This is for internal use only which is why it is not present in the types
|
|
595
|
-
let id = (_options_id =
|
|
598
|
+
let id = (_options_id = options === null || options === void 0 ? void 0 : options.id) !== null && _options_id !== void 0 ? _options_id : ++variantIdentifier;
|
|
596
599
|
let isSpecial = variant === "@";
|
|
600
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
597
601
|
var _options_values;
|
|
598
|
-
for (let [key, value] of Object.entries((_options_values =
|
|
602
|
+
for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
|
|
599
603
|
if (key === "DEFAULT") continue;
|
|
600
|
-
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args, container
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
+
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>{
|
|
605
|
+
return variantFn(value, modifiersEnabled ? {
|
|
606
|
+
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
607
|
+
container
|
|
608
|
+
} : {
|
|
604
609
|
container
|
|
605
610
|
});
|
|
606
611
|
}, {
|
|
@@ -612,16 +617,17 @@ function parseVariant(variant) {
|
|
|
612
617
|
});
|
|
613
618
|
}
|
|
614
619
|
var _options_values1;
|
|
615
|
-
let hasDefault = "DEFAULT" in ((_options_values1 =
|
|
616
|
-
api.addVariant(variant, ({ args, container
|
|
617
|
-
|
|
618
|
-
_args2, _args3;
|
|
619
|
-
if (((_args = args) === null || _args === void 0 ? void 0 : _args.value) === _sharedState.NONE && !hasDefault) {
|
|
620
|
+
let hasDefault = "DEFAULT" in ((_options_values1 = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {});
|
|
621
|
+
api.addVariant(variant, ({ args , container })=>{
|
|
622
|
+
if ((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE && !hasDefault) {
|
|
620
623
|
return null;
|
|
621
624
|
}
|
|
622
|
-
var
|
|
623
|
-
|
|
624
|
-
|
|
625
|
+
var // (JetBrains) plugins.
|
|
626
|
+
_args_value;
|
|
627
|
+
return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (_args_value = args === null || args === void 0 ? void 0 : args.value) !== null && _args_value !== void 0 ? _args_value : typeof args === "string" ? args : "", modifiersEnabled ? {
|
|
628
|
+
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
629
|
+
container
|
|
630
|
+
} : {
|
|
625
631
|
container
|
|
626
632
|
});
|
|
627
633
|
}, {
|
|
@@ -694,7 +700,7 @@ function collectLayerPlugins(root) {
|
|
|
694
700
|
extractVariantAtRules(layerRule);
|
|
695
701
|
if (layerRule.params === "base") {
|
|
696
702
|
for (let node of layerRule.nodes){
|
|
697
|
-
layerPlugins.push(function({ addBase
|
|
703
|
+
layerPlugins.push(function({ addBase }) {
|
|
698
704
|
addBase(node, {
|
|
699
705
|
respectPrefix: false
|
|
700
706
|
});
|
|
@@ -703,7 +709,7 @@ function collectLayerPlugins(root) {
|
|
|
703
709
|
layerRule.remove();
|
|
704
710
|
} else if (layerRule.params === "components") {
|
|
705
711
|
for (let node of layerRule.nodes){
|
|
706
|
-
layerPlugins.push(function({ addComponents
|
|
712
|
+
layerPlugins.push(function({ addComponents }) {
|
|
707
713
|
addComponents(node, {
|
|
708
714
|
respectPrefix: false,
|
|
709
715
|
preserveSource: true
|
|
@@ -713,7 +719,7 @@ function collectLayerPlugins(root) {
|
|
|
713
719
|
layerRule.remove();
|
|
714
720
|
} else if (layerRule.params === "utilities") {
|
|
715
721
|
for (let node of layerRule.nodes){
|
|
716
|
-
layerPlugins.push(function({ addUtilities
|
|
722
|
+
layerPlugins.push(function({ addUtilities }) {
|
|
717
723
|
addUtilities(node, {
|
|
718
724
|
respectPrefix: false,
|
|
719
725
|
preserveSource: true
|
|
@@ -726,7 +732,10 @@ function collectLayerPlugins(root) {
|
|
|
726
732
|
return layerPlugins;
|
|
727
733
|
}
|
|
728
734
|
function resolvePlugins(context, root) {
|
|
729
|
-
let corePluginList = Object.entries(
|
|
735
|
+
let corePluginList = Object.entries({
|
|
736
|
+
..._corePlugins.variantPlugins,
|
|
737
|
+
..._corePlugins.corePlugins
|
|
738
|
+
}).map(([name, plugin])=>{
|
|
730
739
|
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
731
740
|
return null;
|
|
732
741
|
}
|
|
@@ -742,6 +751,7 @@ function resolvePlugins(context, root) {
|
|
|
742
751
|
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
743
752
|
// were historically sorted before screen/stackable variants.
|
|
744
753
|
let beforeVariants = [
|
|
754
|
+
_corePlugins.variantPlugins["childVariant"],
|
|
745
755
|
_corePlugins.variantPlugins["pseudoElementVariants"],
|
|
746
756
|
_corePlugins.variantPlugins["pseudoClassVariants"],
|
|
747
757
|
_corePlugins.variantPlugins["hasVariants"],
|
|
@@ -750,14 +760,31 @@ function resolvePlugins(context, root) {
|
|
|
750
760
|
];
|
|
751
761
|
let afterVariants = [
|
|
752
762
|
_corePlugins.variantPlugins["supportsVariants"],
|
|
753
|
-
_corePlugins.variantPlugins["directionVariants"],
|
|
754
763
|
_corePlugins.variantPlugins["reducedMotionVariants"],
|
|
755
764
|
_corePlugins.variantPlugins["prefersContrastVariants"],
|
|
756
|
-
_corePlugins.variantPlugins["darkVariants"],
|
|
757
|
-
_corePlugins.variantPlugins["printVariant"],
|
|
758
765
|
_corePlugins.variantPlugins["screenVariants"],
|
|
759
|
-
_corePlugins.variantPlugins["orientationVariants"]
|
|
766
|
+
_corePlugins.variantPlugins["orientationVariants"],
|
|
767
|
+
_corePlugins.variantPlugins["directionVariants"],
|
|
768
|
+
_corePlugins.variantPlugins["darkVariants"],
|
|
769
|
+
_corePlugins.variantPlugins["forcedColorsVariants"],
|
|
770
|
+
_corePlugins.variantPlugins["printVariant"]
|
|
760
771
|
];
|
|
772
|
+
// This is a compatibility fix for the pre 3.4 dark mode behavior
|
|
773
|
+
// `class` retains the old behavior, but `selector` keeps the new behavior
|
|
774
|
+
let isLegacyDarkMode = context.tailwindConfig.darkMode === "class" || Array.isArray(context.tailwindConfig.darkMode) && context.tailwindConfig.darkMode[0] === "class";
|
|
775
|
+
if (isLegacyDarkMode) {
|
|
776
|
+
afterVariants = [
|
|
777
|
+
_corePlugins.variantPlugins["supportsVariants"],
|
|
778
|
+
_corePlugins.variantPlugins["reducedMotionVariants"],
|
|
779
|
+
_corePlugins.variantPlugins["prefersContrastVariants"],
|
|
780
|
+
_corePlugins.variantPlugins["darkVariants"],
|
|
781
|
+
_corePlugins.variantPlugins["screenVariants"],
|
|
782
|
+
_corePlugins.variantPlugins["orientationVariants"],
|
|
783
|
+
_corePlugins.variantPlugins["directionVariants"],
|
|
784
|
+
_corePlugins.variantPlugins["forcedColorsVariants"],
|
|
785
|
+
_corePlugins.variantPlugins["printVariant"]
|
|
786
|
+
];
|
|
787
|
+
}
|
|
761
788
|
return [
|
|
762
789
|
...corePluginList,
|
|
763
790
|
...beforeVariants,
|
|
@@ -785,8 +812,7 @@ function registerPlugins(plugins, context) {
|
|
|
785
812
|
pluginItem(pluginApi);
|
|
786
813
|
}
|
|
787
814
|
} else {
|
|
788
|
-
|
|
789
|
-
(_plugin = plugin) === null || _plugin === void 0 ? void 0 : _plugin(pluginApi);
|
|
815
|
+
plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
|
|
790
816
|
}
|
|
791
817
|
}
|
|
792
818
|
// Make sure to record bit masks for every variant
|
|
@@ -826,12 +852,11 @@ function registerPlugins(plugins, context) {
|
|
|
826
852
|
let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
|
|
827
853
|
for (let util of classList){
|
|
828
854
|
let utils = Array.isArray(util) ? (()=>{
|
|
829
|
-
var _options, _options1, _options2;
|
|
830
855
|
let [utilName, options] = util;
|
|
831
856
|
var _options_values;
|
|
832
|
-
let values = Object.keys((_options_values =
|
|
857
|
+
let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
|
|
833
858
|
let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
|
|
834
|
-
if (
|
|
859
|
+
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
835
860
|
// This is the normal negated version
|
|
836
861
|
// e.g. `-inset-1` or `-tw-inset-1`
|
|
837
862
|
classes = [
|
|
@@ -847,13 +872,13 @@ function registerPlugins(plugins, context) {
|
|
|
847
872
|
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
|
|
848
873
|
];
|
|
849
874
|
}
|
|
850
|
-
if (options.types.some(({ type
|
|
875
|
+
if (options.types.some(({ type })=>type === "color")) {
|
|
851
876
|
classes = [
|
|
852
877
|
...classes,
|
|
853
878
|
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
|
|
854
879
|
];
|
|
855
880
|
}
|
|
856
|
-
if (checkImportantUtils && (
|
|
881
|
+
if (checkImportantUtils && (options === null || options === void 0 ? void 0 : options.respectImportant)) {
|
|
857
882
|
classes = [
|
|
858
883
|
...classes,
|
|
859
884
|
...classes.map((cls)=>"!" + cls)
|
|
@@ -864,7 +889,7 @@ function registerPlugins(plugins, context) {
|
|
|
864
889
|
util
|
|
865
890
|
];
|
|
866
891
|
for (let util of utils){
|
|
867
|
-
for (let { pattern, variants =
|
|
892
|
+
for (let { pattern , variants =[] } of checks){
|
|
868
893
|
// RegExp with the /g flag are stateful, so let's reset the last
|
|
869
894
|
// index pointer to reset the state.
|
|
870
895
|
pattern.lastIndex = 0;
|
|
@@ -923,7 +948,7 @@ function registerPlugins(plugins, context) {
|
|
|
923
948
|
]));
|
|
924
949
|
// Sort all classes in order
|
|
925
950
|
// Non-tailwind classes won't be generated and will be left as `null`
|
|
926
|
-
let rules = (0, _generateRules.generateRules)(new Set(sorted), context);
|
|
951
|
+
let rules = (0, _generateRules.generateRules)(new Set(sorted), context, true);
|
|
927
952
|
rules = context.offsets.sort(rules);
|
|
928
953
|
let idx = BigInt(parasiteUtilities.length);
|
|
929
954
|
for (const [, rule] of rules){
|
|
@@ -955,12 +980,12 @@ function registerPlugins(plugins, context) {
|
|
|
955
980
|
let output = [];
|
|
956
981
|
for (let util of classList){
|
|
957
982
|
if (Array.isArray(util)) {
|
|
958
|
-
var
|
|
983
|
+
var _utilOptions_types;
|
|
959
984
|
let [utilName, utilOptions] = util;
|
|
960
985
|
let negativeClasses = [];
|
|
961
986
|
var _utilOptions_modifiers;
|
|
962
|
-
let modifiers = Object.keys((_utilOptions_modifiers =
|
|
963
|
-
if (
|
|
987
|
+
let modifiers = Object.keys((_utilOptions_modifiers = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.modifiers) !== null && _utilOptions_modifiers !== void 0 ? _utilOptions_modifiers : {});
|
|
988
|
+
if (utilOptions === null || utilOptions === void 0 ? void 0 : (_utilOptions_types = utilOptions.types) === null || _utilOptions_types === void 0 ? void 0 : _utilOptions_types.some(({ type })=>type === "color")) {
|
|
964
989
|
var _context_tailwindConfig_theme_opacity;
|
|
965
990
|
modifiers.push(...Object.keys((_context_tailwindConfig_theme_opacity = context.tailwindConfig.theme.opacity) !== null && _context_tailwindConfig_theme_opacity !== void 0 ? _context_tailwindConfig_theme_opacity : {}));
|
|
966
991
|
}
|
|
@@ -969,8 +994,7 @@ function registerPlugins(plugins, context) {
|
|
|
969
994
|
};
|
|
970
995
|
let includeMetadata = options.includeMetadata && modifiers.length > 0;
|
|
971
996
|
var _utilOptions_values;
|
|
972
|
-
for (let [key, value] of Object.entries((_utilOptions_values =
|
|
973
|
-
var _utilOptions3;
|
|
997
|
+
for (let [key, value] of Object.entries((_utilOptions_values = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.values) !== null && _utilOptions_values !== void 0 ? _utilOptions_values : {})){
|
|
974
998
|
// Ignore undefined and null values
|
|
975
999
|
if (value == null) {
|
|
976
1000
|
continue;
|
|
@@ -980,7 +1004,7 @@ function registerPlugins(plugins, context) {
|
|
|
980
1004
|
cls,
|
|
981
1005
|
metadata
|
|
982
1006
|
] : cls);
|
|
983
|
-
if ((
|
|
1007
|
+
if ((utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.supportsNegativeValues) && (0, _negateValue.default)(value)) {
|
|
984
1008
|
let cls = (0, _nameClass.formatClass)(utilName, `-${key}`);
|
|
985
1009
|
negativeClasses.push(includeMetadata ? [
|
|
986
1010
|
cls,
|
|
@@ -997,6 +1021,10 @@ function registerPlugins(plugins, context) {
|
|
|
997
1021
|
};
|
|
998
1022
|
// Generate a list of available variants with meta information of the type of variant.
|
|
999
1023
|
context.getVariants = function getVariants() {
|
|
1024
|
+
// We use a unique, random ID for candidate names to avoid conflicts
|
|
1025
|
+
// We can't use characters like `_`, `:`, `@` or `.` because they might
|
|
1026
|
+
// be used as a separator
|
|
1027
|
+
let id = Math.random().toString(36).substring(7).toUpperCase();
|
|
1000
1028
|
let result = [];
|
|
1001
1029
|
for (let [name, options] of context.variantOptions.entries()){
|
|
1002
1030
|
if (options.variantInfo === VARIANT_INFO.Base) continue;
|
|
@@ -1006,8 +1034,8 @@ function registerPlugins(plugins, context) {
|
|
|
1006
1034
|
isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
|
|
1007
1035
|
values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
|
|
1008
1036
|
hasDash: name !== "@",
|
|
1009
|
-
selectors ({ modifier, value
|
|
1010
|
-
let candidate =
|
|
1037
|
+
selectors ({ modifier , value } = {}) {
|
|
1038
|
+
let candidate = `TAILWINDPLACEHOLDER${id}`;
|
|
1011
1039
|
let rule = _postcss.default.rule({
|
|
1012
1040
|
selector: `.${candidate}`
|
|
1013
1041
|
});
|
|
@@ -42,7 +42,6 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
42
42
|
}
|
|
43
43
|
// Get the config object based on a path
|
|
44
44
|
function getTailwindConfig(configOrPath) {
|
|
45
|
-
var _configOrPath;
|
|
46
45
|
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
47
46
|
if (userConfigPath !== null) {
|
|
48
47
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
@@ -86,7 +85,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
86
85
|
}
|
|
87
86
|
var _configOrPath_config, _ref;
|
|
88
87
|
// It's a plain object, not a path
|
|
89
|
-
let newConfig = (0, _resolveconfig.default)((_ref = (_configOrPath_config =
|
|
88
|
+
let newConfig = (0, _resolveconfig.default)((_ref = (_configOrPath_config = configOrPath === null || configOrPath === void 0 ? void 0 : configOrPath.config) !== null && _configOrPath_config !== void 0 ? _configOrPath_config : configOrPath) !== null && _ref !== void 0 ? _ref : {});
|
|
90
89
|
newConfig = (0, _validateConfig.validateConfig)(newConfig);
|
|
91
90
|
return [
|
|
92
91
|
newConfig,
|
|
@@ -96,7 +95,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
96
95
|
];
|
|
97
96
|
}
|
|
98
97
|
function setupTrackingContext(configOrPath) {
|
|
99
|
-
return ({ tailwindDirectives, registerDependency
|
|
98
|
+
return ({ tailwindDirectives , registerDependency })=>{
|
|
100
99
|
return (root, result)=>{
|
|
101
100
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
102
101
|
let contextDependencies = new Set(configDependencies);
|
|
@@ -15,12 +15,12 @@ function _interop_require_default(obj) {
|
|
|
15
15
|
default: obj
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function _default({ tailwindConfig: { theme
|
|
18
|
+
function _default({ tailwindConfig: { theme } }) {
|
|
19
19
|
return function(css) {
|
|
20
20
|
css.walkAtRules("screen", (atRule)=>{
|
|
21
21
|
let screen = atRule.params;
|
|
22
22
|
let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
|
|
23
|
-
let screenDefinition = screens.find(({ name
|
|
23
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
24
24
|
if (!screenDefinition) {
|
|
25
25
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
26
26
|
}
|
package/lib/plugin.js
CHANGED
|
@@ -2,62 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
6
|
-
const _lightningcss = /*#__PURE__*/ _interop_require_wildcard(require("lightningcss"));
|
|
7
|
-
const _browserslist = /*#__PURE__*/ _interop_require_default(require("browserslist"));
|
|
8
5
|
const _setupTrackingContext = /*#__PURE__*/ _interop_require_default(require("./lib/setupTrackingContext"));
|
|
9
6
|
const _processTailwindFeatures = /*#__PURE__*/ _interop_require_default(require("./processTailwindFeatures"));
|
|
10
7
|
const _sharedState = require("./lib/sharedState");
|
|
11
8
|
const _findAtConfigPath = require("./lib/findAtConfigPath");
|
|
12
|
-
const _handleImportAtRules = require("./lib/handleImportAtRules");
|
|
13
|
-
const _packagejson = require("../package.json");
|
|
14
9
|
function _interop_require_default(obj) {
|
|
15
10
|
return obj && obj.__esModule ? obj : {
|
|
16
11
|
default: obj
|
|
17
12
|
};
|
|
18
13
|
}
|
|
19
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
20
|
-
if (typeof WeakMap !== "function") return null;
|
|
21
|
-
var cacheBabelInterop = new WeakMap();
|
|
22
|
-
var cacheNodeInterop = new WeakMap();
|
|
23
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
24
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
25
|
-
})(nodeInterop);
|
|
26
|
-
}
|
|
27
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
|
-
return obj;
|
|
30
|
-
}
|
|
31
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
32
|
-
return {
|
|
33
|
-
default: obj
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
37
|
-
if (cache && cache.has(obj)) {
|
|
38
|
-
return cache.get(obj);
|
|
39
|
-
}
|
|
40
|
-
var newObj = {};
|
|
41
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
-
for(var key in obj){
|
|
43
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
-
if (desc && (desc.get || desc.set)) {
|
|
46
|
-
Object.defineProperty(newObj, key, desc);
|
|
47
|
-
} else {
|
|
48
|
-
newObj[key] = obj[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
newObj.default = obj;
|
|
53
|
-
if (cache) {
|
|
54
|
-
cache.set(obj, newObj);
|
|
55
|
-
}
|
|
56
|
-
return newObj;
|
|
57
|
-
}
|
|
58
|
-
function license() {
|
|
59
|
-
return `/* ! tailwindcss v${_packagejson.version} | MIT License | https://tailwindcss.com */\n`;
|
|
60
|
-
}
|
|
61
14
|
module.exports = function tailwindcss(configOrPath) {
|
|
62
15
|
return {
|
|
63
16
|
postcssPlugin: "tailwindcss",
|
|
@@ -67,7 +20,6 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
67
20
|
console.time("JIT TOTAL");
|
|
68
21
|
return root;
|
|
69
22
|
},
|
|
70
|
-
...(0, _handleImportAtRules.handleImportAtRules)(),
|
|
71
23
|
async function(root, result) {
|
|
72
24
|
var _findAtConfigPath1;
|
|
73
25
|
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
@@ -85,74 +37,6 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
85
37
|
}
|
|
86
38
|
await (0, _processTailwindFeatures.default)(context)(root, result);
|
|
87
39
|
},
|
|
88
|
-
function lightningCssPlugin(_root, result) {
|
|
89
|
-
var _intermediateResult_map_toJSON, _intermediateResult_map;
|
|
90
|
-
var _result_map;
|
|
91
|
-
let map = (_result_map = result.map) !== null && _result_map !== void 0 ? _result_map : result.opts.map;
|
|
92
|
-
let intermediateResult = result.root.toResult({
|
|
93
|
-
map: map ? {
|
|
94
|
-
inline: true
|
|
95
|
-
} : false
|
|
96
|
-
});
|
|
97
|
-
var _intermediateResult_map_toJSON1;
|
|
98
|
-
let intermediateMap = (_intermediateResult_map_toJSON1 = (_intermediateResult_map = intermediateResult.map) === null || _intermediateResult_map === void 0 ? void 0 : (_intermediateResult_map_toJSON = _intermediateResult_map.toJSON) === null || _intermediateResult_map_toJSON === void 0 ? void 0 : _intermediateResult_map_toJSON.call(_intermediateResult_map)) !== null && _intermediateResult_map_toJSON1 !== void 0 ? _intermediateResult_map_toJSON1 : map;
|
|
99
|
-
try {
|
|
100
|
-
var _browserslist_findConfig;
|
|
101
|
-
var _result_opts_from;
|
|
102
|
-
let resolvedBrowsersListConfig = (_browserslist_findConfig = _browserslist.default.findConfig((_result_opts_from = result.opts.from) !== null && _result_opts_from !== void 0 ? _result_opts_from : process.cwd())) === null || _browserslist_findConfig === void 0 ? void 0 : _browserslist_findConfig.defaults;
|
|
103
|
-
let defaultBrowsersListConfig = require("../package.json").browserslist;
|
|
104
|
-
let browsersListConfig = resolvedBrowsersListConfig !== null && resolvedBrowsersListConfig !== void 0 ? resolvedBrowsersListConfig : defaultBrowsersListConfig;
|
|
105
|
-
let transformed = _lightningcss.default.transform({
|
|
106
|
-
filename: result.opts.from,
|
|
107
|
-
code: Buffer.from(intermediateResult.css),
|
|
108
|
-
minify: false,
|
|
109
|
-
sourceMap: !!intermediateMap,
|
|
110
|
-
targets: _lightningcss.default.browserslistToTargets((0, _browserslist.default)(browsersListConfig)),
|
|
111
|
-
drafts: {
|
|
112
|
-
nesting: true,
|
|
113
|
-
customMedia: true
|
|
114
|
-
},
|
|
115
|
-
nonStandard: {
|
|
116
|
-
deepSelectorCombinator: true
|
|
117
|
-
},
|
|
118
|
-
include: _lightningcss.Features.Nesting,
|
|
119
|
-
exclude: _lightningcss.Features.LogicalProperties
|
|
120
|
-
});
|
|
121
|
-
let code = transformed.code.toString();
|
|
122
|
-
// https://postcss.org/api/#sourcemapoptions
|
|
123
|
-
if (intermediateMap && transformed.map != null) {
|
|
124
|
-
let prev = transformed.map.toString();
|
|
125
|
-
if (typeof intermediateMap === "object") {
|
|
126
|
-
intermediateMap.prev = prev;
|
|
127
|
-
} else {
|
|
128
|
-
code = `${code}\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(prev).toString("base64")} */`;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
result.root = _postcss.default.parse(license() + code, {
|
|
132
|
-
...result.opts,
|
|
133
|
-
map: intermediateMap
|
|
134
|
-
});
|
|
135
|
-
} catch (err) {
|
|
136
|
-
if (err.source && typeof process !== "undefined" && process.env.JEST_WORKER_ID) {
|
|
137
|
-
let lines = err.source.split("\n");
|
|
138
|
-
err = new Error([
|
|
139
|
-
"Error formatting using Lightning CSS:",
|
|
140
|
-
"",
|
|
141
|
-
...[
|
|
142
|
-
"```css",
|
|
143
|
-
...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line),
|
|
144
|
-
" ".repeat(err.loc.column - 1) + "^-- " + err.toString(),
|
|
145
|
-
...lines.slice(err.loc.line, err.loc.line + 2),
|
|
146
|
-
"```"
|
|
147
|
-
]
|
|
148
|
-
].join("\n"));
|
|
149
|
-
}
|
|
150
|
-
if (Error.captureStackTrace) {
|
|
151
|
-
Error.captureStackTrace(err, lightningCssPlugin);
|
|
152
|
-
}
|
|
153
|
-
throw err;
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
40
|
_sharedState.env.DEBUG && function(root) {
|
|
157
41
|
console.timeEnd("JIT TOTAL");
|
|
158
42
|
console.log("\n");
|
|
@@ -12,7 +12,7 @@ const _plugin = require("./plugin");
|
|
|
12
12
|
const _default = Object.assign(function(opts) {
|
|
13
13
|
return {
|
|
14
14
|
postcssPlugin: "tailwindcss/nesting",
|
|
15
|
-
Once (root, { result
|
|
15
|
+
Once (root, { result }) {
|
|
16
16
|
return (0, _plugin.nesting)(opts)(root, result);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -30,8 +30,8 @@ function nesting(opts = _postcssnested.default) {
|
|
|
30
30
|
rule.remove();
|
|
31
31
|
});
|
|
32
32
|
let plugin = (()=>{
|
|
33
|
-
var _opts_hasOwnProperty
|
|
34
|
-
if (typeof opts === "function" || typeof opts === "object" && (
|
|
33
|
+
var _opts_hasOwnProperty;
|
|
34
|
+
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (_opts_hasOwnProperty = opts.hasOwnProperty) === null || _opts_hasOwnProperty === void 0 ? void 0 : _opts_hasOwnProperty.call(opts, "postcssPlugin"))) {
|
|
35
35
|
return opts;
|
|
36
36
|
}
|
|
37
37
|
if (typeof opts === "string") {
|