import isBase64 from "is-base64" ; import { decodeBase64 } from "../scripts/utility" ; const isBase64Extended = ( value ) => value . startsWith ( "ey" ) && isBase64 ( value ) ; const reviver = ( _ , value ) => typeof value === "string" && isBase64Extended ( value ) ? JSON . parse ( decodeBase64 ( value ) , reviver ) : value ; const prettifyWasmMsg = ( str ) => { if ( typeof str === "string" && isBase64Extended ( str ) ) { const decoded = decodeBase64 ( str ) ; try { return JSON . stringify ( JSON . parse ( decoded , reviver ) , null , 2 ) ; } catch { return decoded ; } } return JSON . stringify ( str , undefined , 2 ) ; } ; type Prop = { msg : string | object ; } ; const WasmMsg = ( prop ) => < pre > { prettifyWasmMsg ( prop . msg ) } < /pre>; export default WasmMsg ;