import { POPUP_HEIGHT , POPUP_WIDTH } from '@shared/constants' ; interface PopupOptions { url ? : string ; title ? : string ; w ? : number ; h ? : number ; skipPopupFallback ? : boolean ; } export function popupCenter ( options ) { const { url , w = POPUP_WIDTH , h = POPUP_HEIGHT } = options ; chrome . windows . getCurrent ( async ( win ) => { const dualScreenLeft = win . left || window . screenLeft ; const dualScreenTop = win . top || window . screenTop ; const width = win . width || window . innerWidth ; const height = win . height || window . innerHeight ; const left = Math . floor ( width / 2 - w / 2 + dualScreenLeft ) ; const top = Math . floor ( height / 2 - h / 2 + dualScreenTop ) ; await chrome . windows . create ( { url , width : w , height : h , top , left , focused : true , type : 'popup' , } ) ; } ) ; }