d2
d2 copied to clipboard
d2js : in chrome, top-level await doesn't work with file:// URLs.
| protocol | firefox | chrome | edge(chromium) |
|---|---|---|---|
| file:// | OK | NG | NG |
| http(s):// | OK | OK | OK |
mermaid supports rendering diagrams from local files. https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs
i hope d2 supports local files too. https://esm.sh/@terrastruct/d2@nightly/es2022/d2.mjs
const d2 = new D2();
const result = await d2.compile(source);
const svg = await d2.render(result.diagram, result.renderOptions);
I don't quite understand, can you give more details in the example?
https://alixander-d2js.web.val.run/
D2.js Demo.html.txt you will understand if you launch this HTML file (D2.js.Demo.html) locally.
the cause may not be 'await', but rather 'cross-origin redirection'.