asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
323 stars 97 forks source link

graphviz diagram preview fails #267

Closed Kinokin closed 4 years ago

Kinokin commented 4 years ago

Since some time (2.7.8 or 2.7.9) simple graphviz diagram fail with 'TypeError: Cannot call a class as a function' notification by VSCode

== Live preview

[graphviz]
....
digraph G {

subgraph cluster_0 {
    style=filled;
    color=lightgrey;
    node [style=filled,color=white];
    a0 -> a1 -> a2 -> a3;
    label = "process #1";
}

subgraph cluster_1 {
    node [style=filled];
    b0 -> b1 -> b2 -> b3;
    label = "process #2";
    color=blue
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;

start [shape=Mdiamond];
end [shape=Msquare];
}
....
joaompinto commented 4 years ago

I am able to reproduce it, I will take at look at it when possible

Thanks for reporting.

danyill commented 4 years ago

@joaompinto moving from viz.js 1.8.1 to 2.1.2 did this.

The API changes are described in https://github.com/mdaines/viz.js/issues/113

viz.js appears to be archived on Github and likely no longer supported. The author calls it a "hack", it was last released in late 2018, and issues are no longer being resolved. It is being abandoned by other downstream projects e.g. see https://github.com/magjac/d3-graphviz/issues/55 which also suggests an alternative (https://github.com/hpcc-systems/hpcc-js-wasm) which I don't think is suitable for our application...

I've tried using both the WebWorker and Module/Render options from https://github.com/mdaines/viz.js/wiki/Usage but without being able to successfully integrate either. I suspect they are not working "nicely" within either vs-code or the synchronous requirements of Asciidoctor.js. See the commit referenced above.

You may be able to make better sense of this than me (incidentally @joaompinto if you can increase my rights I'm happy to do some issue management on this project).

Otherwise two other options:

  1. Drop support of graphviz via Viz.js and require the end user to use e.g. asciidoctor-diagram, asciidoctor-kroki, asciidoctor-plantuml.

  2. Revert the dependency to 1.8.1 which is easy and will work (but I think we should make an effort to use only supported packages).

joaompinto commented 4 years ago

@danyill added you as admin

joaompinto commented 4 years ago

I vote for option 1, we just need to make asciidoctor-kroki more discoverable, probably adding some snippets