tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +380 -1
- package/LICENSE +1 -2
- package/README.md +8 -4
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +3 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +311 -213
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +11 -1
- package/lib/corePlugins.js +1895 -1773
- package/lib/css/preflight.css +19 -13
- package/lib/featureFlags.js +22 -16
- package/lib/index.js +17 -8
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +30 -14
- package/lib/lib/collapseDuplicateDeclarations.js +80 -0
- package/lib/lib/defaultExtractor.js +187 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +40 -24
- package/lib/lib/expandApplyAtRules.js +414 -157
- package/lib/lib/expandTailwindAtRules.js +156 -151
- package/lib/lib/generateRules.js +402 -68
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +45 -36
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/regex.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +105 -90
- package/lib/lib/setupContextUtils.js +416 -291
- package/lib/lib/setupTrackingContext.js +60 -56
- package/lib/lib/sharedState.js +38 -15
- package/lib/lib/substituteScreenAtRules.js +9 -6
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +85 -0
- package/lib/processTailwindFeatures.js +21 -9
- package/lib/public/colors.js +244 -248
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +43 -32
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +13 -17
- package/lib/util/dataTypes.js +114 -74
- package/lib/util/defaults.js +6 -0
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -4
- package/lib/util/formatVariantSelector.js +194 -0
- package/lib/util/getAllConfigs.js +13 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +35 -19
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +5 -3
- package/lib/util/normalizeConfig.js +233 -0
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +76 -0
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +67 -170
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +123 -133
- package/lib/util/resolveConfigPath.js +17 -18
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +72 -0
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +42 -34
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +19 -19
- package/nesting/index.js +2 -12
- package/package.json +41 -42
- package/peers/index.js +11539 -10859
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/create-plugin-list.js +2 -2
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +174 -41
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +641 -596
- package/src/css/preflight.css +19 -13
- package/src/featureFlags.js +16 -10
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/defaultExtractor.js +192 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +24 -7
- package/src/lib/expandApplyAtRules.js +442 -154
- package/src/lib/expandTailwindAtRules.js +91 -65
- package/src/lib/generateRules.js +409 -43
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +74 -53
- package/src/lib/setupContextUtils.js +388 -208
- package/src/lib/setupTrackingContext.js +15 -12
- package/src/lib/sharedState.js +42 -7
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +17 -2
- package/src/public/colors.js +4 -9
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +56 -16
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +213 -0
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +2 -2
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +262 -0
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/pluginUtils.js +51 -147
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +108 -79
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +24 -7
- package/src/util/validateConfig.js +13 -0
- package/stubs/defaultConfig.stub.js +157 -94
- package/stubs/simpleConfig.stub.js +0 -1
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types.d.ts +1 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function partitionRules(root) {
|
|
2
|
+
if (!root.walkAtRules) return
|
|
3
|
+
|
|
4
|
+
let applyParents = new Set()
|
|
5
|
+
|
|
6
|
+
root.walkAtRules('apply', (rule) => {
|
|
7
|
+
applyParents.add(rule.parent)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
if (applyParents.size === 0) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
for (let rule of applyParents) {
|
|
15
|
+
let nodeGroups = []
|
|
16
|
+
let lastGroup = []
|
|
17
|
+
|
|
18
|
+
for (let node of rule.nodes) {
|
|
19
|
+
if (node.type === 'atrule' && node.name === 'apply') {
|
|
20
|
+
if (lastGroup.length > 0) {
|
|
21
|
+
nodeGroups.push(lastGroup)
|
|
22
|
+
lastGroup = []
|
|
23
|
+
}
|
|
24
|
+
nodeGroups.push([node])
|
|
25
|
+
} else {
|
|
26
|
+
lastGroup.push(node)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (lastGroup.length > 0) {
|
|
31
|
+
nodeGroups.push(lastGroup)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (nodeGroups.length === 1) {
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (let group of [...nodeGroups].reverse()) {
|
|
39
|
+
let clone = rule.clone({ nodes: [] })
|
|
40
|
+
clone.append(group)
|
|
41
|
+
rule.after(clone)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
rule.remove()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default function expandApplyAtRules() {
|
|
49
|
+
return (root) => {
|
|
50
|
+
partitionRules(root)
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/lib/regex.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g
|
|
2
|
+
const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source)
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string|RegExp|Array<string|RegExp>} source
|
|
6
|
+
*/
|
|
7
|
+
function toSource(source) {
|
|
8
|
+
source = Array.isArray(source) ? source : [source]
|
|
9
|
+
|
|
10
|
+
source = source.map((item) => (item instanceof RegExp ? item.source : item))
|
|
11
|
+
|
|
12
|
+
return source.join('')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string|RegExp|Array<string|RegExp>} source
|
|
17
|
+
*/
|
|
18
|
+
export function pattern(source) {
|
|
19
|
+
return new RegExp(toSource(source), 'g')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string|RegExp|Array<string|RegExp>} source
|
|
24
|
+
*/
|
|
25
|
+
export function withoutCapturing(source) {
|
|
26
|
+
return new RegExp(`(?:${toSource(source)})`, 'g')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {Array<string|RegExp>} sources
|
|
31
|
+
*/
|
|
32
|
+
export function any(sources) {
|
|
33
|
+
return `(?:${sources.map(toSource).join('|')})`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string|RegExp} source
|
|
38
|
+
*/
|
|
39
|
+
export function optional(source) {
|
|
40
|
+
return `(?:${toSource(source)})?`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {string|RegExp|Array<string|RegExp>} source
|
|
45
|
+
*/
|
|
46
|
+
export function zeroOrMore(source) {
|
|
47
|
+
return `(?:${toSource(source)})*`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Generate a RegExp that matches balanced brackets for a given depth
|
|
52
|
+
* We have to specify a depth because JS doesn't support recursive groups using ?R
|
|
53
|
+
*
|
|
54
|
+
* Based on https://stackoverflow.com/questions/17759004/how-to-match-string-within-parentheses-nested-in-java/17759264#17759264
|
|
55
|
+
*
|
|
56
|
+
* @param {string|RegExp|Array<string|RegExp>} source
|
|
57
|
+
*/
|
|
58
|
+
export function nestedBrackets(open, close, depth = 1) {
|
|
59
|
+
return withoutCapturing([
|
|
60
|
+
escape(open),
|
|
61
|
+
/[^\s]*/,
|
|
62
|
+
depth === 1
|
|
63
|
+
? `[^${escape(open)}${escape(close)}\s]*`
|
|
64
|
+
: any([`[^${escape(open)}${escape(close)}\s]*`, nestedBrackets(open, close, depth - 1)]),
|
|
65
|
+
/[^\s]*/,
|
|
66
|
+
escape(close),
|
|
67
|
+
])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function escape(string) {
|
|
71
|
+
return string && REGEX_HAS_SPECIAL.test(string)
|
|
72
|
+
? string.replace(REGEX_SPECIAL, '\\$&')
|
|
73
|
+
: string || ''
|
|
74
|
+
}
|
|
@@ -2,60 +2,56 @@ import postcss from 'postcss'
|
|
|
2
2
|
import selectorParser from 'postcss-selector-parser'
|
|
3
3
|
import { flagEnabled } from '../featureFlags'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
let getNode = {
|
|
6
|
+
id(node) {
|
|
7
|
+
return selectorParser.attribute({
|
|
8
|
+
attribute: 'id',
|
|
9
|
+
operator: '=',
|
|
10
|
+
value: node.value,
|
|
11
|
+
quoteMark: '"',
|
|
12
|
+
})
|
|
13
|
+
},
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function minimumImpactSelector(nodes) {
|
|
17
17
|
let rest = nodes
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// Keep pseudo
|
|
23
|
-
|
|
18
|
+
.filter((node) => {
|
|
19
|
+
// Keep non-pseudo nodes
|
|
20
|
+
if (node.type !== 'pseudo') return true
|
|
21
|
+
|
|
22
|
+
// Keep pseudo nodes that have subnodes
|
|
23
|
+
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
24
|
+
if (node.nodes.length > 0) return true
|
|
25
|
+
|
|
26
|
+
// Keep pseudo `elements`
|
|
27
|
+
// This implicitly means that we ignore pseudo `classes`
|
|
28
|
+
return (
|
|
29
|
+
node.value.startsWith('::') ||
|
|
30
|
+
[':before', ':after', ':first-line', ':first-letter'].includes(node.value)
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
.reverse()
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
if (idx > 0 && n.type === 'pseudo' && all[idx - 1].type === 'pseudo') return false
|
|
35
|
+
let searchFor = new Set(['tag', 'class', 'id', 'attribute'])
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
let splitPointIdx = rest.findIndex((n) => searchFor.has(n.type))
|
|
38
|
+
if (splitPointIdx === -1) return rest.reverse().join('').trim()
|
|
30
39
|
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
operator: '=',
|
|
41
|
-
value: n.value,
|
|
42
|
-
quoteMark: '"',
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
['attribute'],
|
|
46
|
-
]) {
|
|
47
|
-
let match = nodes.find((n) => n.type === type)
|
|
48
|
-
|
|
49
|
-
if (match) {
|
|
50
|
-
bestNode = getNode(match)
|
|
51
|
-
break
|
|
52
|
-
}
|
|
40
|
+
let node = rest[splitPointIdx]
|
|
41
|
+
let bestNode = getNode[node.type] ? getNode[node.type](node) : node
|
|
42
|
+
|
|
43
|
+
rest = rest.slice(0, splitPointIdx)
|
|
44
|
+
|
|
45
|
+
let combinatorIdx = rest.findIndex((n) => n.type === 'combinator' && n.value === '>')
|
|
46
|
+
if (combinatorIdx !== -1) {
|
|
47
|
+
rest.splice(0, combinatorIdx)
|
|
48
|
+
rest.unshift(selectorParser.universal())
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
return [bestNode, ...rest].join('').trim()
|
|
51
|
+
return [bestNode, ...rest.reverse()].join('').trim()
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
let elementSelectorParser = selectorParser((selectors) => {
|
|
54
|
+
export let elementSelectorParser = selectorParser((selectors) => {
|
|
59
55
|
return selectors.map((s) => {
|
|
60
56
|
let nodes = s.split((n) => n.type === 'combinator' && n.value === ' ').pop()
|
|
61
57
|
return minimumImpactSelector(nodes)
|
|
@@ -75,6 +71,8 @@ function extractElementSelector(selector) {
|
|
|
75
71
|
export default function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
76
72
|
return (root) => {
|
|
77
73
|
let variableNodeMap = new Map()
|
|
74
|
+
|
|
75
|
+
/** @type {Set<import('postcss').AtRule>} */
|
|
78
76
|
let universals = new Set()
|
|
79
77
|
|
|
80
78
|
root.walkAtRules('defaults', (rule) => {
|
|
@@ -94,31 +92,54 @@ export default function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
94
92
|
})
|
|
95
93
|
|
|
96
94
|
for (let universal of universals) {
|
|
97
|
-
|
|
95
|
+
/** @type {Map<string, Set<string>>} */
|
|
96
|
+
let selectorGroups = new Map()
|
|
98
97
|
|
|
99
98
|
let rules = variableNodeMap.get(universal.params) ?? []
|
|
100
99
|
|
|
101
100
|
for (let rule of rules) {
|
|
102
101
|
for (let selector of extractElementSelector(rule.selector)) {
|
|
102
|
+
// If selector contains a vendor prefix after a pseudo element or class,
|
|
103
|
+
// we consider them separately because merging the declarations into
|
|
104
|
+
// a single rule will cause browsers that do not understand the
|
|
105
|
+
// vendor prefix to throw out the whole rule
|
|
106
|
+
let selectorGroupName =
|
|
107
|
+
selector.includes(':-') || selector.includes('::-') ? selector : '__DEFAULT__'
|
|
108
|
+
|
|
109
|
+
let selectors = selectorGroups.get(selectorGroupName) ?? new Set()
|
|
110
|
+
selectorGroups.set(selectorGroupName, selectors)
|
|
111
|
+
|
|
103
112
|
selectors.add(selector)
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
if (flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
|
|
117
|
+
if (selectorGroups.size === 0) {
|
|
118
|
+
universal.remove()
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
111
121
|
|
|
112
|
-
|
|
122
|
+
for (let [, selectors] of selectorGroups) {
|
|
123
|
+
let universalRule = postcss.rule({
|
|
124
|
+
source: universal.source,
|
|
125
|
+
})
|
|
113
126
|
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
universalRule.selectors = [...selectors]
|
|
128
|
+
|
|
129
|
+
universalRule.append(universal.nodes.map((node) => node.clone()))
|
|
130
|
+
universal.before(universalRule)
|
|
131
|
+
}
|
|
116
132
|
} else {
|
|
133
|
+
let universalRule = postcss.rule({
|
|
134
|
+
source: universal.source,
|
|
135
|
+
})
|
|
136
|
+
|
|
117
137
|
universalRule.selectors = ['*', '::before', '::after']
|
|
138
|
+
|
|
139
|
+
universalRule.append(universal.nodes)
|
|
140
|
+
universal.before(universalRule)
|
|
118
141
|
}
|
|
119
142
|
|
|
120
|
-
universalRule.append(universal.nodes)
|
|
121
|
-
universal.before(universalRule)
|
|
122
143
|
universal.remove()
|
|
123
144
|
}
|
|
124
145
|
}
|