Embed the scripts in the html template
This commit is contained in:
@@ -485,17 +485,7 @@ function crateGraph(ctx: Ctx, full: boolean): Cmd {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dot = await ctx.client.sendRequest(ra.viewCrateGraph, params);
|
const dot = await ctx.client.sendRequest(ra.viewCrateGraph, params);
|
||||||
|
const uri = panel.webview.asWebviewUri(nodeModulesPath);
|
||||||
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 html = `
|
const html = `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -515,7 +505,9 @@ function crateGraph(ctx: Ctx, full: boolean): Cmd {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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>
|
<div id="graph"></div>
|
||||||
<script>
|
<script>
|
||||||
let graph = d3.select("#graph")
|
let graph = d3.select("#graph")
|
||||||
|
|||||||
Reference in New Issue
Block a user