1import type { Spec } from 'vega'2import { RenderError } from '../runtime/errors'3import type { RendererAdapter } from '../runtime/types'4import { containsUrl, parsedSpecification, renderVegaSpecification } from './vega-common'5import { edgeFailure, edgeResult } from './types'67const VERSION = 'vega@6.3.1'89export const vegaAdapter: RendererAdapter = {10 id: 'vega',11 runtime: 'edge-js',12 version: VERSION,13 async render(request, signal) {14 if (signal.aborted) throw signal.reason15 try {16 const specification = parsedSpecification(request.source)17 if (containsUrl(specification)) {18 throw new RenderError(422, 'unsafe_include', 'URL-backed Vega data and images are disabled; embed data as values.')19 }20 return edgeResult('vega', VERSION, await renderVegaSpecification(specification as Spec))21 } catch (error) {22 return edgeFailure('vega', error)23 }24 },25}