Embed the scripts in the html template

This commit is contained in:
André Oliveira 2021-08-10 12:42:50 +00:00
parent 51a6d2204e
commit 7666eb1fb8

View file

@ -485,17 +485,7 @@ function crateGraph(ctx: Ctx, full: boolean): Cmd {
};
const dot = await ctx.client.sendRequest(ra.viewCrateGraph, params);
const scripts = [
{ file: '/d3/dist/d3.min.js' },
{ file: '/@hpcc-js/wasm/dist/index.min.js', worker: true },
{ file: '/d3-graphviz/build/d3-graphviz.min.js' },
];
const scriptsHtml = scripts.map(({ file, worker }) => {
const uri = panel.webview.asWebviewUri(vscode.Uri.joinPath(nodeModulesPath, file));
return `<script type="${worker ? "javascript/worker" : "text/javascript"}" src="${uri}"></script>`;
}).join("\n");
const uri = panel.webview.asWebviewUri(nodeModulesPath);
const html = `
<!DOCTYPE html>
@ -515,7 +505,9 @@ function crateGraph(ctx: Ctx, full: boolean): Cmd {
</style>
</head>
<body>
${scriptsHtml}
<script type="text/javascript" src="${uri}/d3/dist/d3.min.js"></script>
<script type="javascript/worker" src="${uri}/@hpcc-js/wasm/dist/index.min.js"></script>
<script type="text/javascript" src="${uri}/d3-graphviz/build/d3-graphviz.min.js"></script>
<div id="graph"></div>
<script>
let graph = d3.select("#graph")