
import { Spec, View } from 'vega';
import { strip_svg } from '../svg';
import { parse_vega_spec } from './vega-spec';

export async function render_vega_spec(spec: Spec) {
	const runtime = parse_vega_spec(spec);
	
	const view = new View(runtime, { renderer: 'none' });
	let svg = await view.toSVG();

	svg = strip_svg(svg);
	
	return svg;
}
