UNPKG

@loopback/context-explorer

Version:

Visualize context hierarchy, bindings, configurations, and dependencies

34 lines 1.22 kB
"use strict"; // Copyright IBM Corp. 2020. All Rights Reserved. // Node module: @loopback/context-explorer // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT Object.defineProperty(exports, "__esModule", { value: true }); exports.renderGraph = void 0; const Viz = require('viz.js'); let vizOptions; /** * Render a graphviz dot string * @param graph - A graph in dot format * @param options - Options for the rendering */ function renderGraph(graph, options = {}) { options = { engine: 'fdp', format: 'svg', ...options, }; // Loading `full.render.js` seems to cause crash of `npm test` for // `loopback-next` if it happens too early in the module scope if (vizOptions == null) { // For some reason, the 2nd execution of `require('viz.js/full.render.js')` // returns {undefined, undefined} const { Module, render } = require('viz.js/full.render.js'); // Cache the options vizOptions = { Module, render }; } const viz = new Viz(vizOptions); return viz.renderString(graph, options); } exports.renderGraph = renderGraph; //# sourceMappingURL=visualizer.js.map