|
1 | 1 | import{JSDOM}from'jsdom' |
2 | 2 | import*aspathfrom'path' |
3 | 3 | import*asvscodefrom'vscode' |
4 | | -importonErrorfrom'services/sentry/onError' |
| 4 | +importonErrorfrom'../services/sentry/onError' |
5 | 5 |
|
6 | 6 | constgetNonce=():string=>{ |
7 | 7 | lettext='' |
@@ -29,11 +29,14 @@ async function render(panel: vscode.WebviewPanel, rootPath: string) { |
29 | 29 |
|
30 | 30 | // generate vscode-resource build path uri |
31 | 31 | constcreateUri=(filePath:string):any=>{ |
32 | | -returnpanel.webview |
33 | | -.asWebviewUri(vscode.Uri.file(filePath)) |
34 | | -.toString() |
35 | | -.replace(/^\/+/g,'')// remove leading '/' |
36 | | -.replace('/vscode-resource%3A',rootPath)// replace mangled resource path with root |
| 32 | +return( |
| 33 | +panel.webview |
| 34 | +//@ts-ignore |
| 35 | +.asWebviewUri(vscode.Uri.file(filePath)) |
| 36 | +.toString() |
| 37 | +.replace(/^\/+/g,'')// remove leading '/' |
| 38 | +.replace('/vscode-resource%3A',rootPath) |
| 39 | +)// replace mangled resource path with root |
37 | 40 | } |
38 | 41 |
|
39 | 42 | // fix paths for scripts |
@@ -70,9 +73,12 @@ async function render(panel: vscode.WebviewPanel, rootPath: string) { |
70 | 73 | [ |
71 | 74 | `default-src 'self'`, |
72 | 75 | `connect-src https: http:`, |
| 76 | +//@ts-ignore |
73 | 77 | `font-src${panel.webview.cspSource} http: https: data:`, |
| 78 | +//@ts-ignore |
74 | 79 | `img-src${panel.webview.cspSource} https:`, |
75 | 80 | `script-src${nonces.map(nonce=>`'nonce-${nonce}'`).join(' ')} data:`, |
| 81 | +//@ts-ignore |
76 | 82 | `style-src${panel.webview.cspSource} https: 'self' 'unsafe-inline'`, |
77 | 83 | ].join('; ')+';' |
78 | 84 | document.head.appendChild(cspMeta) |
|