1import type { RendererAdapter } from '../runtime/types'2import { RenderError } from '../runtime/errors'3import { parseSquaring } from '../languages/squaring'4import { buildSquaring } from '../languages/squaring-model'5import { renderSquaring } from '../languages/squaring-renderer'6import { edgeFailure, edgeResult } from './types'78const VERSION = 'diagramzip-squaring@3'910function validateOptions(options: Record<string, string>): void {11 for (const name of Object.keys(options)) {12 throw new RenderError(400, 'unsupported_options', `Unsupported squaring option: ${name}.`)13 }14}1516export const squaringAdapter: RendererAdapter = {17 id: 'squaring',18 runtime: 'edge-js',19 version: VERSION,20 render(request, signal) {21 if (signal.aborted) throw signal.reason22 try {23 validateOptions(request.options)24 const document = parseSquaring(request.source)25 return Promise.resolve(edgeResult('squaring', VERSION, renderSquaring(document, buildSquaring(document))))26 } catch (error) {27 return edgeFailure('squaring', error)28 }29 },30}