index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/celltags-extension'),
  18. import('@jupyterlab/codemirror-extension'),
  19. import('@jupyterlab/completer-extension'),
  20. import('@jupyterlab/console-extension'),
  21. import('@jupyterlab/csvviewer-extension'),
  22. import('@jupyterlab/docmanager-extension'),
  23. import('@jupyterlab/filebrowser-extension'),
  24. import('@jupyterlab/fileeditor-extension'),
  25. import('@jupyterlab/help-extension'),
  26. import('@jupyterlab/imageviewer-extension'),
  27. import('@jupyterlab/inspector-extension'),
  28. import('@jupyterlab/launcher-extension'),
  29. import('@jupyterlab/mainmenu-extension'),
  30. import('@jupyterlab/markdownviewer-extension'),
  31. import('@jupyterlab/mathjax2-extension'),
  32. import('@jupyterlab/notebook-extension'),
  33. import('@jupyterlab/rendermime-extension'),
  34. import('@jupyterlab/running-extension'),
  35. import('@jupyterlab/settingeditor-extension'),
  36. import('@jupyterlab/shortcuts-extension'),
  37. import('@jupyterlab/statusbar-extension'),
  38. import('@jupyterlab/terminal-extension'),
  39. import('@jupyterlab/theme-dark-extension'),
  40. import('@jupyterlab/theme-light-extension'),
  41. import('@jupyterlab/toc-extension'),
  42. import('@jupyterlab/tooltip-extension'),
  43. import('@jupyterlab/translation-extension'),
  44. import('@jupyterlab/ui-components-extension')
  45. ];
  46. const mimeExtensions = [
  47. import('@jupyterlab/json-extension'),
  48. import('@jupyterlab/pdf-extension')
  49. ];
  50. window.addEventListener('load', async function () {
  51. // Make sure the styles have loaded
  52. await styles;
  53. // Initialize JupyterLab with the mime extensions and application extensions.
  54. const lab = new JupyterLab({
  55. mimeExtensions: await Promise.all(mimeExtensions)
  56. });
  57. lab.registerPluginModules(await Promise.all(extensions));
  58. /* eslint-disable no-console */
  59. console.log('Starting app');
  60. await lab.start();
  61. console.log('App started, waiting for restore');
  62. await lab.restored;
  63. console.log('Example started!');
  64. });