From 1c302009f0cfa4af0da95de335964a6c8ec52545 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Sat, 30 Oct 2021 12:18:28 +0200 Subject: [PATCH] Fix handling of federated mime extensions --- app/index.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/index.js b/app/index.js index 71a6ad4bf..1bfb995da 100644 --- a/app/index.js +++ b/app/index.js @@ -69,15 +69,13 @@ async function main() { // load extra packages require('@jupyterlab/celltags'); - const mimeExtensions = [ + const mimeExtensionsMods = [ require('@jupyterlab/javascript-extension'), require('@jupyterlab/json-extension'), require('@jupyterlab/pdf-extension'), require('@jupyterlab/vega5-extension') ]; - - const RetroApp = require('@retrolab/application').RetroApp; - const app = new RetroApp({ mimeExtensions }); + const mimeExtensions = await Promise.all(mimeExtensionsMods); const disabled = []; // TODO: formalize the way the set of initial extensions and plugins are specified @@ -302,6 +300,20 @@ async function main() { } }); + // Add the federated mime extensions. + const federatedMimeExtensions = await Promise.allSettled( + federatedMimeExtensionPromises + ); + federatedMimeExtensions.forEach(p => { + if (p.status === 'fulfilled') { + for (let plugin of activePlugins(p.value)) { + mimeExtensions.push(plugin); + } + } else { + console.error(p.reason); + } + }); + // Load all federated component styles and log errors for any that do not (await Promise.allSettled(federatedStylePromises)) .filter(({ status }) => status === 'rejected') @@ -309,6 +321,9 @@ async function main() { console.error(reason); }); + const RetroApp = require('@retrolab/application').RetroApp; + const app = new RetroApp({ mimeExtensions }); + app.registerPluginModules(mods); // Expose global app instance when in dev mode or when toggled explicitly.