tailwindcss 3.3.1 → 3.3.3
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 +47 -6
- package/lib/cli/build/deps.js +17 -9
- package/lib/cli/build/index.js +10 -8
- package/lib/cli/build/plugin.js +29 -27
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +12 -10
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +4 -4
- package/lib/cli/init/index.js +8 -6
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +3 -1
- package/lib/corePlugins.js +52 -42
- package/lib/css/preflight.css +9 -0
- package/lib/featureFlags.js +14 -9
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +3 -1
- package/lib/lib/collapseDuplicateDeclarations.js +10 -8
- package/lib/lib/content.js +18 -14
- package/lib/lib/defaultExtractor.js +6 -4
- package/lib/lib/detectNesting.js +3 -1
- package/lib/lib/evaluateTailwindFunctions.js +20 -16
- package/lib/lib/expandApplyAtRules.js +37 -40
- package/lib/lib/expandTailwindAtRules.js +19 -17
- package/lib/lib/findAtConfigPath.js +6 -4
- package/lib/lib/generateRules.js +52 -38
- package/lib/lib/getModuleDependencies.js +10 -8
- package/lib/lib/load-config.js +5 -3
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +7 -5
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +3 -1
- package/lib/lib/resolveDefaultsAtRules.js +24 -20
- package/lib/lib/setupContextUtils.js +91 -63
- package/lib/lib/setupTrackingContext.js +27 -24
- package/lib/lib/sharedState.js +28 -24
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/oxide/cli/build/deps.js +16 -8
- package/lib/oxide/cli/build/index.js +6 -4
- package/lib/oxide/cli/build/plugin.js +19 -17
- package/lib/oxide/cli/build/utils.js +18 -8
- package/lib/oxide/cli/build/watching.js +10 -8
- package/lib/oxide/cli/help/index.js +6 -4
- package/lib/oxide/cli/index.js +4 -4
- package/lib/oxide/cli/init/index.js +6 -4
- package/lib/plugin.js +9 -9
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +8 -6
- package/lib/processTailwindFeatures.js +16 -14
- package/lib/public/colors.js +5 -3
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +5 -3
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +9 -10
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +3 -1
- package/lib/util/color.js +10 -6
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +5 -3
- package/lib/util/dataTypes.js +59 -21
- package/lib/util/defaults.js +6 -4
- package/lib/util/escapeClassName.js +7 -5
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +30 -110
- package/lib/util/getAllConfigs.js +6 -4
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +8 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +7 -5
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +30 -18
- package/lib/util/prefixSelector.js +6 -4
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +10 -8
- package/lib/util/resolveConfigPath.js +9 -5
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +3 -1
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +5 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/package.json +30 -35
- package/peers/index.js +65828 -48819
- package/src/cli/build/plugin.js +3 -3
- package/src/cli.js +1 -1
- package/src/corePlugins.js +29 -24
- package/src/css/preflight.css +9 -0
- package/src/featureFlags.js +2 -3
- package/src/index.js +1 -5
- package/src/lib/defaultExtractor.js +1 -1
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +2 -8
- package/src/lib/expandTailwindAtRules.js +12 -10
- package/src/lib/generateRules.js +15 -8
- package/src/lib/setupContextUtils.js +18 -5
- package/src/lib/setupTrackingContext.js +2 -4
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +4 -4
- package/src/processTailwindFeatures.js +3 -2
- package/src/util/applyImportantSelector.js +2 -5
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +17 -6
- package/src/util/formatVariantSelector.js +4 -126
- package/src/util/pluginUtils.js +1 -5
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +167 -0
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/config.full.js +1 -0
- package/types/generated/default-theme.d.ts +1 -0
package/src/cli/build/plugin.js
CHANGED
|
@@ -185,7 +185,7 @@ let state = {
|
|
|
185
185
|
let files = fastGlob.sync(this.contentPatterns.all)
|
|
186
186
|
|
|
187
187
|
for (let file of files) {
|
|
188
|
-
if (
|
|
188
|
+
if (__OXIDE__) {
|
|
189
189
|
content.push({
|
|
190
190
|
file,
|
|
191
191
|
extension: path.extname(file).slice(1),
|
|
@@ -278,9 +278,9 @@ export async function createProcessor(args, cliConfigPath) {
|
|
|
278
278
|
let tailwindPlugin = () => {
|
|
279
279
|
return {
|
|
280
280
|
postcssPlugin: 'tailwindcss',
|
|
281
|
-
Once(root, { result }) {
|
|
281
|
+
async Once(root, { result }) {
|
|
282
282
|
env.DEBUG && console.time('Compiling CSS')
|
|
283
|
-
tailwind(({ createContext }) => {
|
|
283
|
+
await tailwind(({ createContext }) => {
|
|
284
284
|
console.error()
|
|
285
285
|
console.error('Rebuilding...')
|
|
286
286
|
|
package/src/cli.js
CHANGED
package/src/corePlugins.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import postcss from 'postcss'
|
|
4
|
-
import { env } from './lib/sharedState'
|
|
5
4
|
import createUtilityPlugin from './util/createUtilityPlugin'
|
|
6
5
|
import buildMediaQuery from './util/buildMediaQuery'
|
|
7
6
|
import escapeClassName from './util/escapeClassName'
|
|
@@ -23,6 +22,7 @@ import { formatBoxShadowValue, parseBoxShadowValue } from './util/parseBoxShadow
|
|
|
23
22
|
import { removeAlphaVariables } from './util/removeAlphaVariables'
|
|
24
23
|
import { flagEnabled } from './featureFlags'
|
|
25
24
|
import { normalize } from './util/dataTypes'
|
|
25
|
+
import { INTERNAL_FEATURES } from './lib/setupContextUtils'
|
|
26
26
|
|
|
27
27
|
export let variantPlugins = {
|
|
28
28
|
pseudoElementVariants: ({ addVariant }) => {
|
|
@@ -81,7 +81,7 @@ export let variantPlugins = {
|
|
|
81
81
|
})
|
|
82
82
|
},
|
|
83
83
|
|
|
84
|
-
pseudoClassVariants: ({ addVariant, matchVariant, config }) => {
|
|
84
|
+
pseudoClassVariants: ({ addVariant, matchVariant, config, prefix }) => {
|
|
85
85
|
let pseudoVariants = [
|
|
86
86
|
// Positional
|
|
87
87
|
['first', '&:first-child'],
|
|
@@ -152,12 +152,12 @@ export let variantPlugins = {
|
|
|
152
152
|
let variants = {
|
|
153
153
|
group: (_, { modifier }) =>
|
|
154
154
|
modifier
|
|
155
|
-
? [`:merge(.group\\/${escapeClassName(modifier)})`, ' &']
|
|
156
|
-
: [`:merge(.group)`, ' &'],
|
|
155
|
+
? [`:merge(${prefix('.group')}\\/${escapeClassName(modifier)})`, ' &']
|
|
156
|
+
: [`:merge(${prefix('.group')})`, ' &'],
|
|
157
157
|
peer: (_, { modifier }) =>
|
|
158
158
|
modifier
|
|
159
|
-
? [`:merge(.peer\\/${escapeClassName(modifier)})`, ' ~ &']
|
|
160
|
-
: [`:merge(.peer)`, ' ~ &'],
|
|
159
|
+
? [`:merge(${prefix('.peer')}\\/${escapeClassName(modifier)})`, ' ~ &']
|
|
160
|
+
: [`:merge(${prefix('.peer')})`, ' ~ &'],
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
for (let [name, fn] of Object.entries(variants)) {
|
|
@@ -193,7 +193,12 @@ export let variantPlugins = {
|
|
|
193
193
|
|
|
194
194
|
return result.slice(0, start) + a + result.slice(start + 1, end) + b + result.slice(end)
|
|
195
195
|
},
|
|
196
|
-
{
|
|
196
|
+
{
|
|
197
|
+
values: Object.fromEntries(pseudoVariants),
|
|
198
|
+
[INTERNAL_FEATURES]: {
|
|
199
|
+
respectPrefix: false,
|
|
200
|
+
},
|
|
201
|
+
}
|
|
197
202
|
)
|
|
198
203
|
}
|
|
199
204
|
},
|
|
@@ -914,7 +919,7 @@ export let corePlugins = {
|
|
|
914
919
|
},
|
|
915
920
|
|
|
916
921
|
animation: ({ matchUtilities, theme, config }) => {
|
|
917
|
-
let prefixName = (name) =>
|
|
922
|
+
let prefixName = (name) => escapeClassName(config('prefix') + name)
|
|
918
923
|
let keyframes = Object.fromEntries(
|
|
919
924
|
Object.entries(theme('keyframes') ?? {}).map(([key, value]) => {
|
|
920
925
|
return [key, { [`@keyframes ${prefixName(key)}`]: value }]
|
|
@@ -1262,7 +1267,7 @@ export let corePlugins = {
|
|
|
1262
1267
|
'space-x': (value) => {
|
|
1263
1268
|
value = value === '0' ? '0px' : value
|
|
1264
1269
|
|
|
1265
|
-
if (
|
|
1270
|
+
if (__OXIDE__) {
|
|
1266
1271
|
return {
|
|
1267
1272
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
1268
1273
|
'--tw-space-x-reverse': '0',
|
|
@@ -1307,7 +1312,7 @@ export let corePlugins = {
|
|
|
1307
1312
|
'divide-x': (value) => {
|
|
1308
1313
|
value = value === '0' ? '0px' : value
|
|
1309
1314
|
|
|
1310
|
-
if (
|
|
1315
|
+
if (__OXIDE__) {
|
|
1311
1316
|
return {
|
|
1312
1317
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
1313
1318
|
'@defaults border-width': {},
|
|
@@ -1750,7 +1755,13 @@ export let corePlugins = {
|
|
|
1750
1755
|
return withAlphaValue(value, 0, 'rgb(255 255 255 / 0)')
|
|
1751
1756
|
}
|
|
1752
1757
|
|
|
1753
|
-
return function ({ matchUtilities, theme }) {
|
|
1758
|
+
return function ({ matchUtilities, theme, addDefaults }) {
|
|
1759
|
+
addDefaults('gradient-color-stops', {
|
|
1760
|
+
'--tw-gradient-from-position': ' ',
|
|
1761
|
+
'--tw-gradient-via-position': ' ',
|
|
1762
|
+
'--tw-gradient-to-position': ' ',
|
|
1763
|
+
})
|
|
1764
|
+
|
|
1754
1765
|
let options = {
|
|
1755
1766
|
values: flattenColorPalette(theme('gradientColorStops')),
|
|
1756
1767
|
type: ['color', 'any'],
|
|
@@ -1767,13 +1778,9 @@ export let corePlugins = {
|
|
|
1767
1778
|
let transparentToValue = transparentTo(value)
|
|
1768
1779
|
|
|
1769
1780
|
return {
|
|
1770
|
-
'
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
)} var(--tw-gradient-from-position)`,
|
|
1774
|
-
'--tw-gradient-from-position': ' ',
|
|
1775
|
-
'--tw-gradient-to': `${transparentToValue} var(--tw-gradient-from-position)`,
|
|
1776
|
-
'--tw-gradient-to-position': ' ',
|
|
1781
|
+
'@defaults gradient-color-stops': {},
|
|
1782
|
+
'--tw-gradient-from': `${toColorValue(value)} var(--tw-gradient-from-position)`,
|
|
1783
|
+
'--tw-gradient-to': `${transparentToValue} var(--tw-gradient-to-position)`,
|
|
1777
1784
|
'--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to)`,
|
|
1778
1785
|
}
|
|
1779
1786
|
},
|
|
@@ -1798,12 +1805,10 @@ export let corePlugins = {
|
|
|
1798
1805
|
let transparentToValue = transparentTo(value)
|
|
1799
1806
|
|
|
1800
1807
|
return {
|
|
1801
|
-
'
|
|
1808
|
+
'@defaults gradient-color-stops': {},
|
|
1802
1809
|
'--tw-gradient-to': `${transparentToValue} var(--tw-gradient-to-position)`,
|
|
1803
|
-
'--tw-gradient-to-position': ' ',
|
|
1804
1810
|
'--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
|
|
1805
|
-
value
|
|
1806
|
-
'via'
|
|
1811
|
+
value
|
|
1807
1812
|
)} var(--tw-gradient-via-position), var(--tw-gradient-to)`,
|
|
1808
1813
|
}
|
|
1809
1814
|
},
|
|
@@ -1825,8 +1830,8 @@ export let corePlugins = {
|
|
|
1825
1830
|
matchUtilities(
|
|
1826
1831
|
{
|
|
1827
1832
|
to: (value) => ({
|
|
1828
|
-
'
|
|
1829
|
-
'--tw-gradient-to
|
|
1833
|
+
'@defaults gradient-color-stops': {},
|
|
1834
|
+
'--tw-gradient-to': `${toColorValue(value)} var(--tw-gradient-to-position)`,
|
|
1830
1835
|
}),
|
|
1831
1836
|
},
|
|
1832
1837
|
options
|
package/src/css/preflight.css
CHANGED
|
@@ -163,6 +163,8 @@ optgroup,
|
|
|
163
163
|
select,
|
|
164
164
|
textarea {
|
|
165
165
|
font-family: inherit; /* 1 */
|
|
166
|
+
font-feature-settings: inherit; /* 1 */
|
|
167
|
+
font-variation-settings: inherit; /* 1 */
|
|
166
168
|
font-size: 100%; /* 1 */
|
|
167
169
|
font-weight: inherit; /* 1 */
|
|
168
170
|
line-height: inherit; /* 1 */
|
|
@@ -300,6 +302,13 @@ menu {
|
|
|
300
302
|
padding: 0;
|
|
301
303
|
}
|
|
302
304
|
|
|
305
|
+
/*
|
|
306
|
+
Reset default styling for dialogs.
|
|
307
|
+
*/
|
|
308
|
+
dialog {
|
|
309
|
+
padding: 0;
|
|
310
|
+
}
|
|
311
|
+
|
|
303
312
|
/*
|
|
304
313
|
Prevent resizing textareas horizontally by default.
|
|
305
314
|
*/
|
package/src/featureFlags.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import colors from 'picocolors'
|
|
2
2
|
import log from './util/log'
|
|
3
|
-
import { env } from './lib/sharedState'
|
|
4
3
|
|
|
5
4
|
let defaults = {
|
|
6
5
|
optimizeUniversalDefaults: false,
|
|
7
6
|
generalizedModifiers: true,
|
|
8
7
|
get disableColorOpacityUtilitiesByDefault() {
|
|
9
|
-
return
|
|
8
|
+
return __OXIDE__
|
|
10
9
|
},
|
|
11
10
|
get relativeContentPathsByDefault() {
|
|
12
|
-
return
|
|
11
|
+
return __OXIDE__
|
|
13
12
|
},
|
|
14
13
|
}
|
|
15
14
|
|
package/src/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function* buildRegExps(context) {
|
|
|
35
35
|
// This is a targeted fix to continue to allow theme()
|
|
36
36
|
// with square brackets to work in arbitrary properties
|
|
37
37
|
// while fixing a problem with the regex matching too much
|
|
38
|
-
/\[[^\s:'"`]+:[^\s]+?\[[^\s]
|
|
38
|
+
/\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
|
|
39
39
|
|
|
40
40
|
// Utilities
|
|
41
41
|
regex.pattern([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dlv from 'dlv'
|
|
2
2
|
import didYouMean from 'didyoumean'
|
|
3
3
|
import transformThemeValue from '../util/transformThemeValue'
|
|
4
|
-
import parseValue from '
|
|
4
|
+
import parseValue from '../value-parser/index'
|
|
5
5
|
import { normalizeScreens } from '../util/normalizeScreens'
|
|
6
6
|
import buildMediaQuery from '../util/buildMediaQuery'
|
|
7
7
|
import { toPath } from '../util/toPath'
|
|
@@ -146,6 +146,9 @@ function resolveVNode(node, vNode, functions) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
function resolveFunctions(node, input, functions) {
|
|
149
|
+
let hasAnyFn = Object.keys(functions).some((fn) => input.includes(`${fn}(`))
|
|
150
|
+
if (!hasAnyFn) return input
|
|
151
|
+
|
|
149
152
|
return parseValue(input)
|
|
150
153
|
.walk((vNode) => {
|
|
151
154
|
resolveVNode(node, vNode, functions)
|
|
@@ -4,7 +4,7 @@ import parser from 'postcss-selector-parser'
|
|
|
4
4
|
import { resolveMatches } from './generateRules'
|
|
5
5
|
import escapeClassName from '../util/escapeClassName'
|
|
6
6
|
import { applyImportantSelector } from '../util/applyImportantSelector'
|
|
7
|
-
import {
|
|
7
|
+
import { movePseudos } from '../util/pseudoElements'
|
|
8
8
|
|
|
9
9
|
/** @typedef {Map<string, [any, import('postcss').Rule[]]>} ApplyCache */
|
|
10
10
|
|
|
@@ -566,13 +566,7 @@ function processApply(root, context, localCache) {
|
|
|
566
566
|
|
|
567
567
|
// Move pseudo elements to the end of the selector (if necessary)
|
|
568
568
|
let selector = parser().astSync(rule.selector)
|
|
569
|
-
selector.each((sel) =>
|
|
570
|
-
let [pseudoElements] = collectPseudoElements(sel)
|
|
571
|
-
if (pseudoElements.length > 0) {
|
|
572
|
-
sel.nodes.push(...pseudoElements.sort(sortSelector))
|
|
573
|
-
}
|
|
574
|
-
})
|
|
575
|
-
|
|
569
|
+
selector.each((sel) => movePseudos(sel))
|
|
576
570
|
rule.selector = selector.toString()
|
|
577
571
|
})
|
|
578
572
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
|
-
import LRU from 'quick-lru'
|
|
2
|
+
import LRU from '@alloc/quick-lru'
|
|
3
3
|
import * as sharedState from './sharedState'
|
|
4
4
|
import { generateRules } from './generateRules'
|
|
5
5
|
import log from '../util/log'
|
|
@@ -98,7 +98,7 @@ function buildStylesheet(rules, context) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export default function expandTailwindAtRules(context) {
|
|
101
|
-
return (root) => {
|
|
101
|
+
return async (root) => {
|
|
102
102
|
let layerNodes = {
|
|
103
103
|
base: null,
|
|
104
104
|
components: null,
|
|
@@ -130,7 +130,7 @@ export default function expandTailwindAtRules(context) {
|
|
|
130
130
|
|
|
131
131
|
env.DEBUG && console.time('Reading changed files')
|
|
132
132
|
|
|
133
|
-
if (
|
|
133
|
+
if (__OXIDE__) {
|
|
134
134
|
// TODO: Pass through or implement `extractor`
|
|
135
135
|
for (let candidate of require('@tailwindcss/oxide').parseCandidateStringsFromFiles(
|
|
136
136
|
context.changedContent
|
|
@@ -145,12 +145,14 @@ export default function expandTailwindAtRules(context) {
|
|
|
145
145
|
// getClassCandidatesOxide(file, transformer(content), extractor, candidates, seen)
|
|
146
146
|
// }
|
|
147
147
|
} else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
await Promise.all(
|
|
149
|
+
context.changedContent.map(async ({ file, content, extension }) => {
|
|
150
|
+
let transformer = getTransformer(context.tailwindConfig, extension)
|
|
151
|
+
let extractor = getExtractor(context, extension)
|
|
152
|
+
content = file ? await fs.promises.readFile(file, 'utf8') : content
|
|
153
|
+
getClassCandidates(transformer(content), extractor, candidates, seen)
|
|
154
|
+
})
|
|
155
|
+
)
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
env.DEBUG && console.timeEnd('Reading changed files')
|
|
@@ -162,7 +164,7 @@ export default function expandTailwindAtRules(context) {
|
|
|
162
164
|
|
|
163
165
|
env.DEBUG && console.time('Generate rules')
|
|
164
166
|
env.DEBUG && console.time('Sorting candidates')
|
|
165
|
-
let sortedCandidates =
|
|
167
|
+
let sortedCandidates = __OXIDE__
|
|
166
168
|
? candidates
|
|
167
169
|
: new Set(
|
|
168
170
|
[...candidates].sort((a, z) => {
|
package/src/lib/generateRules.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '../util/formatVariantSelector'
|
|
14
14
|
import { asClass } from '../util/nameClass'
|
|
15
15
|
import { normalize } from '../util/dataTypes'
|
|
16
|
-
import { isValidVariantFormatString, parseVariant } from './setupContextUtils'
|
|
16
|
+
import { isValidVariantFormatString, parseVariant, INTERNAL_FEATURES } from './setupContextUtils'
|
|
17
17
|
import isValidArbitraryValue from '../util/isSyntacticallyValidPropertyValue'
|
|
18
18
|
import { splitAtTopLevelOnly } from '../util/splitAtTopLevelOnly.js'
|
|
19
19
|
import { flagEnabled } from '../featureFlags'
|
|
@@ -193,13 +193,13 @@ function applyVariant(variant, matches, context) {
|
|
|
193
193
|
// group[:hover] (`-` is missing)
|
|
194
194
|
let match = /(.)(-?)\[(.*)\]/g.exec(variant)
|
|
195
195
|
if (match) {
|
|
196
|
-
let [, char,
|
|
196
|
+
let [, char, separator, value] = match
|
|
197
197
|
// @-[200px] case
|
|
198
|
-
if (char === '@' &&
|
|
198
|
+
if (char === '@' && separator === '-') return []
|
|
199
199
|
// group[:hover] case
|
|
200
|
-
if (char !== '@' &&
|
|
200
|
+
if (char !== '@' && separator === '') return []
|
|
201
201
|
|
|
202
|
-
variant = variant.replace(`${
|
|
202
|
+
variant = variant.replace(`${separator}[${value}]`, '')
|
|
203
203
|
args.value = value
|
|
204
204
|
}
|
|
205
205
|
}
|
|
@@ -230,9 +230,16 @@ function applyVariant(variant, matches, context) {
|
|
|
230
230
|
|
|
231
231
|
if (context.variantMap.has(variant)) {
|
|
232
232
|
let isArbitraryVariant = isArbitraryValue(variant)
|
|
233
|
+
let internalFeatures = context.variantOptions.get(variant)?.[INTERNAL_FEATURES] ?? {}
|
|
233
234
|
let variantFunctionTuples = context.variantMap.get(variant).slice()
|
|
234
235
|
let result = []
|
|
235
236
|
|
|
237
|
+
let respectPrefix = (() => {
|
|
238
|
+
if (isArbitraryVariant) return false
|
|
239
|
+
if (internalFeatures.respectPrefix === false) return false
|
|
240
|
+
return true
|
|
241
|
+
})()
|
|
242
|
+
|
|
236
243
|
for (let [meta, rule] of matches) {
|
|
237
244
|
// Don't generate variants for user css
|
|
238
245
|
if (meta.layer === 'user') {
|
|
@@ -293,7 +300,7 @@ function applyVariant(variant, matches, context) {
|
|
|
293
300
|
format(selectorFormat) {
|
|
294
301
|
collectedFormats.push({
|
|
295
302
|
format: selectorFormat,
|
|
296
|
-
|
|
303
|
+
respectPrefix,
|
|
297
304
|
})
|
|
298
305
|
},
|
|
299
306
|
args,
|
|
@@ -322,7 +329,7 @@ function applyVariant(variant, matches, context) {
|
|
|
322
329
|
if (typeof ruleWithVariant === 'string') {
|
|
323
330
|
collectedFormats.push({
|
|
324
331
|
format: ruleWithVariant,
|
|
325
|
-
|
|
332
|
+
respectPrefix,
|
|
326
333
|
})
|
|
327
334
|
}
|
|
328
335
|
|
|
@@ -366,7 +373,7 @@ function applyVariant(variant, matches, context) {
|
|
|
366
373
|
// format: .foo &
|
|
367
374
|
collectedFormats.push({
|
|
368
375
|
format: modified.replace(rebuiltBase, '&'),
|
|
369
|
-
|
|
376
|
+
respectPrefix,
|
|
370
377
|
})
|
|
371
378
|
rule.selector = before
|
|
372
379
|
})
|
|
@@ -24,6 +24,8 @@ import { Offsets } from './offsets.js'
|
|
|
24
24
|
import { flagEnabled } from '../featureFlags.js'
|
|
25
25
|
import { finalizeSelector, formatVariantSelector } from '../util/formatVariantSelector'
|
|
26
26
|
|
|
27
|
+
export const INTERNAL_FEATURES = Symbol()
|
|
28
|
+
|
|
27
29
|
const VARIANT_TYPES = {
|
|
28
30
|
AddVariant: Symbol.for('ADD_VARIANT'),
|
|
29
31
|
MatchVariant: Symbol.for('MATCH_VARIANT'),
|
|
@@ -230,8 +232,8 @@ export function parseVariant(variant) {
|
|
|
230
232
|
return ({ format }) => format(str)
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
let [, name, params] = /@(
|
|
234
|
-
return ({ wrap }) => wrap(postcss.atRule({ name, params: params
|
|
235
|
+
let [, name, params] = /@(\S*)( .+|[({].*)?/g.exec(str)
|
|
236
|
+
return ({ wrap }) => wrap(postcss.atRule({ name, params: params?.trim() ?? '' }))
|
|
235
237
|
})
|
|
236
238
|
.reverse()
|
|
237
239
|
|
|
@@ -949,7 +951,11 @@ function registerPlugins(plugins, context) {
|
|
|
949
951
|
let idx = BigInt(parasiteUtilities.length)
|
|
950
952
|
|
|
951
953
|
for (const [, rule] of rules) {
|
|
952
|
-
|
|
954
|
+
let candidate = rule.raws.tailwind.candidate
|
|
955
|
+
|
|
956
|
+
// When multiple rules match a candidate
|
|
957
|
+
// always take the position of the first one
|
|
958
|
+
sortedClassNames.set(candidate, sortedClassNames.get(candidate) ?? idx++)
|
|
953
959
|
}
|
|
954
960
|
|
|
955
961
|
return classes.map((className) => {
|
|
@@ -1119,17 +1125,24 @@ function registerPlugins(plugins, context) {
|
|
|
1119
1125
|
}
|
|
1120
1126
|
|
|
1121
1127
|
let isArbitraryVariant = !(value in (options.values ?? {}))
|
|
1128
|
+
let internalFeatures = options[INTERNAL_FEATURES] ?? {}
|
|
1129
|
+
|
|
1130
|
+
let respectPrefix = (() => {
|
|
1131
|
+
if (isArbitraryVariant) return false
|
|
1132
|
+
if (internalFeatures.respectPrefix === false) return false
|
|
1133
|
+
return true
|
|
1134
|
+
})()
|
|
1122
1135
|
|
|
1123
1136
|
formatStrings = formatStrings.map((format) =>
|
|
1124
1137
|
format.map((str) => ({
|
|
1125
1138
|
format: str,
|
|
1126
|
-
|
|
1139
|
+
respectPrefix,
|
|
1127
1140
|
}))
|
|
1128
1141
|
)
|
|
1129
1142
|
|
|
1130
1143
|
manualFormatStrings = manualFormatStrings.map((format) => ({
|
|
1131
1144
|
format,
|
|
1132
|
-
|
|
1145
|
+
respectPrefix,
|
|
1133
1146
|
}))
|
|
1134
1147
|
|
|
1135
1148
|
let opts = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import fs from 'fs'
|
|
4
|
-
import LRU from 'quick-lru'
|
|
4
|
+
import LRU from '@alloc/quick-lru'
|
|
5
5
|
|
|
6
6
|
import hash from '../util/hashConfig'
|
|
7
7
|
import resolveConfig from '../public/resolve-config'
|
|
@@ -63,9 +63,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// It's a plain object, not a path
|
|
66
|
-
let newConfig = resolveConfig(
|
|
67
|
-
configOrPath.config === undefined ? configOrPath : configOrPath.config
|
|
68
|
-
)
|
|
66
|
+
let newConfig = resolveConfig(configOrPath?.config ?? configOrPath ?? {})
|
|
69
67
|
|
|
70
68
|
newConfig = validateConfig(newConfig)
|
|
71
69
|
|
package/src/lib/sharedState.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import pkg from '../../package.json'
|
|
2
|
-
let OXIDE_DEFAULT_ENABLED = pkg.tailwindcss.engine === 'oxide'
|
|
3
2
|
|
|
4
3
|
export const env =
|
|
5
4
|
typeof process !== 'undefined'
|
|
@@ -7,13 +6,11 @@ export const env =
|
|
|
7
6
|
NODE_ENV: process.env.NODE_ENV,
|
|
8
7
|
DEBUG: resolveDebug(process.env.DEBUG),
|
|
9
8
|
ENGINE: pkg.tailwindcss.engine,
|
|
10
|
-
OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED),
|
|
11
9
|
}
|
|
12
10
|
: {
|
|
13
11
|
NODE_ENV: 'production',
|
|
14
12
|
DEBUG: false,
|
|
15
13
|
ENGINE: pkg.tailwindcss.engine,
|
|
16
|
-
OXIDE: OXIDE_DEFAULT_ENABLED,
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
export const contextMap = new Map()
|
|
@@ -24,18 +21,6 @@ export const NOT_ON_DEMAND = new String('*')
|
|
|
24
21
|
|
|
25
22
|
export const NONE = Symbol('__NONE__')
|
|
26
23
|
|
|
27
|
-
function resolveBoolean(value, defaultValue) {
|
|
28
|
-
if (value === undefined) {
|
|
29
|
-
return defaultValue
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (value === '0' || value === 'false') {
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return true
|
|
37
|
-
}
|
|
38
|
-
|
|
39
24
|
export function resolveDebug(debug) {
|
|
40
25
|
if (debug === undefined) {
|
|
41
26
|
return false
|
package/src/plugin.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
13
13
|
console.time('JIT TOTAL')
|
|
14
14
|
return root
|
|
15
15
|
},
|
|
16
|
-
function (root, result) {
|
|
16
|
+
async function (root, result) {
|
|
17
17
|
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
18
18
|
// path for the file being processed
|
|
19
19
|
configOrPath = findAtConfigPath(root, result) ?? configOrPath
|
|
@@ -25,16 +25,16 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
25
25
|
|
|
26
26
|
for (const root of roots) {
|
|
27
27
|
if (root.type === 'root') {
|
|
28
|
-
processTailwindFeatures(context)(root, result)
|
|
28
|
+
await processTailwindFeatures(context)(root, result)
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
processTailwindFeatures(context)(root, result)
|
|
35
|
+
await processTailwindFeatures(context)(root, result)
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
__OXIDE__ &&
|
|
38
38
|
function lightningCssPlugin(_root, result) {
|
|
39
39
|
let postcss = require('postcss')
|
|
40
40
|
let lightningcss = require('lightningcss')
|
|
@@ -12,7 +12,7 @@ import { createContext } from './lib/setupContextUtils'
|
|
|
12
12
|
import { issueFlagNotices } from './featureFlags'
|
|
13
13
|
|
|
14
14
|
export default function processTailwindFeatures(setupContext) {
|
|
15
|
-
return function (root, result) {
|
|
15
|
+
return async function (root, result) {
|
|
16
16
|
let { tailwindDirectives, applyDirectives } = normalizeTailwindDirectives(root)
|
|
17
17
|
|
|
18
18
|
detectNesting()(root, result)
|
|
@@ -44,7 +44,8 @@ export default function processTailwindFeatures(setupContext) {
|
|
|
44
44
|
|
|
45
45
|
issueFlagNotices(context.tailwindConfig)
|
|
46
46
|
|
|
47
|
-
expandTailwindAtRules(context)(root, result)
|
|
47
|
+
await expandTailwindAtRules(context)(root, result)
|
|
48
|
+
|
|
48
49
|
// Partition apply rules that are generated by
|
|
49
50
|
// addComponents, addUtilities and so on.
|
|
50
51
|
partitionApplyAtRules()(root, result)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parser from 'postcss-selector-parser'
|
|
2
|
-
import {
|
|
2
|
+
import { movePseudos } from './pseudoElements'
|
|
3
3
|
|
|
4
4
|
export function applyImportantSelector(selector, important) {
|
|
5
5
|
let sel = parser().astSync(selector)
|
|
@@ -20,10 +20,7 @@ export function applyImportantSelector(selector, important) {
|
|
|
20
20
|
]
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
if (pseudoElements.length > 0) {
|
|
25
|
-
sel.nodes.push(...pseudoElements.sort(sortSelector))
|
|
26
|
-
}
|
|
23
|
+
movePseudos(sel)
|
|
27
24
|
})
|
|
28
25
|
|
|
29
26
|
return `${important} ${sel.toString()}`
|
package/src/util/color.js
CHANGED