import { shell , ipcRenderer as ipc } from 'electron' ; interface LintPanelComponent extends polymer . Base { showLintResult ( ) : void ; _messagesUpdated ( messages ) : void ; _showLintRules ( ) : void ; } Polymer ( { is : 'lint-panel' , properties : { messages : { type : Array , observer : '_messagesUpdated' , } , lint_url : String , voice_src : { type : String , value : '' , } , enable_inset : { type : Boolean , value : false , } , already_previewed : { type : Boolean , value : false , } , sanitize_error : Object , } , attached ( ) { if ( this . enable_inset && process . platform === 'darwin' ) { const header = document . getElementById ( 'lint-header' ) ; header . style . textAlign = 'center' ; } ipc . on ( 'shiba:return-lint-rule-url' , ( _ , url ) => { this . lint_url = url ; } ) ; ipc . send ( 'shiba:request-lint-rule-url' ) ; } , showLintResult ( ) { this . already_previewed = true ; if ( ! this . messages ) { return ; } const content = document . querySelector ( '.lint-content' ) ; while ( content . firstChild ) { content . removeChild ( content . firstChild ) ; } if ( this . sanitize_error ) { this . messages . unshift ( this . sanitize_error ) ; } for ( const m of this . messages ) { const msg = document . createElement ( 'lint-message' ) as LintMessageElement ; msg . header = m . header ; msg . body = m . body ; content . appendChild ( msg ) ; } const header = document . getElementById ( 'lint-header' ) ; if ( this . messages . length > 0 ) { header . innerText = 'Error' ; header . setAttribute ( 'error' , '' ) ; if ( this . voice_src !== '' ) { const voice = document . querySelector ( '.voice-notification' ) ; if ( voice ) { voice . play ( ) . catch ( err => { console . error ( 'Failed to play voice:' , err ) ; } ) ; } } } else { header . innerText = 'No Error' ; header . setAttribute ( 'no_error' , '' ) ; } } , _messagesUpdated ( _ ) { if ( this . messages && this . already_previewed ) { this . showLintResult ( ) ; } } , _showLintRules ( ) { if ( this . lint_url === undefined ) { console . log ( 'No lint URL' ) ; return ; } shell . openExternal ( this . lint_url ) ; } , } as LintPanelComponent ) ;