-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathexplorerWebviewViewProvider.ts
More file actions
68 lines (58 loc) · 1.59 KB
/
explorerWebviewViewProvider.ts
File metadata and controls
68 lines (58 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type {
CancellationToken,
Disposable,
ExtensionContext,
WebviewView,
WebviewViewProvider,
WebviewViewResolveContext,
} from "vscode";
import { WebviewHelper } from "@src/features/lightspeed/vue/views/helper";
export class LightspeedExplorerWebviewViewProvider implements WebviewViewProvider {
public static readonly viewType = "lightspeed-explorer-webview";
private disposables: Disposable[] = [];
private context: ExtensionContext;
private _view?: WebviewView;
constructor(context: ExtensionContext) {
this.context = context;
}
public async resolveWebviewView(
webviewView: WebviewView,
_resolveContext: WebviewViewResolveContext,
_token: CancellationToken,
) {
this._view = webviewView;
webviewView.webview.options = {
enableScripts: true,
enableCommandUris: true,
};
// Setup HTML content using the Vue-based explorer
webviewView.webview.html = WebviewHelper.setupHtml(
webviewView.webview,
this.context,
"explorer",
);
// Setup message handlers
await WebviewHelper.setupWebviewHooks(
webviewView.webview,
this.disposables,
this.context,
);
// Cleanup disposables when the view is disposed
webviewView.onDidDispose(() => {
while (this.disposables.length) {
const disposable = this.disposables.pop();
if (disposable) {
disposable.dispose();
}
}
});
}
public refreshWebView() {
if (this._view) {
this._view.webview.postMessage({
type: "userRefreshExplorerState",
data: {},
});
}
}
}