import { getAssemblyNameFromUrl , getFileNameFromUrl } from '../Url' ; const currentBrowserIsChrome = ( window as any ) . chrome && navigator . userAgent . indexOf ( 'Edge' ) < 0 ; let hasReferencedPdbs = false ; export function hasDebuggingEnabled ( ) { return hasReferencedPdbs && currentBrowserIsChrome ; } export function attachDebuggerHotkey ( loadAssemblyUrls ) { hasReferencedPdbs = loadAssemblyUrls . some ( url => /\.pdb$/ . test ( getFileNameFromUrl ( url ) ) ) ; const altKeyName = navigator . platform . match ( /^Mac/i ) ? 'Cmd' : 'Alt' ; if ( hasDebuggingEnabled ( ) ) { console . info ( `Debugging hotkey: Shift+${ altKeyName }+D (when application has focus)` ) ; } document . addEventListener ( 'keydown' , evt => { if ( evt . shiftKey && ( evt . metaKey || evt . altKey ) && evt . code === 'KeyD' ) { if ( ! hasReferencedPdbs ) { console . error ( 'Cannot start debugging, because the application was not compiled with debugging enabled.' ) ; } else if ( ! currentBrowserIsChrome ) { console . error ( 'Currently, only Edge(Chromium) or Chrome is supported for debugging.' ) ; } else { launchDebugger ( ) ; } } } ) ; } function launchDebugger ( ) { const link = document . createElement ( 'a' ) ; link . href = `_framework/debug?url=${ encodeURIComponent ( location . href ) }` ; link . target = '_blank' ; link . rel = 'noopener noreferrer' ; link . click ( ) ; }