format import { FlipperServer , FlipperServerConfig , isProduction } from 'flipper-common' ; import type { RenderHost } from 'flipper-ui-core' ; export function initializeRenderHost ( flipperServer , flipperServerConfig ) { FlipperRenderHostInstance = { readTextFromClipboard ( ) { return undefined ; } , writeTextToClipboard ( _text ) { } , async importFile ( ) { throw new Error ( 'Not implemented' ) ; } , async exportFile ( ) { throw new Error ( 'Not implemented' ) ; } , openLink ( url ) { window . open ( url , '_blank' ) ; } , hasFocus ( ) { return document . hasFocus ( ) ; } , onIpcEvent ( _event ) { } , sendIpcEvent ( _event , ... _args ) { } , shouldUseDarkColors ( ) { return ! ! ( window . flipperConfig . theme === 'dark' || ( window . flipperConfig . theme === 'system' && window . matchMedia ?. ( '(prefers-color-scheme: dark)' ) ) ) ; } , restartFlipper ( ) { window . flipperShowError ! ( 'Flipper settings have changed, please restart flipper server for the changes to take effect' ) ; } , loadDefaultPlugins : getDefaultPluginsIndex , serverConfig : flipperServerConfig , GK ( gatekeeper ) { return flipperServerConfig . gatekeepers [ gatekeeper ] ?? false ; } , flipperServer , async requirePlugin ( path ) { let source = await flipperServer . exec ( 'plugin-source' , path ) ; source += `\n//# sourceURL=file://${ path }` ; source += `\n//# sourceMappingURL=file://${ path . replace ( /.js$/ , '.map' ) }` ; const cjsLoader = eval ( '(module) => {' + source + '\n}' ) ; const theModule = { exports : { } } ; cjsLoader ( theModule ) ; return theModule . exports ; } , getStaticResourceUrl ( path ) { return '/' + path ; } , getLocalIconUrl ( icon , url ) { if ( isProduction ( ) ) { return `icons/${ icon . name }-${ icon . variant }-${ icon . size }@${ icon . density }x.png` ; } return url ; } , } as RenderHost ; } function getDefaultPluginsIndex ( ) { const index = require ( './defaultPlugins' ) ; return index . default || index ; }