diff --git a/src/vscode/overview-view.ts b/src/vscode/overview-view.ts index 92ffddd..d50c383 100644 --- a/src/vscode/overview-view.ts +++ b/src/vscode/overview-view.ts @@ -1,5 +1,6 @@ import * as vscode from "vscode"; - +import * as fs from "fs"; +import * as crypto from "crypto"; export class OverviewViewProvider implements vscode.WebviewViewProvider { public static readonly viewType = "functionGraphOverview.overview"; private readonly helloWorldSvg: string; @@ -34,63 +35,54 @@ export class OverviewViewProvider implements vscode.WebviewViewProvider { webviewView.webview.html = this._getHtmlForWebview(webviewView.webview); } + + private getUri(filename: string): vscode.Uri { + return vscode.Uri.joinPath(this._extensionUri, "webview-content", filename); + } + + private getWebviewUri(webview: vscode.Webview, filename: string): vscode.Uri { + return webview.asWebviewUri(this.getUri(filename)); + } + private _getHtmlForWebview(webview: vscode.Webview): string { // Get the local path to main script run in the webview, then convert it to a uri we can use in the webview. - const scriptUri = webview.asWebviewUri( - vscode.Uri.joinPath(this._extensionUri, "webview-content", "main.js"), - ); + const scriptUri = this.getWebviewUri(webview, "main.js"); // Do the same for the stylesheet. - const styleResetUri = webview.asWebviewUri( - vscode.Uri.joinPath(this._extensionUri, "webview-content", "reset.css"), - ); - const styleVSCodeUri = webview.asWebviewUri( - vscode.Uri.joinPath(this._extensionUri, "webview-content", "vscode.css"), - ); - const styleMainUri = webview.asWebviewUri( - vscode.Uri.joinPath(this._extensionUri, "webview-content", "main.css"), - ); + const styleResetUri = this.getWebviewUri(webview, "reset.css"); + const styleVSCodeUri = this.getWebviewUri(webview, "vscode.css"); + const styleMainUri = this.getWebviewUri(webview, "main.css"); // Use a nonce to only allow a specific script to be run. const nonce = getNonce(); - return ` - -
- - - - - - - - - - -