index.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { JupyterLab } from '@jupyterlab/application';
  4. // The webpack public path needs to be set before loading the CSS assets.
  5. import { PageConfig } from '@jupyterlab/coreutils';
  6. // eslint-disable-next-line
  7. __webpack_public_path__ = PageConfig.getOption('fullStaticUrl') + '/';
  8. // Load the CSS assets
  9. const styles = import('./build/style.js');
  10. // These extension and mimeExtension imports should match the list of extensions in package.json. They are listed
  11. // separately in package.json so the webpack config Build.ensureAssets step can copy
  12. // extension assets to the build directory. These import statements assume
  13. // the JupyterLab plugins are the default export from each package.
  14. const extensions = [
  15. import('@jupyterlab/application-extension'),
  16. import('@jupyterlab/apputils-extension'),
  17. import('@jupyterlab/codemirror-extension'),
  18. import('@jupyterlab/completer-extension'),
  19. import('@jupyterlab/console-extension'),
  20. import('@jupyterlab/csvviewer-extension'),
  21. import('@jupyterlab/docmanager-extension'),
  22. import('@jupyterlab/filebrowser-extension'),
  23. import('@jupyterlab/fileeditor-extension'),
  24. import('@jupyterlab/help-extension'),
  25. import('@jupyterlab/imageviewer-extension'),
  26. import('@jupyterlab/inspector-extension'),
  27. import('@jupyterlab/launcher-extension'),
  28. import('@jupyterlab/mainmenu-extension'),
  29. import('@jupyterlab/markdownviewer-extension'),
  30. import('@jupyterlab/mathjax2-extension'),
  31. import('@jupyterlab/notebook-extension'),
  32. import('@jupyterlab/rendermime-extension'),
  33. import('@jupyterlab/running-extension'),
  34. import('@jupyterlab/settingeditor-extension'),
  35. import('@jupyterlab/shortcuts-extension'),
  36. import('@jupyterlab/statusbar-extension'),
  37. import('@jupyterlab/terminal-extension'),
  38. import('@jupyterlab/theme-dark-extension'),
  39. import('@jupyterlab/theme-light-extension'),
  40. import('@jupyterlab/tooltip-extension'),
  41. import('@jupyterlab/translation-extension'),
  42. import('@jupyterlab/ui-components-extension')
  43. ];
  44. const mimeExtensions = [
  45. import('@jupyterlab/json-extension'),
  46. import('@jupyterlab/pdf-extension')
  47. ];
  48. window.addEventListener('load', async function () {
  49. // Make sure the styles have loaded
  50. await styles;
  51. // Initialize JupyterLab with the mime extensions and application extensions.
  52. const lab = new JupyterLab({
  53. mimeExtensions: await Promise.all(mimeExtensions)
  54. });
  55. lab.registerPluginModules(await Promise.all(extensions));
  56. /* eslint-disable no-console */
  57. console.log('Starting app');
  58. await lab.start();
  59. console.log('App started, waiting for restore');
  60. await lab.restored;
  61. console.log('Example started!');
  62. });