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
package/lib/lib/generateRules.js
CHANGED
|
@@ -80,7 +80,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
80
80
|
return newObj;
|
|
81
81
|
}
|
|
82
82
|
let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
83
|
-
return selectors.first.filter(({ type
|
|
83
|
+
return selectors.first.filter(({ type })=>type === "class").pop().value;
|
|
84
84
|
});
|
|
85
85
|
function getClassNameFromSelector(selector) {
|
|
86
86
|
return classNameParser.transformSync(selector);
|
|
@@ -100,7 +100,7 @@ function* candidatePermutations(candidate) {
|
|
|
100
100
|
if (lastIndex === Infinity && candidate.endsWith("]")) {
|
|
101
101
|
let bracketIdx = candidate.indexOf("[");
|
|
102
102
|
// If character before `[` isn't a dash or a slash, this isn't a dynamic class
|
|
103
|
-
//
|
|
103
|
+
// eg. string[]
|
|
104
104
|
if (candidate[bracketIdx - 1] === "-") {
|
|
105
105
|
dashIdx = bracketIdx - 1;
|
|
106
106
|
} else if (candidate[bracketIdx - 1] === "/") {
|
|
@@ -162,6 +162,9 @@ function applyImportant(matches, classCandidate) {
|
|
|
162
162
|
return matches;
|
|
163
163
|
}
|
|
164
164
|
let result = [];
|
|
165
|
+
function isInKeyframes(rule) {
|
|
166
|
+
return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
|
|
167
|
+
}
|
|
165
168
|
for (let [meta, rule] of matches){
|
|
166
169
|
let container = _postcss.default.root({
|
|
167
170
|
nodes: [
|
|
@@ -169,6 +172,11 @@ function applyImportant(matches, classCandidate) {
|
|
|
169
172
|
]
|
|
170
173
|
});
|
|
171
174
|
container.walkRules((r)=>{
|
|
175
|
+
// Declarations inside keyframes cannot be marked as important
|
|
176
|
+
// They will be ignored by the browser
|
|
177
|
+
if (isInKeyframes(r)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
172
180
|
let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
|
|
173
181
|
// Remove extraneous selectors that do not include the base candidate
|
|
174
182
|
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
@@ -215,6 +223,9 @@ function applyVariant(variant, matches, context) {
|
|
|
215
223
|
if (modifiers.length && !context.variantMap.has(variant)) {
|
|
216
224
|
variant = baseVariant;
|
|
217
225
|
args.modifier = modifiers[0];
|
|
226
|
+
if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
218
229
|
}
|
|
219
230
|
}
|
|
220
231
|
// Retrieve "arbitrary value"
|
|
@@ -472,9 +483,9 @@ function isParsableNode(node) {
|
|
|
472
483
|
return isParsable;
|
|
473
484
|
}
|
|
474
485
|
function isParsableCssValue(property, value) {
|
|
475
|
-
// We don't want to treat [https://example.com] as a custom property
|
|
486
|
+
// We don't want to to treat [https://example.com] as a custom property
|
|
476
487
|
// Even though, according to the CSS grammar, it's a totally valid CSS declaration
|
|
477
|
-
// So we short-circuit here by checking if the custom property looks like a
|
|
488
|
+
// So we short-circuit here by checking if the custom property looks like a url
|
|
478
489
|
if (looksLikeUri(`${property}:${value}`)) {
|
|
479
490
|
return false;
|
|
480
491
|
}
|
|
@@ -497,16 +508,21 @@ function extractArbitraryProperty(classCandidate, context) {
|
|
|
497
508
|
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
498
509
|
return null;
|
|
499
510
|
}
|
|
500
|
-
let normalized = (0, _dataTypes.normalize)(value
|
|
511
|
+
let normalized = (0, _dataTypes.normalize)(value, {
|
|
512
|
+
property
|
|
513
|
+
});
|
|
501
514
|
if (!isParsableCssValue(property, normalized)) {
|
|
502
515
|
return null;
|
|
503
516
|
}
|
|
504
|
-
let sort = context.offsets.arbitraryProperty();
|
|
517
|
+
let sort = context.offsets.arbitraryProperty(classCandidate);
|
|
505
518
|
return [
|
|
506
519
|
[
|
|
507
520
|
{
|
|
508
521
|
sort,
|
|
509
|
-
layer: "utilities"
|
|
522
|
+
layer: "utilities",
|
|
523
|
+
options: {
|
|
524
|
+
respectImportant: true
|
|
525
|
+
}
|
|
510
526
|
},
|
|
511
527
|
()=>({
|
|
512
528
|
[(0, _nameClass.asClass)(classCandidate)]: {
|
|
@@ -575,7 +591,7 @@ function* recordCandidates(matches, classCandidate) {
|
|
|
575
591
|
yield match;
|
|
576
592
|
}
|
|
577
593
|
}
|
|
578
|
-
function* resolveMatches(candidate, context
|
|
594
|
+
function* resolveMatches(candidate, context) {
|
|
579
595
|
let separator = context.tailwindConfig.separator;
|
|
580
596
|
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
|
|
581
597
|
let important = false;
|
|
@@ -583,14 +599,6 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
583
599
|
important = true;
|
|
584
600
|
classCandidate = classCandidate.slice(1);
|
|
585
601
|
}
|
|
586
|
-
if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
|
|
587
|
-
if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
|
|
588
|
-
let base = variants.slice().reverse().join(separator);
|
|
589
|
-
for (let part of (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
|
|
590
|
-
yield* resolveMatches(base + separator + part, context, original);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
602
|
// TODO: Reintroduce this in ways that doesn't break on false positives
|
|
595
603
|
// function sortAgainst(toSort, against) {
|
|
596
604
|
// return toSort.slice().sort((a, z) => {
|
|
@@ -658,7 +666,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
658
666
|
// Partition plugins in 2 categories so that we can start searching in the plugins that
|
|
659
667
|
// don't have `any` as a type first.
|
|
660
668
|
let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
|
|
661
|
-
let hasAnyType = plugin.some(([{ options
|
|
669
|
+
let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === "any"));
|
|
662
670
|
if (hasAnyType) {
|
|
663
671
|
group[0].push(plugin);
|
|
664
672
|
} else {
|
|
@@ -678,11 +686,11 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
678
686
|
// also has the correct type which preferOnConflicts the plugin in case of clashes.
|
|
679
687
|
return matches.find((rules)=>{
|
|
680
688
|
let matchingTypes = typesByMatches.get(rules);
|
|
681
|
-
return rules.some(([{ options
|
|
689
|
+
return rules.some(([{ options }, rule])=>{
|
|
682
690
|
if (!isParsableNode(rule)) {
|
|
683
691
|
return false;
|
|
684
692
|
}
|
|
685
|
-
return options.types.some(({ type, preferOnConflict
|
|
693
|
+
return options.types.some(({ type , preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
|
|
686
694
|
});
|
|
687
695
|
});
|
|
688
696
|
}
|
|
@@ -750,8 +758,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
750
758
|
// Apply final format selector
|
|
751
759
|
match = applyFinalFormat(match, {
|
|
752
760
|
context,
|
|
753
|
-
candidate
|
|
754
|
-
original
|
|
761
|
+
candidate
|
|
755
762
|
});
|
|
756
763
|
// Skip rules with invalid selectors
|
|
757
764
|
// This will cause the candidate to be added to the "not class"
|
|
@@ -763,7 +770,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
763
770
|
}
|
|
764
771
|
}
|
|
765
772
|
}
|
|
766
|
-
function applyFinalFormat(match, { context, candidate
|
|
773
|
+
function applyFinalFormat(match, { context , candidate }) {
|
|
767
774
|
if (!match[0].collectedFormats) {
|
|
768
775
|
return match;
|
|
769
776
|
}
|
|
@@ -772,7 +779,7 @@ function applyFinalFormat(match, { context, candidate, original }) {
|
|
|
772
779
|
try {
|
|
773
780
|
finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
|
|
774
781
|
context,
|
|
775
|
-
candidate
|
|
782
|
+
candidate
|
|
776
783
|
});
|
|
777
784
|
} catch {
|
|
778
785
|
// The format selector we produced is invalid
|
|
@@ -796,10 +803,17 @@ function applyFinalFormat(match, { context, candidate, original }) {
|
|
|
796
803
|
return;
|
|
797
804
|
}
|
|
798
805
|
try {
|
|
799
|
-
|
|
806
|
+
let selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
|
|
800
807
|
candidate,
|
|
801
808
|
context
|
|
802
809
|
});
|
|
810
|
+
// Finalize Selector determined that this candidate is irrelevant
|
|
811
|
+
// TODO: This elimination should happen earlier so this never happens
|
|
812
|
+
if (selector === null) {
|
|
813
|
+
rule.remove();
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
rule.selector = selector;
|
|
803
817
|
} catch {
|
|
804
818
|
// If this selector is invalid we also want to skip it
|
|
805
819
|
// But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
|
|
@@ -810,6 +824,10 @@ function applyFinalFormat(match, { context, candidate, original }) {
|
|
|
810
824
|
if (!isValid) {
|
|
811
825
|
return null;
|
|
812
826
|
}
|
|
827
|
+
// If all rules have been eliminated we can skip this candidate entirely
|
|
828
|
+
if (container.nodes.length === 0) {
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
813
831
|
match[1] = container.nodes[0];
|
|
814
832
|
return match;
|
|
815
833
|
}
|
|
@@ -840,7 +858,7 @@ function getImportantStrategy(important) {
|
|
|
840
858
|
};
|
|
841
859
|
}
|
|
842
860
|
}
|
|
843
|
-
function generateRules(candidates, context) {
|
|
861
|
+
function generateRules(candidates, context, isSorting = false) {
|
|
844
862
|
let allRules = [];
|
|
845
863
|
let strategy = getImportantStrategy(context.tailwindConfig.important);
|
|
846
864
|
for (let candidate of candidates){
|
|
@@ -861,7 +879,7 @@ function generateRules(candidates, context) {
|
|
|
861
879
|
let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
|
|
862
880
|
context.candidateRuleCache.set(candidate, rules);
|
|
863
881
|
for (const match of matches){
|
|
864
|
-
let [{ sort, options
|
|
882
|
+
let [{ sort , options }, rule] = match;
|
|
865
883
|
if (options.respectImportant && strategy) {
|
|
866
884
|
let container = _postcss.default.root({
|
|
867
885
|
nodes: [
|
|
@@ -871,9 +889,11 @@ function generateRules(candidates, context) {
|
|
|
871
889
|
container.walkRules(strategy);
|
|
872
890
|
rule = container.nodes[0];
|
|
873
891
|
}
|
|
892
|
+
// Note: We have to clone rules during sorting
|
|
893
|
+
// so we eliminate some shared mutable state
|
|
874
894
|
let newEntry = [
|
|
875
895
|
sort,
|
|
876
|
-
rule
|
|
896
|
+
isSorting ? rule.clone() : rule
|
|
877
897
|
];
|
|
878
898
|
rules.add(newEntry);
|
|
879
899
|
context.ruleCache.add(newEntry);
|
package/lib/lib/load-config.js
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
useCustomJiti: function() {
|
|
13
|
+
return useCustomJiti;
|
|
14
|
+
},
|
|
15
|
+
loadConfig: function() {
|
|
8
16
|
return loadConfig;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
@@ -16,10 +24,17 @@ function _interop_require_default(obj) {
|
|
|
16
24
|
};
|
|
17
25
|
}
|
|
18
26
|
let jiti = null;
|
|
27
|
+
function useCustomJiti(_jiti) {
|
|
28
|
+
jiti = _jiti();
|
|
29
|
+
}
|
|
19
30
|
function lazyJiti() {
|
|
20
31
|
return jiti !== null && jiti !== void 0 ? jiti : jiti = (0, _jiti.default)(__filename, {
|
|
21
32
|
interopDefault: true,
|
|
22
33
|
transform: (opts)=>{
|
|
34
|
+
// Sucrase can't transform import.meta so we have to use Babel
|
|
35
|
+
if (opts.source.includes("import.meta")) {
|
|
36
|
+
return require("jiti/dist/babel.js")(opts);
|
|
37
|
+
}
|
|
23
38
|
return (0, _sucrase.transform)(opts.source, {
|
|
24
39
|
transforms: [
|
|
25
40
|
"typescript",
|
|
@@ -22,6 +22,21 @@ function normalizeTailwindDirectives(root) {
|
|
|
22
22
|
if (atRule.name === "apply") {
|
|
23
23
|
applyDirectives.add(atRule);
|
|
24
24
|
}
|
|
25
|
+
if (atRule.name === "import") {
|
|
26
|
+
if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
|
|
27
|
+
atRule.name = "tailwind";
|
|
28
|
+
atRule.params = "base";
|
|
29
|
+
} else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
|
|
30
|
+
atRule.name = "tailwind";
|
|
31
|
+
atRule.params = "components";
|
|
32
|
+
} else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
|
|
33
|
+
atRule.name = "tailwind";
|
|
34
|
+
atRule.params = "utilities";
|
|
35
|
+
} else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
|
|
36
|
+
atRule.name = "tailwind";
|
|
37
|
+
atRule.params = "variants";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
25
40
|
if (atRule.name === "tailwind") {
|
|
26
41
|
if (atRule.params === "screens") {
|
|
27
42
|
atRule.params = "variants";
|
package/lib/lib/offsets.js
CHANGED
|
@@ -66,15 +66,19 @@ class Offsets {
|
|
|
66
66
|
variants: 0n,
|
|
67
67
|
parallelIndex: 0n,
|
|
68
68
|
index: this.offsets[layer]++,
|
|
69
|
+
propertyOffset: 0n,
|
|
70
|
+
property: "",
|
|
69
71
|
options: []
|
|
70
72
|
};
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
75
|
+
* @param {string} name
|
|
73
76
|
* @returns {RuleOffset}
|
|
74
|
-
*/ arbitraryProperty() {
|
|
77
|
+
*/ arbitraryProperty(name) {
|
|
75
78
|
return {
|
|
76
79
|
...this.create("utilities"),
|
|
77
|
-
arbitrary: 1n
|
|
80
|
+
arbitrary: 1n,
|
|
81
|
+
property: name
|
|
78
82
|
};
|
|
79
83
|
}
|
|
80
84
|
/**
|
|
@@ -214,6 +218,10 @@ class Offsets {
|
|
|
214
218
|
if (a.arbitrary !== b.arbitrary) {
|
|
215
219
|
return a.arbitrary - b.arbitrary;
|
|
216
220
|
}
|
|
221
|
+
// Always sort arbitrary properties alphabetically
|
|
222
|
+
if (a.propertyOffset !== b.propertyOffset) {
|
|
223
|
+
return a.propertyOffset - b.propertyOffset;
|
|
224
|
+
}
|
|
217
225
|
// Sort utilities, components, etc… in the order they were registered
|
|
218
226
|
return a.index - b.index;
|
|
219
227
|
}
|
|
@@ -246,7 +254,7 @@ class Offsets {
|
|
|
246
254
|
*/ remapArbitraryVariantOffsets(list) {
|
|
247
255
|
let mapping = this.recalculateVariantOffsets();
|
|
248
256
|
// No arbitrary variants? Nothing to do.
|
|
249
|
-
//
|
|
257
|
+
// Everyhing already in order? Nothing to do.
|
|
250
258
|
if (mapping.length === 0) {
|
|
251
259
|
return list;
|
|
252
260
|
}
|
|
@@ -267,8 +275,49 @@ class Offsets {
|
|
|
267
275
|
* @template T
|
|
268
276
|
* @param {[RuleOffset, T][]} list
|
|
269
277
|
* @returns {[RuleOffset, T][]}
|
|
278
|
+
*/ sortArbitraryProperties(list) {
|
|
279
|
+
// Collect all known arbitrary properties
|
|
280
|
+
let known = new Set();
|
|
281
|
+
for (let [offset] of list){
|
|
282
|
+
if (offset.arbitrary === 1n) {
|
|
283
|
+
known.add(offset.property);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// No arbitrary properties? Nothing to do.
|
|
287
|
+
if (known.size === 0) {
|
|
288
|
+
return list;
|
|
289
|
+
}
|
|
290
|
+
// Sort the properties alphabetically
|
|
291
|
+
let properties = Array.from(known).sort();
|
|
292
|
+
// Create a map from the property name to its offset
|
|
293
|
+
let offsets = new Map();
|
|
294
|
+
let offset = 1n;
|
|
295
|
+
for (let property of properties){
|
|
296
|
+
offsets.set(property, offset++);
|
|
297
|
+
}
|
|
298
|
+
// Apply the sorted offsets to the list
|
|
299
|
+
return list.map((item)=>{
|
|
300
|
+
let [offset, rule] = item;
|
|
301
|
+
var _offsets_get;
|
|
302
|
+
offset = {
|
|
303
|
+
...offset,
|
|
304
|
+
propertyOffset: (_offsets_get = offsets.get(offset.property)) !== null && _offsets_get !== void 0 ? _offsets_get : 0n
|
|
305
|
+
};
|
|
306
|
+
return [
|
|
307
|
+
offset,
|
|
308
|
+
rule
|
|
309
|
+
];
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* @template T
|
|
314
|
+
* @param {[RuleOffset, T][]} list
|
|
315
|
+
* @returns {[RuleOffset, T][]}
|
|
270
316
|
*/ sort(list) {
|
|
317
|
+
// Sort arbitrary variants so they're in alphabetical order
|
|
271
318
|
list = this.remapArbitraryVariantOffsets(list);
|
|
319
|
+
// Sort arbitrary properties so they're in alphabetical order
|
|
320
|
+
list = this.sortArbitraryProperties(list);
|
|
272
321
|
return list.sort(([a], [b])=>(0, _bigSign.default)(this.compare(a, b)));
|
|
273
322
|
}
|
|
274
323
|
}
|
|
@@ -290,7 +339,7 @@ class Offsets {
|
|
|
290
339
|
* Using `.sort()` without a custom compare function is faster
|
|
291
340
|
* But you can only use that if you're sorting an array of
|
|
292
341
|
* only strings. If you're sorting strings inside objects
|
|
293
|
-
* or arrays, you need
|
|
342
|
+
* or arrays, you need must use a custom compare function.
|
|
294
343
|
*
|
|
295
344
|
* @param {string} a
|
|
296
345
|
* @param {string} b
|
|
@@ -84,7 +84,7 @@ function extractElementSelector(selector) {
|
|
|
84
84
|
}
|
|
85
85
|
return cache.get(selector);
|
|
86
86
|
}
|
|
87
|
-
function resolveDefaultsAtRules({ tailwindConfig
|
|
87
|
+
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
88
88
|
return (root)=>{
|
|
89
89
|
let variableNodeMap = new Map();
|
|
90
90
|
/** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
|
|
@@ -111,7 +111,9 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
111
111
|
// we consider them separately because merging the declarations into
|
|
112
112
|
// a single rule will cause browsers that do not understand the
|
|
113
113
|
// vendor prefix to throw out the whole rule
|
|
114
|
-
|
|
114
|
+
// Additionally if a selector contains `:has` we also consider
|
|
115
|
+
// it separately because FF only recently gained support for it
|
|
116
|
+
let selectorGroupName = selector.includes(":-") || selector.includes("::-") || selector.includes(":has") ? selector : "__DEFAULT__";
|
|
115
117
|
var _selectorGroups_get;
|
|
116
118
|
let selectors = (_selectorGroups_get = selectorGroups.get(selectorGroupName)) !== null && _selectorGroups_get !== void 0 ? _selectorGroups_get : new Set();
|
|
117
119
|
selectorGroups.set(selectorGroupName, selectors);
|