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.
Files changed (148) hide show
  1. package/CHANGELOG.md +47 -6
  2. package/lib/cli/build/deps.js +17 -9
  3. package/lib/cli/build/index.js +10 -8
  4. package/lib/cli/build/plugin.js +29 -27
  5. package/lib/cli/build/utils.js +18 -8
  6. package/lib/cli/build/watching.js +12 -10
  7. package/lib/cli/help/index.js +6 -4
  8. package/lib/cli/index.js +4 -4
  9. package/lib/cli/init/index.js +8 -6
  10. package/lib/cli-peer-dependencies.js +12 -4
  11. package/lib/cli.js +1 -1
  12. package/lib/corePluginList.js +3 -1
  13. package/lib/corePlugins.js +52 -42
  14. package/lib/css/preflight.css +9 -0
  15. package/lib/featureFlags.js +14 -9
  16. package/lib/index.js +1 -5
  17. package/lib/lib/cacheInvalidation.js +7 -5
  18. package/lib/lib/collapseAdjacentRules.js +3 -1
  19. package/lib/lib/collapseDuplicateDeclarations.js +10 -8
  20. package/lib/lib/content.js +18 -14
  21. package/lib/lib/defaultExtractor.js +6 -4
  22. package/lib/lib/detectNesting.js +3 -1
  23. package/lib/lib/evaluateTailwindFunctions.js +20 -16
  24. package/lib/lib/expandApplyAtRules.js +37 -40
  25. package/lib/lib/expandTailwindAtRules.js +19 -17
  26. package/lib/lib/findAtConfigPath.js +6 -4
  27. package/lib/lib/generateRules.js +52 -38
  28. package/lib/lib/getModuleDependencies.js +10 -8
  29. package/lib/lib/load-config.js +5 -3
  30. package/lib/lib/normalizeTailwindDirectives.js +5 -3
  31. package/lib/lib/offsets.js +7 -5
  32. package/lib/lib/partitionApplyAtRules.js +3 -1
  33. package/lib/lib/regex.js +21 -7
  34. package/lib/lib/remap-bitfield.js +3 -1
  35. package/lib/lib/resolveDefaultsAtRules.js +24 -20
  36. package/lib/lib/setupContextUtils.js +91 -63
  37. package/lib/lib/setupTrackingContext.js +27 -24
  38. package/lib/lib/sharedState.js +28 -24
  39. package/lib/lib/substituteScreenAtRules.js +5 -3
  40. package/lib/oxide/cli/build/deps.js +16 -8
  41. package/lib/oxide/cli/build/index.js +6 -4
  42. package/lib/oxide/cli/build/plugin.js +19 -17
  43. package/lib/oxide/cli/build/utils.js +18 -8
  44. package/lib/oxide/cli/build/watching.js +10 -8
  45. package/lib/oxide/cli/help/index.js +6 -4
  46. package/lib/oxide/cli/index.js +4 -4
  47. package/lib/oxide/cli/init/index.js +6 -4
  48. package/lib/plugin.js +9 -9
  49. package/lib/postcss-plugins/nesting/index.js +3 -1
  50. package/lib/postcss-plugins/nesting/plugin.js +8 -6
  51. package/lib/processTailwindFeatures.js +16 -14
  52. package/lib/public/colors.js +5 -3
  53. package/lib/public/create-plugin.js +5 -3
  54. package/lib/public/default-config.js +6 -4
  55. package/lib/public/default-theme.js +6 -4
  56. package/lib/public/load-config.js +5 -3
  57. package/lib/public/resolve-config.js +6 -4
  58. package/lib/util/applyImportantSelector.js +9 -10
  59. package/lib/util/bigSign.js +3 -1
  60. package/lib/util/buildMediaQuery.js +3 -1
  61. package/lib/util/cloneDeep.js +3 -1
  62. package/lib/util/cloneNodes.js +3 -1
  63. package/lib/util/color.js +10 -6
  64. package/lib/util/colorNames.js +752 -0
  65. package/lib/util/configurePlugins.js +3 -1
  66. package/lib/util/createPlugin.js +3 -1
  67. package/lib/util/createUtilityPlugin.js +5 -3
  68. package/lib/util/dataTypes.js +59 -21
  69. package/lib/util/defaults.js +6 -4
  70. package/lib/util/escapeClassName.js +7 -5
  71. package/lib/util/escapeCommas.js +3 -1
  72. package/lib/util/flattenColorPalette.js +3 -1
  73. package/lib/util/formatVariantSelector.js +30 -110
  74. package/lib/util/getAllConfigs.js +6 -4
  75. package/lib/util/hashConfig.js +6 -4
  76. package/lib/util/isKeyframeRule.js +3 -1
  77. package/lib/util/isPlainObject.js +3 -1
  78. package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
  79. package/lib/util/log.js +8 -4
  80. package/lib/util/nameClass.js +12 -6
  81. package/lib/util/negateValue.js +3 -1
  82. package/lib/util/normalizeConfig.js +7 -5
  83. package/lib/util/normalizeScreens.js +12 -4
  84. package/lib/util/parseAnimationValue.js +3 -1
  85. package/lib/util/parseBoxShadowValue.js +6 -2
  86. package/lib/util/parseDependency.js +3 -1
  87. package/lib/util/parseGlob.js +6 -4
  88. package/lib/util/parseObjectStyles.js +9 -7
  89. package/lib/util/pluginUtils.js +30 -18
  90. package/lib/util/prefixSelector.js +6 -4
  91. package/lib/util/pseudoElements.js +209 -0
  92. package/lib/util/removeAlphaVariables.js +3 -1
  93. package/lib/util/resolveConfig.js +10 -8
  94. package/lib/util/resolveConfigPath.js +9 -5
  95. package/lib/util/responsive.js +6 -4
  96. package/lib/util/splitAtTopLevelOnly.js +3 -1
  97. package/lib/util/tap.js +3 -1
  98. package/lib/util/toColorValue.js +3 -1
  99. package/lib/util/toPath.js +3 -1
  100. package/lib/util/transformThemeValue.js +6 -4
  101. package/lib/util/validateConfig.js +5 -3
  102. package/lib/util/validateFormalSyntax.js +3 -1
  103. package/lib/util/withAlphaVariable.js +6 -2
  104. package/lib/value-parser/LICENSE +22 -0
  105. package/lib/value-parser/README.md +3 -0
  106. package/lib/value-parser/index.d.js +2 -0
  107. package/lib/value-parser/index.js +22 -0
  108. package/lib/value-parser/parse.js +259 -0
  109. package/lib/value-parser/stringify.js +38 -0
  110. package/lib/value-parser/unit.js +86 -0
  111. package/lib/value-parser/walk.js +16 -0
  112. package/package.json +30 -35
  113. package/peers/index.js +65828 -48819
  114. package/src/cli/build/plugin.js +3 -3
  115. package/src/cli.js +1 -1
  116. package/src/corePlugins.js +29 -24
  117. package/src/css/preflight.css +9 -0
  118. package/src/featureFlags.js +2 -3
  119. package/src/index.js +1 -5
  120. package/src/lib/defaultExtractor.js +1 -1
  121. package/src/lib/evaluateTailwindFunctions.js +4 -1
  122. package/src/lib/expandApplyAtRules.js +2 -8
  123. package/src/lib/expandTailwindAtRules.js +12 -10
  124. package/src/lib/generateRules.js +15 -8
  125. package/src/lib/setupContextUtils.js +18 -5
  126. package/src/lib/setupTrackingContext.js +2 -4
  127. package/src/lib/sharedState.js +0 -15
  128. package/src/oxide/cli/build/plugin.ts +1 -1
  129. package/src/plugin.js +4 -4
  130. package/src/processTailwindFeatures.js +3 -2
  131. package/src/util/applyImportantSelector.js +2 -5
  132. package/src/util/color.js +1 -1
  133. package/src/util/colorNames.js +150 -0
  134. package/src/util/dataTypes.js +17 -6
  135. package/src/util/formatVariantSelector.js +4 -126
  136. package/src/util/pluginUtils.js +1 -5
  137. package/src/util/prefixSelector.js +1 -0
  138. package/src/util/pseudoElements.js +167 -0
  139. package/src/value-parser/LICENSE +22 -0
  140. package/src/value-parser/README.md +3 -0
  141. package/src/value-parser/index.d.ts +177 -0
  142. package/src/value-parser/index.js +28 -0
  143. package/src/value-parser/parse.js +303 -0
  144. package/src/value-parser/stringify.js +41 -0
  145. package/src/value-parser/unit.js +118 -0
  146. package/src/value-parser/walk.js +18 -0
  147. package/stubs/config.full.js +1 -0
  148. package/types/generated/default-theme.d.ts +1 -0
@@ -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 (env.OXIDE) {
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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- if (process.env.OXIDE) {
3
+ if (__OXIDE__) {
4
4
  module.exports = require('./oxide/cli')
5
5
  } else {
6
6
  module.exports = require('./cli/index')
@@ -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
- { values: Object.fromEntries(pseudoVariants) }
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) => `${config('prefix')}${escapeClassName(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 (env.OXIDE) {
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 (env.OXIDE) {
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
- '--tw-gradient-from': `${toColorValue(
1771
- value,
1772
- 'from'
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
- '--tw-gradient-via-position': ' ',
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
- '--tw-gradient-to': `${toColorValue(value, 'to')} var(--tw-gradient-to-position)`,
1829
- '--tw-gradient-to-position': ' ',
1833
+ '@defaults gradient-color-stops': {},
1834
+ '--tw-gradient-to': `${toColorValue(value)} var(--tw-gradient-to-position)`,
1830
1835
  }),
1831
1836
  },
1832
1837
  options
@@ -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
  */
@@ -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 env.OXIDE
8
+ return __OXIDE__
10
9
  },
11
10
  get relativeContentPathsByDefault() {
12
- return env.OXIDE
11
+ return __OXIDE__
13
12
  },
14
13
  }
15
14
 
package/src/index.js CHANGED
@@ -1,5 +1 @@
1
- if (process.env.OXIDE) {
2
- module.exports = require('./oxide/postcss-plugin')
3
- } else {
4
- module.exports = require('./plugin')
5
- }
1
+ module.exports = require('./plugin')
@@ -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]+?\][^\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 'postcss-value-parser'
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 { collectPseudoElements, sortSelector } from '../util/formatVariantSelector.js'
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 (env.OXIDE) {
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
- for (let { file, content, extension } of context.changedContent) {
149
- let transformer = getTransformer(context.tailwindConfig, extension)
150
- let extractor = getExtractor(context, extension)
151
- content = file ? fs.readFileSync(file, 'utf8') : content
152
- getClassCandidates(transformer(content), extractor, candidates, seen)
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 = env.OXIDE
167
+ let sortedCandidates = __OXIDE__
166
168
  ? candidates
167
169
  : new Set(
168
170
  [...candidates].sort((a, z) => {
@@ -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, seperator, value] = match
196
+ let [, char, separator, value] = match
197
197
  // @-[200px] case
198
- if (char === '@' && seperator === '-') return []
198
+ if (char === '@' && separator === '-') return []
199
199
  // group[:hover] case
200
- if (char !== '@' && seperator === '') return []
200
+ if (char !== '@' && separator === '') return []
201
201
 
202
- variant = variant.replace(`${seperator}[${value}]`, '')
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
- isArbitraryVariant,
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
- isArbitraryVariant,
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
- isArbitraryVariant,
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] = /@(.*?)( .+|[({].*)/g.exec(str)
234
- return ({ wrap }) => wrap(postcss.atRule({ name, params: params.trim() }))
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
- sortedClassNames.set(rule.raws.tailwind.candidate, idx++)
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
- isArbitraryVariant,
1139
+ respectPrefix,
1127
1140
  }))
1128
1141
  )
1129
1142
 
1130
1143
  manualFormatStrings = manualFormatStrings.map((format) => ({
1131
1144
  format,
1132
- isArbitraryVariant,
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
 
@@ -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
@@ -184,7 +184,7 @@ let state = {
184
184
  let files = fastGlob.sync(this.contentPatterns.all)
185
185
 
186
186
  for (let file of files) {
187
- if (env.OXIDE) {
187
+ if (__OXIDE__) {
188
188
  content.push({
189
189
  file,
190
190
  extension: path.extname(file).slice(1),
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
- env.OXIDE &&
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 { collectPseudoElements, sortSelector } from './formatVariantSelector.js'
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
- let [pseudoElements] = collectPseudoElements(sel)
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
@@ -1,4 +1,4 @@
1
- import namedColors from 'color-name'
1
+ import namedColors from './colorNames'
2
2
 
3
3
  let HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i
4
4
  let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i