Prechádzať zdrojové kódy

Add "namespace" to app info as a prerequisite for state database prefix.

Afshin Darian 8 rokov pred
rodič
commit
bb14a9b2cf

+ 1 - 1
examples/lab/index.js

@@ -43,7 +43,7 @@ var mods = [
 
 
 window.onload = function() {
-  var lab = new JupyterLab();
+  var lab = new JupyterLab({ namespace: 'lab-example' });
   lab.registerPluginModules(mods);
   lab.start();
 }

+ 7 - 4
jupyterlab/src/main.ts

@@ -16,7 +16,8 @@ import '../../lib/default-theme/index.css';
 polyfill();
 
 
-let mods: JupyterLab.IPluginModule[] = [
+/* tslint:disable */
+const mods: JupyterLab.IPluginModule[] = [
   require('../../lib/about/plugin'),
   require('../../lib/application/plugin'),
   require('../../lib/clipboard/plugin'),
@@ -46,6 +47,7 @@ let mods: JupyterLab.IPluginModule[] = [
   require('../../lib/statedb/plugin'),
   require('../../lib/terminal/plugin')
 ];
+/* tslint:enable */
 
 
 /**
@@ -57,10 +59,11 @@ let mods: JupyterLab.IPluginModule[] = [
  */
 export
 function createLab(loader: ModuleLoader): JupyterLab {
-  let lab = new JupyterLab({
+  const lab = new JupyterLab({
     loader,
-    version: require('../../package.json').version,
-    gitDescription: process.env.GIT_DESCRIPTION
+    gitDescription: process.env.GIT_DESCRIPTION,
+    namespace: 'jupyterlab',
+    version: require('../../package.json').version
   });
   lab.registerPluginModules(mods);
   return lab;

+ 28 - 11
src/application/index.ts

@@ -39,8 +39,9 @@ class JupyterLab extends Application<ApplicationShell> {
   constructor(options: JupyterLab.IOptions = {}) {
     super();
     this._info = {
-      version:  options.version || 'unknown',
-      gitDescription: options.gitDescription || 'unknown'
+      gitDescription: options.gitDescription || 'unknown',
+      namespace: options.namespace || 'jupyterlab',
+      version:  options.version || 'unknown'
     };
     this._loader = options.loader || null;
   }
@@ -135,11 +136,6 @@ namespace JupyterLab {
    */
   export
   interface IOptions {
-    /**
-     * The version of the JupyterLab application.
-     */
-    version?: string;
-
     /**
      * The git description of the JupyterLab application.
      */
@@ -149,6 +145,22 @@ namespace JupyterLab {
      * The module loader used by the application.
      */
     loader?: ModuleLoader;
+
+    /**
+     * The namespace/prefix plugins may use to denote their origin.
+     *
+     * #### Notes
+     * This field may be used by persisten storage mechanisms such as state
+     * databases, cookies, session storage, etc.
+     *
+     * If unspecified, the default value is `'jupyterlab'`.
+     */
+    namespace?: string;
+
+    /**
+     * The version of the JupyterLab application.
+     */
+    version?: string;
   }
 
   /**
@@ -157,14 +169,19 @@ namespace JupyterLab {
   export
   interface IInfo {
     /**
-     * The version of the JupyterLab application.
+     * The git description of the JupyterLab application.
      */
-    readonly version: string;
+    readonly gitDescription: string;
 
     /**
-     * The git description of the JupyterLab application.
+     * The namespace/prefix plugins may use to denote their origin.
      */
-    readonly gitDescription: string;
+    readonly namespace: string;
+
+    /**
+     * The version of the JupyterLab application.
+     */
+    readonly version: string;
   }
 
   /**

+ 1 - 1
src/common/instancetracker.ts

@@ -411,7 +411,7 @@ namespace InstanceTracker {
   export
   interface IRestoreOptions<T extends Widget> extends IInstanceRestorer.IRestoreOptions<T> {
     /*
-     * The instance restorer to use to re-arrange restored tabs.
+     * The instance restorer to use to recreate restored widgets.
      */
     restorer: IInstanceRestorer;
 

+ 2 - 2
src/statedb/plugin.ts

@@ -26,8 +26,8 @@ import {
  * The default state database for storing application state.
  */
 const plugin: JupyterLabPlugin<IStateDB> = {
+  activate,
   id: 'jupyter.services.statedb',
-  activate: activateState,
   autoStart: true,
   provides: IStateDB,
   requires: [ICommandPalette]
@@ -43,7 +43,7 @@ export default plugin;
 /**
  * Activate the state database.
  */
-function activateState(app: JupyterLab, palette: ICommandPalette): Promise<IStateDB> {
+function activate(app: JupyterLab, palette: ICommandPalette): Promise<IStateDB> {
   let state = new StateDB();
   let version = app.info.version;
   let command = 'statedb:clear';