d2 icon indicating copy to clipboard operation
d2 copied to clipboard

d2js : in chrome, top-level await doesn't work with file:// URLs.

Open bo-ku-ra opened this issue 7 months ago • 3 comments

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);

bo-ku-ra avatar Aug 08 '25 20:08 bo-ku-ra

I don't quite understand, can you give more details in the example?

alixander avatar Aug 12 '25 13:08 alixander

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.

bo-ku-ra avatar Aug 12 '25 22:08 bo-ku-ra

the cause may not be 'await', but rather 'cross-origin redirection'.

bo-ku-ra avatar Aug 12 '25 22:08 bo-ku-ra