| 818 | export type { DecodedSourceMap } |
| 819 | |
| 820 | export async function compile( |
| 821 | css: string, |
| 822 | opts: CompileOptions = {}, |
| 823 | ): Promise<{ |
| 824 | sources: { base: string; pattern: string; negated: boolean }[] |
| 825 | root: Root |
| 826 | features: Features |
| 827 | build(candidates: string[]): string |
| 828 | buildSourceMap(): DecodedSourceMap |
| 829 | }> { |
| 830 | let ast = CSS.parse(css, { from: opts.from }) |
| 831 | let api = await compileAst(ast, opts) |
| 832 | let compiledAst = ast |
| 833 | let compiledCss = css |
| 834 | |
| 835 | return { |
| 836 | ...api, |
| 837 | build(newCandidates) { |
| 838 | let newAst = api.build(newCandidates) |
| 839 | |
| 840 | if (newAst === compiledAst) { |
| 841 | return compiledCss |
| 842 | } |
| 843 | |
| 844 | compiledCss = toCss(newAst, !!opts.from) |
| 845 | compiledAst = newAst |
| 846 | |
| 847 | return compiledCss |
| 848 | }, |
| 849 | |
| 850 | buildSourceMap() { |
| 851 | return createSourceMap({ |
| 852 | ast: compiledAst, |
| 853 | }) |
| 854 | }, |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | export async function __unstable__loadDesignSystem(css: string, opts: CompileOptions = {}) { |
| 859 | let result = await parseCss(CSS.parse(css, { from: opts.from }), opts) |