浏览代码

Merge pull request #622 from afshin/plugin-refactor

Plugin refactor
Steven Silvester 8 年之前
父节点
当前提交
381d0f0dca

+ 2 - 2
examples/lab/index.js

@@ -14,10 +14,10 @@ var lab = new JupyterLab();
 lab.registerPlugins([
   require('jupyterlab/lib/about/plugin').aboutExtension,
   require('jupyterlab/lib/clipboard/plugin').clipboardProvider,
-  require('jupyterlab/lib/commandpalette/plugin').commandPaletteExtension,
+  require('jupyterlab/lib/commandpalette/plugin').commandPaletteProvider,
   require('jupyterlab/lib/console/plugin').consoleExtension,
   require('jupyterlab/lib/docregistry/plugin').docRegistryProvider,
-  require('jupyterlab/lib/editorwidget/plugin').editorHandlerExtension,
+  require('jupyterlab/lib/editorwidget/plugin').editorHandlerProvider,
   require('jupyterlab/lib/faq/plugin').faqExtension,
   require('jupyterlab/lib/filebrowser/plugin').fileBrowserProvider,
   require('jupyterlab/lib/help/plugin').helpHandlerExtension,

+ 2 - 2
jupyterlab/index.js

@@ -15,11 +15,11 @@ var lab = new JupyterLab();
 lab.registerPlugins([
   require('jupyterlab/lib/about/plugin').aboutExtension,
   require('jupyterlab/lib/clipboard/plugin').clipboardProvider,
-  require('jupyterlab/lib/commandpalette/plugin').commandPaletteExtension,
+  require('jupyterlab/lib/commandpalette/plugin').commandPaletteProvider,
   require('jupyterlab/lib/console/plugin').consoleExtension,
   require('jupyterlab/lib/csvwidget/plugin').csvHandlerExtension,
   require('jupyterlab/lib/docregistry/plugin').docRegistryProvider,
-  require('jupyterlab/lib/editorwidget/plugin').editorHandlerExtension,
+  require('jupyterlab/lib/editorwidget/plugin').editorHandlerProvider,
   require('jupyterlab/lib/faq/plugin').faqExtension,
   require('jupyterlab/lib/filebrowser/plugin').fileBrowserProvider,
   require('jupyterlab/lib/help/plugin').helpHandlerExtension,

+ 1 - 1
src/about/plugin.ts

@@ -11,7 +11,7 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   html

+ 23 - 0
src/clipboard/index.ts

@@ -1,6 +1,29 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+import {
+  MimeData
+} from 'phosphor/lib/core/mimedata';
+
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
+/* tslint:disable */
+/**
+ * The clipboard token.
+ */
+export
+const IClipboard = new Token<IClipboard>('jupyter.services.clipboard');
+/* tslint:enable */
+
+
+/**
+ * The clipboard interface.
+ */
+export
+interface IClipboard extends MimeData {}
+
 /**
  * Copy text to the system clipboard.
  *

+ 3 - 19
src/clipboard/plugin.ts

@@ -5,29 +5,13 @@ import {
   MimeData
 } from 'phosphor/lib/core/mimedata';
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   JupyterLabPlugin
 } from '../application';
 
-
-/* tslint:disable */
-/**
- * The clipboard token.
- */
-export
-const IClipboard = new Token<IClipboard>('jupyter.services.clipboard');
-/* tslint:enable */
-
-
-/**
- * The clipboard interface.
- */
-export
-interface IClipboard extends MimeData {}
+import {
+  IClipboard
+} from './';
 
 
 /**

+ 24 - 0
src/commandpalette/index.ts

@@ -0,0 +1,24 @@
+/*-----------------------------------------------------------------------------
+| Copyright (c) Jupyter Development Team.
+| Distributed under the terms of the Modified BSD License.
+|----------------------------------------------------------------------------*/
+
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
+import {
+  CommandPalette
+} from 'phosphor/lib/ui/commandpalette';
+
+
+/* tslint:disable */
+/**
+ * The command palette token.
+ */
+export
+const ICommandPalette = new Token<ICommandPalette>('jupyter.services.commandpalette');
+/* tslint:enable */
+
+export
+interface ICommandPalette extends CommandPalette {}

+ 4 - 15
src/commandpalette/plugin.ts

@@ -3,10 +3,6 @@
 | Distributed under the terms of the Modified BSD License.
 |----------------------------------------------------------------------------*/
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   CommandPalette
 } from 'phosphor/lib/ui/commandpalette';
@@ -15,30 +11,23 @@ import {
   JupyterLab, JupyterLabPlugin
 } from '../application';
 
+import {
+  ICommandPalette
+} from './';
 
-/* tslint:disable */
-/**
- * The command palette token.
- */
-export
-const ICommandPalette = new Token<ICommandPalette>('jupyter.services.commandpalette');
-/* tslint:enable */
 
 
 /**
  * The default commmand palette extension.
  */
 export
-const commandPaletteExtension: JupyterLabPlugin<ICommandPalette> = {
+const commandPaletteProvider: JupyterLabPlugin<ICommandPalette> = {
   id: 'jupyter.services.commandpalette',
   provides: ICommandPalette,
   activate: activateCommandPalette,
   autoStart: true
 };
 
-export
-interface ICommandPalette extends CommandPalette {}
-
 
 /**
  * Activate the command palette.

+ 8 - 5
src/console/plugin.ts

@@ -15,7 +15,7 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   selectKernel
@@ -23,19 +23,19 @@ import {
 
 import {
   IInspector
-} from '../inspector/plugin';
+} from '../inspector';
 
 import {
   IMainMenu
-} from '../mainmenu/plugin';
+} from '../mainmenu';
 
 import {
   IRenderMime
-} from '../rendermime/plugin';
+} from '../rendermime';
 
 import {
   IServiceManager
-} from '../services/plugin';
+} from '../services';
 
 import {
   WidgetTracker
@@ -92,6 +92,9 @@ function activateConsole(app: JupyterLab, services: IServiceManager, rendermime:
     inspector.source = panel.content.inspectionHandler;
   });
 
+  // Set the main menu title.
+  menu.title.label = 'Console';
+
   // Add the ability to create new consoles for each kernel.
   let specs = services.kernelspecs;
   let displayNameMap: { [key: string]: string } = Object.create(null);

+ 4 - 0
src/editorwidget/index.ts

@@ -0,0 +1,4 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+export * from './widget';

+ 8 - 24
src/editorwidget/plugin.ts

@@ -1,10 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   Menu
 } from 'phosphor/lib/ui/menu';
@@ -23,16 +19,20 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   IMainMenu
-} from '../mainmenu/plugin';
+} from '../mainmenu';
 
 import {
   WidgetTracker
 } from '../widgettracker';
 
+import {
+  IEditorTracker
+} from './index';
+
 import 'codemirror/theme/material.css';
 import 'codemirror/theme/zenburn.css';
 import 'codemirror/theme/abcdef.css';
@@ -62,28 +62,12 @@ const PORTRAIT_ICON_CLASS = 'jp-MainAreaPortraitIcon';
 const EDITOR_ICON_CLASS = 'jp-ImageTextEditor';
 
 
-/**
- * A class that tracks editor widgets.
- */
-export
-interface IEditorTracker extends WidgetTracker<EditorWidget> { }
-
-
-/* tslint:disable */
-/**
- * The editor tracker token.
- */
-export
-const IEditorTracker = new Token<IEditorTracker>('jupyter.services.editor-tracker');
-/* tslint:enable */
-
-
 /**
  * The editor handler extension.
  */
 export
-const editorHandlerExtension: JupyterLabPlugin<IEditorTracker> = {
-  id: 'jupyter.extensions.editor-handler',
+const editorHandlerProvider: JupyterLabPlugin<IEditorTracker> = {
+  id: 'jupyter.services.editor-handler',
   requires: [IDocumentRegistry, IMainMenu, ICommandPalette],
   provides: IEditorTracker,
   activate: activateEditorHandler,

+ 24 - 0
src/editorwidget/widget.ts

@@ -10,6 +10,10 @@ import {
   IKernel
 } from 'jupyter-js-services';
 
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
 import {
   loadModeByFileName
 } from '../codemirror';
@@ -22,6 +26,10 @@ import {
   ABCWidgetFactory, IDocumentModel, IDocumentContext
 } from '../docregistry';
 
+import {
+  WidgetTracker
+} from '../widgettracker';
+
 
 /**
  * The class name added to a dirty widget.
@@ -34,6 +42,22 @@ const DIRTY_CLASS = 'jp-mod-dirty';
 const EDITOR_CLASS = 'jp-EditorWidget';
 
 
+/**
+ * A class that tracks editor widgets.
+ */
+export
+interface IEditorTracker extends WidgetTracker<EditorWidget> {}
+
+
+/* tslint:disable */
+/**
+ * The editor tracker token.
+ */
+export
+const IEditorTracker = new Token<IEditorTracker>('jupyter.services.editor-tracker');
+/* tslint:enable */
+
+
 /**
  * A document widget for codemirrors.
  */

+ 1 - 1
src/faq/plugin.ts

@@ -17,7 +17,7 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 
 /**

+ 1 - 0
src/filebrowser/index.ts

@@ -3,3 +3,4 @@
 
 export * from './browser';
 export * from './model';
+export * from './tracker';

+ 5 - 50
src/filebrowser/plugin.ts

@@ -5,14 +5,6 @@ import {
   DisposableSet
 } from 'phosphor/lib/core/disposable';
 
-import {
-  ISignal
-} from 'phosphor/lib/core/signaling';
-
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   Menu
 } from 'phosphor/lib/ui/menu';
@@ -27,11 +19,7 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
-
-import {
-  IChangedArgs
-} from '../common/interfaces';
+} from '../commandpalette';
 
 import {
   DocumentManager
@@ -43,52 +31,19 @@ import {
 
 import {
   IMainMenu
-} from '../mainmenu/plugin';
+} from '../mainmenu';
 
 import {
   IServiceManager
-} from '../services/plugin';
+} from '../services';
 
 import {
   WidgetTracker
 } from '../widgettracker';
 
 import {
-  IWidgetOpener, FileBrowserWidget
-} from './browser';
-
-import {
-  FileBrowserModel
-} from './model';
-
-
-/* tslint:disable */
-/**
- * The path tracker token.
- */
-export
-const IPathTracker = new Token<IPathTracker>('jupyter.services.file-browser');
-/* tslint:enable */
-
-
-/**
- * An interface a file browser path tracker.
- */
-export
-interface IPathTracker {
-  /**
-   * A signal emitted when the current path changes.
-   */
-  pathChanged: ISignal<IPathTracker, IChangedArgs<string>>;
-
-  /**
-   * The current path of the filebrowser.
-   *
-   * #### Notes
-   * This is a read-only property.
-   */
-  path: string;
-}
+  FileBrowserModel, FileBrowserWidget, IPathTracker, IWidgetOpener
+} from './';
 
 
 /**

+ 43 - 0
src/filebrowser/tracker.ts

@@ -0,0 +1,43 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+import {
+  ISignal
+} from 'phosphor/lib/core/signaling';
+
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
+import {
+  IChangedArgs
+} from '../common/interfaces';
+
+
+/* tslint:disable */
+/**
+ * The path tracker token.
+ */
+export
+const IPathTracker = new Token<IPathTracker>('jupyter.services.file-browser');
+/* tslint:enable */
+
+
+/**
+ * An interface a file browser path tracker.
+ */
+export
+interface IPathTracker {
+  /**
+   * A signal emitted when the current path changes.
+   */
+  pathChanged: ISignal<IPathTracker, IChangedArgs<string>>;
+
+  /**
+   * The current path of the filebrowser.
+   *
+   * #### Notes
+   * This is a read-only property.
+   */
+  path: string;
+}

+ 2 - 2
src/help/plugin.ts

@@ -15,7 +15,7 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   IFrame
@@ -23,7 +23,7 @@ import {
 
 import {
   IMainMenu
-} from '../mainmenu/plugin';
+} from '../mainmenu';
 
 
 /**

+ 1 - 1
src/imagewidget/plugin.ts

@@ -7,7 +7,7 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   IDocumentRegistry

+ 13 - 0
src/inspector/inspector.ts

@@ -9,6 +9,10 @@ import {
   clearSignalData, defineSignal, ISignal
 } from 'phosphor/lib/core/signaling';
 
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
 import {
   Panel
 } from 'phosphor/lib/ui/panel';
@@ -67,6 +71,15 @@ const BOTTOM_TOGGLE_CLASS = 'jp-InspectorItem-bottom';
 const RIGHT_TOGGLE_CLASS = 'jp-InspectorItem-right';
 
 
+/* tslint:disable */
+/**
+ * The inspector panel token.
+ */
+export
+const IInspector = new Token<IInspector>('jupyter.services.inspector');
+/* tslint:enable */
+
+
 /**
  * An interface for an inspector panel.
  */

+ 1 - 16
src/inspector/plugin.ts

@@ -1,30 +1,15 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   JupyterLab, JupyterLabPlugin
 } from '../application';
 
 import {
-  IInspector as IBaseInspector, Inspector
+  IInspector, Inspector
 } from './';
 
 
-export
-interface IInspector extends IBaseInspector {}
-
-/* tslint:disable */
-/**
- * The inspector panel token.
- */
-export
-const IInspector = new Token<IInspector>('jupyter.services.inspector');
-/* tslint:enable */
-
 
 /**
  * A service providing an inspector panel.

+ 3 - 3
src/landing/plugin.ts

@@ -11,15 +11,15 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   IPathTracker
-} from '../filebrowser/plugin';
+} from '../filebrowser';
 
 import {
   IServiceManager
-} from '../services/plugin';
+} from '../services';
 
 /**
  * The landing page extension.

+ 1 - 1
src/leafletwidget/plugin.ts

@@ -27,7 +27,7 @@ const EXTENSIONS = ['.geojson'];
  */
 export
 const mapHandlerExtension: JupyterLabPlugin<void> = {
-  id: 'jupyter.extensions.mapHandler',
+  id: 'jupyter.extensions.map-handler',
   requires: [IDocumentRegistry],
   activate: activateMapWidget,
   autoStart: true

+ 11 - 5
src/main/plugin.ts

@@ -13,11 +13,17 @@ export
 const mainExtension: JupyterLabPlugin<void> = {
   id: 'jupyter.extensions.main',
   activate: (app: JupyterLab) => {
-    window.onbeforeunload = event => {
-      let msg = 'Are you sure you want to exit JupyterLab?';
-      msg += '\nAny unsaved changes will be lost.';
-      return msg;
-    };
+    const message = 'Are you sure you want to exit JupyterLab?\n' +
+                    'Any unsaved changes will be lost.';
+
+    // The spec for the `beforeunload` event is implemented differently by
+    // the different browser vendors. Consequently, the `event.returnValue`
+    // attribute needs to set in addition to a return value being returned.
+    // For more information, see:
+    // https://developer.mozilla.org/en/docs/Web/Events/beforeunload
+    window.addEventListener('beforeunload', event => {
+      return (event as any).returnValue = message;
+    });
   },
   autoStart: true
 };

+ 113 - 0
src/mainmenu/index.ts

@@ -0,0 +1,113 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+import {
+  find, indexOf, upperBound
+} from 'phosphor/lib/algorithm/searching';
+
+import {
+  Vector
+} from 'phosphor/lib/collections/vector';
+
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
+import {
+  Menu
+} from 'phosphor/lib/ui/menu';
+
+import {
+  MenuBar
+} from 'phosphor/lib/ui/menubar';
+
+
+/* tslint:disable */
+/**
+ * The main menu token.
+ */
+export
+const IMainMenu = new Token<IMainMenu>('jupyter.services.main-menu');
+/* tslint:enable */
+
+
+/**
+ * The main menu interface.
+ */
+export
+interface IMainMenu {
+  /**
+   * Add a new menu to the main menu bar.
+   */
+  addMenu(menu: Menu, options: IAddMenuOptions): void;
+}
+
+
+/**
+ * The options used to add a menu to the main menu.
+ */
+export
+interface IAddMenuOptions {
+  /**
+   * The rank order of the menu among its siblings.
+   */
+  rank?: number;
+}
+
+
+/**
+ * The main menu class.  It is intended to be used as a singleton.
+ */
+export
+class MainMenu extends MenuBar implements IMainMenu {
+  /**
+   * Add a new menu to the main menu bar.
+   */
+  addMenu(menu: Menu, options: IAddMenuOptions = {}): void {
+    if (indexOf(this.menus, menu) > -1) {
+      return;
+    }
+
+    let rank = 'rank' in options ? options.rank : 100;
+    let rankItem = { menu, rank };
+    let index = upperBound(this._items, rankItem, Private.itemCmp);
+
+    // Upon disposal, remove the menu reference from the rank list.
+    menu.disposed.connect(() => this._items.remove(rankItem));
+
+    this._items.insert(index, rankItem);
+    this.insertMenu(index, menu);
+  }
+
+  private _items = new Vector<Private.IRankItem>();
+}
+
+
+/**
+ * A namespace for private data.
+ */
+namespace Private {
+  /**
+   * An object which holds a menu and its sort rank.
+   */
+  export
+  interface IRankItem {
+    /**
+     * The menu for the item.
+     */
+    menu: Menu;
+
+    /**
+     * The sort rank of the menu.
+     */
+    rank: number;
+  }
+
+  /**
+   * A comparator function for menu rank items.
+   */
+  export
+  function itemCmp(first: IRankItem, second: IRankItem): number {
+    return first.rank - second.rank;
+  }
+}

+ 8 - 127
src/mainmenu/plugin.ts

@@ -1,26 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import {
-  indexOf, upperBound
-} from 'phosphor/lib/algorithm/searching';
-
-import {
-  Vector
-} from 'phosphor/lib/collections/vector';
-
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
-import {
-  Menu
-} from 'phosphor/lib/ui/menu';
-
-import {
-  MenuBar
-} from 'phosphor/lib/ui/menubar';
-
 import {
   Widget
 } from 'phosphor/lib/ui/widget';
@@ -29,6 +9,10 @@ import {
   JupyterLab, JupyterLabPlugin
 } from '../application';
 
+import {
+  IMainMenu, MainMenu
+} from './';
+
 
 /**
  * The class name for all main area portrait tab icons.
@@ -41,66 +25,6 @@ const PORTRAIT_ICON_CLASS = 'jp-MainAreaPortraitIcon';
 const JUPYTER_ICON_CLASS = 'jp-JupyterIcon';
 
 
-/* tslint:disable */
-/**
- * The main menu token.
- */
-export
-const IMainMenu = new Token<IMainMenu>('jupyter.services.main-menu');
-/* tslint:enable */
-
-
-/**
- * The main menu interface.
- */
-export
-interface IMainMenu {
-  /**
-   * Add a new menu to the main menu bar.
-   */
-  addMenu(menu: Menu, options: IAddMenuOptions): void;
-}
-
-
-/**
- * The options used to add a menu to the main menu.
- */
-export
-interface IAddMenuOptions {
-  /**
-   * The rank order of the menu among its siblings.
-   */
-  rank?: number;
-}
-
-
-/**
- * The main menu class.  It is intended to be used as a singleton.
- */
-class MainMenu implements IMainMenu {
-  /**
-   * Add a new menu to the main menu bar.
-   */
-  addMenu(menu: Menu, options: IAddMenuOptions = {}): void {
-    if (indexOf(Private.menuBar.menus, menu) > -1) {
-      return;
-    }
-
-    let rank = 'rank' in options ? options.rank : 100;
-    let rankItem = { menu, rank };
-    let index = upperBound(this._items, rankItem, Private.itemCmp);
-
-    // Upon disposal, remove the menu reference from the rank list.
-    menu.disposed.connect(() => this._items.remove(rankItem));
-
-    this._items.insert(index, rankItem);
-    Private.menuBar.insertMenu(index, menu);
-  }
-
-  private _items = new Vector<Private.IRankItem>();
-}
-
-
 /**
  * A service providing an interface to the main menu.
  */
@@ -116,58 +40,15 @@ const mainMenuProvider: JupyterLabPlugin<IMainMenu> = {
  * Activate the main menu extension.
  */
 function activateMainMenu(app: JupyterLab): IMainMenu {
-  Private.menuBar = new MenuBar({ keymap: app.keymap });
-  Private.menuBar.id = 'jp-MainMenu';
+  let menu = new MainMenu({ keymap: app.keymap });
+  menu.id = 'jp-MainMenu';
 
   let logo = new Widget();
   logo.node.className = `${PORTRAIT_ICON_CLASS} ${JUPYTER_ICON_CLASS}`;
   logo.id = 'jp-MainLogo';
 
   app.shell.addToTopArea(logo);
-  app.shell.addToTopArea(Private.menuBar);
-
-  return Private.mainMenu;
-}
-
-
-/**
- * A namespace for private data.
- */
-namespace Private {
-  /**
-   * The singleton menu bar instance.
-   */
-  export
-  let menuBar: MenuBar;
-
-  /**
-   * The singleton main menu instance.
-   */
-  export
-  const mainMenu = new MainMenu();
-
-
-  /**
-   * An object which holds a menu and its sort rank.
-   */
-  export
-  interface IRankItem {
-    /**
-     * The menu for the item.
-     */
-    menu: Menu;
-
-    /**
-     * The sort rank of the menu.
-     */
-    rank: number;
-  }
+  app.shell.addToTopArea(menu);
 
-  /**
-   * A comparator function for menu rank items.
-   */
-  export
-  function itemCmp(first: IRankItem, second: IRankItem): number {
-    return first.rank - second.rank;
-  }
+  return menu;
 }

+ 1 - 1
src/markdownwidget/plugin.ts

@@ -11,7 +11,7 @@ import {
 
 import {
   IRenderMime
-} from '../rendermime/plugin';
+} from '../rendermime';
 
 import {
   MarkdownWidgetFactory

+ 1 - 0
src/notebook/index.ts

@@ -2,3 +2,4 @@
 // Distributed under the terms of the Modified BSD License.
 
 export * from './notebook/index';
+export * from './tracker';

+ 10 - 29
src/notebook/plugin.ts

@@ -1,10 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   Menu
 } from 'phosphor/lib/ui/menu';
@@ -15,38 +11,40 @@ import {
 
 import {
   IClipboard
-} from '../clipboard/plugin';
+} from '../clipboard';
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   IMainMenu
-} from '../mainmenu/plugin';
+} from '../mainmenu';
 
 import {
-  IDocumentRegistry, restartKernel, selectKernelForContext, IWidgetFactoryOptions
+  IDocumentRegistry, IWidgetFactoryOptions,
+  restartKernel, selectKernelForContext
 } from '../docregistry';
 
 import {
   IInspector
-} from '../inspector/plugin';
+} from '../inspector';
 
 import {
   IRenderMime
-} from '../rendermime/plugin';
+} from '../rendermime';
 
 import {
   IServiceManager
-} from '../services/plugin';
+} from '../services';
 
 import {
   WidgetTracker
 } from '../widgettracker';
 
 import {
-  NotebookPanel, NotebookModelFactory, NotebookWidgetFactory, NotebookActions
+  INotebookTracker, NotebookPanel, NotebookModelFactory,
+  NotebookWidgetFactory, NotebookActions
 } from './index';
 
 
@@ -60,7 +58,6 @@ const PORTRAIT_ICON_CLASS = 'jp-MainAreaPortraitIcon';
  */
 const NOTEBOOK_ICON_CLASS = 'jp-ImageNotebook';
 
-
 /**
  * The map of command ids used by the notebook.
  */
@@ -106,22 +103,6 @@ const cmdIds = {
 };
 
 
-/* tslint:disable */
-/**
- * The notebook tracker token.
- */
-export
-const INotebookTracker = new Token<INotebookTracker>('jupyter.services.notebook-handler');
-/* tslint:enable */
-
-
-/**
- * A class that tracks notebook widgets.
- */
-export
-interface INotebookTracker extends WidgetTracker<NotebookPanel> { }
-
-
 /**
  * The notebook widget tracker provider.
  */

+ 30 - 0
src/notebook/tracker.ts

@@ -0,0 +1,30 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
+import {
+  WidgetTracker
+} from '../widgettracker';
+
+import {
+  NotebookPanel
+} from './';
+
+
+/* tslint:disable */
+/**
+ * The notebook tracker token.
+ */
+export
+const INotebookTracker = new Token<INotebookTracker>('jupyter.services.notebook-handler');
+/* tslint:enable */
+
+
+/**
+ * A class that tracks notebook widgets.
+ */
+export
+interface INotebookTracker extends WidgetTracker<NotebookPanel> {}

+ 13 - 0
src/rendermime/index.ts

@@ -1,6 +1,10 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
 import {
   Widget
 } from 'phosphor/lib/ui/widget';
@@ -10,6 +14,15 @@ import {
 } from '../sanitizer';
 
 
+/* tslint:disable */
+/**
+ * The rendermime token.
+ */
+export
+const IRenderMime = new Token<IRenderMime>('jupyter.services.rendermime');
+/* tslint:enable */
+
+
 /**
  * The rendermime interface.
  */

+ 2 - 22
src/rendermime/plugin.ts

@@ -1,10 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   JupyterLabPlugin
 } from '../application';
@@ -19,24 +15,8 @@ import {
 } from '../sanitizer';
 
 import {
-  IRenderMime as IBaseRenderMime, RenderMime
-} from './index';
-
-
-/* tslint:disable */
-/**
- * The rendermime token.
- */
-export
-const IRenderMime = new Token<IRenderMime>('jupyter.services.rendermime');
-/* tslint:enable */
-
-
-/**
- * The rendermime interface.
- */
-export
-interface IRenderMime extends IBaseRenderMime {}
+  IRenderMime, RenderMime
+} from './';
 
 
 /**

+ 1 - 1
src/running/plugin.ts

@@ -7,7 +7,7 @@ import {
 
 import {
   IServiceManager
-} from '../services/plugin';
+} from '../services';
 
 import {
   RunningSessions

+ 2 - 1
src/sanitizer/index.ts

@@ -24,7 +24,8 @@ class Sanitizer implements ISanitizer {
   }
 
   private _options: sanitize.IOptions = {
-    allowedTags: sanitize.defaults.allowedTags.concat('svg', 'h1', 'h2', 'img', 'span'),
+    allowedTags: sanitize.defaults.allowedTags
+      .concat('svg', 'h1', 'h2', 'img', 'span'),
     allowedAttributes: {
       // Allow the "rel" attribute for <a> tags.
       'a': sanitize.defaults.allowedAttributes['a'].concat('rel'),

+ 26 - 0
src/services/index.ts

@@ -0,0 +1,26 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+import {
+  IServiceManager as IBaseServiceManager
+} from 'jupyter-js-services';
+
+import {
+  Token
+} from 'phosphor/lib/core/token';
+
+
+/* tslint:disable */
+/**
+ * The default services provider token.
+ */
+export
+const IServiceManager = new Token<IServiceManager>('jupyter.services.services');
+/* tslint:enable */
+
+
+/**
+ * The service manager interface.
+ */
+export
+interface IServiceManager extends IBaseServiceManager { };

+ 4 - 20
src/services/plugin.ts

@@ -2,32 +2,16 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  createServiceManager, IServiceManager as IBaseServiceManager
+  createServiceManager
 } from 'jupyter-js-services';
 
-import {
-  Token
-} from 'phosphor/lib/core/token';
-
 import {
   JupyterLabPlugin
 } from '../application';
 
-
-/* tslint:disable */
-/**
- * The default services provider token.
- */
-export
-const IServiceManager = new Token<IServiceManager>('jupyter.services.services');
-/* tslint:enable */
-
-
-/**
- * The service manager interface.
- */
-export
-interface IServiceManager extends IBaseServiceManager { };
+import {
+  IServiceManager
+} from './';
 
 
 /**

+ 3 - 3
src/terminal/plugin.ts

@@ -11,15 +11,15 @@ import {
 
 import {
   ICommandPalette
-} from '../commandpalette/plugin';
+} from '../commandpalette';
 
 import {
   IMainMenu
-} from '../mainmenu/plugin';
+} from '../mainmenu';
 
 import {
   IServiceManager
-} from '../services/plugin';
+} from '../services';
 
 import {
   WidgetTracker