tailwindcss 0.0.0-insiders.fc623da → 0.0.0-insiders.fc63ce7
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/LICENSE +1 -2
- package/README.md +18 -15
- package/dist/chunk-GFBUASX3.mjs +1 -0
- package/dist/chunk-HI3XV5H7.mjs +38 -0
- package/dist/chunk-HTB5LLOP.mjs +1 -0
- package/dist/colors-b_6i0Oi7.d.ts +295 -0
- package/dist/colors.d.mts +295 -0
- package/dist/colors.d.ts +5 -0
- package/dist/colors.js +1 -0
- package/dist/colors.mjs +1 -0
- package/dist/default-theme.d.mts +1147 -0
- package/dist/default-theme.d.ts +1147 -0
- package/dist/default-theme.js +1 -0
- package/dist/default-theme.mjs +1 -0
- package/dist/flatten-color-palette.d.mts +6 -0
- package/dist/flatten-color-palette.d.ts +6 -0
- package/dist/flatten-color-palette.js +18 -0
- package/dist/flatten-color-palette.mjs +1 -0
- package/dist/lib.d.mts +363 -0
- package/dist/lib.d.ts +3 -0
- package/dist/lib.js +38 -0
- package/dist/lib.mjs +1 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.d.ts +131 -0
- package/dist/plugin.js +1 -0
- package/dist/plugin.mjs +1 -0
- package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
- package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
- package/dist/types-WlZgYgM8.d.mts +125 -0
- package/index.css +896 -0
- package/package.json +76 -101
- package/preflight.css +393 -0
- package/theme.css +462 -0
- package/CHANGELOG.md +0 -1882
- package/base.css +0 -1
- package/colors.js +0 -2
- package/components.css +0 -1
- package/defaultConfig.js +0 -2
- package/defaultTheme.js +0 -2
- package/lib/cli-peer-dependencies.js +0 -15
- package/lib/cli.js +0 -706
- package/lib/constants.js +0 -37
- package/lib/corePluginList.js +0 -178
- package/lib/corePlugins.js +0 -3647
- package/lib/css/LICENSE +0 -25
- package/lib/css/preflight.css +0 -368
- package/lib/featureFlags.js +0 -62
- package/lib/index.js +0 -32
- package/lib/lib/collapseAdjacentRules.js +0 -41
- package/lib/lib/collapseDuplicateDeclarations.js +0 -29
- package/lib/lib/detectNesting.js +0 -34
- package/lib/lib/evaluateTailwindFunctions.js +0 -171
- package/lib/lib/expandApplyAtRules.js +0 -245
- package/lib/lib/expandTailwindAtRules.js +0 -263
- package/lib/lib/generateRules.js +0 -547
- package/lib/lib/getModuleDependencies.js +0 -48
- package/lib/lib/normalizeTailwindDirectives.js +0 -76
- package/lib/lib/resolveDefaultsAtRules.js +0 -139
- package/lib/lib/setupContextUtils.js +0 -837
- package/lib/lib/setupTrackingContext.js +0 -170
- package/lib/lib/setupWatchingContext.js +0 -288
- package/lib/lib/sharedState.js +0 -19
- package/lib/lib/substituteScreenAtRules.js +0 -27
- package/lib/processTailwindFeatures.js +0 -51
- package/lib/public/colors.js +0 -329
- package/lib/public/create-plugin.js +0 -13
- package/lib/public/default-config.js +0 -14
- package/lib/public/default-theme.js +0 -14
- package/lib/public/resolve-config.js +0 -19
- package/lib/util/bigSign.js +0 -8
- package/lib/util/buildMediaQuery.js +0 -20
- package/lib/util/cloneDeep.js +0 -19
- package/lib/util/cloneNodes.js +0 -14
- package/lib/util/color.js +0 -84
- package/lib/util/configurePlugins.js +0 -18
- package/lib/util/createPlugin.js +0 -30
- package/lib/util/createUtilityPlugin.js +0 -53
- package/lib/util/dataTypes.js +0 -233
- package/lib/util/defaults.js +0 -22
- package/lib/util/escapeClassName.js +0 -19
- package/lib/util/escapeCommas.js +0 -8
- package/lib/util/flattenColorPalette.js +0 -19
- package/lib/util/formatVariantSelector.js +0 -186
- package/lib/util/getAllConfigs.js +0 -29
- package/lib/util/hashConfig.js +0 -16
- package/lib/util/isKeyframeRule.js +0 -8
- package/lib/util/isPlainObject.js +0 -12
- package/lib/util/isValidArbitraryValue.js +0 -64
- package/lib/util/log.js +0 -51
- package/lib/util/nameClass.js +0 -32
- package/lib/util/negateValue.js +0 -19
- package/lib/util/normalizeConfig.js +0 -237
- package/lib/util/normalizeScreens.js +0 -61
- package/lib/util/parseAnimationValue.js +0 -89
- package/lib/util/parseBoxShadowValue.js +0 -77
- package/lib/util/parseDependency.js +0 -63
- package/lib/util/parseObjectStyles.js +0 -31
- package/lib/util/pluginUtils.js +0 -186
- package/lib/util/prefixSelector.js +0 -21
- package/lib/util/resolveConfig.js +0 -234
- package/lib/util/resolveConfigPath.js +0 -52
- package/lib/util/responsive.js +0 -19
- package/lib/util/tap.js +0 -9
- package/lib/util/toColorValue.js +0 -9
- package/lib/util/toPath.js +0 -9
- package/lib/util/transformThemeValue.js +0 -63
- package/lib/util/withAlphaVariable.js +0 -67
- package/nesting/README.md +0 -42
- package/nesting/index.js +0 -12
- package/nesting/plugin.js +0 -41
- package/peers/index.js +0 -76107
- package/plugin.js +0 -2
- package/prettier.config.js +0 -19
- package/resolveConfig.js +0 -2
- package/screens.css +0 -1
- package/scripts/create-plugin-list.js +0 -10
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli-peer-dependencies.js +0 -9
- package/src/cli.js +0 -768
- package/src/constants.js +0 -17
- package/src/corePluginList.js +0 -1
- package/src/corePlugins.js +0 -2359
- package/src/css/LICENSE +0 -25
- package/src/css/preflight.css +0 -368
- package/src/featureFlags.js +0 -58
- package/src/index.js +0 -34
- package/src/lib/collapseAdjacentRules.js +0 -39
- package/src/lib/collapseDuplicateDeclarations.js +0 -28
- package/src/lib/detectNesting.js +0 -39
- package/src/lib/evaluateTailwindFunctions.js +0 -198
- package/src/lib/expandApplyAtRules.js +0 -278
- package/src/lib/expandTailwindAtRules.js +0 -270
- package/src/lib/generateRules.js +0 -552
- package/src/lib/getModuleDependencies.js +0 -39
- package/src/lib/normalizeTailwindDirectives.js +0 -78
- package/src/lib/resolveDefaultsAtRules.js +0 -142
- package/src/lib/setupContextUtils.js +0 -834
- package/src/lib/setupTrackingContext.js +0 -182
- package/src/lib/setupWatchingContext.js +0 -311
- package/src/lib/sharedState.js +0 -10
- package/src/lib/substituteScreenAtRules.js +0 -19
- package/src/processTailwindFeatures.js +0 -48
- package/src/public/colors.js +0 -300
- package/src/public/create-plugin.js +0 -2
- package/src/public/default-config.js +0 -4
- package/src/public/default-theme.js +0 -4
- package/src/public/resolve-config.js +0 -7
- package/src/util/bigSign.js +0 -3
- package/src/util/buildMediaQuery.js +0 -20
- package/src/util/cloneDeep.js +0 -11
- package/src/util/cloneNodes.js +0 -11
- package/src/util/color.js +0 -56
- package/src/util/configurePlugins.js +0 -23
- package/src/util/createPlugin.js +0 -27
- package/src/util/createUtilityPlugin.js +0 -37
- package/src/util/dataTypes.js +0 -248
- package/src/util/defaults.js +0 -17
- package/src/util/escapeClassName.js +0 -8
- package/src/util/escapeCommas.js +0 -3
- package/src/util/flattenColorPalette.js +0 -13
- package/src/util/formatVariantSelector.js +0 -196
- package/src/util/getAllConfigs.js +0 -19
- package/src/util/hashConfig.js +0 -5
- package/src/util/isKeyframeRule.js +0 -3
- package/src/util/isPlainObject.js +0 -8
- package/src/util/isValidArbitraryValue.js +0 -61
- package/src/util/log.js +0 -29
- package/src/util/nameClass.js +0 -26
- package/src/util/negateValue.js +0 -16
- package/src/util/normalizeConfig.js +0 -262
- package/src/util/normalizeScreens.js +0 -45
- package/src/util/parseAnimationValue.js +0 -68
- package/src/util/parseBoxShadowValue.js +0 -71
- package/src/util/parseDependency.js +0 -49
- package/src/util/parseObjectStyles.js +0 -19
- package/src/util/pluginUtils.js +0 -192
- package/src/util/prefixSelector.js +0 -12
- package/src/util/resolveConfig.js +0 -229
- package/src/util/resolveConfigPath.js +0 -55
- package/src/util/responsive.js +0 -10
- package/src/util/tap.js +0 -4
- package/src/util/toColorValue.js +0 -3
- package/src/util/toPath.js +0 -4
- package/src/util/transformThemeValue.js +0 -52
- package/src/util/withAlphaVariable.js +0 -49
- package/stubs/defaultConfig.stub.js +0 -950
- package/stubs/defaultPostCssConfig.stub.js +0 -6
- package/stubs/simpleConfig.stub.js +0 -7
- package/tailwind.css +0 -5
- package/variants.css +0 -1
|
@@ -1,834 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import url from 'url'
|
|
3
|
-
import postcss from 'postcss'
|
|
4
|
-
import dlv from 'dlv'
|
|
5
|
-
import selectorParser from 'postcss-selector-parser'
|
|
6
|
-
|
|
7
|
-
import transformThemeValue from '../util/transformThemeValue'
|
|
8
|
-
import parseObjectStyles from '../util/parseObjectStyles'
|
|
9
|
-
import prefixSelector from '../util/prefixSelector'
|
|
10
|
-
import isPlainObject from '../util/isPlainObject'
|
|
11
|
-
import escapeClassName from '../util/escapeClassName'
|
|
12
|
-
import nameClass, { formatClass } from '../util/nameClass'
|
|
13
|
-
import { coerceValue } from '../util/pluginUtils'
|
|
14
|
-
import bigSign from '../util/bigSign'
|
|
15
|
-
import { variantPlugins, corePlugins } from '../corePlugins'
|
|
16
|
-
import * as sharedState from './sharedState'
|
|
17
|
-
import { env } from './sharedState'
|
|
18
|
-
import { toPath } from '../util/toPath'
|
|
19
|
-
import log from '../util/log'
|
|
20
|
-
import negateValue from '../util/negateValue'
|
|
21
|
-
import isValidArbitraryValue from '../util/isValidArbitraryValue'
|
|
22
|
-
|
|
23
|
-
function parseVariantFormatString(input) {
|
|
24
|
-
if (input.includes('{')) {
|
|
25
|
-
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`)
|
|
26
|
-
|
|
27
|
-
return input
|
|
28
|
-
.split(/{(.*)}/gim)
|
|
29
|
-
.flatMap((line) => parseVariantFormatString(line))
|
|
30
|
-
.filter(Boolean)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return [input.trim()]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function isBalanced(input) {
|
|
37
|
-
let count = 0
|
|
38
|
-
|
|
39
|
-
for (let char of input) {
|
|
40
|
-
if (char === '{') {
|
|
41
|
-
count++
|
|
42
|
-
} else if (char === '}') {
|
|
43
|
-
if (--count < 0) {
|
|
44
|
-
return false // unbalanced
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return count === 0
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function insertInto(list, value, { before = [] } = {}) {
|
|
53
|
-
before = [].concat(before)
|
|
54
|
-
|
|
55
|
-
if (before.length <= 0) {
|
|
56
|
-
list.push(value)
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let idx = list.length - 1
|
|
61
|
-
for (let other of before) {
|
|
62
|
-
let iidx = list.indexOf(other)
|
|
63
|
-
if (iidx === -1) continue
|
|
64
|
-
idx = Math.min(idx, iidx)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
list.splice(idx, 0, value)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function parseStyles(styles) {
|
|
71
|
-
if (!Array.isArray(styles)) {
|
|
72
|
-
return parseStyles([styles])
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return styles.flatMap((style) => {
|
|
76
|
-
let isNode = !Array.isArray(style) && !isPlainObject(style)
|
|
77
|
-
return isNode ? style : parseObjectStyles(style)
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function getClasses(selector) {
|
|
82
|
-
let parser = selectorParser((selectors) => {
|
|
83
|
-
let allClasses = []
|
|
84
|
-
selectors.walkClasses((classNode) => {
|
|
85
|
-
allClasses.push(classNode.value)
|
|
86
|
-
})
|
|
87
|
-
return allClasses
|
|
88
|
-
})
|
|
89
|
-
return parser.transformSync(selector)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function extractCandidates(node) {
|
|
93
|
-
let classes = []
|
|
94
|
-
|
|
95
|
-
if (node.type === 'rule') {
|
|
96
|
-
for (let selector of node.selectors) {
|
|
97
|
-
let classCandidates = getClasses(selector)
|
|
98
|
-
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
99
|
-
if (classCandidates.length === 0) return []
|
|
100
|
-
|
|
101
|
-
classes = [...classes, ...classCandidates]
|
|
102
|
-
}
|
|
103
|
-
return classes
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (node.type === 'atrule') {
|
|
107
|
-
node.walkRules((rule) => {
|
|
108
|
-
classes = [...classes, ...rule.selectors.flatMap((selector) => getClasses(selector))]
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return classes
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function withIdentifiers(styles) {
|
|
116
|
-
return parseStyles(styles).flatMap((node) => {
|
|
117
|
-
let nodeMap = new Map()
|
|
118
|
-
let candidates = extractCandidates(node)
|
|
119
|
-
|
|
120
|
-
// If this isn't "on-demandable", assign it a universal candidate.
|
|
121
|
-
if (candidates.length === 0) {
|
|
122
|
-
return [['*', node]]
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return candidates.map((c) => {
|
|
126
|
-
if (!nodeMap.has(node)) {
|
|
127
|
-
nodeMap.set(node, node)
|
|
128
|
-
}
|
|
129
|
-
return [c, nodeMap.get(node)]
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offsets, classList }) {
|
|
135
|
-
function getConfigValue(path, defaultValue) {
|
|
136
|
-
return path ? dlv(tailwindConfig, path, defaultValue) : tailwindConfig
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function applyConfiguredPrefix(selector) {
|
|
140
|
-
return prefixSelector(tailwindConfig.prefix, selector)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function prefixIdentifier(identifier, options) {
|
|
144
|
-
if (identifier === '*') {
|
|
145
|
-
return '*'
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!options.respectPrefix) {
|
|
149
|
-
return identifier
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return context.tailwindConfig.prefix + identifier
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
addVariant(variantName, variantFunctions, options = {}) {
|
|
157
|
-
variantFunctions = [].concat(variantFunctions).map((variantFunction) => {
|
|
158
|
-
if (typeof variantFunction !== 'string') {
|
|
159
|
-
// Safelist public API functions
|
|
160
|
-
return ({ modifySelectors, container, separator }) => {
|
|
161
|
-
return variantFunction({ modifySelectors, container, separator })
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
variantFunction = variantFunction
|
|
166
|
-
.replace(/\n+/g, '')
|
|
167
|
-
.replace(/\s{1,}/g, ' ')
|
|
168
|
-
.trim()
|
|
169
|
-
|
|
170
|
-
let fns = parseVariantFormatString(variantFunction)
|
|
171
|
-
.map((str) => {
|
|
172
|
-
if (!str.startsWith('@')) {
|
|
173
|
-
return ({ format }) => format(str)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
let [, name, params] = /@(.*?) (.*)/g.exec(str)
|
|
177
|
-
return ({ wrap }) => wrap(postcss.atRule({ name, params }))
|
|
178
|
-
})
|
|
179
|
-
.reverse()
|
|
180
|
-
|
|
181
|
-
return (api) => {
|
|
182
|
-
for (let fn of fns) {
|
|
183
|
-
fn(api)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
insertInto(variantList, variantName, options)
|
|
189
|
-
variantMap.set(variantName, variantFunctions)
|
|
190
|
-
},
|
|
191
|
-
postcss,
|
|
192
|
-
prefix: applyConfiguredPrefix,
|
|
193
|
-
e: escapeClassName,
|
|
194
|
-
config: getConfigValue,
|
|
195
|
-
theme(path, defaultValue) {
|
|
196
|
-
const [pathRoot, ...subPaths] = toPath(path)
|
|
197
|
-
const value = getConfigValue(['theme', pathRoot, ...subPaths], defaultValue)
|
|
198
|
-
return transformThemeValue(pathRoot)(value)
|
|
199
|
-
},
|
|
200
|
-
corePlugins: (path) => {
|
|
201
|
-
if (Array.isArray(tailwindConfig.corePlugins)) {
|
|
202
|
-
return tailwindConfig.corePlugins.includes(path)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return getConfigValue(['corePlugins', path], true)
|
|
206
|
-
},
|
|
207
|
-
variants: () => {
|
|
208
|
-
// Preserved for backwards compatibility but not used in v3.0+
|
|
209
|
-
return []
|
|
210
|
-
},
|
|
211
|
-
addUserCss(userCss) {
|
|
212
|
-
for (let [identifier, rule] of withIdentifiers(userCss)) {
|
|
213
|
-
let offset = offsets.user++
|
|
214
|
-
|
|
215
|
-
if (!context.candidateRuleMap.has(identifier)) {
|
|
216
|
-
context.candidateRuleMap.set(identifier, [])
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
context.candidateRuleMap.get(identifier).push([{ sort: offset, layer: 'user' }, rule])
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
addBase(base) {
|
|
223
|
-
for (let [identifier, rule] of withIdentifiers(base)) {
|
|
224
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {})
|
|
225
|
-
let offset = offsets.base++
|
|
226
|
-
|
|
227
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
228
|
-
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
context.candidateRuleMap
|
|
232
|
-
.get(prefixedIdentifier)
|
|
233
|
-
.push([{ sort: offset, layer: 'base' }, rule])
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
/**
|
|
237
|
-
* @param {string} group
|
|
238
|
-
* @param {Record<string, string | string[]>} declarations
|
|
239
|
-
*/
|
|
240
|
-
addDefaults(group, declarations) {
|
|
241
|
-
const groups = {
|
|
242
|
-
[`@defaults ${group}`]: declarations,
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
for (let [identifier, rule] of withIdentifiers(groups)) {
|
|
246
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {})
|
|
247
|
-
let offset = offsets.base++
|
|
248
|
-
|
|
249
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
250
|
-
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
context.candidateRuleMap
|
|
254
|
-
.get(prefixedIdentifier)
|
|
255
|
-
.push([{ sort: offset, layer: 'defaults' }, rule])
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
addComponents(components, options) {
|
|
259
|
-
let defaultOptions = {
|
|
260
|
-
respectPrefix: true,
|
|
261
|
-
respectImportant: false,
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options)
|
|
265
|
-
|
|
266
|
-
for (let [identifier, rule] of withIdentifiers(components)) {
|
|
267
|
-
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
268
|
-
let offset = offsets.components++
|
|
269
|
-
|
|
270
|
-
classList.add(prefixedIdentifier)
|
|
271
|
-
|
|
272
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
273
|
-
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
context.candidateRuleMap
|
|
277
|
-
.get(prefixedIdentifier)
|
|
278
|
-
.push([{ sort: offset, layer: 'components', options }, rule])
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
addUtilities(utilities, options) {
|
|
282
|
-
let defaultOptions = {
|
|
283
|
-
respectPrefix: true,
|
|
284
|
-
respectImportant: true,
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options)
|
|
288
|
-
|
|
289
|
-
for (let [identifier, rule] of withIdentifiers(utilities)) {
|
|
290
|
-
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
291
|
-
let offset = offsets.utilities++
|
|
292
|
-
|
|
293
|
-
classList.add(prefixedIdentifier)
|
|
294
|
-
|
|
295
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
296
|
-
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
context.candidateRuleMap
|
|
300
|
-
.get(prefixedIdentifier)
|
|
301
|
-
.push([{ sort: offset, layer: 'utilities', options }, rule])
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
matchUtilities: function (utilities, options) {
|
|
305
|
-
let defaultOptions = {
|
|
306
|
-
respectPrefix: true,
|
|
307
|
-
respectImportant: true,
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
options = { ...defaultOptions, ...options }
|
|
311
|
-
|
|
312
|
-
let offset = offsets.utilities++
|
|
313
|
-
|
|
314
|
-
for (let identifier in utilities) {
|
|
315
|
-
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
316
|
-
let rule = utilities[identifier]
|
|
317
|
-
|
|
318
|
-
classList.add([prefixedIdentifier, options])
|
|
319
|
-
|
|
320
|
-
function wrapped(modifier, { isOnlyPlugin }) {
|
|
321
|
-
let { type = 'any' } = options
|
|
322
|
-
type = [].concat(type)
|
|
323
|
-
let [value, coercedType] = coerceValue(type, modifier, options, tailwindConfig)
|
|
324
|
-
|
|
325
|
-
if (value === undefined) {
|
|
326
|
-
return []
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
330
|
-
return []
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (!isValidArbitraryValue(value)) {
|
|
334
|
-
return []
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
let ruleSets = []
|
|
338
|
-
.concat(rule(value))
|
|
339
|
-
.filter(Boolean)
|
|
340
|
-
.map((declaration) => ({
|
|
341
|
-
[nameClass(identifier, modifier)]: declaration,
|
|
342
|
-
}))
|
|
343
|
-
|
|
344
|
-
return ruleSets
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
let withOffsets = [{ sort: offset, layer: 'utilities', options }, wrapped]
|
|
348
|
-
|
|
349
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
350
|
-
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets)
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
matchComponents: function (components, options) {
|
|
357
|
-
let defaultOptions = {
|
|
358
|
-
respectPrefix: true,
|
|
359
|
-
respectImportant: false,
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
options = { ...defaultOptions, ...options }
|
|
363
|
-
|
|
364
|
-
let offset = offsets.components++
|
|
365
|
-
|
|
366
|
-
for (let identifier in components) {
|
|
367
|
-
let prefixedIdentifier = prefixIdentifier(identifier, options)
|
|
368
|
-
let rule = components[identifier]
|
|
369
|
-
|
|
370
|
-
classList.add([prefixedIdentifier, options])
|
|
371
|
-
|
|
372
|
-
function wrapped(modifier, { isOnlyPlugin }) {
|
|
373
|
-
let { type = 'any' } = options
|
|
374
|
-
type = [].concat(type)
|
|
375
|
-
let [value, coercedType] = coerceValue(type, modifier, options, tailwindConfig)
|
|
376
|
-
|
|
377
|
-
if (value === undefined) {
|
|
378
|
-
return []
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (!type.includes(coercedType)) {
|
|
382
|
-
if (isOnlyPlugin) {
|
|
383
|
-
log.warn([
|
|
384
|
-
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
385
|
-
`You can safely update it to \`${identifier}-${modifier.replace(
|
|
386
|
-
coercedType + ':',
|
|
387
|
-
''
|
|
388
|
-
)}\`.`,
|
|
389
|
-
])
|
|
390
|
-
} else {
|
|
391
|
-
return []
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (!isValidArbitraryValue(value)) {
|
|
396
|
-
return []
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
let ruleSets = []
|
|
400
|
-
.concat(rule(value))
|
|
401
|
-
.filter(Boolean)
|
|
402
|
-
.map((declaration) => ({
|
|
403
|
-
[nameClass(identifier, modifier)]: declaration,
|
|
404
|
-
}))
|
|
405
|
-
|
|
406
|
-
return ruleSets
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
let withOffsets = [{ sort: offset, layer: 'components', options }, wrapped]
|
|
410
|
-
|
|
411
|
-
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
412
|
-
context.candidateRuleMap.set(prefixedIdentifier, [])
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets)
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
let fileModifiedMapCache = new WeakMap()
|
|
422
|
-
export function getFileModifiedMap(context) {
|
|
423
|
-
if (!fileModifiedMapCache.has(context)) {
|
|
424
|
-
fileModifiedMapCache.set(context, new Map())
|
|
425
|
-
}
|
|
426
|
-
return fileModifiedMapCache.get(context)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function trackModified(files, fileModifiedMap) {
|
|
430
|
-
let changed = false
|
|
431
|
-
|
|
432
|
-
for (let file of files) {
|
|
433
|
-
if (!file) continue
|
|
434
|
-
|
|
435
|
-
let parsed = url.parse(file)
|
|
436
|
-
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href
|
|
437
|
-
pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname
|
|
438
|
-
let newModified = fs.statSync(decodeURIComponent(pathname)).mtimeMs
|
|
439
|
-
|
|
440
|
-
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
441
|
-
changed = true
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
fileModifiedMap.set(file, newModified)
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
return changed
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function extractVariantAtRules(node) {
|
|
451
|
-
node.walkAtRules((atRule) => {
|
|
452
|
-
if (['responsive', 'variants'].includes(atRule.name)) {
|
|
453
|
-
extractVariantAtRules(atRule)
|
|
454
|
-
atRule.before(atRule.nodes)
|
|
455
|
-
atRule.remove()
|
|
456
|
-
}
|
|
457
|
-
})
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function collectLayerPlugins(root) {
|
|
461
|
-
let layerPlugins = []
|
|
462
|
-
|
|
463
|
-
root.each((node) => {
|
|
464
|
-
if (node.type === 'atrule' && ['responsive', 'variants'].includes(node.name)) {
|
|
465
|
-
node.name = 'layer'
|
|
466
|
-
node.params = 'utilities'
|
|
467
|
-
}
|
|
468
|
-
})
|
|
469
|
-
|
|
470
|
-
// Walk @layer rules and treat them like plugins
|
|
471
|
-
root.walkAtRules('layer', (layerRule) => {
|
|
472
|
-
extractVariantAtRules(layerRule)
|
|
473
|
-
|
|
474
|
-
if (layerRule.params === 'base') {
|
|
475
|
-
for (let node of layerRule.nodes) {
|
|
476
|
-
layerPlugins.push(function ({ addBase }) {
|
|
477
|
-
addBase(node, { respectPrefix: false })
|
|
478
|
-
})
|
|
479
|
-
}
|
|
480
|
-
layerRule.remove()
|
|
481
|
-
} else if (layerRule.params === 'components') {
|
|
482
|
-
for (let node of layerRule.nodes) {
|
|
483
|
-
layerPlugins.push(function ({ addComponents }) {
|
|
484
|
-
addComponents(node, { respectPrefix: false })
|
|
485
|
-
})
|
|
486
|
-
}
|
|
487
|
-
layerRule.remove()
|
|
488
|
-
} else if (layerRule.params === 'utilities') {
|
|
489
|
-
for (let node of layerRule.nodes) {
|
|
490
|
-
layerPlugins.push(function ({ addUtilities }) {
|
|
491
|
-
addUtilities(node, { respectPrefix: false })
|
|
492
|
-
})
|
|
493
|
-
}
|
|
494
|
-
layerRule.remove()
|
|
495
|
-
}
|
|
496
|
-
})
|
|
497
|
-
|
|
498
|
-
root.walkRules((rule) => {
|
|
499
|
-
// At this point it is safe to include all the left-over css from the
|
|
500
|
-
// user's css file. This is because the `@tailwind` and `@layer` directives
|
|
501
|
-
// will already be handled and will be removed from the css tree.
|
|
502
|
-
layerPlugins.push(function ({ addUserCss }) {
|
|
503
|
-
addUserCss(rule, { respectPrefix: false })
|
|
504
|
-
})
|
|
505
|
-
})
|
|
506
|
-
|
|
507
|
-
return layerPlugins
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
function resolvePlugins(context, root) {
|
|
511
|
-
let corePluginList = Object.entries({ ...variantPlugins, ...corePlugins })
|
|
512
|
-
.map(([name, plugin]) => {
|
|
513
|
-
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
514
|
-
return null
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
return plugin
|
|
518
|
-
})
|
|
519
|
-
.filter(Boolean)
|
|
520
|
-
|
|
521
|
-
let userPlugins = context.tailwindConfig.plugins.map((plugin) => {
|
|
522
|
-
if (plugin.__isOptionsFunction) {
|
|
523
|
-
plugin = plugin()
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return typeof plugin === 'function' ? plugin : plugin.handler
|
|
527
|
-
})
|
|
528
|
-
|
|
529
|
-
let layerPlugins = collectLayerPlugins(root)
|
|
530
|
-
|
|
531
|
-
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
532
|
-
// were historically sorted before screen/stackable variants.
|
|
533
|
-
let beforeVariants = [
|
|
534
|
-
variantPlugins['pseudoElementVariants'],
|
|
535
|
-
variantPlugins['pseudoClassVariants'],
|
|
536
|
-
]
|
|
537
|
-
let afterVariants = [
|
|
538
|
-
variantPlugins['directionVariants'],
|
|
539
|
-
variantPlugins['reducedMotionVariants'],
|
|
540
|
-
variantPlugins['darkVariants'],
|
|
541
|
-
variantPlugins['printVariant'],
|
|
542
|
-
variantPlugins['screenVariants'],
|
|
543
|
-
variantPlugins['orientationVariants'],
|
|
544
|
-
]
|
|
545
|
-
|
|
546
|
-
return [...corePluginList, ...beforeVariants, ...userPlugins, ...afterVariants, ...layerPlugins]
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function registerPlugins(plugins, context) {
|
|
550
|
-
let variantList = []
|
|
551
|
-
let variantMap = new Map()
|
|
552
|
-
let offsets = {
|
|
553
|
-
defaults: 0n,
|
|
554
|
-
base: 0n,
|
|
555
|
-
components: 0n,
|
|
556
|
-
utilities: 0n,
|
|
557
|
-
user: 0n,
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
let classList = new Set()
|
|
561
|
-
|
|
562
|
-
let pluginApi = buildPluginApi(context.tailwindConfig, context, {
|
|
563
|
-
variantList,
|
|
564
|
-
variantMap,
|
|
565
|
-
offsets,
|
|
566
|
-
classList,
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
for (let plugin of plugins) {
|
|
570
|
-
if (Array.isArray(plugin)) {
|
|
571
|
-
for (let pluginItem of plugin) {
|
|
572
|
-
pluginItem(pluginApi)
|
|
573
|
-
}
|
|
574
|
-
} else {
|
|
575
|
-
plugin?.(pluginApi)
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
let highestOffset = ((args) => args.reduce((m, e) => (e > m ? e : m)))([
|
|
580
|
-
offsets.base,
|
|
581
|
-
offsets.defaults,
|
|
582
|
-
offsets.components,
|
|
583
|
-
offsets.utilities,
|
|
584
|
-
offsets.user,
|
|
585
|
-
])
|
|
586
|
-
let reservedBits = BigInt(highestOffset.toString(2).length)
|
|
587
|
-
|
|
588
|
-
// A number one less than the top range of the highest offset area
|
|
589
|
-
// so arbitrary properties are always sorted at the end.
|
|
590
|
-
context.arbitraryPropertiesSort = ((1n << reservedBits) << 0n) - 1n
|
|
591
|
-
|
|
592
|
-
context.layerOrder = {
|
|
593
|
-
defaults: (1n << reservedBits) << 0n,
|
|
594
|
-
base: (1n << reservedBits) << 1n,
|
|
595
|
-
components: (1n << reservedBits) << 2n,
|
|
596
|
-
utilities: (1n << reservedBits) << 3n,
|
|
597
|
-
user: (1n << reservedBits) << 4n,
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
reservedBits += 5n
|
|
601
|
-
|
|
602
|
-
let offset = 0
|
|
603
|
-
context.variantOrder = new Map(
|
|
604
|
-
variantList
|
|
605
|
-
.map((variant, i) => {
|
|
606
|
-
let variantFunctions = variantMap.get(variant).length
|
|
607
|
-
let bits = (1n << BigInt(i + offset)) << reservedBits
|
|
608
|
-
offset += variantFunctions - 1
|
|
609
|
-
return [variant, bits]
|
|
610
|
-
})
|
|
611
|
-
.sort(([, a], [, z]) => bigSign(a - z))
|
|
612
|
-
)
|
|
613
|
-
|
|
614
|
-
context.minimumScreen = [...context.variantOrder.values()].shift()
|
|
615
|
-
|
|
616
|
-
// Build variantMap
|
|
617
|
-
for (let [variantName, variantFunctions] of variantMap.entries()) {
|
|
618
|
-
let sort = context.variantOrder.get(variantName)
|
|
619
|
-
context.variantMap.set(
|
|
620
|
-
variantName,
|
|
621
|
-
variantFunctions.map((variantFunction, idx) => [sort << BigInt(idx), variantFunction])
|
|
622
|
-
)
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
let safelist = (context.tailwindConfig.safelist ?? []).filter(Boolean)
|
|
626
|
-
if (safelist.length > 0) {
|
|
627
|
-
let checks = []
|
|
628
|
-
|
|
629
|
-
for (let value of safelist) {
|
|
630
|
-
if (typeof value === 'string') {
|
|
631
|
-
context.changedContent.push({ content: value, extension: 'html' })
|
|
632
|
-
continue
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
if (value instanceof RegExp) {
|
|
636
|
-
log.warn('root-regex', [
|
|
637
|
-
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
638
|
-
'Update your `safelist` configuration to eliminate this warning.',
|
|
639
|
-
// TODO: Add https://tw.wtf/regex-safelist
|
|
640
|
-
])
|
|
641
|
-
continue
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
checks.push(value)
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
if (checks.length > 0) {
|
|
648
|
-
let patternMatchingCount = new Map()
|
|
649
|
-
|
|
650
|
-
for (let util of classList) {
|
|
651
|
-
let utils = Array.isArray(util)
|
|
652
|
-
? (() => {
|
|
653
|
-
let [utilName, options] = util
|
|
654
|
-
let classes = Object.keys(options?.values ?? {}).map((value) =>
|
|
655
|
-
formatClass(utilName, value)
|
|
656
|
-
)
|
|
657
|
-
|
|
658
|
-
if (options?.supportsNegativeValues) {
|
|
659
|
-
classes = [...classes, ...classes.map((cls) => '-' + cls)]
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
return classes
|
|
663
|
-
})()
|
|
664
|
-
: [util]
|
|
665
|
-
|
|
666
|
-
for (let util of utils) {
|
|
667
|
-
for (let { pattern, variants = [] } of checks) {
|
|
668
|
-
// RegExp with the /g flag are stateful, so let's reset the last
|
|
669
|
-
// index pointer to reset the state.
|
|
670
|
-
pattern.lastIndex = 0
|
|
671
|
-
|
|
672
|
-
if (!patternMatchingCount.has(pattern)) {
|
|
673
|
-
patternMatchingCount.set(pattern, 0)
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
if (!pattern.test(util)) continue
|
|
677
|
-
|
|
678
|
-
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1)
|
|
679
|
-
|
|
680
|
-
context.changedContent.push({ content: util, extension: 'html' })
|
|
681
|
-
for (let variant of variants) {
|
|
682
|
-
context.changedContent.push({
|
|
683
|
-
content: variant + context.tailwindConfig.separator + util,
|
|
684
|
-
extension: 'html',
|
|
685
|
-
})
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
for (let [regex, count] of patternMatchingCount.entries()) {
|
|
692
|
-
if (count !== 0) continue
|
|
693
|
-
|
|
694
|
-
log.warn([
|
|
695
|
-
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
696
|
-
'Fix this pattern or remove it from your `safelist` configuration.',
|
|
697
|
-
])
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// Generate a list of strings for autocompletion purposes, e.g.
|
|
703
|
-
// ['uppercase', 'lowercase', ...]
|
|
704
|
-
context.getClassList = function () {
|
|
705
|
-
let output = []
|
|
706
|
-
|
|
707
|
-
for (let util of classList) {
|
|
708
|
-
if (Array.isArray(util)) {
|
|
709
|
-
let [utilName, options] = util
|
|
710
|
-
let negativeClasses = []
|
|
711
|
-
|
|
712
|
-
for (let [key, value] of Object.entries(options?.values ?? {})) {
|
|
713
|
-
output.push(formatClass(utilName, key))
|
|
714
|
-
if (options?.supportsNegativeValues && negateValue(value)) {
|
|
715
|
-
negativeClasses.push(formatClass(utilName, `-${key}`))
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
output.push(...negativeClasses)
|
|
720
|
-
} else {
|
|
721
|
-
output.push(util)
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
return output
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
export function createContext(tailwindConfig, changedContent = [], root = postcss.root()) {
|
|
730
|
-
let context = {
|
|
731
|
-
disposables: [],
|
|
732
|
-
ruleCache: new Set(),
|
|
733
|
-
classCache: new Map(),
|
|
734
|
-
applyClassCache: new Map(),
|
|
735
|
-
notClassCache: new Set(),
|
|
736
|
-
postCssNodeCache: new Map(),
|
|
737
|
-
candidateRuleMap: new Map(),
|
|
738
|
-
tailwindConfig,
|
|
739
|
-
changedContent: changedContent,
|
|
740
|
-
variantMap: new Map(),
|
|
741
|
-
stylesheetCache: null,
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
let resolvedPlugins = resolvePlugins(context, root)
|
|
745
|
-
registerPlugins(resolvedPlugins, context)
|
|
746
|
-
|
|
747
|
-
return context
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
let contextMap = sharedState.contextMap
|
|
751
|
-
let configContextMap = sharedState.configContextMap
|
|
752
|
-
let contextSourcesMap = sharedState.contextSourcesMap
|
|
753
|
-
|
|
754
|
-
export function getContext(
|
|
755
|
-
root,
|
|
756
|
-
result,
|
|
757
|
-
tailwindConfig,
|
|
758
|
-
userConfigPath,
|
|
759
|
-
tailwindConfigHash,
|
|
760
|
-
contextDependencies
|
|
761
|
-
) {
|
|
762
|
-
let sourcePath = result.opts.from
|
|
763
|
-
let isConfigFile = userConfigPath !== null
|
|
764
|
-
|
|
765
|
-
env.DEBUG && console.log('Source path:', sourcePath)
|
|
766
|
-
|
|
767
|
-
let existingContext
|
|
768
|
-
|
|
769
|
-
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
770
|
-
existingContext = contextMap.get(sourcePath)
|
|
771
|
-
} else if (configContextMap.has(tailwindConfigHash)) {
|
|
772
|
-
let context = configContextMap.get(tailwindConfigHash)
|
|
773
|
-
contextSourcesMap.get(context).add(sourcePath)
|
|
774
|
-
contextMap.set(sourcePath, context)
|
|
775
|
-
|
|
776
|
-
existingContext = context
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// If there's already a context in the cache and we don't need to
|
|
780
|
-
// reset the context, return the cached context.
|
|
781
|
-
if (existingContext) {
|
|
782
|
-
let contextDependenciesChanged = trackModified(
|
|
783
|
-
[...contextDependencies],
|
|
784
|
-
getFileModifiedMap(existingContext)
|
|
785
|
-
)
|
|
786
|
-
if (!contextDependenciesChanged) {
|
|
787
|
-
return [existingContext, false]
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
// If this source is in the context map, get the old context.
|
|
792
|
-
// Remove this source from the context sources for the old context,
|
|
793
|
-
// and clean up that context if no one else is using it. This can be
|
|
794
|
-
// called by many processes in rapid succession, so we check for presence
|
|
795
|
-
// first because the first process to run this code will wipe it out first.
|
|
796
|
-
if (contextMap.has(sourcePath)) {
|
|
797
|
-
let oldContext = contextMap.get(sourcePath)
|
|
798
|
-
if (contextSourcesMap.has(oldContext)) {
|
|
799
|
-
contextSourcesMap.get(oldContext).delete(sourcePath)
|
|
800
|
-
if (contextSourcesMap.get(oldContext).size === 0) {
|
|
801
|
-
contextSourcesMap.delete(oldContext)
|
|
802
|
-
for (let [tailwindConfigHash, context] of configContextMap) {
|
|
803
|
-
if (context === oldContext) {
|
|
804
|
-
configContextMap.delete(tailwindConfigHash)
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
for (let disposable of oldContext.disposables.splice(0)) {
|
|
808
|
-
disposable(oldContext)
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
env.DEBUG && console.log('Setting up new context...')
|
|
815
|
-
|
|
816
|
-
let context = createContext(tailwindConfig, [], root)
|
|
817
|
-
|
|
818
|
-
trackModified([...contextDependencies], getFileModifiedMap(context))
|
|
819
|
-
|
|
820
|
-
// ---
|
|
821
|
-
|
|
822
|
-
// Update all context tracking state
|
|
823
|
-
|
|
824
|
-
configContextMap.set(tailwindConfigHash, context)
|
|
825
|
-
contextMap.set(sourcePath, context)
|
|
826
|
-
|
|
827
|
-
if (!contextSourcesMap.has(context)) {
|
|
828
|
-
contextSourcesMap.set(context, new Set())
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
contextSourcesMap.get(context).add(sourcePath)
|
|
832
|
-
|
|
833
|
-
return [context, true]
|
|
834
|
-
}
|