1const base = process.env.PLANTUML_WORKER_URL ?? 'http://127.0.0.1:18790'23async function render(host, source, options = {}) {4 const response = await fetch(`${base.replace('127.0.0.1', `${host}.localhost`)}/v1/svg`, {5 method: 'POST',6 headers: { 'Content-Type': 'application/json' },7 body: JSON.stringify({ source, options }),8 })9 const body = await response.text()10 if (!response.ok || !body.includes('<svg') || /Syntax Error\?|Error line \d+/i.test(body)) throw new Error(`${host}: ${response.status} ${body.slice(0, 300)}`)11 return body12}1314const sequence = '@startuml\nAlice -> Bob: hello\n@enduml'15const classDiagram = '@startuml\nclass Foo\nclass Bar\nFoo --> Bar\n@enduml'16const c4 = '@startuml\n!include <C4/C4_Context>\nPerson(alice, "Alice")\nSystem(app, "App")\nRel(alice, app, "uses")\n@enduml'1718const [sequenceA, sequenceB, classSvg, c4Svg] = await Promise.all([19 render('plantuml', sequence), render('plantuml', sequence), render('plantuml', classDiagram), render('c4plantuml', c4),20])21if (sequenceA !== sequenceB) throw new Error('serialized repeated renders were not deterministic')22if (!classSvg.includes('Foo') || !classSvg.includes('Bar')) throw new Error('class labels missing')23if (!c4Svg.includes('Alice') || !c4Svg.includes('#1168BD')) throw new Error('C4 lowering did not affect output')24await render('plantuml', sequence, { theme: 'plain', 'no-metadata': '' })25console.log('PlantUML family workerd smoke passed')