tailwindcss 0.0.0-insiders.dddaded → 0.0.0-insiders.de00a62
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/lib/cli/build/deps.js +17 -9
- package/lib/cli/build/index.js +10 -8
- package/lib/cli/build/plugin.js +31 -29
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +13 -11
- 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 +8 -2
- package/lib/corePlugins.js +211 -48
- package/lib/css/preflight.css +24 -8
- 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 +51 -14
- package/lib/lib/defaultExtractor.js +38 -28
- package/lib/lib/detectNesting.js +3 -1
- package/lib/lib/evaluateTailwindFunctions.js +20 -16
- package/lib/lib/expandApplyAtRules.js +41 -33
- package/lib/lib/expandTailwindAtRules.js +38 -19
- package/lib/lib/findAtConfigPath.js +6 -4
- package/lib/lib/generateRules.js +83 -55
- package/lib/lib/getModuleDependencies.js +10 -8
- package/lib/lib/load-config.js +18 -5
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +58 -7
- 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 +27 -21
- package/lib/lib/setupContextUtils.js +143 -94
- 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 +25 -23
- 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 +7 -5
- 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 +36 -14
- package/lib/util/color.js +11 -7
- 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 +180 -31
- 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 +36 -21
- 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 +4 -2
- 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 +43 -18
- package/lib/util/prefixSelector.js +6 -4
- package/lib/util/pseudoElements.js +24 -35
- 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/nesting/index.d.ts +4 -0
- package/package.json +31 -36
- package/peers/index.js +65266 -48224
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/src/cli/build/plugin.js +7 -7
- package/src/cli/build/watching.js +1 -1
- package/src/cli.js +1 -1
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +165 -29
- package/src/css/preflight.css +24 -8
- package/src/featureFlags.js +3 -8
- package/src/index.js +1 -5
- package/src/lib/content.js +42 -1
- package/src/lib/defaultExtractor.js +30 -17
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +7 -0
- package/src/lib/expandTailwindAtRules.js +26 -9
- package/src/lib/generateRules.js +50 -26
- package/src/lib/load-config.ts +8 -0
- package/src/lib/offsets.js +61 -2
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +77 -38
- package/src/lib/setupTrackingContext.js +2 -4
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +7 -7
- package/src/plugin.js +4 -4
- package/src/processTailwindFeatures.js +3 -2
- package/src/util/cloneNodes.js +35 -14
- package/src/util/color.js +2 -2
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +143 -18
- package/src/util/formatVariantSelector.js +11 -3
- package/src/util/isPlainObject.js +1 -1
- package/src/util/pluginUtils.js +17 -5
- package/src/util/prefixSelector.js +1 -0
- package/src/util/pseudoElements.js +18 -17
- 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 +86 -14
- package/types/config.d.ts +17 -9
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +35 -9
- package/types/index.d.ts +7 -3
|
@@ -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'),
|
|
@@ -146,43 +148,45 @@ function getClasses(selector, mutate) {
|
|
|
146
148
|
return parser.transformSync(selector)
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Ignore everything inside a :not(...). This allows you to write code like
|
|
153
|
+
* `div:not(.foo)`. If `.foo` is never found in your code, then we used to
|
|
154
|
+
* not generated it. But now we will ignore everything inside a `:not`, so
|
|
155
|
+
* that it still gets generated.
|
|
156
|
+
*
|
|
157
|
+
* @param {selectorParser.Root} selectors
|
|
158
|
+
*/
|
|
159
|
+
function ignoreNot(selectors) {
|
|
160
|
+
selectors.walkPseudos((pseudo) => {
|
|
161
|
+
if (pseudo.value === ':not') {
|
|
162
|
+
pseudo.remove()
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
|
|
149
167
|
function extractCandidates(node, state = { containsNonOnDemandable: false }, depth = 0) {
|
|
150
168
|
let classes = []
|
|
169
|
+
let selectors = []
|
|
151
170
|
|
|
152
|
-
// Handle normal rules
|
|
153
171
|
if (node.type === 'rule') {
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (pseudo.value === ':not') {
|
|
161
|
-
pseudo.remove()
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
}
|
|
172
|
+
// Handle normal rules
|
|
173
|
+
selectors.push(...node.selectors)
|
|
174
|
+
} else if (node.type === 'atrule') {
|
|
175
|
+
// Handle at-rules (which contains nested rules)
|
|
176
|
+
node.walkRules((rule) => selectors.push(...rule.selectors))
|
|
177
|
+
}
|
|
165
178
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
169
|
-
if (classCandidates.length === 0) {
|
|
170
|
-
state.containsNonOnDemandable = true
|
|
171
|
-
}
|
|
179
|
+
for (let selector of selectors) {
|
|
180
|
+
let classCandidates = getClasses(selector, ignoreNot)
|
|
172
181
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
182
|
+
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
183
|
+
if (classCandidates.length === 0) {
|
|
184
|
+
state.containsNonOnDemandable = true
|
|
176
185
|
}
|
|
177
|
-
}
|
|
178
186
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
for (let classCandidate of rule.selectors.flatMap((selector) => getClasses(selector))) {
|
|
183
|
-
classes.push(classCandidate)
|
|
184
|
-
}
|
|
185
|
-
})
|
|
187
|
+
for (let classCandidate of classCandidates) {
|
|
188
|
+
classes.push(classCandidate)
|
|
189
|
+
}
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
if (depth === 0) {
|
|
@@ -230,8 +234,8 @@ export function parseVariant(variant) {
|
|
|
230
234
|
return ({ format }) => format(str)
|
|
231
235
|
}
|
|
232
236
|
|
|
233
|
-
let [, name, params] = /@(
|
|
234
|
-
return ({ wrap }) => wrap(postcss.atRule({ name, params: params
|
|
237
|
+
let [, name, params] = /@(\S*)( .+|[({].*)?/g.exec(str)
|
|
238
|
+
return ({ wrap }) => wrap(postcss.atRule({ name, params: params?.trim() ?? '' }))
|
|
235
239
|
})
|
|
236
240
|
.reverse()
|
|
237
241
|
|
|
@@ -752,22 +756,46 @@ function resolvePlugins(context, root) {
|
|
|
752
756
|
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
753
757
|
// were historically sorted before screen/stackable variants.
|
|
754
758
|
let beforeVariants = [
|
|
759
|
+
variantPlugins['childVariant'],
|
|
755
760
|
variantPlugins['pseudoElementVariants'],
|
|
756
761
|
variantPlugins['pseudoClassVariants'],
|
|
762
|
+
variantPlugins['hasVariants'],
|
|
757
763
|
variantPlugins['ariaVariants'],
|
|
758
764
|
variantPlugins['dataVariants'],
|
|
759
765
|
]
|
|
760
766
|
let afterVariants = [
|
|
761
767
|
variantPlugins['supportsVariants'],
|
|
762
|
-
variantPlugins['directionVariants'],
|
|
763
768
|
variantPlugins['reducedMotionVariants'],
|
|
764
769
|
variantPlugins['prefersContrastVariants'],
|
|
765
|
-
variantPlugins['darkVariants'],
|
|
766
|
-
variantPlugins['printVariant'],
|
|
767
770
|
variantPlugins['screenVariants'],
|
|
768
771
|
variantPlugins['orientationVariants'],
|
|
772
|
+
variantPlugins['directionVariants'],
|
|
773
|
+
variantPlugins['darkVariants'],
|
|
774
|
+
variantPlugins['forcedColorsVariants'],
|
|
775
|
+
variantPlugins['printVariant'],
|
|
769
776
|
]
|
|
770
777
|
|
|
778
|
+
// This is a compatibility fix for the pre 3.4 dark mode behavior
|
|
779
|
+
// `class` retains the old behavior, but `selector` keeps the new behavior
|
|
780
|
+
let isLegacyDarkMode =
|
|
781
|
+
context.tailwindConfig.darkMode === 'class' ||
|
|
782
|
+
(Array.isArray(context.tailwindConfig.darkMode) &&
|
|
783
|
+
context.tailwindConfig.darkMode[0] === 'class')
|
|
784
|
+
|
|
785
|
+
if (isLegacyDarkMode) {
|
|
786
|
+
afterVariants = [
|
|
787
|
+
variantPlugins['supportsVariants'],
|
|
788
|
+
variantPlugins['reducedMotionVariants'],
|
|
789
|
+
variantPlugins['prefersContrastVariants'],
|
|
790
|
+
variantPlugins['darkVariants'],
|
|
791
|
+
variantPlugins['screenVariants'],
|
|
792
|
+
variantPlugins['orientationVariants'],
|
|
793
|
+
variantPlugins['directionVariants'],
|
|
794
|
+
variantPlugins['forcedColorsVariants'],
|
|
795
|
+
variantPlugins['printVariant'],
|
|
796
|
+
]
|
|
797
|
+
}
|
|
798
|
+
|
|
771
799
|
return [...corePluginList, ...beforeVariants, ...userPlugins, ...afterVariants, ...layerPlugins]
|
|
772
800
|
}
|
|
773
801
|
|
|
@@ -943,13 +971,17 @@ function registerPlugins(plugins, context) {
|
|
|
943
971
|
|
|
944
972
|
// Sort all classes in order
|
|
945
973
|
// Non-tailwind classes won't be generated and will be left as `null`
|
|
946
|
-
let rules = generateRules(new Set(sorted), context)
|
|
974
|
+
let rules = generateRules(new Set(sorted), context, true)
|
|
947
975
|
rules = context.offsets.sort(rules)
|
|
948
976
|
|
|
949
977
|
let idx = BigInt(parasiteUtilities.length)
|
|
950
978
|
|
|
951
979
|
for (const [, rule] of rules) {
|
|
952
|
-
|
|
980
|
+
let candidate = rule.raws.tailwind.candidate
|
|
981
|
+
|
|
982
|
+
// When multiple rules match a candidate
|
|
983
|
+
// always take the position of the first one
|
|
984
|
+
sortedClassNames.set(candidate, sortedClassNames.get(candidate) ?? idx++)
|
|
953
985
|
}
|
|
954
986
|
|
|
955
987
|
return classes.map((className) => {
|
|
@@ -1119,17 +1151,24 @@ function registerPlugins(plugins, context) {
|
|
|
1119
1151
|
}
|
|
1120
1152
|
|
|
1121
1153
|
let isArbitraryVariant = !(value in (options.values ?? {}))
|
|
1154
|
+
let internalFeatures = options[INTERNAL_FEATURES] ?? {}
|
|
1155
|
+
|
|
1156
|
+
let respectPrefix = (() => {
|
|
1157
|
+
if (isArbitraryVariant) return false
|
|
1158
|
+
if (internalFeatures.respectPrefix === false) return false
|
|
1159
|
+
return true
|
|
1160
|
+
})()
|
|
1122
1161
|
|
|
1123
1162
|
formatStrings = formatStrings.map((format) =>
|
|
1124
1163
|
format.map((str) => ({
|
|
1125
1164
|
format: str,
|
|
1126
|
-
|
|
1165
|
+
respectPrefix,
|
|
1127
1166
|
}))
|
|
1128
1167
|
)
|
|
1129
1168
|
|
|
1130
1169
|
manualFormatStrings = manualFormatStrings.map((format) => ({
|
|
1131
1170
|
format,
|
|
1132
|
-
|
|
1171
|
+
respectPrefix,
|
|
1133
1172
|
}))
|
|
1134
1173
|
|
|
1135
1174
|
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
|
|
@@ -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 (
|
|
187
|
+
if (__OXIDE__) {
|
|
188
188
|
content.push({
|
|
189
189
|
file,
|
|
190
190
|
extension: path.extname(file).slice(1),
|
|
@@ -210,16 +210,16 @@ let state = {
|
|
|
210
210
|
},
|
|
211
211
|
|
|
212
212
|
getContext({ createContext, cliConfigPath, root, result, content }) {
|
|
213
|
+
env.DEBUG && console.time('Searching for config')
|
|
214
|
+
let configPath = findAtConfigPath(root, result) ?? cliConfigPath
|
|
215
|
+
env.DEBUG && console.timeEnd('Searching for config')
|
|
216
|
+
|
|
213
217
|
if (this.context) {
|
|
214
218
|
this.context.changedContent = this.changedContent.splice(0)
|
|
215
219
|
|
|
216
220
|
return this.context
|
|
217
221
|
}
|
|
218
222
|
|
|
219
|
-
env.DEBUG && console.time('Searching for config')
|
|
220
|
-
let configPath = findAtConfigPath(root, result) ?? cliConfigPath
|
|
221
|
-
env.DEBUG && console.timeEnd('Searching for config')
|
|
222
|
-
|
|
223
223
|
env.DEBUG && console.time('Loading config')
|
|
224
224
|
let config = this.loadConfig(configPath, content)
|
|
225
225
|
env.DEBUG && console.timeEnd('Loading config')
|
|
@@ -277,9 +277,9 @@ export async function createProcessor(args, cliConfigPath) {
|
|
|
277
277
|
let tailwindPlugin = () => {
|
|
278
278
|
return {
|
|
279
279
|
postcssPlugin: 'tailwindcss',
|
|
280
|
-
Once(root, { result }) {
|
|
280
|
+
async Once(root, { result }) {
|
|
281
281
|
env.DEBUG && console.time('Compiling CSS')
|
|
282
|
-
tailwind(({ createContext }) => {
|
|
282
|
+
await tailwind(({ createContext }) => {
|
|
283
283
|
console.error()
|
|
284
284
|
console.error('Rebuilding...')
|
|
285
285
|
|
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)
|
package/src/util/cloneNodes.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('postcss').Container[]} nodes
|
|
3
|
+
* @param {any} source
|
|
4
|
+
* @param {any} raws
|
|
5
|
+
* @returns {import('postcss').Container[]}
|
|
6
|
+
*/
|
|
1
7
|
export default function cloneNodes(nodes, source = undefined, raws = undefined) {
|
|
2
8
|
return nodes.map((node) => {
|
|
3
9
|
let cloned = node.clone()
|
|
4
10
|
|
|
5
|
-
// We always want override the source map
|
|
6
|
-
// except when explicitly told not to
|
|
7
|
-
let shouldOverwriteSource = node.raws.tailwind?.preserveSource !== true || !cloned.source
|
|
8
|
-
|
|
9
|
-
if (source !== undefined && shouldOverwriteSource) {
|
|
10
|
-
cloned.source = source
|
|
11
|
-
|
|
12
|
-
if ('walk' in cloned) {
|
|
13
|
-
cloned.walk((child) => {
|
|
14
|
-
child.source = source
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
11
|
if (raws !== undefined) {
|
|
20
12
|
cloned.raws.tailwind = {
|
|
21
13
|
...cloned.raws.tailwind,
|
|
@@ -23,6 +15,35 @@ export default function cloneNodes(nodes, source = undefined, raws = undefined)
|
|
|
23
15
|
}
|
|
24
16
|
}
|
|
25
17
|
|
|
18
|
+
if (source !== undefined) {
|
|
19
|
+
traverse(cloned, (node) => {
|
|
20
|
+
// Do not traverse nodes that have opted
|
|
21
|
+
// to preserve their original source
|
|
22
|
+
let shouldPreserveSource = node.raws.tailwind?.preserveSource === true && node.source
|
|
23
|
+
if (shouldPreserveSource) {
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Otherwise we can safely replace the source
|
|
28
|
+
// And continue traversing
|
|
29
|
+
node.source = source
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
return cloned
|
|
27
34
|
})
|
|
28
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Traverse a tree of nodes and don't traverse children if the callback
|
|
39
|
+
* returns false. Ideally we'd use Container#walk instead of this
|
|
40
|
+
* function but it stops traversing siblings too.
|
|
41
|
+
*
|
|
42
|
+
* @param {import('postcss').Container} node
|
|
43
|
+
* @param {(node: import('postcss').Container) => boolean} onNode
|
|
44
|
+
*/
|
|
45
|
+
function traverse(node, onNode) {
|
|
46
|
+
if (onNode(node) !== false) {
|
|
47
|
+
node.each?.((child) => traverse(child, onNode))
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/util/color.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import namedColors from '
|
|
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
|
|
5
5
|
let VALUE = /(?:\d+|\d*\.\d+)%?/
|
|
6
6
|
let SEP = /(?:\s*,\s*|\s+)/
|
|
7
7
|
let ALPHA_SEP = /\s*[,/]\s*/
|
|
8
|
-
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/
|
|
8
|
+
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)(?:,(?:[^ )]*?|var\(--[^ )]*?\)))?\)/
|
|
9
9
|
|
|
10
10
|
let RGB = new RegExp(
|
|
11
11
|
`^(rgba?)\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
aliceblue: [240, 248, 255],
|
|
3
|
+
antiquewhite: [250, 235, 215],
|
|
4
|
+
aqua: [0, 255, 255],
|
|
5
|
+
aquamarine: [127, 255, 212],
|
|
6
|
+
azure: [240, 255, 255],
|
|
7
|
+
beige: [245, 245, 220],
|
|
8
|
+
bisque: [255, 228, 196],
|
|
9
|
+
black: [0, 0, 0],
|
|
10
|
+
blanchedalmond: [255, 235, 205],
|
|
11
|
+
blue: [0, 0, 255],
|
|
12
|
+
blueviolet: [138, 43, 226],
|
|
13
|
+
brown: [165, 42, 42],
|
|
14
|
+
burlywood: [222, 184, 135],
|
|
15
|
+
cadetblue: [95, 158, 160],
|
|
16
|
+
chartreuse: [127, 255, 0],
|
|
17
|
+
chocolate: [210, 105, 30],
|
|
18
|
+
coral: [255, 127, 80],
|
|
19
|
+
cornflowerblue: [100, 149, 237],
|
|
20
|
+
cornsilk: [255, 248, 220],
|
|
21
|
+
crimson: [220, 20, 60],
|
|
22
|
+
cyan: [0, 255, 255],
|
|
23
|
+
darkblue: [0, 0, 139],
|
|
24
|
+
darkcyan: [0, 139, 139],
|
|
25
|
+
darkgoldenrod: [184, 134, 11],
|
|
26
|
+
darkgray: [169, 169, 169],
|
|
27
|
+
darkgreen: [0, 100, 0],
|
|
28
|
+
darkgrey: [169, 169, 169],
|
|
29
|
+
darkkhaki: [189, 183, 107],
|
|
30
|
+
darkmagenta: [139, 0, 139],
|
|
31
|
+
darkolivegreen: [85, 107, 47],
|
|
32
|
+
darkorange: [255, 140, 0],
|
|
33
|
+
darkorchid: [153, 50, 204],
|
|
34
|
+
darkred: [139, 0, 0],
|
|
35
|
+
darksalmon: [233, 150, 122],
|
|
36
|
+
darkseagreen: [143, 188, 143],
|
|
37
|
+
darkslateblue: [72, 61, 139],
|
|
38
|
+
darkslategray: [47, 79, 79],
|
|
39
|
+
darkslategrey: [47, 79, 79],
|
|
40
|
+
darkturquoise: [0, 206, 209],
|
|
41
|
+
darkviolet: [148, 0, 211],
|
|
42
|
+
deeppink: [255, 20, 147],
|
|
43
|
+
deepskyblue: [0, 191, 255],
|
|
44
|
+
dimgray: [105, 105, 105],
|
|
45
|
+
dimgrey: [105, 105, 105],
|
|
46
|
+
dodgerblue: [30, 144, 255],
|
|
47
|
+
firebrick: [178, 34, 34],
|
|
48
|
+
floralwhite: [255, 250, 240],
|
|
49
|
+
forestgreen: [34, 139, 34],
|
|
50
|
+
fuchsia: [255, 0, 255],
|
|
51
|
+
gainsboro: [220, 220, 220],
|
|
52
|
+
ghostwhite: [248, 248, 255],
|
|
53
|
+
gold: [255, 215, 0],
|
|
54
|
+
goldenrod: [218, 165, 32],
|
|
55
|
+
gray: [128, 128, 128],
|
|
56
|
+
green: [0, 128, 0],
|
|
57
|
+
greenyellow: [173, 255, 47],
|
|
58
|
+
grey: [128, 128, 128],
|
|
59
|
+
honeydew: [240, 255, 240],
|
|
60
|
+
hotpink: [255, 105, 180],
|
|
61
|
+
indianred: [205, 92, 92],
|
|
62
|
+
indigo: [75, 0, 130],
|
|
63
|
+
ivory: [255, 255, 240],
|
|
64
|
+
khaki: [240, 230, 140],
|
|
65
|
+
lavender: [230, 230, 250],
|
|
66
|
+
lavenderblush: [255, 240, 245],
|
|
67
|
+
lawngreen: [124, 252, 0],
|
|
68
|
+
lemonchiffon: [255, 250, 205],
|
|
69
|
+
lightblue: [173, 216, 230],
|
|
70
|
+
lightcoral: [240, 128, 128],
|
|
71
|
+
lightcyan: [224, 255, 255],
|
|
72
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
73
|
+
lightgray: [211, 211, 211],
|
|
74
|
+
lightgreen: [144, 238, 144],
|
|
75
|
+
lightgrey: [211, 211, 211],
|
|
76
|
+
lightpink: [255, 182, 193],
|
|
77
|
+
lightsalmon: [255, 160, 122],
|
|
78
|
+
lightseagreen: [32, 178, 170],
|
|
79
|
+
lightskyblue: [135, 206, 250],
|
|
80
|
+
lightslategray: [119, 136, 153],
|
|
81
|
+
lightslategrey: [119, 136, 153],
|
|
82
|
+
lightsteelblue: [176, 196, 222],
|
|
83
|
+
lightyellow: [255, 255, 224],
|
|
84
|
+
lime: [0, 255, 0],
|
|
85
|
+
limegreen: [50, 205, 50],
|
|
86
|
+
linen: [250, 240, 230],
|
|
87
|
+
magenta: [255, 0, 255],
|
|
88
|
+
maroon: [128, 0, 0],
|
|
89
|
+
mediumaquamarine: [102, 205, 170],
|
|
90
|
+
mediumblue: [0, 0, 205],
|
|
91
|
+
mediumorchid: [186, 85, 211],
|
|
92
|
+
mediumpurple: [147, 112, 219],
|
|
93
|
+
mediumseagreen: [60, 179, 113],
|
|
94
|
+
mediumslateblue: [123, 104, 238],
|
|
95
|
+
mediumspringgreen: [0, 250, 154],
|
|
96
|
+
mediumturquoise: [72, 209, 204],
|
|
97
|
+
mediumvioletred: [199, 21, 133],
|
|
98
|
+
midnightblue: [25, 25, 112],
|
|
99
|
+
mintcream: [245, 255, 250],
|
|
100
|
+
mistyrose: [255, 228, 225],
|
|
101
|
+
moccasin: [255, 228, 181],
|
|
102
|
+
navajowhite: [255, 222, 173],
|
|
103
|
+
navy: [0, 0, 128],
|
|
104
|
+
oldlace: [253, 245, 230],
|
|
105
|
+
olive: [128, 128, 0],
|
|
106
|
+
olivedrab: [107, 142, 35],
|
|
107
|
+
orange: [255, 165, 0],
|
|
108
|
+
orangered: [255, 69, 0],
|
|
109
|
+
orchid: [218, 112, 214],
|
|
110
|
+
palegoldenrod: [238, 232, 170],
|
|
111
|
+
palegreen: [152, 251, 152],
|
|
112
|
+
paleturquoise: [175, 238, 238],
|
|
113
|
+
palevioletred: [219, 112, 147],
|
|
114
|
+
papayawhip: [255, 239, 213],
|
|
115
|
+
peachpuff: [255, 218, 185],
|
|
116
|
+
peru: [205, 133, 63],
|
|
117
|
+
pink: [255, 192, 203],
|
|
118
|
+
plum: [221, 160, 221],
|
|
119
|
+
powderblue: [176, 224, 230],
|
|
120
|
+
purple: [128, 0, 128],
|
|
121
|
+
rebeccapurple: [102, 51, 153],
|
|
122
|
+
red: [255, 0, 0],
|
|
123
|
+
rosybrown: [188, 143, 143],
|
|
124
|
+
royalblue: [65, 105, 225],
|
|
125
|
+
saddlebrown: [139, 69, 19],
|
|
126
|
+
salmon: [250, 128, 114],
|
|
127
|
+
sandybrown: [244, 164, 96],
|
|
128
|
+
seagreen: [46, 139, 87],
|
|
129
|
+
seashell: [255, 245, 238],
|
|
130
|
+
sienna: [160, 82, 45],
|
|
131
|
+
silver: [192, 192, 192],
|
|
132
|
+
skyblue: [135, 206, 235],
|
|
133
|
+
slateblue: [106, 90, 205],
|
|
134
|
+
slategray: [112, 128, 144],
|
|
135
|
+
slategrey: [112, 128, 144],
|
|
136
|
+
snow: [255, 250, 250],
|
|
137
|
+
springgreen: [0, 255, 127],
|
|
138
|
+
steelblue: [70, 130, 180],
|
|
139
|
+
tan: [210, 180, 140],
|
|
140
|
+
teal: [0, 128, 128],
|
|
141
|
+
thistle: [216, 191, 216],
|
|
142
|
+
tomato: [255, 99, 71],
|
|
143
|
+
turquoise: [64, 224, 208],
|
|
144
|
+
violet: [238, 130, 238],
|
|
145
|
+
wheat: [245, 222, 179],
|
|
146
|
+
white: [255, 255, 255],
|
|
147
|
+
whitesmoke: [245, 245, 245],
|
|
148
|
+
yellow: [255, 255, 0],
|
|
149
|
+
yellowgreen: [154, 205, 50],
|
|
150
|
+
}
|