import * as protobuf from 'protobufjs/light' ; export function parseConfigure ( data ) { if ( typeof data === 'string' ) { return protobuf . Root . fromJSON ( JSON . parse ( data ) ) ; } return protobuf . Root . fromJSON ( data ) ; } export const createMessageFromName = ( messages , name ) => { const Message = messages . lookupType ( name ) ; const MessageType = messages . lookupEnum ( `MessageType` ) ; let messageType = MessageType . values [ `MessageType_${ name }` ] ; if ( ! messageType && Message . options ) { messageType = Message . options [ '(wire_type)' ] ; } return { Message , messageType , } ; } ; export const createMessageFromType = ( messages , typeId ) => { const MessageType = messages . lookupEnum ( `MessageType` ) ; const messageName = MessageType . valuesById [ typeId ] . replace ( 'MessageType_' , '' ) ; const Message = messages . lookupType ( messageName ) ; return { Message , messageName , } ; } ;