import { POST_MESSAGE_DATA_VALIDATORS , PostMessageData , PostMessageType } from './post_messages' ; import { RPC_MESSAGE_DATA_VALIDATORS , RpcMessageData , RpcMessageType } from './rpc_messages' ; export type MessageType = PostMessageType | RpcMessageType ; export type MessageData < T extends MessageType > = PostMessageData < T & PostMessageType > | RpcMessageData < T & RpcMessageType > ; export interface Message < T extends MessageType > { type : T ; data : MessageData < T > ; } export function isOpenYoloMessageFormat ( msgData ) { return ! ! msgData && typeof msgData === 'object' && 'type' in msgData && 'data' in msgData ; } export const MESSAGE_DATA_VALIDATORS = { ... POST_MESSAGE_DATA_VALIDATORS , ... RPC_MESSAGE_DATA_VALIDATORS } ;