import type { EventBasedChannel } from 'async-call-rpc/full' ; export class AndroidGeckoViewChannel implements EventBasedChannel { port = browser . runtime . connectNative ( 'browser' ) ; on ( cb ) { this . port . onMessage . addListener ( cb ) ; return ( ) => this . port . onMessage . removeListener ( cb ) ; } send ( data ) { this . port . postMessage ( data ) ; } }