import IVSCode from './interfaces/IVSCode' ; declare const vscode ; class Utils { static changeRoute ( newPath ) { dispatchEvent ( new MessageEvent ( 'message' , { data : { path : newPath } } ) ) ; } static postToVSCode ( message ) { if ( ! ( window as any ) [ 'Cypress' ] ) { vscode . postMessage ( message ) ; } else { window . postMessage ( message , '*' ) ; } } static isNameInvalid ( name ) { const regex = /^[a-zA-Z0-9-_]+$/ ; const validName = regex . test ( name ) ; if ( name . length === 0 || ! validName ) { return true ; } else { return false ; } } static isVersionInvalid ( version ) { if ( version . length === 0 ) { return true ; } else { return false ; } } static readFileAsync ( blob ) { return new Promise ( ( resolve , reject ) => { const reader = new FileReader ( ) ; reader . onload = ( ) => { resolve ( reader . result as string ) ; } ; reader . onerror = reject ; reader . readAsText ( blob , 'UTF-8' ) ; } ) ; } } export default Utils ;