import * as vscode from 'vscode'; export class SimulatorView { private _webPanel: vscode.WebviewPanel | undefined = undefined; get webPanel(): vscode.WebviewPanel | undefined { return this._webPanel; } constructor(context: vscode.ExtensionContext) { this._webPanel = vscode.window.createWebviewPanel( 'simulatorView', 'PayPay Simulator View', { viewColumn: vscode.ViewColumn.Two, preserveFocus: true, }, { enableScripts: true, retainContextWhenHidden: true, } ); vscode.commands .executeCommand('paypay.devtool.simulator.geturl') .then((simulatorUrl) => { if (this._webPanel) { this._webPanel.webview.html = this.getWebviewContent( String(simulatorUrl) ); } }); // Handle messages from the webview this._webPanel.webview.onDidReceiveMessage( (message) => { switch (message.command) { case 'alert': vscode.window.showErrorMessage(message.text); return; case 'command': vscode.commands.executeCommand(message.text); return; } }, undefined, context.subscriptions ); this._webPanel.onDidDispose( () => { this._webPanel = undefined; }, undefined, context.subscriptions ); } getWebviewContent(simulatorUrl: string) { return ( ` PayPay Simulator View ` ); } }