diff --git a/setup.py b/setup.py index 327fe1e4b..4c6d23dda 100644 --- a/setup.py +++ b/setup.py @@ -241,7 +241,8 @@ def get_data_files(): 'pytest', 'pytest-tornasync', 'matplotlib', - 'ipywidgets' + 'ipywidgets', + 'pyppeteer', ] }, 'url': 'https://github.com/voila-dashboards/voila', diff --git a/share/jupyter/voila/templates/base/static/main.js b/share/jupyter/voila/templates/base/static/main.js index c703a05b5..1ece04cca 100644 --- a/share/jupyter/voila/templates/base/static/main.js +++ b/share/jupyter/voila/templates/base/static/main.js @@ -6,6 +6,27 @@ * The full license is in the file LICENSE, distributed with this software. * ****************************************************************************/ +window.VoilaDebug = VoilaDebug = { + _widgetManagerPromiseResolve: null, + _widgetManagerPromise: null, + async waitForWidgetManager() { + await _widgetManagerPromise; + }, + async waitForViews(modelId) { + const widgetManager = await window.VoilaDebug._widgetManagerPromise; + const model = await widgetManager._models[modelId]; + await Promise.all(Object.values(model.views)) + }, + async waitForAllViews() { + const widgetManager = await window.VoilaDebug._widgetManagerPromise; + for(const modelId in widgetManager._models) { + await window.VoilaDebug.waitForViews(modelId); + } + } +} + +window.VoilaDebug._widgetManagerPromise = new Promise((resolve) => window.VoilaDebug._widgetManagerPromiseResolve = resolve), + // NOTE: this file is not transpiled, async/await is the only modern feature we use here require([window.voila_js_url || 'static/voila'], function(voila) { // requirejs doesn't like to be passed an async function, so create one inside @@ -45,6 +66,7 @@ require([window.voila_js_url || 'static/voila'], function(voila) { }); await widgetManager.build_widgets(); voila.renderMathJax(); + window.VoilaDebug._widgetManagerPromiseResolve(widgetManager); } if (document.readyState === 'complete') { diff --git a/share/jupyter/voila/templates/base/voila_setup.macro.html.j2 b/share/jupyter/voila/templates/base/voila_setup.macro.html.j2 index 34693afb5..9f7e49d86 100644 --- a/share/jupyter/voila/templates/base/voila_setup.macro.html.j2 +++ b/share/jupyter/voila/templates/base/voila_setup.macro.html.j2 @@ -7,9 +7,10 @@