(
ast: AstNode[],
{
base = '',
from,
loadModule = throwOnLoadModule,
loadStylesheet = throwOnLoadStylesheet,
}: CompileOptions = {},
)
| 140 | } |
| 141 | |
| 142 | async function parseCss( |
| 143 | ast: AstNode[], |
| 144 | { |
| 145 | base = class="st">'', |
| 146 | from, |
| 147 | loadModule = throwOnLoadModule, |
| 148 | loadStylesheet = throwOnLoadStylesheet, |
| 149 | }: CompileOptions = {}, |
| 150 | ) { |
| 151 | let features = Features.None |
| 152 | ast = [contextNode({ base }, ast)] as AstNode[] |
| 153 | |
| 154 | features |= await substituteAtImports(ast, base, loadStylesheet, 0, from !== undefined) |
| 155 | |
| 156 | let important = null as boolean | null |
| 157 | let theme = new Theme() |
| 158 | let customVariants = new Map<string, (designSystem: DesignSystem) => void>() |
| 159 | let customVariantDependencies = new Map<string, Set<string>>() |
| 160 | let customUtilities: ((designSystem: DesignSystem) => void)[] = [] |
| 161 | let firstThemeRule = null as StyleRule | null |
| 162 | let utilitiesNode = null as AtRule | null |
| 163 | let variantNodes: AtRule[] = [] |
| 164 | let sources: { base: string; pattern: string; negated: boolean }[] = [] |
| 165 | let inlineCandidates: string[] = [] |
| 166 | let ignoredCandidates: string[] = [] |
| 167 | let root = null as Root |
| 168 | |
| 169 | class="cm">// Handle at-rules |
| 170 | walk(ast, (node, _ctx) => { |
| 171 | if (node.kind !== class="st">'at-rule') return |
| 172 | let ctx = cssContext(_ctx) |
| 173 | |
| 174 | class="cm">// Find `@tailwind utilities` so that we can later replace it with the |
| 175 | class="cm">// actual generated utility class CSS. |
| 176 | if ( |
| 177 | node.name === class="st">'@tailwind' && |
| 178 | (node.params === class="st">'utilities' || node.params.startsWith(class="st">'utilities')) |
| 179 | ) { |
| 180 | class="cm">// Any additional `@tailwind utilities` nodes can be removed |
| 181 | if (utilitiesNode !== null) { |
| 182 | return WalkAction.Replace([]) |
| 183 | } |
| 184 | |
| 185 | class="cm">// When inside `@reference` we should treat `@tailwind utilities` as if |
| 186 | class="cm">// it wasn't there in the first place. This should also let `build()` |
| 187 | class="cm">// return the cached static AST. |
| 188 | if (ctx.context.reference) { |
| 189 | return WalkAction.Replace([]) |
| 190 | } |
| 191 | |
| 192 | let params = segment(node.params, class="st">' ') |
| 193 | for (let param of params) { |
| 194 | if (param.startsWith(class="st">'source(')) { |
| 195 | let path = param.slice(7, -1) |
| 196 | |
| 197 | class="cm">// Keyword: `source(none)` |
| 198 | if (path === class="st">'none') { |
| 199 | root = path |
no test coverage detected