import { getMessage } from "@extend-chrome/messages" ; import { MessageType } from "./MessageType" ; export const [ sendMessage , messageStream , _waitForMessage ] = getMessage < MessageType > ( "ARGENTX" ) ; export async function waitForMessage < K extends MessageType [ "type" ] , T extends { type : K ; } & MessageType > ( type , predicate = ( ) => true ) { return _waitForMessage ( ( [ msg ] ) => msg . type === type && predicate ( msg ) ) . then ( ( [ msg ] ) => msg . data ) ; }