import * as vscode from 'vscode' ; import { ShowOptions , SimpleBrowserView } from './simpleBrowserView' ; export class SimpleBrowserManager { private _activeView ? : SimpleBrowserView ; constructor ( private readonly extensionUri ) { } dispose ( ) { this . _activeView ?. dispose ( ) ; this . _activeView = undefined ; } public show ( url , options ? ) { if ( this . _activeView ) { this . _activeView . show ( url , options ) ; } else { const view = SimpleBrowserView . create ( this . extensionUri , url , options ) ; this . registerWebviewListeners ( view ) ; this . _activeView = view ; } } public restore ( panel , state ) { const url = state ?. url ?? '' ; const view = SimpleBrowserView . restore ( this . extensionUri , url , panel ) ; this . registerWebviewListeners ( view ) ; return ; } private registerWebviewListeners ( view ) { view . onDispose ( ( ) => { if ( this . _activeView === view ) { this . _activeView = undefined ; } } ) ; } }