@@ -16,9 +16,10 @@ import './style.css';
1616
1717import { PageConfig , URLExt } from '@jupyterlab/coreutils' ;
1818
19- import { VoilaApp } from '@voila-dashboards/voila' ;
19+ import { VoilaApp } from './app' ;
20+ import { VoilaShell } from './shell' ;
2021
21- function loadScript ( url ) {
22+ function loadScript ( url : string ) : Promise < any > {
2223 return new Promise ( ( resolve , reject ) => {
2324 const newScript = document . createElement ( 'script' ) ;
2425 newScript . onerror = reject ;
@@ -28,7 +29,7 @@ function loadScript(url) {
2829 newScript . src = url ;
2930 } ) ;
3031}
31- async function loadComponent ( url , scope ) {
32+ async function loadComponent ( url : string , scope : string ) : Promise < void > {
3233 await loadScript ( url ) ;
3334
3435 // From MIT-licensed https://github.com/module-federation/module-federation-examples/blob/af043acd6be1718ee195b2511adf6011fba4233c/advanced-api/dynamic-remotes/app1/src/App.js#L6-L12
@@ -40,7 +41,7 @@ async function loadComponent(url, scope) {
4041 await container . init ( __webpack_share_scopes__ . default ) ;
4142}
4243
43- async function createModule ( scope , module ) {
44+ async function createModule ( scope : string , module : string ) {
4445 try {
4546 const factory = await window . _JUPYTERLAB [ scope ] . get ( module ) ;
4647 return factory ( ) ;
@@ -58,7 +59,7 @@ const disabled = ['@jupyter-widgets/jupyterlab-manager'];
5859 * The main function
5960 */
6061async function main ( ) {
61- let mods = [
62+ const mods = [
6263 // @jupyterlab plugins
6364 require ( '@jupyterlab/markdownviewer-extension' ) ,
6465 require ( '@jupyterlab/mathjax2-extension' ) ,
@@ -78,7 +79,7 @@ async function main() {
7879 * #### Notes
7980 * This also populates the disabled
8081 */
81- function * activePlugins ( extension ) {
82+ function * activePlugins ( extension : any ) {
8283 // Handle commonjs or es2015 modules
8384 let exports ;
8485 if ( Object . prototype . hasOwnProperty . call ( extension , '__esModule' ) ) {
@@ -88,8 +89,8 @@ async function main() {
8889 exports = extension ;
8990 }
9091
91- let plugins = Array . isArray ( exports ) ? exports : [ exports ] ;
92- for ( let plugin of plugins ) {
92+ const plugins = Array . isArray ( exports ) ? exports : [ exports ] ;
93+ for ( const plugin of plugins ) {
9394 if (
9495 PageConfig . Extension . isDisabled ( plugin . id ) ||
9596 disabled . includes ( plugin . id ) ||
@@ -101,13 +102,13 @@ async function main() {
101102 }
102103 }
103104
104- const extensionData = JSON . parse (
105+ const extensionData : any [ ] = JSON . parse (
105106 PageConfig . getOption ( 'federated_extensions' )
106107 ) ;
107108
108- const federatedExtensionPromises = [ ] ;
109- const federatedMimeExtensionPromises = [ ] ;
110- const federatedStylePromises = [ ] ;
109+ const federatedExtensionPromises : Promise < any > [ ] = [ ] ;
110+ const federatedMimeExtensionPromises : Promise < any > [ ] = [ ] ;
111+ const federatedStylePromises : Promise < any > [ ] = [ ] ;
111112
112113 const extensions = await Promise . allSettled (
113114 extensionData . map ( async data => {
@@ -150,7 +151,7 @@ async function main() {
150151 ) ;
151152 federatedExtensions . forEach ( p => {
152153 if ( p . status === 'fulfilled' ) {
153- for ( let plugin of activePlugins ( p . value ) ) {
154+ for ( const plugin of activePlugins ( p . value ) ) {
154155 mods . push ( plugin ) ;
155156 }
156157 } else {
@@ -164,7 +165,7 @@ async function main() {
164165 ) ;
165166 federatedMimeExtensions . forEach ( p => {
166167 if ( p . status === 'fulfilled' ) {
167- for ( let plugin of activePlugins ( p . value ) ) {
168+ for ( const plugin of activePlugins ( p . value ) ) {
168169 mimeExtensions . push ( plugin ) ;
169170 }
170171 } else {
@@ -175,11 +176,11 @@ async function main() {
175176 // Load all federated component styles and log errors for any that do not
176177 ( await Promise . allSettled ( federatedStylePromises ) )
177178 . filter ( ( { status } ) => status === 'rejected' )
178- . forEach ( ( { reason } ) => {
179- console . error ( reason ) ;
179+ . forEach ( p => {
180+ console . error ( ( p as PromiseRejectedResult ) . reason ) ;
180181 } ) ;
181182
182- const app = new VoilaApp ( { mimeExtensions } ) ;
183+ const app = new VoilaApp ( { mimeExtensions, shell : new VoilaShell ( ) } ) ;
183184 app . registerPluginModules ( mods ) ;
184185 await app . start ( ) ;
185186
0 commit comments