tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21
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 +246 -6
- package/README.md +13 -9
- package/defaultTheme.d.ts +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +362 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +12 -0
- package/lib/cli-peer-dependencies.js +18 -5
- package/lib/cli.js +62 -592
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +619 -347
- package/lib/css/preflight.css +7 -0
- package/lib/featureFlags.js +34 -22
- package/lib/index.js +16 -9
- package/lib/lib/cacheInvalidation.js +42 -21
- package/lib/lib/collapseAdjacentRules.js +16 -14
- package/lib/lib/collapseDuplicateDeclarations.js +13 -10
- package/lib/lib/content.js +177 -0
- package/lib/lib/defaultExtractor.js +230 -33
- package/lib/lib/detectNesting.js +13 -4
- package/lib/lib/evaluateTailwindFunctions.js +105 -42
- package/lib/lib/expandApplyAtRules.js +151 -92
- package/lib/lib/expandTailwindAtRules.js +134 -149
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +404 -185
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +11 -8
- package/lib/lib/offsets.js +285 -0
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +60 -0
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +97 -79
- package/lib/lib/setupContextUtils.js +567 -242
- package/lib/lib/setupTrackingContext.js +77 -106
- package/lib/lib/sharedState.js +18 -10
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +10 -8
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +7 -5
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +10 -5
- package/lib/util/cloneDeep.js +6 -5
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +20 -17
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +15 -13
- package/lib/util/dataTypes.js +75 -51
- package/lib/util/defaults.js +8 -5
- package/lib/util/escapeClassName.js +13 -10
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +7 -8
- package/lib/util/formatVariantSelector.js +270 -103
- package/lib/util/getAllConfigs.js +34 -15
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
- package/lib/util/log.js +14 -8
- package/lib/util/nameClass.js +19 -8
- package/lib/util/negateValue.js +20 -5
- package/lib/util/normalizeConfig.js +94 -53
- package/lib/util/normalizeScreens.js +115 -4
- package/lib/util/parseAnimationValue.js +43 -41
- package/lib/util/parseBoxShadowValue.js +12 -45
- package/lib/util/parseDependency.js +37 -55
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +15 -12
- package/lib/util/pluginUtils.js +146 -42
- package/lib/util/prefixSelector.js +26 -9
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +104 -105
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +23 -11
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +32 -24
- package/package.json +32 -29
- package/peers/index.js +6693 -3036
- package/plugin.d.ts +10 -5
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +434 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +5 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +46 -659
- package/src/corePlugins.js +346 -79
- package/src/css/preflight.css +7 -0
- package/src/featureFlags.js +12 -2
- package/src/index.js +5 -0
- package/src/lib/content.js +213 -0
- package/src/lib/defaultExtractor.js +202 -35
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +129 -34
- package/src/lib/expandTailwindAtRules.js +12 -50
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +379 -126
- package/src/lib/offsets.js +351 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +510 -120
- package/src/lib/setupTrackingContext.js +8 -45
- package/src/lib/sharedState.js +2 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +5 -1
- package/src/util/dataTypes.js +51 -26
- package/src/util/formatVariantSelector.js +317 -101
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +1 -1
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +40 -10
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +28 -10
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -62
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +165 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +77 -37
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -1
- package/types.d.ts +0 -1
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
import fastGlob from 'fast-glob'
|
|
5
2
|
import LRU from 'quick-lru'
|
|
6
|
-
import normalizePath from 'normalize-path'
|
|
7
3
|
|
|
8
4
|
import hash from '../util/hashConfig'
|
|
9
5
|
import getModuleDependencies from '../lib/getModuleDependencies'
|
|
10
|
-
|
|
11
6
|
import resolveConfig from '../public/resolve-config'
|
|
12
|
-
|
|
13
7
|
import resolveConfigPath from '../util/resolveConfigPath'
|
|
14
|
-
|
|
15
|
-
import { env } from './sharedState'
|
|
16
|
-
|
|
17
8
|
import { getContext, getFileModifiedMap } from './setupContextUtils'
|
|
18
9
|
import parseDependency from '../util/parseDependency'
|
|
10
|
+
import { validateConfig } from '../util/validateConfig.js'
|
|
11
|
+
import { parseCandidateFiles, resolvedChangedContent } from './content.js'
|
|
19
12
|
|
|
20
13
|
let configPathCache = new LRU({ maxSize: 100 })
|
|
21
14
|
|
|
@@ -26,9 +19,7 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
26
19
|
return candidateFilesCache.get(context)
|
|
27
20
|
}
|
|
28
21
|
|
|
29
|
-
let candidateFiles = tailwindConfig
|
|
30
|
-
.filter((item) => typeof item === 'string')
|
|
31
|
-
.map((contentPath) => normalizePath(contentPath))
|
|
22
|
+
let candidateFiles = parseCandidateFiles(context, tailwindConfig)
|
|
32
23
|
|
|
33
24
|
return candidateFilesCache.set(context, candidateFiles).get(context)
|
|
34
25
|
}
|
|
@@ -63,6 +54,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
63
54
|
delete require.cache[file]
|
|
64
55
|
}
|
|
65
56
|
let newConfig = resolveConfig(require(userConfigPath))
|
|
57
|
+
newConfig = validateConfig(newConfig)
|
|
66
58
|
let newHash = hash(newConfig)
|
|
67
59
|
configPathCache.set(userConfigPath, [newConfig, newHash, newDeps, newModified])
|
|
68
60
|
return [newConfig, userConfigPath, newHash, newDeps]
|
|
@@ -73,37 +65,9 @@ function getTailwindConfig(configOrPath) {
|
|
|
73
65
|
configOrPath.config === undefined ? configOrPath : configOrPath.config
|
|
74
66
|
)
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
80
|
-
let changedContent = context.tailwindConfig.content.files
|
|
81
|
-
.filter((item) => typeof item.raw === 'string')
|
|
82
|
-
.map(({ raw, extension = 'html' }) => ({ content: raw, extension }))
|
|
83
|
-
|
|
84
|
-
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)) {
|
|
85
|
-
let content = fs.readFileSync(changedFile, 'utf8')
|
|
86
|
-
let extension = path.extname(changedFile).slice(1)
|
|
87
|
-
changedContent.push({ content, extension })
|
|
88
|
-
}
|
|
89
|
-
return changedContent
|
|
90
|
-
}
|
|
68
|
+
newConfig = validateConfig(newConfig)
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
let changedFiles = new Set()
|
|
94
|
-
env.DEBUG && console.time('Finding changed files')
|
|
95
|
-
let files = fastGlob.sync(candidateFiles)
|
|
96
|
-
for (let file of files) {
|
|
97
|
-
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity
|
|
98
|
-
let modified = fs.statSync(file).mtimeMs
|
|
99
|
-
|
|
100
|
-
if (modified > prevModified) {
|
|
101
|
-
changedFiles.add(file)
|
|
102
|
-
fileModifiedMap.set(file, modified)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
env.DEBUG && console.timeEnd('Finding changed files')
|
|
106
|
-
return changedFiles
|
|
70
|
+
return [newConfig, null, hash(newConfig), []]
|
|
107
71
|
}
|
|
108
72
|
|
|
109
73
|
// DISABLE_TOUCH = TRUE
|
|
@@ -157,9 +121,8 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
157
121
|
let fileModifiedMap = getFileModifiedMap(context)
|
|
158
122
|
|
|
159
123
|
// Add template paths as postcss dependencies.
|
|
160
|
-
for (let
|
|
161
|
-
let dependency
|
|
162
|
-
if (dependency) {
|
|
124
|
+
for (let contentPath of candidateFiles) {
|
|
125
|
+
for (let dependency of parseDependency(contentPath)) {
|
|
163
126
|
registerDependency(dependency)
|
|
164
127
|
}
|
|
165
128
|
}
|
package/src/lib/sharedState.js
CHANGED
|
@@ -8,6 +8,8 @@ export const contextSourcesMap = new Map()
|
|
|
8
8
|
export const sourceHashMap = new Map()
|
|
9
9
|
export const NOT_ON_DEMAND = new String('*')
|
|
10
10
|
|
|
11
|
+
export const NONE = Symbol('__NONE__')
|
|
12
|
+
|
|
11
13
|
export function resolveDebug(debug) {
|
|
12
14
|
if (debug === undefined) {
|
|
13
15
|
return false
|
|
@@ -2,8 +2,8 @@ export default function buildMediaQuery(screens) {
|
|
|
2
2
|
screens = Array.isArray(screens) ? screens : [screens]
|
|
3
3
|
|
|
4
4
|
return screens
|
|
5
|
-
.map((screen) =>
|
|
6
|
-
screen.values.map((screen) => {
|
|
5
|
+
.map((screen) => {
|
|
6
|
+
let values = screen.values.map((screen) => {
|
|
7
7
|
if (screen.raw !== undefined) {
|
|
8
8
|
return screen.raw
|
|
9
9
|
}
|
|
@@ -15,6 +15,8 @@ export default function buildMediaQuery(screens) {
|
|
|
15
15
|
.filter(Boolean)
|
|
16
16
|
.join(' and ')
|
|
17
17
|
})
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
return screen.not ? `not all and ${values}` : values
|
|
20
|
+
})
|
|
19
21
|
.join(', ')
|
|
20
22
|
}
|
package/src/util/cloneNodes.js
CHANGED
|
@@ -2,7 +2,11 @@ export default function cloneNodes(nodes, source = undefined, raws = undefined)
|
|
|
2
2
|
return nodes.map((node) => {
|
|
3
3
|
let cloned = node.clone()
|
|
4
4
|
|
|
5
|
-
|
|
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) {
|
|
6
10
|
cloned.source = source
|
|
7
11
|
|
|
8
12
|
if ('walk' in cloned) {
|
package/src/util/dataTypes.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { parseColor } from './color'
|
|
2
2
|
import { parseBoxShadowValue } from './parseBoxShadowValue'
|
|
3
|
+
import { splitAtTopLevelOnly } from './splitAtTopLevelOnly'
|
|
3
4
|
|
|
4
5
|
let cssFunctions = ['min', 'max', 'clamp', 'calc']
|
|
5
6
|
|
|
6
7
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
function isCSSFunction(value) {
|
|
10
|
+
return cssFunctions.some((fn) => new RegExp(`^${fn}\\(.*\\)`).test(value))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const placeholder = '--tw-placeholder'
|
|
14
|
+
const placeholderRe = new RegExp(placeholder, 'g')
|
|
10
15
|
|
|
11
16
|
// This is not a data type, but rather a function that can normalize the
|
|
12
17
|
// correct values.
|
|
13
18
|
export function normalize(value, isRoot = true) {
|
|
19
|
+
if (value.startsWith('--')) {
|
|
20
|
+
return `var(${value})`
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
// Keep raw strings if it starts with `url(`
|
|
15
24
|
if (value.includes('url(')) {
|
|
16
25
|
return value
|
|
@@ -40,18 +49,20 @@ export function normalize(value, isRoot = true) {
|
|
|
40
49
|
value = value.trim()
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
// Add spaces around operators inside calc() that do not follow an operator
|
|
52
|
+
// Add spaces around operators inside math functions like calc() that do not follow an operator
|
|
44
53
|
// or '('.
|
|
45
|
-
value = value.replace(/calc\(.+\)/g, (match) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
|
|
55
|
+
let vars = []
|
|
56
|
+
return match
|
|
57
|
+
.replace(/var\((--.+?)[,)]/g, (match, g1) => {
|
|
58
|
+
vars.push(g1)
|
|
59
|
+
return match.replace(g1, placeholder)
|
|
60
|
+
})
|
|
61
|
+
.replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ')
|
|
62
|
+
.replace(placeholderRe, () => vars.shift())
|
|
50
63
|
})
|
|
51
64
|
|
|
52
|
-
|
|
53
|
-
// or '('.
|
|
54
|
-
return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([\/])/g, '$1 $2 ')
|
|
65
|
+
return value
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
export function url(value) {
|
|
@@ -59,15 +70,16 @@ export function url(value) {
|
|
|
59
70
|
}
|
|
60
71
|
|
|
61
72
|
export function number(value) {
|
|
62
|
-
return !isNaN(Number(value)) ||
|
|
73
|
+
return !isNaN(Number(value)) || isCSSFunction(value)
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
export function percentage(value) {
|
|
66
|
-
return value.
|
|
67
|
-
return /%$/g.test(part) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(part))
|
|
68
|
-
})
|
|
77
|
+
return (value.endsWith('%') && number(value.slice(0, -1))) || isCSSFunction(value)
|
|
69
78
|
}
|
|
70
79
|
|
|
80
|
+
// Please refer to MDN when updating this list:
|
|
81
|
+
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
|
|
82
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
|
|
71
83
|
let lengthUnits = [
|
|
72
84
|
'cm',
|
|
73
85
|
'mm',
|
|
@@ -81,20 +93,33 @@ let lengthUnits = [
|
|
|
81
93
|
'ch',
|
|
82
94
|
'rem',
|
|
83
95
|
'lh',
|
|
96
|
+
'rlh',
|
|
84
97
|
'vw',
|
|
85
98
|
'vh',
|
|
86
99
|
'vmin',
|
|
87
100
|
'vmax',
|
|
101
|
+
'vb',
|
|
102
|
+
'vi',
|
|
103
|
+
'svw',
|
|
104
|
+
'svh',
|
|
105
|
+
'lvw',
|
|
106
|
+
'lvh',
|
|
107
|
+
'dvw',
|
|
108
|
+
'dvh',
|
|
109
|
+
'cqw',
|
|
110
|
+
'cqh',
|
|
111
|
+
'cqi',
|
|
112
|
+
'cqb',
|
|
113
|
+
'cqmin',
|
|
114
|
+
'cqmax',
|
|
88
115
|
]
|
|
89
116
|
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
|
|
90
117
|
export function length(value) {
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
})
|
|
118
|
+
return (
|
|
119
|
+
value === '0' ||
|
|
120
|
+
new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) ||
|
|
121
|
+
isCSSFunction(value)
|
|
122
|
+
)
|
|
98
123
|
}
|
|
99
124
|
|
|
100
125
|
let lineWidths = new Set(['thin', 'medium', 'thick'])
|
|
@@ -117,7 +142,7 @@ export function shadow(value) {
|
|
|
117
142
|
export function color(value) {
|
|
118
143
|
let colors = 0
|
|
119
144
|
|
|
120
|
-
let result = value
|
|
145
|
+
let result = splitAtTopLevelOnly(value, '_').every((part) => {
|
|
121
146
|
part = normalize(part)
|
|
122
147
|
|
|
123
148
|
if (part.startsWith('var(')) return true
|
|
@@ -132,7 +157,7 @@ export function color(value) {
|
|
|
132
157
|
|
|
133
158
|
export function image(value) {
|
|
134
159
|
let images = 0
|
|
135
|
-
let result = value
|
|
160
|
+
let result = splitAtTopLevelOnly(value, ',').every((part) => {
|
|
136
161
|
part = normalize(part)
|
|
137
162
|
|
|
138
163
|
if (part.startsWith('var(')) return true
|
|
@@ -173,7 +198,7 @@ export function gradient(value) {
|
|
|
173
198
|
let validPositions = new Set(['center', 'top', 'right', 'bottom', 'left'])
|
|
174
199
|
export function position(value) {
|
|
175
200
|
let positions = 0
|
|
176
|
-
let result = value
|
|
201
|
+
let result = splitAtTopLevelOnly(value, '_').every((part) => {
|
|
177
202
|
part = normalize(part)
|
|
178
203
|
|
|
179
204
|
if (part.startsWith('var(')) return true
|
|
@@ -191,7 +216,7 @@ export function position(value) {
|
|
|
191
216
|
|
|
192
217
|
export function familyName(value) {
|
|
193
218
|
let fonts = 0
|
|
194
|
-
let result = value
|
|
219
|
+
let result = splitAtTopLevelOnly(value, ',').every((part) => {
|
|
195
220
|
part = normalize(part)
|
|
196
221
|
|
|
197
222
|
if (part.startsWith('var(')) return true
|