Browse Source

Use default exports for plugins

Steven Silvester 8 years ago
parent
commit
3b96e98ba0

+ 38 - 33
examples/lab/index.js

@@ -10,39 +10,44 @@ require('font-awesome/css/font-awesome.min.css');
 require('jupyterlab/lib/default-theme/index.css');
 
 
-var lab = new JupyterLab();
+var mods = [
+  require('../../lib/about/plugin'),
+  require('../../lib/application/plugin'),
+  require('../../lib/clipboard/plugin'),
+  require('../../lib/codemirror/plugin'),
+  require('../../lib/commandlinker/plugin'),
+  require('../../lib/commandpalette/plugin'),
+  require('../../lib/console/plugin'),
+  require('../../lib/csvwidget/plugin'),
+  require('../../lib/docmanager/plugin'),
+  require('../../lib/docregistry/plugin'),
+  require('../../lib/editorwidget/plugin'),
+  require('../../lib/faq/plugin'),
+  require('../../lib/filebrowser/plugin'),
+  require('../../lib/help/plugin'),
+  require('../../lib/imagewidget/plugin'),
+  require('../../lib/inspector/plugin'),
+  require('../../lib/landing/plugin'),
+  require('../../lib/launcher/plugin'),
+  require('../../lib/layoutrestorer/plugin'),
+  require('../../lib/mainmenu/plugin'),
+  require('../../lib/markdownwidget/plugin'),
+  require('../../lib/notebook/plugin'),
+  require('../../lib/rendermime/plugin'),
+  require('../../lib/running/plugin'),
+  require('../../lib/services/plugin'),
+  require('../../lib/shortcuts/plugin'),
+  require('../../lib/statedb/plugin'),
+  require('../../lib/terminal/plugin')
+];
+
 
-lab.registerPlugins([
-  require('jupyterlab/lib/about/plugin').plugin,
-  require('jupyterlab/lib/application/plugin').plugin,
-  require('jupyterlab/lib/clipboard/plugin').plugin,
-  require('jupyterlab/lib/codemirror/plugin').servicesPlugin,
-  require('jupyterlab/lib/codemirror/plugin').commandsPlugin,
-  require('jupyterlab/lib/commandlinker/plugin').plugin,
-  require('jupyterlab/lib/commandpalette/plugin').plugin,
-  require('jupyterlab/lib/console/plugin').trackerPlugin,
-  require('jupyterlab/lib/console/plugin').rendererPlugin,
-  require('jupyterlab/lib/docregistry/plugin').plugin,
-  require('jupyterlab/lib/docmanager/plugin').plugin,
-  require('jupyterlab/lib/editorwidget/plugin').plugin,
-  require('jupyterlab/lib/faq/plugin').plugin,
-  require('jupyterlab/lib/filebrowser/plugin').plugin,
-  require('jupyterlab/lib/help/plugin').plugin,
-  require('jupyterlab/lib/imagewidget/plugin').plugin,
-  require('jupyterlab/lib/inspector/plugin').plugin,
-  require('jupyterlab/lib/landing/plugin').plugin,
-  require('jupyterlab/lib/launcher/plugin').plugin,
-  require('jupyterlab/lib/layoutrestorer/plugin').plugin,
-  require('jupyterlab/lib/mainmenu/plugin').plugin,
-  require('jupyterlab/lib/markdownwidget/plugin').plugin,
-  require('jupyterlab/lib/notebook/plugin').trackerPlugin,
-  require('jupyterlab/lib/notebook/plugin').rendererPlugin,
-  require('jupyterlab/lib/rendermime/plugin').plugin,
-  require('jupyterlab/lib/running/plugin').plugin,
-  require('jupyterlab/lib/services/plugin').plugin,
-  require('jupyterlab/lib/shortcuts/plugin').plugin,
-  require('jupyterlab/lib/statedb/plugin').plugin,
-  require('jupyterlab/lib/terminal/plugin').plugin
-]);
+var lab = new JupyterLab();
+var plugins = [];
+for (var i = 0; i < mods.length; i++) {
+  var mod = mods[i];
+  plugins = plugins.concat(mod.default);
+}
+lab.registerPlugins(plugins);
 
 window.onload = function() { lab.start(); }

+ 2 - 0
examples/lab/main.py

@@ -37,6 +37,8 @@ def main(argv):
                   '--NotebookApp.allow_origin="*"',
                   # disable user password:
                   '--NotebookApp.password=',
+                  # disable token:
+                  '--NotebookApp.token='
               ]
     nb_server = subprocess.Popen(nb_command, stderr=subprocess.STDOUT,
                                  stdout=subprocess.PIPE)

+ 35 - 32
jupyterlab/src/extensions.ts

@@ -1,36 +1,39 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-module.exports = [
-  require('../../lib/about/plugin').plugin,
-  require('../../lib/application/plugin').plugin,
-  require('../../lib/clipboard/plugin').plugin,
-  require('../../lib/codemirror/plugin').servicesPlugin,
-  require('../../lib/codemirror/plugin').commandsPlugin,
-  require('../../lib/commandlinker/plugin').plugin,
-  require('../../lib/commandpalette/plugin').plugin,
-  require('../../lib/console/plugin').trackerPlugin,
-  require('../../lib/console/plugin').rendererPlugin,
-  require('../../lib/csvwidget/plugin').plugin,
-  require('../../lib/docmanager/plugin').plugin,
-  require('../../lib/docregistry/plugin').plugin,
-  require('../../lib/editorwidget/plugin').plugin,
-  require('../../lib/faq/plugin').plugin,
-  require('../../lib/filebrowser/plugin').plugin,
-  require('../../lib/help/plugin').plugin,
-  require('../../lib/imagewidget/plugin').plugin,
-  require('../../lib/inspector/plugin').plugin,
-  require('../../lib/landing/plugin').plugin,
-  require('../../lib/launcher/plugin').plugin,
-  require('../../lib/layoutrestorer/plugin').plugin,
-  require('../../lib/mainmenu/plugin').plugin,
-  require('../../lib/markdownwidget/plugin').plugin,
-  require('../../lib/notebook/plugin').trackerPlugin,
-  require('../../lib/notebook/plugin').rendererPlugin,
-  require('../../lib/rendermime/plugin').plugin,
-  require('../../lib/running/plugin').plugin,
-  require('../../lib/services/plugin').plugin,
-  require('../../lib/shortcuts/plugin').plugin,
-  require('../../lib/statedb/plugin').plugin,
-  require('../../lib/terminal/plugin').plugin
+let mods: any[] = [
+  require('../../lib/about/plugin'),
+  require('../../lib/application/plugin'),
+  require('../../lib/clipboard/plugin'),
+  require('../../lib/codemirror/plugin'),
+  require('../../lib/commandlinker/plugin'),
+  require('../../lib/commandpalette/plugin'),
+  require('../../lib/console/plugin'),
+  require('../../lib/csvwidget/plugin'),
+  require('../../lib/docmanager/plugin'),
+  require('../../lib/docregistry/plugin'),
+  require('../../lib/editorwidget/plugin'),
+  require('../../lib/faq/plugin'),
+  require('../../lib/filebrowser/plugin'),
+  require('../../lib/help/plugin'),
+  require('../../lib/imagewidget/plugin'),
+  require('../../lib/inspector/plugin'),
+  require('../../lib/landing/plugin'),
+  require('../../lib/launcher/plugin'),
+  require('../../lib/layoutrestorer/plugin'),
+  require('../../lib/mainmenu/plugin'),
+  require('../../lib/markdownwidget/plugin'),
+  require('../../lib/notebook/plugin'),
+  require('../../lib/rendermime/plugin'),
+  require('../../lib/running/plugin'),
+  require('../../lib/services/plugin'),
+  require('../../lib/shortcuts/plugin'),
+  require('../../lib/statedb/plugin'),
+  require('../../lib/terminal/plugin')
 ];
+
+var plugins: any[] = [];
+for (let mod of mods) {
+  plugins = plugins.concat(mod.default);
+}
+export default plugins;

+ 6 - 1
src/about/plugin.ts

@@ -24,7 +24,6 @@ import {
 /**
  * The about page extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.about',
   activate: activateAbout,
@@ -33,6 +32,12 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 function activateAbout(app: JupyterLab, palette: ICommandPalette, layout: ILayoutRestorer): void {
   const namespace = 'about-jupyterlab';
   const model = new AboutModel();

+ 6 - 1
src/application/plugin.ts

@@ -13,7 +13,6 @@ import {
 /**
  * The main extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.main',
   requires: [ICommandPalette],
@@ -40,3 +39,9 @@ const plugin: JupyterLabPlugin<void> = {
   },
   autoStart: true
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 6 - 1
src/clipboard/plugin.ts

@@ -17,9 +17,14 @@ import {
 /**
  * The clipboard provider.
  */
-export
 const plugin: JupyterLabPlugin<IClipboard> = {
   id: 'jupyter.services.clipboard',
   provides: IClipboard,
   activate: (): IClipboard => new MimeData()
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 7 - 0
src/codemirror/plugin.ts

@@ -58,6 +58,13 @@ const commandsPlugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugins as default.
+ */
+const plugins: JupyterLabPlugin<any>[] = [commandsPlugin, servicesPlugin];
+export default plugins;
+
+
 /**
  * The map of command ids used by the editor.
  */

+ 6 - 1
src/commandlinker/plugin.ts

@@ -15,10 +15,15 @@ import {
 /**
  * The default commmand linker provider.
  */
-export
 const plugin: JupyterLabPlugin<ICommandLinker> = {
   id: 'jupyter.services.command-linker',
   provides: ICommandLinker,
   activate: (app: JupyterLab) => new CommandLinker({ commands: app.commands }),
   autoStart: true
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 6 - 1
src/commandpalette/plugin.ts

@@ -68,7 +68,6 @@ class Palette implements ICommandPalette {
 /**
  * The default commmand palette extension.
  */
-export
 const plugin: JupyterLabPlugin<ICommandPalette> = {
   id: 'jupyter.services.commandpalette',
   provides: ICommandPalette,
@@ -77,6 +76,12 @@ const plugin: JupyterLabPlugin<ICommandPalette> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the command palette.
  */

+ 7 - 0
src/console/plugin.ts

@@ -103,6 +103,13 @@ const rendererPlugin: JupyterLabPlugin<ConsoleContent.IRenderer> = {
 };
 
 
+/**
+ * Export the plugins as the default.
+ */
+const plugins: JupyterLabPlugin<any>[] = [rendererPlugin, trackerPlugin];
+export default plugins;
+
+
 /**
  * The class name for all main area landscape tab icons.
  */

+ 6 - 1
src/csvwidget/plugin.ts

@@ -31,7 +31,6 @@ const FACTORY = 'Table';
 /**
  * The table file handler extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.csv-handler',
   requires: [IDocumentRegistry, ILayoutRestorer],
@@ -40,6 +39,12 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the table widget extension.
  */

+ 7 - 1
src/docmanager/plugin.ts

@@ -24,7 +24,6 @@ import {
 /**
  * The default document manager provider.
  */
-export
 const plugin: JupyterLabPlugin<IDocumentManager> = {
   id: 'jupyter.services.document-manager',
   provides: IDocumentManager,
@@ -45,3 +44,10 @@ const plugin: JupyterLabPlugin<IDocumentManager> = {
     return new DocumentManager({ registry, manager, opener });
   }
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+

+ 6 - 1
src/docregistry/plugin.ts

@@ -13,7 +13,6 @@ import {
 /**
  * The default document registry provider.
  */
-export
 const plugin: JupyterLabPlugin<IDocumentRegistry> = {
   id: 'jupyter.services.document-registry',
   provides: IDocumentRegistry,
@@ -31,3 +30,9 @@ const plugin: JupyterLabPlugin<IDocumentRegistry> = {
     return registry;
   }
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 6 - 1
src/editorwidget/plugin.ts

@@ -59,7 +59,6 @@ const cmdIds = {
 /**
  * The editor handler extension.
  */
-export
 const plugin: JupyterLabPlugin<IEditorTracker> = {
   id: 'jupyter.services.editor-handler',
   requires: [IDocumentRegistry, ILayoutRestorer, IEditorServices],
@@ -69,6 +68,12 @@ const plugin: JupyterLabPlugin<IEditorTracker> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Sets up the editor widget
  */

+ 6 - 1
src/faq/plugin.ts

@@ -29,7 +29,6 @@ import {
 /**
  * The FAQ page extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.faq',
   requires: [ICommandPalette, ICommandLinker, ILayoutRestorer],
@@ -38,6 +37,12 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the FAQ plugin.
  */

+ 6 - 1
src/filebrowser/plugin.ts

@@ -49,7 +49,6 @@ import {
 /**
  * The default file browser provider.
  */
-export
 const plugin: JupyterLabPlugin<IPathTracker> = {
   id: 'jupyter.services.file-browser',
   provides: IPathTracker,
@@ -66,6 +65,12 @@ const plugin: JupyterLabPlugin<IPathTracker> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * The map of command ids used by the file browser.
  */

+ 6 - 1
src/help/plugin.ts

@@ -105,7 +105,6 @@ const RESOURCES = [
 /**
  * The help handler extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.help-handler',
   requires: [IMainMenu, ICommandPalette, ILayoutRestorer],
@@ -114,6 +113,12 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the help handler extension.
  *

+ 6 - 1
src/imagewidget/plugin.ts

@@ -40,7 +40,6 @@ const FACTORY = 'Image';
 /**
  * The image file handler extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.image-handler',
   requires: [IDocumentRegistry, ICommandPalette, ILayoutRestorer],
@@ -49,6 +48,12 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the image widget extension.
  */

+ 6 - 1
src/inspector/plugin.ts

@@ -26,7 +26,6 @@ import {
 /**
  * A service providing an inspector panel.
  */
-export
 const plugin: JupyterLabPlugin<IInspector> = {
   id: 'jupyter.services.inspector',
   requires: [ICommandPalette, ILayoutRestorer],
@@ -35,6 +34,12 @@ const plugin: JupyterLabPlugin<IInspector> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * A class that manages inspector widget instances and offers persistent
  * `IInspector` instance that other plugins can communicate with.

+ 10 - 3
src/landing/plugin.ts

@@ -29,11 +29,14 @@ import {
   LandingModel, LandingWidget
 } from './widget';
 
+/**
+ * The class name added to the landing plugin.
+ */
+const LANDING_CLASS = 'jp-Landing';
 
 /**
  * The landing page extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.landing',
   requires: [IPathTracker, ICommandPalette, IServiceManager, ILayoutRestorer],
@@ -41,12 +44,16 @@ const plugin: JupyterLabPlugin<void> = {
   autoStart: true
 };
 
+
 /**
- * The class name added to the landing plugin.
+ * Export the plugin as default.
  */
-const LANDING_CLASS = 'jp-Landing';
+export default plugin;
 
 
+/**
+ * Activate the landing plugin.
+ */
 function activateLanding(app: JupyterLab, pathTracker: IPathTracker, palette: ICommandPalette, services: IServiceManager, layout: ILayoutRestorer): void {
   const category = 'Help';
   const command = 'jupyterlab-landing:show';

+ 6 - 1
src/launcher/plugin.ts

@@ -29,7 +29,6 @@ import {
 /**
  * A service providing an interface to the the launcher.
  */
-export
 const plugin: JupyterLabPlugin<ILauncher> = {
   id: 'jupyter.services.launcher',
   requires: [IServiceManager, IPathTracker, ICommandPalette, ICommandLinker],
@@ -39,6 +38,12 @@ const plugin: JupyterLabPlugin<ILauncher> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the launcher.
  */

+ 7 - 1
src/layoutrestorer/plugin.ts

@@ -19,7 +19,6 @@ import {
 /**
  * The default layout restorer provider.
  */
-export
 const plugin: JupyterLabPlugin<ILayoutRestorer> = {
   id: 'jupyter.services.layout-restorer',
   requires: [IStateDB],
@@ -41,3 +40,10 @@ const plugin: JupyterLabPlugin<ILayoutRestorer> = {
   autoStart: true,
   provides: ILayoutRestorer
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+

+ 6 - 1
src/mainmenu/plugin.ts

@@ -28,7 +28,6 @@ const JUPYTER_ICON_CLASS = 'jp-JupyterIcon';
 /**
  * A service providing an interface to the main menu.
  */
-export
 const plugin: JupyterLabPlugin<IMainMenu> = {
   id: 'jupyter.services.main-menu',
   provides: IMainMenu,
@@ -36,6 +35,12 @@ const plugin: JupyterLabPlugin<IMainMenu> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the main menu extension.
  */

+ 7 - 1
src/markdownwidget/plugin.ts

@@ -45,7 +45,6 @@ const FACTORY = 'Rendered Markdown';
 /**
  * The markdown handler extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.rendered-markdown',
   requires: [IDocumentRegistry, IRenderMime, ILayoutRestorer],
@@ -83,3 +82,10 @@ const plugin: JupyterLabPlugin<void> = {
   },
   autoStart: true
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+

+ 7 - 0
src/notebook/plugin.ts

@@ -154,6 +154,13 @@ const rendererPlugin: JupyterLabPlugin<NotebookPanel.IRenderer> = {
 };
 
 
+/**
+ * Export the plugins as default.
+ */
+const plugins: JupyterLabPlugin<any>[] = [rendererPlugin, trackerPlugin];
+export default plugins;
+
+
 /**
  * Activate the notebook handler extension.
  */

+ 6 - 1
src/rendermime/plugin.ts

@@ -17,7 +17,6 @@ import {
 /**
  * The default rendermime provider.
  */
-export
 const plugin: JupyterLabPlugin<IRenderMime> = {
   id: 'jupyter.services.rendermime',
   provides: IRenderMime,
@@ -35,3 +34,9 @@ const plugin: JupyterLabPlugin<IRenderMime> = {
     return new RenderMime({ renderers, order, sanitizer });
   }
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 8 - 1
src/running/plugin.ts

@@ -17,7 +17,6 @@ import {
 /**
  * The default running sessions extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.running-sessions',
   requires: [IServiceManager],
@@ -26,7 +25,15 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
 
+/**
+ * Activate the running plugin.
+ */
 function activateRunningSessions(app: JupyterLab, services: IServiceManager): void {
   let running = new RunningSessions({ manager: services });
   running.id = 'jp-running-sessions';

+ 6 - 1
src/services/plugin.ts

@@ -17,9 +17,14 @@ import {
 /**
  * The default services provider.
  */
-export
 const plugin: JupyterLabPlugin<IServiceManager> = {
   id: 'jupyter.services.services',
   provides: IServiceManager,
   activate: (): IServiceManager => new ServiceManager()
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 6 - 1
src/shortcuts/plugin.ts

@@ -296,7 +296,6 @@ const SHORTCUTS = [
 /**
  * The default shortcuts extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.shortcuts',
   activate: (app: JupyterLab): void => {
@@ -304,3 +303,9 @@ const plugin: JupyterLabPlugin<void> = {
   },
   autoStart: true
 };
+
+
+/**
+ * Export the plugin as default.
+ */
+export default plugin;

+ 6 - 1
src/statedb/plugin.ts

@@ -25,7 +25,6 @@ import {
 /**
  * The default state database for storing application state.
  */
-export
 const plugin: JupyterLabPlugin<IStateDB> = {
   id: 'jupyter.services.statedb',
   activate: activateState,
@@ -35,6 +34,12 @@ const plugin: JupyterLabPlugin<IStateDB> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
 /**
  * Activate the state database.
  */

+ 9 - 1
src/terminal/plugin.ts

@@ -52,7 +52,6 @@ const TERMINAL_ICON_CLASS = 'jp-ImageTerminal';
 /**
  * The default terminal extension.
  */
-export
 const plugin: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.terminal',
   requires: [
@@ -63,6 +62,15 @@ const plugin: JupyterLabPlugin<void> = {
 };
 
 
+/**
+ * Export the plugin as default.
+ */
+export default plugin;
+
+
+/**
+ * Activate the terminal plugin.
+ */
 function activateTerminal(app: JupyterLab, services: IServiceManager, mainMenu: IMainMenu, palette: ICommandPalette, layout: ILayoutRestorer): void {
   // Bail if there are no terminals available.
   if (!services.terminals.isAvailable()) {

+ 1 - 1
tslint.json

@@ -56,7 +56,7 @@
     "no-construct": true,
     "no-constructor-vars": true,
     "no-debugger": true,
-    "no-default-export": true,
+    "no-default-export": false,
     "no-duplicate-key": true,
     "no-duplicate-variable": true,
     "no-empty": true,