@@ -294,9 +294,10 @@ export default {
294
294
}
295
295
},
296
296
297
- async mounted () {
297
+ mounted () {
298
298
// compile & instantiate graphviz wasm
299
- this .graphviz = await Graphviz .load ()
299
+ /** @type {Promise<Graphviz>} */
300
+ this .graphviz = Graphviz .load ()
300
301
// allow render to happen before we go configuring svgPanZoom
301
302
this .$nextTick (() => {
302
303
this .updateTimer ()
@@ -420,9 +421,15 @@ export default {
420
421
}
421
422
return ret
422
423
},
424
+ /**
425
+ * Get the dimensions of currently rendered graph nodes
426
+ * (we feed these dimensions into the GraphViz dot code to improve layout).
427
+ *
428
+ * @param {Object[]} nodes
429
+ * @returns {{ [id: string]: SVGRect }} mapping of node IDs to their
430
+ * bounding boxes.
431
+ */
423
432
getNodeDimensions (nodes ) {
424
- // get the dimensions of currently rendered graph nodes
425
- // (we feed these dimensions into the GraphViz dot code to improve layout)
426
433
const ret = {}
427
434
let bbox
428
435
for (const node of nodes) {
@@ -587,13 +594,13 @@ export default {
587
594
588
595
// layout the graph
589
596
try {
590
- this .layout (nodes, edges, nodeDimensions)
597
+ await this .layout (nodes, edges, nodeDimensions)
591
598
} catch (e) {
592
599
// something went wrong, allow the layout to retry later
593
600
this .graphID = null
594
601
this .updating = false
595
602
// eslint-disable-next-line no-console
596
- console .warn (e)
603
+ console .error (e)
597
604
return
598
605
}
599
606
@@ -624,13 +631,19 @@ export default {
624
631
await this .$nextTick ()
625
632
}
626
633
},
627
- /** re-layout the graph after any new nodes have been rendered */
628
- layout (nodes , edges , nodeDimensions ) {
634
+ /**
635
+ * Re-layout the graph after any new nodes have been rendered.
636
+ *
637
+ * @param {Object[]} nodes
638
+ * @param {Object[]} edges
639
+ * @param {{ [id: string]: SVGRect }} nodeDimensions
640
+ */
641
+ async layout (nodes , edges , nodeDimensions ) {
629
642
// generate the GraphViz dot code
630
643
const dotCode = this .getDotCode (nodeDimensions, nodes, edges)
631
644
632
645
// run the layout algorithm
633
- const jsonString = this .graphviz .layout (dotCode, ' json' )
646
+ const jsonString = ( await this .graphviz ) .layout (dotCode, ' json' )
634
647
const json = JSON .parse (jsonString)
635
648
636
649
// update graph node positions
0 commit comments