import type { ConfigType } from '../../../config' ; interface Viewport { height : number ; width : number ; } type Proxy = ConfigType [ 'browser' ] [ 'chromium' ] [ 'proxy' ] ; interface LaunchArgs { userDataDir : string ; viewport ? : Viewport ; disableSandbox ? : boolean ; proxy : Proxy ; } export const args = ( { userDataDir , disableSandbox , viewport , proxy : proxyConfig } ) => { const flags = [ '--disable-translate' , '--disable-extensions' , '--disable-background-networking' , '--safebrowsing-disable-auto-update' , '--disable-sync' , '--metrics-recording-only' , '--disable-default-apps' , '--mute-audio' , '--no-first-run' , `--user-data-dir=${ userDataDir }` , '--disable-gpu' , '--headless' , '--hide-scrollbars' , `--mainFrameClipsContent=false` , ] ; if ( viewport ) { flags . push ( `--window-size=${ Math . floor ( viewport . width ) },${ Math . floor ( viewport . height ) }` ) ; } if ( proxyConfig . enabled ) { flags . push ( `--proxy-server=${ proxyConfig . server }` ) ; if ( proxyConfig . bypass ) { flags . push ( `--proxy-bypass-list=${ proxyConfig . bypass . join ( ',' ) }` ) ; } } if ( disableSandbox ) { flags . push ( '--no-sandbox' ) ; } if ( process . platform === 'linux' ) { flags . push ( '--disable-setuid-sandbox' ) ; } return [ ... flags , 'about:blank' ] ; } ;