(classes: string[])
| 112 | }) |
| 113 | |
| 114 | function candidatesToAst(classes: string[]): AstNode[][] { |
| 115 | let result: AstNode[][] = [] |
| 116 | |
| 117 | for (let className of classes) { |
| 118 | let wasValid = true |
| 119 | |
| 120 | let { astNodes } = compileCandidates([className], designSystem, { |
| 121 | onInvalidCandidate() { |
| 122 | wasValid = false |
| 123 | }, |
| 124 | }) |
| 125 | |
| 126 | if (utilitiesSrc) { |
| 127 | walk(astNodes, (node) => { |
| 128 | // We do this conditionally to preserve source locations from both |
| 129 | // `@utility` and `@custom-variant`. Even though generated nodes are |
| 130 | // cached this should be fine because `utilitiesNode.src` should not |
| 131 | // change without a full rebuild which destroys the cache. |
| 132 | node.src ??= utilitiesSrc |
| 133 | return WalkAction.Continue |
| 134 | }) |
| 135 | } |
| 136 | |
| 137 | // Disable all polyfills to not unnecessarily pollute IntelliSense output |
| 138 | astNodes = optimizeAst(astNodes, designSystem, Polyfills.None) |
| 139 | |
| 140 | result.push(wasValid ? astNodes : []) |
| 141 | } |
| 142 | |
| 143 | return result |
| 144 | } |
| 145 | |
| 146 | function candidatesToCss(classes: string[]): (string | null)[] { |
| 147 | return candidatesToAst(classes).map((nodes) => { |
no test coverage detected