import { Widget } from '@lumino/widgets' ; import { IRenderMime } from '@jupyterlab/rendermime-interfaces' ; import { HTMLManager } from './htmlmanager' ; export const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget-view+json' ; export class WidgetRenderer extends Widget implements IRenderMime . IRenderer { constructor ( options , manager ) { super ( ) ; this . mimeType = options . mimeType ; this . _manager = manager ; } async renderModel ( model ) { const source = model . data [ this . mimeType ] ; const modelPromise = this . _manager . get_model ( source . model_id ) ; if ( modelPromise ) { try { const wModel = await modelPromise ; const wView = await this . _manager . create_view ( wModel ) ; Widget . attach ( wView . luminoWidget , this . node ) ; } catch ( err ) { console . log ( 'Error displaying widget' ) ; console . log ( err ) ; this . node . textContent = 'Error displaying widget' ; this . addClass ( 'jupyter-widgets' ) ; } } else { this . node . textContent = 'Error creating widget: could not find model' ; this . addClass ( 'jupyter-widgets' ) ; } } /**
     * The mimetype being rendered.
     */ readonly mimeType : string ; private _manager : HTMLManager ; }