Skip to content

Commit faa39de

Browse files
committed
#305 Upgraded the minimum version requirement of Visual Studio Code from 1.31.0 to 1.38.0. Migrated to use asWebviewUri & cspSource.
1 parent 2821eaf commit faa39de

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"license": "SEE LICENSE IN 'LICENSE'",
3131
"icon": "resources/icon.png",
3232
"engines": {
33-
"vscode": "^1.31.0"
33+
"vscode": "^1.38.0"
3434
},
3535
"extensionKind": [
3636
"workspace"
@@ -833,7 +833,7 @@
833833
"devDependencies": {
834834
"@types/jest": "^25.2.1",
835835
"@types/node": "^8.10.25",
836-
"@types/vscode": "1.31.0",
836+
"@types/vscode": "1.38.0",
837837
"jest": "^25.4.0",
838838
"ts-jest": "^25.4.0",
839839
"tslint": "^5.12.1",

src/gitGraphView.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export class GitGraphView implements vscode.Disposable {
9292
retainContextWhenHidden: config.retainContextWhenHidden
9393
});
9494
this.panel.iconPath = config.tabIconColourTheme === TabIconColourTheme.Colour
95-
? this.getUri('resources', 'webview-icon.svg')
96-
: { light: this.getUri('resources', 'webview-icon-light.svg'), dark: this.getUri('resources', 'webview-icon-dark.svg') };
95+
? this.getResourcesUri('webview-icon.svg')
96+
: {
97+
light: this.getResourcesUri('webview-icon-light.svg'),
98+
dark: this.getResourcesUri('webview-icon-dark.svg')
99+
};
97100

98101
// Dispose this Git Graph View when the Webview is disposed
99102
this.panel.onDidDispose(() => this.dispose(), null, this.disposables);
@@ -660,7 +663,7 @@ export class GitGraphView implements vscode.Disposable {
660663
<html lang="en">
661664
<head>
662665
<meta charset="UTF-8">
663-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src vscode-resource: 'unsafe-inline'; script-src vscode-resource: 'nonce-${nonce}'; img-src data:;">
666+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${this.panel.webview.cspSource} 'unsafe-inline'; script-src ${this.panel.webview.cspSource} 'nonce-${nonce}'; img-src data:;">
664667
<meta name="viewport" content="width=device-width, initial-scale=1.0">
665668
<link rel="stylesheet" type="text/css" href="${this.getMediaUri('out.min.css')}">
666669
<title>Git Graph</title>
@@ -674,18 +677,27 @@ export class GitGraphView implements vscode.Disposable {
674677
/* URI Manipulation Methods */
675678

676679
/**
677-
* Get a URI for a media file included in the extension.
680+
* Get a WebviewUri for a media file included in the extension.
678681
* @param file The file name in the `media` directory.
679-
* @returns The URI.
682+
* @returns The WebviewUri.
680683
*/
681684
private getMediaUri(file: string) {
682-
return this.getUri('media', file).with({ scheme: 'vscode-resource' });
685+
return this.panel.webview.asWebviewUri(this.getUri('media', file));
683686
}
684687

685688
/**
686-
* Get a URI for a file included in the extension.
689+
* Get a File Uri for a resource file included in the extension.
690+
* @param file The file name in the `resource` directory.
691+
* @returns The Uri.
692+
*/
693+
private getResourcesUri(file: string) {
694+
return this.getUri('resources', file);
695+
}
696+
697+
/**
698+
* Get a File Uri for a file included in the extension.
687699
* @param pathComps The path components relative to the root directory of the extension.
688-
* @returns The URI.
700+
* @returns The File Uri.
689701
*/
690702
private getUri(...pathComps: string[]) {
691703
return vscode.Uri.file(path.join(this.extensionPath, ...pathComps));

0 commit comments

Comments
 (0)