import * as vsc from 'vscode' ; export function getNonce ( ) { let text = '' ; const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ; for ( let i = 0 ; i < 32 ; i ++ ) { text += possible . charAt ( Math . floor ( Math . random ( ) * possible . length ) ) ; } return text ; } export class WebviewCollection { private readonly _webviews = new Set < { readonly resource : string ; readonly webviewPanel : vsc . WebviewPanel ; } > ( ) ; public * get ( uri ) { const key = uri . toString ( ) ; for ( const entry of this . _webviews ) { if ( entry . resource === key ) { yield entry . webviewPanel ; } } } public has ( uri ) { return ! this . get ( uri ) . next ( ) . done ; } public add ( uri , webviewPanel ) { const entry = { resource : uri . toString ( ) , webviewPanel } ; this . _webviews . add ( entry ) ; webviewPanel . onDidDispose ( ( ) => { this . _webviews . delete ( entry ) ; } ) ; } }