format import { getLogger , Logger , setLoggerInstance } from 'flipper-common' ; import { initializeRenderHost } from './initializeRenderHost' ; import { createFlipperServer } from './flipperServerConnection' ; document . getElementById ( 'root' ) ! . innerText = 'flipper-ui-browser started' ; async function start ( ) { electronRequire = function ( path ) { console . error ( `[decapitate] Tried to electronRequire ${ path }, this module is not available in the browser and will be stubbed` ) ; return { default : { } , } ; } ; const logger = createDelegatedLogger ( ) ; setLoggerInstance ( logger ) ; const flipperServer = await createFlipperServer ( ) ; await flipperServer . connect ( ) ; const flipperServerConfig = await flipperServer . exec ( 'get-config' ) ; initializeRenderHost ( flipperServer , flipperServerConfig ) ; window . flipperShowError ?. ( 'Connected to Flipper Server successfully' ) ; require ( 'flipper-ui-core' ) . startFlipperDesktop ( flipperServer ) ; window . flipperHideError ?. ( ) ; } start ( ) . catch ( ( e ) => { console . error ( 'Failed to start flipper-ui-browser' , e ) ; window . flipperShowError ?. ( 'Failed to start flipper-ui-browser: ' + e ) ; } ) ; function createDelegatedLogger ( ) { const naiveLogger = { track ( ... args ) { console . warn ( '(skipper track)' , args ) ; } , trackTimeSince ( ... args ) { console . warn ( '(skipped trackTimeSince)' , args ) ; } , debug ( ... args ) { console . debug ( ... args ) ; } , error ( ... args ) { console . error ( ... args ) ; console . warn ( '(skipped error reporting)' ) ; } , warn ( ... args ) { console . warn ( ... args ) ; console . warn ( '(skipped error reporting)' ) ; } , info ( ... args ) { console . info ( ... args ) ; } , } ; setLoggerInstance ( naiveLogger ) ; return { track ( ) { } , trackTimeSince ( ) { } , debug ( ... args ) { getLogger ( ) . debug ( ... args ) ; } , error ( ... args ) { getLogger ( ) . error ( ... args ) ; } , warn ( ... args ) { getLogger ( ) . warn ( ... args ) ; } , info ( ... args ) { getLogger ( ) . info ( ... args ) ; } , } ; }