postcss-merge-rules 8.0.5 → 9.0.1
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/package.json +8 -13
- package/src/index.js +547 -518
- package/src/lib/computeBrowsersToSupport.js +10 -12
- package/src/lib/declarations.js +146 -0
- package/src/lib/ensureCompatibility.js +4 -4
- package/src/lib/getBrowsersForWebBuild.js +2 -4
- package/src/lib/propertyRelations.js +2 -5
- package/src/lib/rule-meta.js +58 -0
- package/src/lib/rule-rewrite.js +170 -0
- package/types/index.d.ts +15 -2
- package/types/index.d.ts.map +1 -1
- package/types/lib/computeBrowsersToSupport.d.ts +2 -2
- package/types/lib/computeBrowsersToSupport.d.ts.map +1 -1
- package/types/lib/declarations.d.ts +31 -0
- package/types/lib/declarations.d.ts.map +1 -0
- package/types/lib/ensureCompatibility.d.ts +54 -59
- package/types/lib/ensureCompatibility.d.ts.map +1 -1
- package/types/lib/getBrowsersForWebBuild.d.ts +2 -2
- package/types/lib/propertyRelations.d.ts +1 -4
- package/types/lib/propertyRelations.d.ts.map +1 -1
- package/types/lib/rule-meta.d.ts +21 -0
- package/types/lib/rule-meta.d.ts.map +1 -0
- package/types/lib/rule-rewrite.d.ts +40 -0
- package/types/lib/rule-rewrite.d.ts.map +1 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import browserslist from 'browserslist';
|
|
3
|
+
import nodepath from 'node:path';
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
const { dirname } = require('node:path');
|
|
5
|
+
const { dirname } = nodepath;
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
@@ -12,16 +13,13 @@ const { dirname } = require('node:path');
|
|
|
12
13
|
* @param {browserslist.Options["env"]} [env]
|
|
13
14
|
* @returns {string[]}
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
options,
|
|
17
|
-
stats,
|
|
18
|
-
from,
|
|
19
|
-
file,
|
|
20
|
-
env
|
|
21
|
-
) {
|
|
16
|
+
function computeBrowsersToSupport(options, stats, from, file, env) {
|
|
22
17
|
return browserslist(options.overrideBrowserslist, {
|
|
23
18
|
stats: options.stats || stats,
|
|
24
|
-
path:
|
|
19
|
+
path:
|
|
20
|
+
options.path || dirname(from || file || fileURLToPath(import.meta.url)),
|
|
25
21
|
env: options.env || env,
|
|
26
22
|
});
|
|
27
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default computeBrowsersToSupport;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { isConflictingProp } from './propertyRelations.js';
|
|
2
|
+
|
|
3
|
+
/** @import {Declaration} from 'postcss' */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {Declaration} a
|
|
7
|
+
* @param {Declaration} b
|
|
8
|
+
* @return {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function declarationIsEqual(a, b) {
|
|
11
|
+
return (
|
|
12
|
+
a.important === b.important && a.prop === b.prop && a.value === b.value
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {Declaration[]} array
|
|
18
|
+
* @param {Declaration} decl
|
|
19
|
+
* @return {number}
|
|
20
|
+
*/
|
|
21
|
+
export function indexOfDeclaration(array, decl) {
|
|
22
|
+
return array.findIndex((d) => declarationIsEqual(d, decl));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {Declaration[]} a
|
|
27
|
+
* @param {Declaration[]} b
|
|
28
|
+
* @param {boolean} [not=false]
|
|
29
|
+
* @return {Declaration[]}
|
|
30
|
+
*/
|
|
31
|
+
export function intersect(a, b, not) {
|
|
32
|
+
return a.filter((c) => {
|
|
33
|
+
const index = indexOfDeclaration(b, c) !== -1;
|
|
34
|
+
return not ? !index : index;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {Declaration[]} a
|
|
40
|
+
* @param {Declaration[]} b
|
|
41
|
+
* @return {boolean}
|
|
42
|
+
*/
|
|
43
|
+
export function sameDeclarationsAndOrder(a, b) {
|
|
44
|
+
if (a.length !== b.length) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return a.every((d, index) => declarationIsEqual(d, b[index]));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {Declaration} candidate
|
|
52
|
+
* @param {number} candidateIndex
|
|
53
|
+
* @param {Declaration[]} hoistCandidates
|
|
54
|
+
* @param {Declaration[]} earlierRuleDeclarations
|
|
55
|
+
* @return {boolean}
|
|
56
|
+
*/
|
|
57
|
+
function hoistingPreservesOverrideOrder(
|
|
58
|
+
candidate,
|
|
59
|
+
candidateIndex,
|
|
60
|
+
hoistCandidates,
|
|
61
|
+
earlierRuleDeclarations
|
|
62
|
+
) {
|
|
63
|
+
const indexInEarlierRule = indexOfDeclaration(
|
|
64
|
+
earlierRuleDeclarations,
|
|
65
|
+
candidate
|
|
66
|
+
);
|
|
67
|
+
const overridesInEarlierRule = earlierRuleDeclarations
|
|
68
|
+
.slice(indexInEarlierRule + 1)
|
|
69
|
+
.filter((d) => isConflictingProp(d.prop, candidate.prop));
|
|
70
|
+
if (overridesInEarlierRule.length === 0) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const overridesAmongCandidates = hoistCandidates
|
|
74
|
+
.slice(candidateIndex + 1)
|
|
75
|
+
.filter((d) => isConflictingProp(d.prop, candidate.prop));
|
|
76
|
+
if (overridesInEarlierRule.length !== overridesAmongCandidates.length) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return overridesInEarlierRule.every((d, index) =>
|
|
80
|
+
declarationIsEqual(d, overridesAmongCandidates[index])
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {Declaration} candidate
|
|
86
|
+
* @param {Declaration[]} laterDeclarations
|
|
87
|
+
* @param {Set<number>} claimedIndices
|
|
88
|
+
* @return {boolean}
|
|
89
|
+
*/
|
|
90
|
+
function claimMatchInLaterRule(candidate, laterDeclarations, claimedIndices) {
|
|
91
|
+
const matchIndex = laterDeclarations.findIndex(
|
|
92
|
+
(d, index) =>
|
|
93
|
+
!claimedIndices.has(index) && isConflictingProp(d.prop, candidate.prop)
|
|
94
|
+
);
|
|
95
|
+
if (matchIndex === -1) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (!declarationIsEqual(laterDeclarations[matchIndex], candidate)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (
|
|
102
|
+
candidate.prop.toLowerCase() !== 'direction' &&
|
|
103
|
+
candidate.prop.toLowerCase() !== 'unicode-bidi' &&
|
|
104
|
+
laterDeclarations.some(
|
|
105
|
+
(declaration) => declaration.prop.toLowerCase() === 'all'
|
|
106
|
+
)
|
|
107
|
+
) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
claimedIndices.add(matchIndex);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {Declaration[]} hoistCandidates
|
|
116
|
+
* @param {Declaration[]} earlierRuleDeclarations
|
|
117
|
+
* @param {Declaration[]} laterRuleDeclarations
|
|
118
|
+
* @return {{intersection: Declaration[], claimedIndices: Set<number>}}
|
|
119
|
+
*/
|
|
120
|
+
export function filterRuleIntersections(
|
|
121
|
+
hoistCandidates,
|
|
122
|
+
earlierRuleDeclarations,
|
|
123
|
+
laterRuleDeclarations
|
|
124
|
+
) {
|
|
125
|
+
let remainingCandidates = hoistCandidates;
|
|
126
|
+
for (;;) {
|
|
127
|
+
const claimedIndices = new Set();
|
|
128
|
+
const survivors = remainingCandidates.filter(
|
|
129
|
+
(candidate, candidateIndex) =>
|
|
130
|
+
hoistingPreservesOverrideOrder(
|
|
131
|
+
candidate,
|
|
132
|
+
candidateIndex,
|
|
133
|
+
remainingCandidates,
|
|
134
|
+
earlierRuleDeclarations
|
|
135
|
+
) &&
|
|
136
|
+
claimMatchInLaterRule(candidate, laterRuleDeclarations, claimedIndices)
|
|
137
|
+
);
|
|
138
|
+
if (
|
|
139
|
+
survivors.length === remainingCandidates.length ||
|
|
140
|
+
survivors.length === 0
|
|
141
|
+
) {
|
|
142
|
+
return { intersection: survivors, claimedIndices };
|
|
143
|
+
}
|
|
144
|
+
remainingCandidates = survivors;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const selectorParser = require('postcss-selector-parser');
|
|
1
|
+
import caniuseApi from 'caniuse-api';
|
|
2
|
+
import selectorParser from 'postcss-selector-parser';
|
|
4
3
|
|
|
4
|
+
const { isSupported } = caniuseApi;
|
|
5
5
|
const simpleSelectorRe = /^#?[-._a-z0-9 ]+$/i;
|
|
6
6
|
|
|
7
7
|
const cssSel2 = 'css-sel2';
|
|
@@ -246,4 +246,4 @@ function ensureCompatibility(selectors, browsers, compatibilityCache) {
|
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
export { sameVendor, noVendor, pseudoElements, ensureCompatibility };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
'
|
|
2
|
-
|
|
3
|
-
const data = require('../data/propertyGroups.json');
|
|
1
|
+
import data from '../data/propertyGroups.json' with { type: 'json' };
|
|
4
2
|
|
|
5
3
|
const vendorPrefixRegex = /^-\w+-/;
|
|
6
4
|
/**
|
|
@@ -167,5 +165,4 @@ function isConflictingProp(propA, propB) {
|
|
|
167
165
|
}
|
|
168
166
|
return false;
|
|
169
167
|
}
|
|
170
|
-
|
|
171
|
-
module.exports = { isConflictingProp };
|
|
168
|
+
export { isConflictingProp };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @import {Declaration, Rule} from 'postcss' */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} RuleMeta
|
|
5
|
+
* @property {string[]} selectors
|
|
6
|
+
* @property {Declaration[]} declarations
|
|
7
|
+
* @property {boolean} dirty
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('postcss').ChildNode} node
|
|
12
|
+
* @return {node is Declaration}
|
|
13
|
+
*/
|
|
14
|
+
function isDeclaration(node) {
|
|
15
|
+
return node.type === 'decl';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Rule} rule
|
|
20
|
+
* @param {WeakMap<Rule, RuleMeta>} [ruleMeta]
|
|
21
|
+
* @return {RuleMeta}
|
|
22
|
+
*/
|
|
23
|
+
export function getMeta(rule, ruleMeta) {
|
|
24
|
+
if (ruleMeta && rule) {
|
|
25
|
+
let meta = ruleMeta.get(rule);
|
|
26
|
+
if (!meta && rule.nodes) {
|
|
27
|
+
meta = {
|
|
28
|
+
selectors: rule.selectors,
|
|
29
|
+
declarations: rule.nodes.filter(isDeclaration),
|
|
30
|
+
dirty: false,
|
|
31
|
+
};
|
|
32
|
+
ruleMeta.set(rule, meta);
|
|
33
|
+
}
|
|
34
|
+
return meta ?? { selectors: [], declarations: [], dirty: false };
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
selectors: rule?.selectors ?? [],
|
|
38
|
+
declarations: rule?.nodes?.filter(isDeclaration) ?? [],
|
|
39
|
+
dirty: false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {Rule} rule
|
|
45
|
+
* @param {WeakMap<Rule, RuleMeta>} ruleMeta
|
|
46
|
+
*/
|
|
47
|
+
export function flush(rule, ruleMeta) {
|
|
48
|
+
const meta = ruleMeta.get(rule);
|
|
49
|
+
if (meta && meta.dirty) {
|
|
50
|
+
rule.selector = meta.selectors.join(',');
|
|
51
|
+
meta.dirty = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @param {Rule} rule @return {Declaration[]} */
|
|
56
|
+
export function getDecls(rule) {
|
|
57
|
+
return rule.nodes.filter(isDeclaration);
|
|
58
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { intersect, indexOfDeclaration } from './declarations.js';
|
|
2
|
+
import { flush, getMeta } from './rule-meta.js';
|
|
3
|
+
|
|
4
|
+
/** @import {Declaration, Rule} from 'postcss' */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {Rule} first
|
|
8
|
+
* @param {Rule} second
|
|
9
|
+
* @return {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export function mergeParents(first, second) {
|
|
12
|
+
if (!first.parent || !second.parent || first.parent === second.parent) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
second.remove();
|
|
16
|
+
first.parent.append(second);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @param {Rule} second @return {Rule | null} */
|
|
21
|
+
function getNextRule(second) {
|
|
22
|
+
let nextRule = second.next();
|
|
23
|
+
if (!nextRule) {
|
|
24
|
+
const parentSibling =
|
|
25
|
+
/** @type {import('postcss').Container | undefined} */ (
|
|
26
|
+
/** @type {import('postcss').Container<import('postcss').ChildNode>} */ (
|
|
27
|
+
second.parent
|
|
28
|
+
).next()
|
|
29
|
+
);
|
|
30
|
+
nextRule = parentSibling && parentSibling.nodes && parentSibling.nodes[0];
|
|
31
|
+
}
|
|
32
|
+
return nextRule?.type === 'rule' ? nextRule : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {...Rule} rules
|
|
37
|
+
* @return {number}
|
|
38
|
+
*/
|
|
39
|
+
function ruleLength(...rules) {
|
|
40
|
+
return rules.map((r) => (r.nodes.length ? String(r) : '')).join('').length;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {Rule} first
|
|
45
|
+
* @param {Rule} second
|
|
46
|
+
* @param {Declaration[]} intersection
|
|
47
|
+
* @param {string[]} browsers
|
|
48
|
+
* @param {Map<string, boolean>} compatibilityCache
|
|
49
|
+
* @param {WeakSet<Rule>} ruleCache
|
|
50
|
+
* @param {WeakMap<Rule, import('./rule-meta.js').RuleMeta>} ruleMeta
|
|
51
|
+
* @param {(a: Rule, b: Rule, browsers: string[], compatibilityCache: Map<string, boolean>, ruleCache: WeakSet<Rule>, ruleMeta: WeakMap<Rule, import('./rule-meta.js').RuleMeta>) => boolean} canMerge
|
|
52
|
+
* @param {(rule: Rule, oldParent: import('postcss').Container, newParent: import('postcss').Container) => void} [onMove]
|
|
53
|
+
* @return {{first: Rule, second: Rule, intersection: Declaration[], moved: boolean}}
|
|
54
|
+
*/
|
|
55
|
+
export function mergeWithNextRule(
|
|
56
|
+
first,
|
|
57
|
+
second,
|
|
58
|
+
intersection,
|
|
59
|
+
browsers,
|
|
60
|
+
compatibilityCache,
|
|
61
|
+
ruleCache,
|
|
62
|
+
ruleMeta,
|
|
63
|
+
canMerge,
|
|
64
|
+
onMove
|
|
65
|
+
) {
|
|
66
|
+
const nextRule = getNextRule(second);
|
|
67
|
+
if (
|
|
68
|
+
!nextRule ||
|
|
69
|
+
!canMerge(
|
|
70
|
+
second,
|
|
71
|
+
nextRule,
|
|
72
|
+
browsers,
|
|
73
|
+
compatibilityCache,
|
|
74
|
+
ruleCache,
|
|
75
|
+
ruleMeta
|
|
76
|
+
)
|
|
77
|
+
) {
|
|
78
|
+
return { first, second, intersection, moved: false };
|
|
79
|
+
}
|
|
80
|
+
const nextIntersection = intersect(
|
|
81
|
+
getMeta(second, ruleMeta).declarations,
|
|
82
|
+
getMeta(nextRule, ruleMeta).declarations
|
|
83
|
+
);
|
|
84
|
+
if (nextIntersection.length <= intersection.length) {
|
|
85
|
+
return { first, second, intersection, moved: false };
|
|
86
|
+
}
|
|
87
|
+
const oldParent = nextRule.parent;
|
|
88
|
+
const newParent = second.parent;
|
|
89
|
+
const moved = mergeParents(second, nextRule);
|
|
90
|
+
if (moved && oldParent && newParent) onMove?.(nextRule, oldParent, newParent);
|
|
91
|
+
return {
|
|
92
|
+
first: second,
|
|
93
|
+
second: nextRule,
|
|
94
|
+
intersection: nextIntersection,
|
|
95
|
+
moved,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {Rule} first
|
|
101
|
+
* @param {Rule} second
|
|
102
|
+
* @param {Declaration[]} intersection
|
|
103
|
+
* @param {Set<number>} claimedIndices
|
|
104
|
+
* @param {WeakSet<Rule>} ruleCache
|
|
105
|
+
* @param {WeakMap<Rule, import('./rule-meta.js').RuleMeta>} ruleMeta
|
|
106
|
+
* @return {{rule: Rule, replacements: Rule[]}}
|
|
107
|
+
*/
|
|
108
|
+
export function buildMergedRule(
|
|
109
|
+
first,
|
|
110
|
+
second,
|
|
111
|
+
intersection,
|
|
112
|
+
claimedIndices,
|
|
113
|
+
ruleCache,
|
|
114
|
+
ruleMeta
|
|
115
|
+
) {
|
|
116
|
+
const receivingBlock = second.clone();
|
|
117
|
+
const firstSelectors = getMeta(first, ruleMeta).selectors;
|
|
118
|
+
const secondSelectors = getMeta(second, ruleMeta).selectors;
|
|
119
|
+
receivingBlock.selector = [...firstSelectors, ...secondSelectors].join();
|
|
120
|
+
receivingBlock.nodes = [];
|
|
121
|
+
/** @type {import('postcss').Container<import('postcss').ChildNode>} */ (
|
|
122
|
+
second.parent
|
|
123
|
+
).insertBefore(second, receivingBlock);
|
|
124
|
+
const firstClone = first.clone({ selectors: firstSelectors });
|
|
125
|
+
const secondClone = second.clone({ selectors: secondSelectors });
|
|
126
|
+
firstClone.walkDecls((decl) => {
|
|
127
|
+
if (indexOfDeclaration(intersection, decl) !== -1) {
|
|
128
|
+
decl.remove();
|
|
129
|
+
receivingBlock.append(decl);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
let laterIndex = 0;
|
|
133
|
+
secondClone.walkDecls((decl) => {
|
|
134
|
+
if (claimedIndices.has(laterIndex++)) {
|
|
135
|
+
decl.remove();
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
flush(first, ruleMeta);
|
|
139
|
+
flush(second, ruleMeta);
|
|
140
|
+
const merged = ruleLength(firstClone, receivingBlock, secondClone);
|
|
141
|
+
const original = ruleLength(first, second);
|
|
142
|
+
if (merged < original) {
|
|
143
|
+
first.replaceWith(firstClone);
|
|
144
|
+
second.replaceWith(secondClone);
|
|
145
|
+
for (const rule of [firstClone, receivingBlock, secondClone]) {
|
|
146
|
+
if (rule.nodes.length === 0) rule.remove();
|
|
147
|
+
}
|
|
148
|
+
if (!secondClone.parent) {
|
|
149
|
+
ruleCache?.add(receivingBlock);
|
|
150
|
+
return {
|
|
151
|
+
rule: receivingBlock,
|
|
152
|
+
replacements: [firstClone, receivingBlock].filter((rule) =>
|
|
153
|
+
Boolean(rule.parent)
|
|
154
|
+
),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
ruleCache?.add(receivingBlock);
|
|
158
|
+
ruleCache?.add(secondClone);
|
|
159
|
+
ruleMeta?.delete(first);
|
|
160
|
+
ruleMeta?.delete(second);
|
|
161
|
+
return {
|
|
162
|
+
rule: secondClone,
|
|
163
|
+
replacements: [firstClone, receivingBlock, secondClone].filter((rule) =>
|
|
164
|
+
Boolean(rule.parent)
|
|
165
|
+
),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
receivingBlock.remove();
|
|
169
|
+
return { rule: second, replacements: [] };
|
|
170
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const _exports: import("postcss").PluginCreator<Options>;
|
|
2
|
-
export = _exports;
|
|
3
1
|
import type browserslist from 'browserslist';
|
|
4
2
|
import type { Declaration } from 'postcss';
|
|
5
3
|
export type RuleMeta = {
|
|
@@ -21,4 +19,19 @@ export type AutoprefixerOptions = {
|
|
|
21
19
|
};
|
|
22
20
|
export type BrowserslistOptions = Pick<browserslist.Options, 'stats' | 'path' | 'env'>;
|
|
23
21
|
export type Options = AutoprefixerOptions & BrowserslistOptions;
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
|
|
24
|
+
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
|
|
25
|
+
* @typedef {AutoprefixerOptions & BrowserslistOptions} Options
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @param {Options} opts
|
|
29
|
+
* @return {import('postcss').Plugin}
|
|
30
|
+
*/
|
|
31
|
+
declare function pluginCreator(opts?: Options): import('postcss').Plugin;
|
|
32
|
+
declare namespace pluginCreator {
|
|
33
|
+
var postcss: true;
|
|
34
|
+
}
|
|
35
|
+
declare const moduleExports: typeof pluginCreator;
|
|
36
|
+
export { moduleExports as default, moduleExports as 'module.exports' };
|
|
24
37
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAoBI,OAAQ,KAAA,YAAY,MAAM,cAAc,CAAA;AAExC,OAAQ,KAAA,EAAC,WAAW,EAAO,MAAM,SAAS,CAAA;AAE3C,YAAkB,QAAQ,GAC1B;;;;IAAqB,SAAS,EAAnB,MAAM,EAAE,CACnB;;;;IAA0B,YAAY,EAA3B,WAAW,EAAE,CACxB;;;;IAAoB,KAAK,EAAd,OAAO,CACpB;CAAA,CAAA;AAoqBE,YAAwD,mBAAmB,GAAjE;IAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,CAAqB;AAC3E,YAAgE,mBAAmB,GAAzE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,CAAqB;AACnF,YAAqD,OAAO,GAAlD,mBAAmB,GAAG,mBAAmB,CAAS;AAH/D;;;;GAIG;AAEH;;;GAGG;AACH,iBAAS,aAAa,CAAC,IAAI,GAHhB,OAGqB,GAFpB,OAAO,SAAS,EAAE,MAAM,CAmCnC;kBAjCQ,aAAa;iBAkCX,IAAI;;AAEf,QAAA,MAAM,aAAa,sBAAgB,CAAC;AAEpC,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import browserslist from 'browserslist';
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* @param {{overrideBrowserslist?: string | string[] | undefined, stats?: browserslist.Options["stats"], path?: browserslist.Options["path"], env?: browserslist.Options["env"]}} options
|
|
@@ -14,5 +14,5 @@ declare function computeBrowsersToSupport(options: {
|
|
|
14
14
|
path?: browserslist.Options["path"];
|
|
15
15
|
env?: browserslist.Options["env"];
|
|
16
16
|
}, stats: browserslist.Options["stats"], from: string | undefined, file?: string, env?: browserslist.Options["env"]): string[];
|
|
17
|
-
|
|
17
|
+
export default computeBrowsersToSupport;
|
|
18
18
|
//# sourceMappingURL=computeBrowsersToSupport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeBrowsersToSupport.d.ts","sourceRoot":"","sources":["../../src/lib/computeBrowsersToSupport.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"computeBrowsersToSupport.d.ts","sourceRoot":"","sources":["../../src/lib/computeBrowsersToSupport.js"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAKxC;;;;;;;;GAQG;AACH,iBAAS,wBAAwB,CAAC,OAAO,EAP9B;IAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAAC,GAAG,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;CAOtI,EAAE,KAAK,EANrC,YAAY,CAAC,OAAO,CAAC,OAAO,CAMS,EAAE,IAAI,EAL3C,MAAM,GAAC,SAKoC,EAAE,IAAI,AAJzD,CACA,EADQ,MAIiD,EAAE,GAAG,AAH9D,CACA,EADQ,YAAY,CAAC,OAAO,CAAC,KAAK,CAG4B,GAFpD,MAAM,EAAE,CASpB;eAEc,wBAAwB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Declaration } from 'postcss';
|
|
2
|
+
/**
|
|
3
|
+
* @param {Declaration[]} array
|
|
4
|
+
* @param {Declaration} decl
|
|
5
|
+
* @return {number}
|
|
6
|
+
*/
|
|
7
|
+
export declare function indexOfDeclaration(array: Declaration[], decl: Declaration): number;
|
|
8
|
+
/**
|
|
9
|
+
* @param {Declaration[]} a
|
|
10
|
+
* @param {Declaration[]} b
|
|
11
|
+
* @param {boolean} [not=false]
|
|
12
|
+
* @return {Declaration[]}
|
|
13
|
+
*/
|
|
14
|
+
export declare function intersect(a: Declaration[], b: Declaration[], not?: boolean): Declaration[];
|
|
15
|
+
/**
|
|
16
|
+
* @param {Declaration[]} a
|
|
17
|
+
* @param {Declaration[]} b
|
|
18
|
+
* @return {boolean}
|
|
19
|
+
*/
|
|
20
|
+
export declare function sameDeclarationsAndOrder(a: Declaration[], b: Declaration[]): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @param {Declaration[]} hoistCandidates
|
|
23
|
+
* @param {Declaration[]} earlierRuleDeclarations
|
|
24
|
+
* @param {Declaration[]} laterRuleDeclarations
|
|
25
|
+
* @return {{intersection: Declaration[], claimedIndices: Set<number>}}
|
|
26
|
+
*/
|
|
27
|
+
export declare function filterRuleIntersections(hoistCandidates: Declaration[], earlierRuleDeclarations: Declaration[], laterRuleDeclarations: Declaration[]): {
|
|
28
|
+
intersection: Declaration[];
|
|
29
|
+
claimedIndices: Set<number>;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/lib/declarations.js"],"names":[],"mappings":"AAEI,OAAQ,KAAA,EAAC,WAAW,EAAC,MAAM,SAAS,CAAA;AAaxC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAJ7B,WAAW,EAIkB,EAAE,IAAI,EAHnC,WAGmC,GAFlC,MAAM,CAIjB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EALhB,WAAW,EAKK,EAAE,CAAC,EAJnB,WAAW,EAIQ,EAAE,GAAG,AAHhC,CACA,EADQ,OAGwB,GAFvB,WAAW,EAAE,CAOxB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAJ/B,WAAW,EAIoB,EAAE,CAAC,EAHlC,WAAW,EAGuB,GAFjC,OAAO,CAOlB;AAkED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EANN,WAAW,EAML,EACf,uBAAuB,EANd,WAAW,EAMG,EACvB,qBAAqB,EANZ,WAAW,EAMC,GALX;IAAC,YAAY,EAAE,WAAW,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAC,CA4BrE"}
|
|
@@ -1,62 +1,3 @@
|
|
|
1
|
-
declare const _exports: {
|
|
2
|
-
sameVendor: typeof sameVendor;
|
|
3
|
-
noVendor: typeof noVendor;
|
|
4
|
-
pseudoElements: {
|
|
5
|
-
':active': string;
|
|
6
|
-
':after': string;
|
|
7
|
-
':any-link': string;
|
|
8
|
-
':before': string;
|
|
9
|
-
':checked': string;
|
|
10
|
-
':default': string;
|
|
11
|
-
':dir': string;
|
|
12
|
-
':disabled': string;
|
|
13
|
-
':empty': string;
|
|
14
|
-
':enabled': string;
|
|
15
|
-
':first-child': string;
|
|
16
|
-
':first-letter': string;
|
|
17
|
-
':first-line': string;
|
|
18
|
-
':first-of-type': string;
|
|
19
|
-
':focus': string;
|
|
20
|
-
':focus-within': string;
|
|
21
|
-
':focus-visible': string;
|
|
22
|
-
':has': string;
|
|
23
|
-
':hover': string;
|
|
24
|
-
':in-range': string;
|
|
25
|
-
':indeterminate': string;
|
|
26
|
-
':invalid': string;
|
|
27
|
-
':is': string;
|
|
28
|
-
':lang': string;
|
|
29
|
-
':last-child': string;
|
|
30
|
-
':last-of-type': string;
|
|
31
|
-
':link': string;
|
|
32
|
-
':matches': string;
|
|
33
|
-
':not': string;
|
|
34
|
-
':nth-child': string;
|
|
35
|
-
':nth-last-child': string;
|
|
36
|
-
':nth-last-of-type': string;
|
|
37
|
-
':nth-of-type': string;
|
|
38
|
-
':only-child': string;
|
|
39
|
-
':only-of-type': string;
|
|
40
|
-
':optional': string;
|
|
41
|
-
':out-of-range': string;
|
|
42
|
-
':placeholder-shown': string;
|
|
43
|
-
':required': string;
|
|
44
|
-
':root': string;
|
|
45
|
-
':target': string;
|
|
46
|
-
'::after': string;
|
|
47
|
-
'::backdrop': string;
|
|
48
|
-
'::before': string;
|
|
49
|
-
'::first-letter': string;
|
|
50
|
-
'::first-line': string;
|
|
51
|
-
'::marker': string;
|
|
52
|
-
'::placeholder': string;
|
|
53
|
-
'::selection': string;
|
|
54
|
-
':valid': string;
|
|
55
|
-
':visited': string;
|
|
56
|
-
};
|
|
57
|
-
ensureCompatibility: typeof ensureCompatibility;
|
|
58
|
-
};
|
|
59
|
-
export = _exports;
|
|
60
1
|
/**
|
|
61
2
|
* @param {string[]} selectorsA
|
|
62
3
|
* @param {string[]} selectorsB
|
|
@@ -68,6 +9,59 @@ declare function sameVendor(selectorsA: string[], selectorsB: string[]): boolean
|
|
|
68
9
|
* @return {boolean}
|
|
69
10
|
*/
|
|
70
11
|
declare function noVendor(selector: string): boolean;
|
|
12
|
+
declare const pseudoElements: {
|
|
13
|
+
':active': string;
|
|
14
|
+
':after': string;
|
|
15
|
+
':any-link': string;
|
|
16
|
+
':before': string;
|
|
17
|
+
':checked': string;
|
|
18
|
+
':default': string;
|
|
19
|
+
':dir': string;
|
|
20
|
+
':disabled': string;
|
|
21
|
+
':empty': string;
|
|
22
|
+
':enabled': string;
|
|
23
|
+
':first-child': string;
|
|
24
|
+
':first-letter': string;
|
|
25
|
+
':first-line': string;
|
|
26
|
+
':first-of-type': string;
|
|
27
|
+
':focus': string;
|
|
28
|
+
':focus-within': string;
|
|
29
|
+
':focus-visible': string;
|
|
30
|
+
':has': string;
|
|
31
|
+
':hover': string;
|
|
32
|
+
':in-range': string;
|
|
33
|
+
':indeterminate': string;
|
|
34
|
+
':invalid': string;
|
|
35
|
+
':is': string;
|
|
36
|
+
':lang': string;
|
|
37
|
+
':last-child': string;
|
|
38
|
+
':last-of-type': string;
|
|
39
|
+
':link': string;
|
|
40
|
+
':matches': string;
|
|
41
|
+
':not': string;
|
|
42
|
+
':nth-child': string;
|
|
43
|
+
':nth-last-child': string;
|
|
44
|
+
':nth-last-of-type': string;
|
|
45
|
+
':nth-of-type': string;
|
|
46
|
+
':only-child': string;
|
|
47
|
+
':only-of-type': string;
|
|
48
|
+
':optional': string;
|
|
49
|
+
':out-of-range': string;
|
|
50
|
+
':placeholder-shown': string;
|
|
51
|
+
':required': string;
|
|
52
|
+
':root': string;
|
|
53
|
+
':target': string;
|
|
54
|
+
'::after': string;
|
|
55
|
+
'::backdrop': string;
|
|
56
|
+
'::before': string;
|
|
57
|
+
'::first-letter': string;
|
|
58
|
+
'::first-line': string;
|
|
59
|
+
'::marker': string;
|
|
60
|
+
'::placeholder': string;
|
|
61
|
+
'::selection': string;
|
|
62
|
+
':valid': string;
|
|
63
|
+
':visited': string;
|
|
64
|
+
};
|
|
71
65
|
/**
|
|
72
66
|
* @param {string[]} selectors
|
|
73
67
|
* @param{string[]=} browsers
|
|
@@ -75,4 +69,5 @@ declare function noVendor(selector: string): boolean;
|
|
|
75
69
|
* @return {boolean}
|
|
76
70
|
*/
|
|
77
71
|
declare function ensureCompatibility(selectors: string[], browsers?: string[] | undefined, compatibilityCache?: Map<string, boolean> | undefined): boolean;
|
|
72
|
+
export { sameVendor, noVendor, pseudoElements, ensureCompatibility };
|
|
78
73
|
//# sourceMappingURL=ensureCompatibility.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureCompatibility.d.ts","sourceRoot":"","sources":["../../src/lib/ensureCompatibility.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ensureCompatibility.d.ts","sourceRoot":"","sources":["../../src/lib/ensureCompatibility.js"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,iBAAS,UAAU,CAAC,UAAU,EAJnB,MAAM,EAIa,EAAE,UAAU,EAH/B,MAAM,EAGyB,GAF9B,OAAO,CAWlB;AAED;;;GAGG;AACH,iBAAS,QAAQ,CAAC,QAAQ,EAHf,MAGe,GAFd,OAAO,CAIlB;AAED,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDnB,CAAC;AAsDF;;;;;GAKG;AACH,iBAAS,mBAAmB,CAAC,SAAS,EAL3B,MAAM,EAKqB,EAAE,QAAQ,AAJ7C,CACA,EADO,MAAM,EAAE,YAI8B,EAAE,kBAAkB,AAHjE,CACA,EADO,GAAG,CAAC,MAAM,EAAC,OAAO,CAAC,YAGuC,GAFxD,OAAO,CA0ElB;AAED,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
declare function
|
|
1
|
+
export default _default;
|
|
2
|
+
declare function _default(): string[];
|
|
3
3
|
//# sourceMappingURL=getBrowsersForWebBuild.d.ts.map
|