export type ErrorHandler = ( error : string ) => void ; class HydraWrapper { hydra : any ; onError : ErrorHandler ; constructor ( canvas , onError ) { const Hydra = require ( "hydra-synth" ) ; const P5 = require ( "./p5-wrapper" ) ; window . P5 = P5 ; if ( ! window . navigator . mediaDevices ) return ; this . hydra = new Hydra ( { canvas } ) ; this . onError = onError || ( ( ) => { } ) ; } tryEval = ( code ) => { let evalCode = code ; console . debug ( evalCode ) ; window . H = this . hydra ; try { eval . call ( window , evalCode ) ; this . onError ( null ) ; } catch ( error ) { this . onError ( String ( error ) ) ; } } ; } export default HydraWrapper ;