function serialize ( state ) { if ( ! state ) return state ; return JSON . parse ( JSON . stringify ( state ) ) ; } export function sendMessageToDevTools ( key , type , value ) { if ( typeof window === 'undefined' ) return ; window . postMessage ( { from : 'state-atom' , type , key , value : serialize ( value ) , } , '*' ) ; }