@jupyterlab/application 0.15.4 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -33,6 +33,10 @@ export declare class JupyterLab extends Application<ApplicationShell> {
33
33
  * The service manager used by the application.
34
34
  */
35
35
  readonly serviceManager: ServiceManager;
36
+ /**
37
+ * A list of all errors encountered when registering plugins.
38
+ */
39
+ readonly registerPluginErrors: Array<Error>;
36
40
  /**
37
41
  * Whether the application is dirty.
38
42
  */
package/lib/index.js CHANGED
@@ -49,6 +49,10 @@ var JupyterLab = /** @class */ (function (_super) {
49
49
  function JupyterLab(options) {
50
50
  if (options === void 0) { options = {}; }
51
51
  var _this = _super.call(this, { shell: new shell_1.ApplicationShell() }) || this;
52
+ /**
53
+ * A list of all errors encountered when registering plugins.
54
+ */
55
+ _this.registerPluginErrors = [];
52
56
  _this._dirtyCount = 0;
53
57
  _this._info = __assign({}, JupyterLab.defaultInfo, options);
54
58
  if (_this._info.devMode) {
@@ -125,7 +129,14 @@ var JupyterLab = /** @class */ (function (_super) {
125
129
  if (!Array.isArray(data)) {
126
130
  data = [data];
127
131
  }
128
- data.forEach(function (item) { _this.registerPlugin(item); });
132
+ data.forEach(function (item) {
133
+ try {
134
+ _this.registerPlugin(item);
135
+ }
136
+ catch (error) {
137
+ _this.registerPluginErrors.push(error);
138
+ }
139
+ });
129
140
  };
130
141
  /**
131
142
  * Register the plugins from multiple plugin modules.
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../application/src/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;;;;;;;;;;;;AAE3D,wDAAwD;AACxD,8BAA4B;AAE5B,mDAE+B;AAE/B,iDAE8B;AAE9B,uDAEiC;AAMjC,iDAE8B;AAE9B,qDAE+B;AAE/B,mDAE8B;AAE9B,iDAEyB;AAEzB,iC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CAAC,iBAAiB,CAAC;YACrD,UAAU,EAAE,sBAAU,CAAC,SAAS,CAAC,YAAY,CAAC;SAC/C;QACD,WAAW,EAAE,sBAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM;KACzE,CAAC;AAaJ,CAAC,EArHS,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAqHnB;AApOK,gCAAU","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\n// Local CSS must be loaded prior to loading other libs.\nimport '../style/index.css';\n\nimport {\n PageConfig\n} from '@jupyterlab/coreutils';\n\nimport {\n CommandLinker\n} from '@jupyterlab/apputils';\n\nimport {\n Base64ModelFactory, DocumentRegistry\n} from '@jupyterlab/docregistry';\n\nimport {\n IRenderMime\n} from '@jupyterlab/rendermime-interfaces';\n\nimport {\n ServiceManager\n} from '@jupyterlab/services';\n\nimport {\n Application, IPlugin\n} from '@phosphor/application';\n\nimport {\n DisposableDelegate, IDisposable\n} from '@phosphor/disposable';\n\nimport {\n createRendermimePlugins\n} from './mimerenderers';\n\nimport {\n ApplicationShell\n} from './shell';\n\nexport { ApplicationShell } from './shell';\nexport { ILayoutRestorer, LayoutRestorer } from './layoutrestorer';\nexport { IRouter, Router } from './router';\n\n\n/**\n * The type for all JupyterLab plugins.\n */\nexport\ntype JupyterLabPlugin<T> = IPlugin<JupyterLab, T>;\n\n\n/**\n * JupyterLab is the main application class. It is instantiated once and shared.\n */\nexport\nclass JupyterLab extends Application<ApplicationShell> {\n /**\n * Construct a new JupyterLab object.\n */\n constructor(options: JupyterLab.IOptions = {}) {\n super({ shell: new ApplicationShell() });\n this._info = { ...JupyterLab.defaultInfo, ...options };\n if (this._info.devMode) {\n this.shell.addClass('jp-mod-devMode');\n }\n\n this.serviceManager = new ServiceManager();\n\n let linker = new CommandLinker({ commands: this.commands });\n this.commandLinker = linker;\n\n let registry = this.docRegistry = new DocumentRegistry();\n registry.addModelFactory(new Base64ModelFactory());\n\n if (options.mimeExtensions) {\n let plugins = createRendermimePlugins(options.mimeExtensions);\n plugins.forEach(plugin => { this.registerPlugin(plugin); });\n }\n }\n\n /**\n * The document registry instance used by the application.\n */\n readonly docRegistry: DocumentRegistry;\n\n /**\n * The command linker used by the application.\n */\n readonly commandLinker: CommandLinker;\n\n /**\n * The service manager used by the application.\n */\n readonly serviceManager: ServiceManager;\n\n /**\n * Whether the application is dirty.\n */\n get isDirty(): boolean {\n return this._dirtyCount > 0;\n }\n\n /**\n * The information about the application.\n */\n get info(): JupyterLab.IInfo {\n return this._info;\n }\n\n /**\n * Promise that resolves when state is first restored, returning layout description.\n *\n * #### Notes\n * This is just a reference to `shell.restored`.\n */\n get restored(): Promise<ApplicationShell.ILayout> {\n return this.shell.restored;\n }\n\n /**\n * Set the application state to dirty.\n *\n * @returns A disposable used to clear the dirty state for the caller.\n */\n setDirty(): IDisposable {\n this._dirtyCount++;\n return new DisposableDelegate(() => {\n this._dirtyCount = Math.max(0, this._dirtyCount - 1);\n });\n }\n\n /**\n * Register plugins from a plugin module.\n *\n * @param mod - The plugin module to register.\n */\n registerPluginModule(mod: JupyterLab.IPluginModule): void {\n let data = mod.default;\n // Handle commonjs exports.\n if (!mod.hasOwnProperty('__esModule')) {\n data = mod as any;\n }\n if (!Array.isArray(data)) {\n data = [data];\n }\n data.forEach(item => { this.registerPlugin(item); });\n }\n\n /**\n * Register the plugins from multiple plugin modules.\n *\n * @param mods - The plugin modules to register.\n */\n registerPluginModules(mods: JupyterLab.IPluginModule[]): void {\n mods.forEach(mod => { this.registerPluginModule(mod); });\n }\n\n private _info: JupyterLab.IInfo;\n private _dirtyCount = 0;\n}\n\n\n/**\n * The namespace for `JupyterLab` class statics.\n */\nexport\nnamespace JupyterLab {\n /**\n * The options used to initialize a JupyterLab object.\n */\n export\n interface IOptions extends Partial<IInfo> {}\n\n /**\n * The information about a JupyterLab application.\n */\n export\n interface IInfo {\n /**\n * The name of the JupyterLab application.\n */\n readonly name: string;\n\n /**\n * The version of the JupyterLab application.\n */\n readonly version: string;\n\n /**\n * The namespace/prefix plugins may use to denote their origin.\n */\n readonly namespace: string;\n\n /**\n * Whether the application is in dev mode.\n */\n readonly devMode: boolean;\n\n /**\n * The collection of deferred extension patterns and matched extensions.\n */\n readonly deferred: { patterns: string[], matches: string[] };\n\n /**\n * The collection of disabled extension patterns and matched extensions.\n */\n readonly disabled: { patterns: string[], matches: string[] };\n\n /**\n * The mime renderer extensions.\n */\n readonly mimeExtensions: IRenderMime.IExtensionModule[];\n\n /**\n * The urls used by the application.\n */\n readonly urls: {\n readonly page: string,\n readonly public: string,\n readonly settings: string,\n readonly themes: string\n };\n\n /**\n * The local directories used by the application.\n */\n readonly directories: {\n readonly appSettings: string,\n readonly schemas: string,\n readonly static: string,\n readonly templates: string,\n readonly themes: string,\n readonly userSettings: string,\n readonly serverRoot: string\n };\n\n /**\n * Whether files are cached on the server.\n */\n readonly filesCached: boolean;\n }\n\n /**\n * The default application info.\n */\n export\n const defaultInfo: IInfo = {\n name: PageConfig.getOption('appName') || 'JupyterLab',\n namespace: PageConfig.getOption('appNamespace'),\n version: PageConfig.getOption('appVersion') || 'unknown',\n devMode: PageConfig.getOption('devMode').toLowerCase() === 'true',\n deferred: { patterns: [], matches: [] },\n disabled: { patterns: [], matches: [] },\n mimeExtensions: [],\n urls: {\n page: PageConfig.getOption('pageUrl'),\n public: PageConfig.getOption('publicUrl'),\n settings: PageConfig.getOption('settingsUrl'),\n themes: PageConfig.getOption('themesUrl')\n },\n directories: {\n appSettings: PageConfig.getOption('appSettingsDir'),\n schemas: PageConfig.getOption('schemasDir'),\n static: PageConfig.getOption('staticDir'),\n templates: PageConfig.getOption('templatesDir'),\n themes: PageConfig.getOption('themesDir'),\n userSettings: PageConfig.getOption('userSettingsDir'),\n serverRoot: PageConfig.getOption('serverRoot')\n },\n filesCached: PageConfig.getOption('cacheFiles').toLowerCase() === 'true'\n };\n\n /**\n * The interface for a module that exports a plugin or plugins as\n * the default value.\n */\n export\n interface IPluginModule {\n /**\n * The default export.\n */\n default: JupyterLabPlugin<any> | JupyterLabPlugin<any>[];\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../application/src/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;;;;;;;;;;;;AAE3D,wDAAwD;AACxD,8BAA4B;AAE5B,mDAE+B;AAE/B,iDAE8B;AAE9B,uDAEiC;AAMjC,iDAE8B;AAE9B,qDAE+B;AAE/B,mDAE8B;AAE9B,iDAEyB;AAEzB,iCAEiB;AAEjB,iCAA2C;AAAlC,mCAAA,gBAAgB,CAAA;AACzB,mDAAmE;AAA1D,2CAAA,eAAe,CAAA;AAAE,0CAAA,cAAc,CAAA;AACxC,mCAA2C;AAAlC,2BAAA,OAAO,CAAA;AAAE,0BAAA,MAAM,CAAA;AAUxB;;GAEG;AACH;IACyB,8BAA6B;IACpD;;OAEG;IACH,oBAAY,OAAiC;QAAjC,wBAAA,EAAA,YAAiC;QAA7C,YACE,kBAAM,EAAE,KAAK,EAAE,IAAI,wBAAgB,EAAE,EAAE,CAAC,SAkBzC;QAiBD;;WAEG;QACM,0BAAoB,GAAiB,EAAE,CAAC;QAuEzC,iBAAW,GAAG,CAAC,CAAC;QA5GtB,KAAI,CAAC,KAAK,gBAAQ,UAAU,CAAC,WAAW,EAAK,OAAO,CAAE,CAAC;QACvD,EAAE,CAAC,CAAC,KAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACvB,KAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACxC,CAAC;QAED,KAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAE3C,IAAI,MAAM,GAAG,IAAI,wBAAa,CAAC,EAAE,QAAQ,EAAE,KAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC5D,KAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAE5B,I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ACJ,IAAI,EAAE,sBAAU,CAAC,SAAS,CAAC,SAAS,CAAC;YACrC,MAAM,EAAE,sBAAU,CAAC,SAAS,CAAC,WAAW,CAAC;YACzC,QAAQ,EAAE,sBAAU,CAAC,SAAS,CAAC,aAAa,CAAC;YAC7C,MAAM,EAAE,sBAAU,CAAC,SAAS,CAAC,WAAW,CAAC;SAC1C;QACD,WAAW,EAAE;YACX,WAAW,EAAE,sBAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACnD,OAAO,EAAE,sBAAU,CAAC,SAAS,CAAC,YAAY,CAAC;YAC3C,MAAM,EAAE,sBAAU,CAAC,SAAS,CAAC,WAAW,CAAC;YACzC,SAAS,EAAE,sBAAU,CAAC,SAAS,CAAC,cAAc,CAAC;YAC/C,MAAM,EAAE,sBAAU,CAAC,SAAS,CAAC,WAAW,CAAC;YACzC,YAAY,EAAE,sBAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC;YACrD,UAAU,EAAE,sBAAU,CAAC,SAAS,CAAC,YAAY,CAAC;SAC/C;QACD,WAAW,EAAE,sBAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM;KACzE,CAAC;AAaJ,CAAC,EArHS,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAqHnB;AA/OK,gCAAU","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\n// Local CSS must be loaded prior to loading other libs.\nimport '../style/index.css';\n\nimport {\n PageConfig\n} from '@jupyterlab/coreutils';\n\nimport {\n CommandLinker\n} from '@jupyterlab/apputils';\n\nimport {\n Base64ModelFactory, DocumentRegistry\n} from '@jupyterlab/docregistry';\n\nimport {\n IRenderMime\n} from '@jupyterlab/rendermime-interfaces';\n\nimport {\n ServiceManager\n} from '@jupyterlab/services';\n\nimport {\n Application, IPlugin\n} from '@phosphor/application';\n\nimport {\n DisposableDelegate, IDisposable\n} from '@phosphor/disposable';\n\nimport {\n createRendermimePlugins\n} from './mimerenderers';\n\nimport {\n ApplicationShell\n} from './shell';\n\nexport { ApplicationShell } from './shell';\nexport { ILayoutRestorer, LayoutRestorer } from './layoutrestorer';\nexport { IRouter, Router } from './router';\n\n\n/**\n * The type for all JupyterLab plugins.\n */\nexport\ntype JupyterLabPlugin<T> = IPlugin<JupyterLab, T>;\n\n\n/**\n * JupyterLab is the main application class. It is instantiated once and shared.\n */\nexport\nclass JupyterLab extends Application<ApplicationShell> {\n /**\n * Construct a new JupyterLab object.\n */\n constructor(options: JupyterLab.IOptions = {}) {\n super({ shell: new ApplicationShell() });\n this._info = { ...JupyterLab.defaultInfo, ...options };\n if (this._info.devMode) {\n this.shell.addClass('jp-mod-devMode');\n }\n\n this.serviceManager = new ServiceManager();\n\n let linker = new CommandLinker({ commands: this.commands });\n this.commandLinker = linker;\n\n let registry = this.docRegistry = new DocumentRegistry();\n registry.addModelFactory(new Base64ModelFactory());\n\n if (options.mimeExtensions) {\n let plugins = createRendermimePlugins(options.mimeExtensions);\n plugins.forEach(plugin => { this.registerPlugin(plugin); });\n }\n }\n\n /**\n * The document registry instance used by the application.\n */\n readonly docRegistry: DocumentRegistry;\n\n /**\n * The command linker used by the application.\n */\n readonly commandLinker: CommandLinker;\n\n /**\n * The service manager used by the application.\n */\n readonly serviceManager: ServiceManager;\n\n /**\n * A list of all errors encountered when registering plugins.\n */\n readonly registerPluginErrors: Array<Error> = [];\n\n /**\n * Whether the application is dirty.\n */\n get isDirty(): boolean {\n return this._dirtyCount > 0;\n }\n\n /**\n * The information about the application.\n */\n get info(): JupyterLab.IInfo {\n return this._info;\n }\n\n /**\n * Promise that resolves when state is first restored, returning layout description.\n *\n * #### Notes\n * This is just a reference to `shell.restored`.\n */\n get restored(): Promise<ApplicationShell.ILayout> {\n return this.shell.restored;\n }\n\n /**\n * Set the application state to dirty.\n *\n * @returns A disposable used to clear the dirty state for the caller.\n */\n setDirty(): IDisposable {\n this._dirtyCount++;\n return new DisposableDelegate(() => {\n this._dirtyCount = Math.max(0, this._dirtyCount - 1);\n });\n }\n\n /**\n * Register plugins from a plugin module.\n *\n * @param mod - The plugin module to register.\n */\n registerPluginModule(mod: JupyterLab.IPluginModule): void {\n let data = mod.default;\n // Handle commonjs exports.\n if (!mod.hasOwnProperty('__esModule')) {\n data = mod as any;\n }\n if (!Array.isArray(data)) {\n data = [data];\n }\n data.forEach(item => {\n try {\n this.registerPlugin(item);\n } catch (error) {\n this.registerPluginErrors.push(error);\n }\n });\n }\n\n /**\n * Register the plugins from multiple plugin modules.\n *\n * @param mods - The plugin modules to register.\n */\n registerPluginModules(mods: JupyterLab.IPluginModule[]): void {\n mods.forEach(mod => { this.registerPluginModule(mod); });\n }\n\n private _info: JupyterLab.IInfo;\n private _dirtyCount = 0;\n}\n\n\n/**\n * The namespace for `JupyterLab` class statics.\n */\nexport\nnamespace JupyterLab {\n /**\n * The options used to initialize a JupyterLab object.\n */\n export\n interface IOptions extends Partial<IInfo> {}\n\n /**\n * The information about a JupyterLab application.\n */\n export\n interface IInfo {\n /**\n * The name of the JupyterLab application.\n */\n readonly name: string;\n\n /**\n * The version of the JupyterLab application.\n */\n readonly version: string;\n\n /**\n * The namespace/prefix plugins may use to denote their origin.\n */\n readonly namespace: string;\n\n /**\n * Whether the application is in dev mode.\n */\n readonly devMode: boolean;\n\n /**\n * The collection of deferred extension patterns and matched extensions.\n */\n readonly deferred: { patterns: string[], matches: string[] };\n\n /**\n * The collection of disabled extension patterns and matched extensions.\n */\n readonly disabled: { patterns: string[], matches: string[] };\n\n /**\n * The mime renderer extensions.\n */\n readonly mimeExtensions: IRenderMime.IExtensionModule[];\n\n /**\n * The urls used by the application.\n */\n readonly urls: {\n readonly page: string,\n readonly public: string,\n readonly settings: string,\n readonly themes: string\n };\n\n /**\n * The local directories used by the application.\n */\n readonly directories: {\n readonly appSettings: string,\n readonly schemas: string,\n readonly static: string,\n readonly templates: string,\n readonly themes: string,\n readonly userSettings: string,\n readonly serverRoot: string\n };\n\n /**\n * Whether files are cached on the server.\n */\n readonly filesCached: boolean;\n }\n\n /**\n * The default application info.\n */\n export\n const defaultInfo: IInfo = {\n name: PageConfig.getOption('appName') || 'JupyterLab',\n namespace: PageConfig.getOption('appNamespace'),\n version: PageConfig.getOption('appVersion') || 'unknown',\n devMode: PageConfig.getOption('devMode').toLowerCase() === 'true',\n deferred: { patterns: [], matches: [] },\n disabled: { patterns: [], matches: [] },\n mimeExtensions: [],\n urls: {\n page: PageConfig.getOption('pageUrl'),\n public: PageConfig.getOption('publicUrl'),\n settings: PageConfig.getOption('settingsUrl'),\n themes: PageConfig.getOption('themesUrl')\n },\n directories: {\n appSettings: PageConfig.getOption('appSettingsDir'),\n schemas: PageConfig.getOption('schemasDir'),\n static: PageConfig.getOption('staticDir'),\n templates: PageConfig.getOption('templatesDir'),\n themes: PageConfig.getOption('themesDir'),\n userSettings: PageConfig.getOption('userSettingsDir'),\n serverRoot: PageConfig.getOption('serverRoot')\n },\n filesCached: PageConfig.getOption('cacheFiles').toLowerCase() === 'true'\n };\n\n /**\n * The interface for a module that exports a plugin or plugins as\n * the default value.\n */\n export\n interface IPluginModule {\n /**\n * The default export.\n */\n default: JupyterLabPlugin<any> | JupyterLabPlugin<any>[];\n }\n}\n"]}
@@ -181,6 +181,8 @@ var LayoutRestorer = /** @class */ (function () {
181
181
  registry: this._registry,
182
182
  state: this._state,
183
183
  when: when ? [first].concat(when) : first
184
+ }).catch(function (error) {
185
+ console.error(error);
184
186
  });
185
187
  this._promises.push(promise);
186
188
  return promise;
@@ -1 +1 @@
1
- {"version":3,"file":"layoutrestorer.js","sourceRoot":"","sources":["../../../../application/src/layoutrestorer.ts"],"names":[],"mappings":";AAAA;;;+EAG+E;;AAc/E,iDAE6B;AAE7B,mDAE8B;AAY9B,oBAAoB;AACpB;;GAEG;AAEG,QAAA,eAAe,GAAG,IAAI,iBAAK,CAAkB,yCAAyC,CAAC,CAAC;AAmE9F;;GAEG;AACH,IAAM,GAAG,GAAG,sBAAsB,CAAC;AA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,CAAC;IAED;;;;;;;;OAQG;IACH,yBACyB,IAAgB,EAAE,KAA0B;QACnE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACV,MAAM,CAAC,IAAI,CAAC;QACd,CAAC;QAED,IAAM,IAAI,GAAI,IAAY,CAAC,OAAO,IAAI,IAAI,CAAC;QAC3C,IAAM,IAAI,GAAI,IAAY,CAAC,IAAI,IAAI,IAAI,CAAC;QACxC,IAAM,IAAI,GAAI,IAAY,CAAC,IAAI,IAAI,IAAI,CAAC;QAExC,MAAM,CAAC;YACL,aAAa,EAAE,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI;YACjE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;YAC1D,IAAI,EAAE,IAAI,KAAK,mBAAmB,IAAI,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI;gBACrE,CAAC,CAAC,IAAI;SACT,CAAC;IACJ,CAAC;IAfQ,uBAAe,kBAevB,CAAA;AACH,CAAC,EA5PS,OAAO,KAAP,OAAO,QA4PhB","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\n\nimport {\n InstanceTracker\n} from '@jupyterlab/apputils';\n\nimport {\n IStateDB\n} from '@jupyterlab/coreutils';\n\nimport {\n CommandRegistry\n} from '@phosphor/commands';\n\nimport {\n JSONObject, PromiseDelegate, ReadonlyJSONObject, Token\n} from '@phosphor/coreutils';\n\nimport {\n AttachedProperty\n} from '@phosphor/properties';\n\nimport {\n DockPanel, Widget\n} from '@phosphor/widgets';\n\nimport {\n ApplicationShell\n} from './shell';\n\n\n\n/* tslint:disable */\n/**\n * The layout restorer token.\n */\nexport\nconst ILayoutRestorer = new Token<ILayoutRestorer>('@jupyterlab/application:ILayoutRestorer');\n/* tslint:enable */\n\n\n/**\n * A static class that restores the widgets of the application when it reloads.\n */\nexport\ninterface ILayoutRestorer {\n /**\n * A promise resolved when the layout restorer is ready to receive signals.\n */\n restored: Promise<void>;\n\n /**\n * Add a widget to be tracked by the layout restorer.\n */\n add(widget: Widget, name: string): void;\n\n /**\n * Restore the widgets of a particular instance tracker.\n *\n * @param tracker - The instance tracker whose widgets will be restored.\n *\n * @param options - The restoration options.\n */\n restore(tracker: InstanceTracker<any>, options: ILayoutRestorer.IRestoreOptions<any>): void;\n}\n\n\n/**\n * A namespace for the layout restorer.\n */\nexport\nnamespace ILayoutRestorer {\n /**\n * The state restoration configuration options.\n */\n export\n interface IRestoreOptions<T extends Widget> {\n /**\n * The command to execute when restoring instances.\n */\n command: string;\n\n /**\n * A function that returns the args needed to restore an instance.\n */\n args: (widget: T) => ReadonlyJSONObject;\n\n /**\n * A function that returns a unique persistent name for this instance.\n */\n name: (widget: T) => string;\n\n /**\n * The point after which it is safe to restore state.\n *\n * #### Notes\n * By definition, this promise or promises will happen after the application\n * has `started`.\n */\n when?: Promise<any> | Array<Promise<any>>;\n }\n}\n\n\n/**\n * The state database key for restorer data.\n */\nconst KEY = 'layout-restorer:data';\n\n\n/**\n * The default implementation of a layout restorer.\n *\n * #### Notes\n * The lifecycle for state restoration is subtle. The sequence of events is:\n *\n * 1. The layout restorer plugin is instantiated and makes a `fetch` call to\n * the database that stores the layout restoration data. The `fetch` call\n * returns a promise that resolves in step 6, below.\n *\n * 2. Other plugins that care about state restoration require the layout\n * restorer as a dependency.\n *\n * 3. As each load-time plugin initializes (which happens before the lab\n * application has `started`), it instructs the layout restorer whether\n * the restorer ought to `restore` its state by passing in its tracker.\n * Alternatively, a plugin that does not require its own instance tracker\n * (because perhaps it only creates a single widget, like a command palette),\n * can simply `add` its widget along with a persistent unique name to the\n * layout restorer so that its layout state can be restored when the lab\n * application restores.\n *\n * 4. After all the load-time plugins have finished initializing, the lab\n * application `started` promise will resolve. This is the `first`\n * promise that the layout restorer waits for. By this point, all of the\n * plugins that care about restoration will have instructed the layout\n * restorer to `restore` their state.\n *\n * 5. The layout restorer will then instruct each plugin's instance tracker\n * to restore its state and reinstantiate whichever widgets it wants. The\n * tracker returns a promise to the layout restorer that resolves when it\n * has completed restoring the tracked widgets it cares about.\n *\n * 6. As each instance tracker finishes restoring the widget instances it cares\n * about, it resolves the promise that was made to the layout restorer\n * (in step 5). After all of the promises that the restorer is awaiting have\n * resolved, the restorer then resolves the outstanding `fetch` promise\n * (from step 1) and hands off a layout state object to the application\n * shell's `restoreLayout` method for restoration.\n *\n * 7. Once the application shell has finished restoring the layout, the\n * JupyterLab application's `restored` promise is resolved.\n *\n * Of particular note are steps 5 and 6: since state restoration of plugins\n * is accomplished by executing commands, the command that is used to restore\n * the state of each plugin must return a promise that only resolves when the\n * widget has been created and added to the plugin's instance tracker.\n */\nexport\nclass LayoutRestorer implements ILayoutRestorer {\n /**\n * Create a layout restorer.\n */\n constructor(options: LayoutRestorer.IOptions) {\n this._registry = options.registry;\n this._state = options.state;\n this._first = options.first;\n this._first\n .then(() => { this._firstDone = true; })\n .then(() => Promise.all(this._promises))\n .then(() => {\n this._promisesDone = true;\n\n // Release the tracker set.\n this._trackers.clear();\n })\n .then(() => { this._restored.resolve(void 0); });\n }\n\n /**\n * A promise resolved when the layout restorer is ready to receive signals.\n */\n get restored(): Promise<void> {\n return this._restored.promise;\n }\n\n /**\n * Add a widget to be tracked by the layout restorer.\n */\n add(widget: Widget, name: string): void {\n Private.nameProperty.set(widget, name);\n this._widgets.set(name, widget);\n widget.disposed.connect(this._onWidgetDisposed, this);\n }\n\n /**\n * Fetch the layout state for the application.\n *\n * #### Notes\n * Fetching the layout relies on all widget restoration to be complete, so\n * calls to `fetch` are guaranteed to return after restoration is complete.\n */\n fetch(): Promise<ApplicationShell.ILayout> {\n const blank: ApplicationShell.ILayout = {\n fresh: true, mainArea: null, leftArea: null, rightArea: null\n };\n let layout = this._state.fetch(KEY);\n\n return Promise.all([layout, this.restored]).then(([data]) => {\n if (!data) {\n return blank;\n }\n\n const { main, left, right } = data as Private.ILayout;\n\n // If any data exists, then this is not a fresh session.\n const fresh = false;\n\n // Rehydrate main area.\n const mainArea = this._rehydrateMainArea(main);\n\n // Rehydrate left area.\n const leftArea = this._rehydrateSideArea(left);\n\n // Rehydrate right area.\n const rightArea = this._rehydrateSideArea(right);\n\n return { fresh, mainArea, leftArea, rightArea };\n }).catch(() => blank); // Let fetch fail gracefully; return blank slate.\n }\n\n /**\n * Restore the widgets of a particular instance tracker.\n *\n * @param tracker - The instance tracker whose widgets will be restored.\n *\n * @param options - The restoration options.\n */\n restore(tracker: InstanceTracker<Widget>, options: ILayoutRestorer.IRestoreOptions<Widget>): Promise<any> {\n const warning = 'restore() can only be called before `first` has resolved.';\n\n if (this._firstDone) {\n console.warn(warning);\n return Promise.reject(warning);\n }\n\n const { namespace } = tracker;\n if (this._trackers.has(namespace)) {\n let warning = `A tracker namespaced ${namespace} was already restored.`;\n console.warn(warning);\n return Promise.reject(warning);\n }\n\n const { args, command, name, when } = options;\n\n // Add the tracker to the private trackers collection.\n this._trackers.add(namespace);\n\n // Whenever a new widget is added to the tracker, record its name.\n tracker.widgetAdded.connect((sender: any, widget: Widget) => {\n const widgetName = name(widget);\n if (widgetName) {\n this.add(widget, `${namespace}:${widgetName}`);\n }\n }, this);\n\n // Whenever a widget is updated, get its new name.\n tracker.widgetUpdated.connect((sender, widget) => {\n const widgetName = name(widget);\n if (widgetName) {\n let name = `${namespace}:${widgetName}`;\n Private.nameProperty.set(widget, name);\n this._widgets.set(name, widget);\n }\n });\n\n const first = this._first;\n const promise = tracker.restore({\n args, command, name,\n registry: this._registry,\n state: this._state,\n when: when ? [first].concat(when) : first\n });\n\n this._promises.push(promise);\n return promise;\n }\n\n /**\n * Save the layout state for the application.\n */\n save(data: ApplicationShell.ILayout): Promise<void> {\n // If there are promises that are unresolved, bail.\n if (!this._promisesDone) {\n let warning = 'save() was called prematurely.';\n console.warn(warning);\n return Promise.reject(warning);\n }\n\n let dehydrated: Private.ILayout = {};\n\n // Dehydrate main area.\n dehydrated.main = this._dehydrateMainArea(data.mainArea);\n\n // Dehydrate left area.\n dehydrated.left = this._dehydrateSideArea(data.leftArea);\n\n // Dehydrate right area.\n dehydrated.right = this._dehydrateSideArea(data.rightArea);\n\n return this._state.save(KEY, dehydrated);\n }\n\n /**\n * Dehydrate a main area description into a serializable object.\n */\n private _dehydrateMainArea(area: ApplicationShell.IMainArea | null): Private.IMainArea | null {\n if (!area) {\n return null;\n }\n return Private.serializeMain(area);\n }\n\n /**\n * Reydrate a serialized main area description object.\n *\n * #### Notes\n * This function consumes data that can become corrupted, so it uses type\n * coercion to guarantee the dehydrated object is safely processed.\n */\n private _rehydrateMainArea(area?: Private.IMainArea | null): ApplicationShell.IMainArea | null {\n if (!area) {\n return null;\n }\n return Private.deserializeMain(area, this._widgets);\n }\n\n /**\n * Dehydrate a side area description into a serializable object.\n */\n private _dehydrateSideArea(area?: ApplicationShell.ISideArea | null): Private.ISideArea | null {\n if (!area) {\n return null;\n }\n let dehydrated: Private.ISideArea = { collapsed: area.collapsed };\n if (area.currentWidget) {\n let current = Private.nameProperty.get(area.currentWidget);\n if (current) {\n dehydrated.current = current;\n }\n }\n if (area.widgets) {\n dehydrated.widgets = area.widgets\n .map(widget => Private.nameProperty.get(widget))\n .filter(name => !!name);\n }\n return dehydrated;\n }\n\n /**\n * Reydrate a serialized side area description object.\n *\n * #### Notes\n * This function consumes data that can become corrupted, so it uses type\n * coercion to guarantee the dehydrated object is safely processed.\n */\n private _rehydrateSideArea(area?: Private.ISideArea | null): ApplicationShell.ISideArea {\n if (!area) {\n return { collapsed: true, currentWidget: null, widgets: null };\n }\n let internal = this._widgets;\n const collapsed = area.hasOwnProperty('collapsed') ? !!area.collapsed\n : false;\n const currentWidget = area.current && internal.has(`${area.current}`) ?\n internal.get(`${area.current}`) : null;\n const widgets = !Array.isArray(area.widgets) ? null\n : area.widgets\n .map(name => internal.has(`${name}`) ? internal.get(`${name}`) : null)\n .filter(widget => !!widget);\n return {\n collapsed,\n currentWidget: currentWidget!,\n widgets: widgets as Widget[] | null\n };\n }\n\n /**\n * Handle a widget disposal.\n */\n private _onWidgetDisposed(widget: Widget): void {\n let name = Private.nameProperty.get(widget);\n this._widgets.delete(name);\n }\n\n private _first: Promise<any>;\n private _firstDone = false;\n private _promisesDone = false;\n private _promises: Promise<any>[] = [];\n private _restored = new PromiseDelegate<void>();\n private _registry: CommandRegistry ;\n private _state: IStateDB;\n private _trackers = new Set<string>();\n private _widgets = new Map<string, Widget>();\n}\n\n\n/**\n * A namespace for `LayoutRestorer` statics.\n */\nexport\nnamespace LayoutRestorer {\n /**\n * The configuration options for layout restorer instantiation.\n */\n export\n interface IOptions {\n /**\n * The initial promise that has to be resolved before restoration.\n *\n * #### Notes\n * This promise should equal the JupyterLab application `started` notifier.\n */\n first: Promise<any>;\n\n /**\n * The application command registry.\n */\n registry: CommandRegistry;\n\n /**\n * The state database instance.\n */\n state: IStateDB;\n }\n}\n\n/*\n * A namespace for private data.\n */\nnamespace Private {\n /**\n * The dehydrated state of the application layout.\n *\n * #### Notes\n * This format is JSON serializable and saved in the state database.\n * It is meant to be a data structure can translate into an\n * `ApplicationShell.ILayout` data structure for consumption by\n * the application shell.\n */\n export\n interface ILayout extends JSONObject {\n /**\n * The main area of the user interface.\n */\n main?: IMainArea | null;\n\n /**\n * The left area of the user interface.\n */\n left?: ISideArea | null;\n\n /**\n * The right area of the user interface.\n */\n right?: ISideArea | null;\n }\n\n /**\n * The restorable description of the main application area.\n */\n export\n interface IMainArea extends JSONObject {\n /**\n * The current widget that has application focus.\n */\n current?: string | null;\n\n /**\n * The main application dock panel.\n */\n dock?: ISplitArea | ITabArea | null;\n\n /**\n * The document mode (i.e., multiple/single) of the main dock panel.\n */\n mode?: DockPanel.Mode | null;\n }\n\n /**\n * The restorable description of a sidebar in the user interface.\n */\n export\n interface ISideArea extends JSONObject {\n /**\n * A flag denoting whether the sidebar has been collapsed.\n */\n collapsed?: boolean | null;\n\n /**\n * The current widget that has side area focus.\n */\n current?: string | null;\n\n /**\n * The collection of widgets held by the sidebar.\n */\n widgets?: Array<string> | null;\n }\n\n /**\n * The restorable description of a tab area in the user interface.\n */\n export\n interface ITabArea extends JSONObject {\n /**\n * The type indicator of the serialized tab area.\n */\n type: 'tab-area';\n\n /**\n * The widgets in the tab area.\n */\n widgets: Array<string> | null;\n\n /**\n * The index of the selected tab.\n */\n currentIndex: number;\n }\n\n /**\n * The restorable description of a split area in the user interface.\n */\n export\n interface ISplitArea extends JSONObject {\n /**\n * The type indicator of the serialized split area.\n */\n type: 'split-area';\n\n /**\n * The orientation of the split area.\n */\n orientation: 'horizontal' | 'vertical';\n\n /**\n * The children in the split area.\n */\n children: Array<ITabArea | ISplitArea> | null;\n\n /**\n * The sizes of the children.\n */\n sizes: Array<number>;\n }\n\n /**\n * An attached property for a widget's ID in the state database.\n */\n export\n const nameProperty = new AttachedProperty<Widget, string>({\n name: 'name',\n create: owner => ''\n });\n\n /**\n * Serialize individual areas within the main area.\n */\n function serializeArea(area: ApplicationShell.AreaConfig | null): ITabArea | ISplitArea | null {\n if (!area || !area.type) {\n return null;\n }\n\n if (area.type === 'tab-area') {\n return {\n type: 'tab-area',\n currentIndex: area.currentIndex,\n widgets: area.widgets\n .map(widget => nameProperty.get(widget))\n .filter(name => !!name)\n };\n }\n\n return {\n type: 'split-area',\n orientation: area.orientation,\n sizes: area.sizes,\n children: area.children.map(serializeArea)\n .filter(area => !!area) as (ITabArea | ISplitArea)[]\n };\n }\n\n /**\n * Return a dehydrated, serializable version of the main dock panel.\n */\n export\n function serializeMain(area: ApplicationShell.IMainArea): IMainArea {\n let dehydrated: IMainArea = {\n dock: area && area.dock && serializeArea(area.dock.main) || null\n };\n if (area) {\n dehydrated.mode = area.mode;\n if (area.currentWidget) {\n let current = Private.nameProperty.get(area.currentWidget);\n if (current) {\n dehydrated.current = current;\n }\n }\n }\n return dehydrated;\n }\n\n /**\n * Deserialize individual areas within the main area.\n *\n * #### Notes\n * Because this data comes from a potentially unreliable foreign source, it is\n * typed as a `JSONObject`; but the actual expected type is:\n * `ITabArea | ISplitArea`.\n *\n * For fault tolerance, types are manually checked in deserialization.\n */\n function deserializeArea(area: JSONObject, names: Map<string, Widget>): ApplicationShell.AreaConfig | null {\n if (!area) {\n return null;\n }\n\n // Because this data is saved to a foreign data source, its type safety is\n // not guaranteed when it is retrieved, so exhaustive checks are necessary.\n const type = (area as any).type as string || 'unknown';\n if (type === 'unknown' || (type !== 'tab-area' && type !== 'split-area')) {\n console.warn(`Attempted to deserialize unknown type: ${type}`);\n return null;\n }\n\n if (type === 'tab-area') {\n const { currentIndex, widgets } = area as ITabArea;\n let hydrated: ApplicationShell.AreaConfig = {\n type: 'tab-area',\n currentIndex: currentIndex || 0,\n widgets: widgets && widgets.map(widget => names.get(widget))\n .filter(widget => !!widget) as Widget[] || []\n };\n\n // Make sure the current index is within bounds.\n if (hydrated.currentIndex > hydrated.widgets.length - 1) {\n hydrated.currentIndex = 0;\n }\n\n return hydrated;\n }\n\n const { orientation, sizes, children } = area as ISplitArea;\n let hydrated: ApplicationShell.AreaConfig = {\n type: 'split-area',\n orientation: orientation,\n sizes: sizes || [],\n children: children &&\n children.map(child => deserializeArea(child, names))\n .filter(widget => !!widget) as ApplicationShell.AreaConfig[] || []\n };\n\n return hydrated;\n }\n\n /**\n * Return the hydrated version of the main dock panel, ready to restore.\n *\n * #### Notes\n * Because this data comes from a potentially unreliable foreign source, it is\n * typed as a `JSONObject`; but the actual expected type is: `IMainArea`.\n *\n * For fault tolerance, types are manually checked in deserialization.\n */\n export\n function deserializeMain(area: JSONObject, names: Map<string, Widget>): ApplicationShell.IMainArea | null {\n if (!area) {\n return null;\n }\n\n const name = (area as any).current || null;\n const dock = (area as any).dock || null;\n const mode = (area as any).mode || null;\n\n return {\n currentWidget: name && names.has(name) && names.get(name) || null,\n dock: dock ? { main: deserializeArea(dock, names) } : null,\n mode: mode === 'multiple-document' || mode === 'single-document' ? mode\n : null\n };\n }\n}\n"]}
1
+ {"version":3,"file":"layoutrestorer.js","sourceRoot":"","sources":["../../../../application/src/layoutrestorer.ts"],"names":[],"mappings":";AAAA;;;+EAG+E;;AAc/E,iDAE6B;AAE7B,mDAE8B;AAY9B,oBAAoB;AACpB;;GAEG;AAEG,QAAA,eAAe,GAAG,IAAI,iBAAK,CAAkB,yCAAyC,CAAC,CAAC;AAmE9F;;GAEG;AACH,IAAM,GAAG,GAAG,sBAAsB,CAAC;AAGnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH;IAEE;;OAEG;IACH,wBAAY,OAAgC;QAA5C,iBAeC;QA4NO,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAG,KAAK,CAAC;QACtB,cAAS,GAAmB,EAAE,CAAC;QAC/B,cAAS,GAAG,IAAI,2BAAe,EAAQ,CAAC;QAGxC,cAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QAC9B,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;QAjP3C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAE5B,IAAI,CAAC,MAAM;aACR,IAAI,CAAC,cAAQ,KAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;aACvC,IAAI,CAAC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,KAAI,CAAC,SAAS,CAAC,EAA3B,CAA2B,CAAC;aACvC,IAAI,CAAC;YACJ,KAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAE1B,2BAA2B;YAC3B,KAAI,CAAC,SAAS,CAAC,KAAK,EAAE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AfQ,uBAAe,kBAevB,CAAA;AACH,CAAC,EA5PS,OAAO,KAAP,OAAO,QA4PhB","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\n\nimport {\n InstanceTracker\n} from '@jupyterlab/apputils';\n\nimport {\n IStateDB\n} from '@jupyterlab/coreutils';\n\nimport {\n CommandRegistry\n} from '@phosphor/commands';\n\nimport {\n JSONObject, PromiseDelegate, ReadonlyJSONObject, Token\n} from '@phosphor/coreutils';\n\nimport {\n AttachedProperty\n} from '@phosphor/properties';\n\nimport {\n DockPanel, Widget\n} from '@phosphor/widgets';\n\nimport {\n ApplicationShell\n} from './shell';\n\n\n\n/* tslint:disable */\n/**\n * The layout restorer token.\n */\nexport\nconst ILayoutRestorer = new Token<ILayoutRestorer>('@jupyterlab/application:ILayoutRestorer');\n/* tslint:enable */\n\n\n/**\n * A static class that restores the widgets of the application when it reloads.\n */\nexport\ninterface ILayoutRestorer {\n /**\n * A promise resolved when the layout restorer is ready to receive signals.\n */\n restored: Promise<void>;\n\n /**\n * Add a widget to be tracked by the layout restorer.\n */\n add(widget: Widget, name: string): void;\n\n /**\n * Restore the widgets of a particular instance tracker.\n *\n * @param tracker - The instance tracker whose widgets will be restored.\n *\n * @param options - The restoration options.\n */\n restore(tracker: InstanceTracker<any>, options: ILayoutRestorer.IRestoreOptions<any>): void;\n}\n\n\n/**\n * A namespace for the layout restorer.\n */\nexport\nnamespace ILayoutRestorer {\n /**\n * The state restoration configuration options.\n */\n export\n interface IRestoreOptions<T extends Widget> {\n /**\n * The command to execute when restoring instances.\n */\n command: string;\n\n /**\n * A function that returns the args needed to restore an instance.\n */\n args: (widget: T) => ReadonlyJSONObject;\n\n /**\n * A function that returns a unique persistent name for this instance.\n */\n name: (widget: T) => string;\n\n /**\n * The point after which it is safe to restore state.\n *\n * #### Notes\n * By definition, this promise or promises will happen after the application\n * has `started`.\n */\n when?: Promise<any> | Array<Promise<any>>;\n }\n}\n\n\n/**\n * The state database key for restorer data.\n */\nconst KEY = 'layout-restorer:data';\n\n\n/**\n * The default implementation of a layout restorer.\n *\n * #### Notes\n * The lifecycle for state restoration is subtle. The sequence of events is:\n *\n * 1. The layout restorer plugin is instantiated and makes a `fetch` call to\n * the database that stores the layout restoration data. The `fetch` call\n * returns a promise that resolves in step 6, below.\n *\n * 2. Other plugins that care about state restoration require the layout\n * restorer as a dependency.\n *\n * 3. As each load-time plugin initializes (which happens before the lab\n * application has `started`), it instructs the layout restorer whether\n * the restorer ought to `restore` its state by passing in its tracker.\n * Alternatively, a plugin that does not require its own instance tracker\n * (because perhaps it only creates a single widget, like a command palette),\n * can simply `add` its widget along with a persistent unique name to the\n * layout restorer so that its layout state can be restored when the lab\n * application restores.\n *\n * 4. After all the load-time plugins have finished initializing, the lab\n * application `started` promise will resolve. This is the `first`\n * promise that the layout restorer waits for. By this point, all of the\n * plugins that care about restoration will have instructed the layout\n * restorer to `restore` their state.\n *\n * 5. The layout restorer will then instruct each plugin's instance tracker\n * to restore its state and reinstantiate whichever widgets it wants. The\n * tracker returns a promise to the layout restorer that resolves when it\n * has completed restoring the tracked widgets it cares about.\n *\n * 6. As each instance tracker finishes restoring the widget instances it cares\n * about, it resolves the promise that was made to the layout restorer\n * (in step 5). After all of the promises that the restorer is awaiting have\n * resolved, the restorer then resolves the outstanding `fetch` promise\n * (from step 1) and hands off a layout state object to the application\n * shell's `restoreLayout` method for restoration.\n *\n * 7. Once the application shell has finished restoring the layout, the\n * JupyterLab application's `restored` promise is resolved.\n *\n * Of particular note are steps 5 and 6: since state restoration of plugins\n * is accomplished by executing commands, the command that is used to restore\n * the state of each plugin must return a promise that only resolves when the\n * widget has been created and added to the plugin's instance tracker.\n */\nexport\nclass LayoutRestorer implements ILayoutRestorer {\n /**\n * Create a layout restorer.\n */\n constructor(options: LayoutRestorer.IOptions) {\n this._registry = options.registry;\n this._state = options.state;\n this._first = options.first;\n\n this._first\n .then(() => { this._firstDone = true; })\n .then(() => Promise.all(this._promises))\n .then(() => {\n this._promisesDone = true;\n\n // Release the tracker set.\n this._trackers.clear();\n })\n .then(() => { this._restored.resolve(void 0); });\n }\n\n /**\n * A promise resolved when the layout restorer is ready to receive signals.\n */\n get restored(): Promise<void> {\n return this._restored.promise;\n }\n\n /**\n * Add a widget to be tracked by the layout restorer.\n */\n add(widget: Widget, name: string): void {\n Private.nameProperty.set(widget, name);\n this._widgets.set(name, widget);\n widget.disposed.connect(this._onWidgetDisposed, this);\n }\n\n /**\n * Fetch the layout state for the application.\n *\n * #### Notes\n * Fetching the layout relies on all widget restoration to be complete, so\n * calls to `fetch` are guaranteed to return after restoration is complete.\n */\n fetch(): Promise<ApplicationShell.ILayout> {\n const blank: ApplicationShell.ILayout = {\n fresh: true, mainArea: null, leftArea: null, rightArea: null\n };\n let layout = this._state.fetch(KEY);\n\n return Promise.all([layout, this.restored]).then(([data]) => {\n if (!data) {\n return blank;\n }\n\n const { main, left, right } = data as Private.ILayout;\n\n // If any data exists, then this is not a fresh session.\n const fresh = false;\n\n // Rehydrate main area.\n const mainArea = this._rehydrateMainArea(main);\n\n // Rehydrate left area.\n const leftArea = this._rehydrateSideArea(left);\n\n // Rehydrate right area.\n const rightArea = this._rehydrateSideArea(right);\n\n return { fresh, mainArea, leftArea, rightArea };\n }).catch(() => blank); // Let fetch fail gracefully; return blank slate.\n }\n\n /**\n * Restore the widgets of a particular instance tracker.\n *\n * @param tracker - The instance tracker whose widgets will be restored.\n *\n * @param options - The restoration options.\n */\n restore(tracker: InstanceTracker<Widget>, options: ILayoutRestorer.IRestoreOptions<Widget>): Promise<any> {\n const warning = 'restore() can only be called before `first` has resolved.';\n\n if (this._firstDone) {\n console.warn(warning);\n return Promise.reject(warning);\n }\n\n const { namespace } = tracker;\n if (this._trackers.has(namespace)) {\n let warning = `A tracker namespaced ${namespace} was already restored.`;\n console.warn(warning);\n return Promise.reject(warning);\n }\n\n const { args, command, name, when } = options;\n\n // Add the tracker to the private trackers collection.\n this._trackers.add(namespace);\n\n // Whenever a new widget is added to the tracker, record its name.\n tracker.widgetAdded.connect((sender: any, widget: Widget) => {\n const widgetName = name(widget);\n if (widgetName) {\n this.add(widget, `${namespace}:${widgetName}`);\n }\n }, this);\n\n // Whenever a widget is updated, get its new name.\n tracker.widgetUpdated.connect((sender, widget) => {\n const widgetName = name(widget);\n if (widgetName) {\n let name = `${namespace}:${widgetName}`;\n Private.nameProperty.set(widget, name);\n this._widgets.set(name, widget);\n }\n });\n\n const first = this._first;\n const promise = tracker.restore({\n args, command, name,\n registry: this._registry,\n state: this._state,\n when: when ? [first].concat(when) : first\n }).catch(error => {\n console.error(error);\n });\n\n this._promises.push(promise);\n return promise;\n }\n\n /**\n * Save the layout state for the application.\n */\n save(data: ApplicationShell.ILayout): Promise<void> {\n // If there are promises that are unresolved, bail.\n if (!this._promisesDone) {\n let warning = 'save() was called prematurely.';\n console.warn(warning);\n return Promise.reject(warning);\n }\n\n let dehydrated: Private.ILayout = {};\n\n // Dehydrate main area.\n dehydrated.main = this._dehydrateMainArea(data.mainArea);\n\n // Dehydrate left area.\n dehydrated.left = this._dehydrateSideArea(data.leftArea);\n\n // Dehydrate right area.\n dehydrated.right = this._dehydrateSideArea(data.rightArea);\n\n return this._state.save(KEY, dehydrated);\n }\n\n /**\n * Dehydrate a main area description into a serializable object.\n */\n private _dehydrateMainArea(area: ApplicationShell.IMainArea | null): Private.IMainArea | null {\n if (!area) {\n return null;\n }\n return Private.serializeMain(area);\n }\n\n /**\n * Reydrate a serialized main area description object.\n *\n * #### Notes\n * This function consumes data that can become corrupted, so it uses type\n * coercion to guarantee the dehydrated object is safely processed.\n */\n private _rehydrateMainArea(area?: Private.IMainArea | null): ApplicationShell.IMainArea | null {\n if (!area) {\n return null;\n }\n return Private.deserializeMain(area, this._widgets);\n }\n\n /**\n * Dehydrate a side area description into a serializable object.\n */\n private _dehydrateSideArea(area?: ApplicationShell.ISideArea | null): Private.ISideArea | null {\n if (!area) {\n return null;\n }\n let dehydrated: Private.ISideArea = { collapsed: area.collapsed };\n if (area.currentWidget) {\n let current = Private.nameProperty.get(area.currentWidget);\n if (current) {\n dehydrated.current = current;\n }\n }\n if (area.widgets) {\n dehydrated.widgets = area.widgets\n .map(widget => Private.nameProperty.get(widget))\n .filter(name => !!name);\n }\n return dehydrated;\n }\n\n /**\n * Reydrate a serialized side area description object.\n *\n * #### Notes\n * This function consumes data that can become corrupted, so it uses type\n * coercion to guarantee the dehydrated object is safely processed.\n */\n private _rehydrateSideArea(area?: Private.ISideArea | null): ApplicationShell.ISideArea {\n if (!area) {\n return { collapsed: true, currentWidget: null, widgets: null };\n }\n let internal = this._widgets;\n const collapsed = area.hasOwnProperty('collapsed') ? !!area.collapsed\n : false;\n const currentWidget = area.current && internal.has(`${area.current}`) ?\n internal.get(`${area.current}`) : null;\n const widgets = !Array.isArray(area.widgets) ? null\n : area.widgets\n .map(name => internal.has(`${name}`) ? internal.get(`${name}`) : null)\n .filter(widget => !!widget);\n return {\n collapsed,\n currentWidget: currentWidget!,\n widgets: widgets as Widget[] | null\n };\n }\n\n /**\n * Handle a widget disposal.\n */\n private _onWidgetDisposed(widget: Widget): void {\n let name = Private.nameProperty.get(widget);\n this._widgets.delete(name);\n }\n\n private _first: Promise<any>;\n private _firstDone = false;\n private _promisesDone = false;\n private _promises: Promise<any>[] = [];\n private _restored = new PromiseDelegate<void>();\n private _registry: CommandRegistry ;\n private _state: IStateDB;\n private _trackers = new Set<string>();\n private _widgets = new Map<string, Widget>();\n}\n\n\n/**\n * A namespace for `LayoutRestorer` statics.\n */\nexport\nnamespace LayoutRestorer {\n /**\n * The configuration options for layout restorer instantiation.\n */\n export\n interface IOptions {\n /**\n * The initial promise that has to be resolved before restoration.\n *\n * #### Notes\n * This promise should equal the JupyterLab application `started` notifier.\n */\n first: Promise<any>;\n\n /**\n * The application command registry.\n */\n registry: CommandRegistry;\n\n /**\n * The state database instance.\n */\n state: IStateDB;\n }\n}\n\n/*\n * A namespace for private data.\n */\nnamespace Private {\n /**\n * The dehydrated state of the application layout.\n *\n * #### Notes\n * This format is JSON serializable and saved in the state database.\n * It is meant to be a data structure can translate into an\n * `ApplicationShell.ILayout` data structure for consumption by\n * the application shell.\n */\n export\n interface ILayout extends JSONObject {\n /**\n * The main area of the user interface.\n */\n main?: IMainArea | null;\n\n /**\n * The left area of the user interface.\n */\n left?: ISideArea | null;\n\n /**\n * The right area of the user interface.\n */\n right?: ISideArea | null;\n }\n\n /**\n * The restorable description of the main application area.\n */\n export\n interface IMainArea extends JSONObject {\n /**\n * The current widget that has application focus.\n */\n current?: string | null;\n\n /**\n * The main application dock panel.\n */\n dock?: ISplitArea | ITabArea | null;\n\n /**\n * The document mode (i.e., multiple/single) of the main dock panel.\n */\n mode?: DockPanel.Mode | null;\n }\n\n /**\n * The restorable description of a sidebar in the user interface.\n */\n export\n interface ISideArea extends JSONObject {\n /**\n * A flag denoting whether the sidebar has been collapsed.\n */\n collapsed?: boolean | null;\n\n /**\n * The current widget that has side area focus.\n */\n current?: string | null;\n\n /**\n * The collection of widgets held by the sidebar.\n */\n widgets?: Array<string> | null;\n }\n\n /**\n * The restorable description of a tab area in the user interface.\n */\n export\n interface ITabArea extends JSONObject {\n /**\n * The type indicator of the serialized tab area.\n */\n type: 'tab-area';\n\n /**\n * The widgets in the tab area.\n */\n widgets: Array<string> | null;\n\n /**\n * The index of the selected tab.\n */\n currentIndex: number;\n }\n\n /**\n * The restorable description of a split area in the user interface.\n */\n export\n interface ISplitArea extends JSONObject {\n /**\n * The type indicator of the serialized split area.\n */\n type: 'split-area';\n\n /**\n * The orientation of the split area.\n */\n orientation: 'horizontal' | 'vertical';\n\n /**\n * The children in the split area.\n */\n children: Array<ITabArea | ISplitArea> | null;\n\n /**\n * The sizes of the children.\n */\n sizes: Array<number>;\n }\n\n /**\n * An attached property for a widget's ID in the state database.\n */\n export\n const nameProperty = new AttachedProperty<Widget, string>({\n name: 'name',\n create: owner => ''\n });\n\n /**\n * Serialize individual areas within the main area.\n */\n function serializeArea(area: ApplicationShell.AreaConfig | null): ITabArea | ISplitArea | null {\n if (!area || !area.type) {\n return null;\n }\n\n if (area.type === 'tab-area') {\n return {\n type: 'tab-area',\n currentIndex: area.currentIndex,\n widgets: area.widgets\n .map(widget => nameProperty.get(widget))\n .filter(name => !!name)\n };\n }\n\n return {\n type: 'split-area',\n orientation: area.orientation,\n sizes: area.sizes,\n children: area.children.map(serializeArea)\n .filter(area => !!area) as (ITabArea | ISplitArea)[]\n };\n }\n\n /**\n * Return a dehydrated, serializable version of the main dock panel.\n */\n export\n function serializeMain(area: ApplicationShell.IMainArea): IMainArea {\n let dehydrated: IMainArea = {\n dock: area && area.dock && serializeArea(area.dock.main) || null\n };\n if (area) {\n dehydrated.mode = area.mode;\n if (area.currentWidget) {\n let current = Private.nameProperty.get(area.currentWidget);\n if (current) {\n dehydrated.current = current;\n }\n }\n }\n return dehydrated;\n }\n\n /**\n * Deserialize individual areas within the main area.\n *\n * #### Notes\n * Because this data comes from a potentially unreliable foreign source, it is\n * typed as a `JSONObject`; but the actual expected type is:\n * `ITabArea | ISplitArea`.\n *\n * For fault tolerance, types are manually checked in deserialization.\n */\n function deserializeArea(area: JSONObject, names: Map<string, Widget>): ApplicationShell.AreaConfig | null {\n if (!area) {\n return null;\n }\n\n // Because this data is saved to a foreign data source, its type safety is\n // not guaranteed when it is retrieved, so exhaustive checks are necessary.\n const type = (area as any).type as string || 'unknown';\n if (type === 'unknown' || (type !== 'tab-area' && type !== 'split-area')) {\n console.warn(`Attempted to deserialize unknown type: ${type}`);\n return null;\n }\n\n if (type === 'tab-area') {\n const { currentIndex, widgets } = area as ITabArea;\n let hydrated: ApplicationShell.AreaConfig = {\n type: 'tab-area',\n currentIndex: currentIndex || 0,\n widgets: widgets && widgets.map(widget => names.get(widget))\n .filter(widget => !!widget) as Widget[] || []\n };\n\n // Make sure the current index is within bounds.\n if (hydrated.currentIndex > hydrated.widgets.length - 1) {\n hydrated.currentIndex = 0;\n }\n\n return hydrated;\n }\n\n const { orientation, sizes, children } = area as ISplitArea;\n let hydrated: ApplicationShell.AreaConfig = {\n type: 'split-area',\n orientation: orientation,\n sizes: sizes || [],\n children: children &&\n children.map(child => deserializeArea(child, names))\n .filter(widget => !!widget) as ApplicationShell.AreaConfig[] || []\n };\n\n return hydrated;\n }\n\n /**\n * Return the hydrated version of the main dock panel, ready to restore.\n *\n * #### Notes\n * Because this data comes from a potentially unreliable foreign source, it is\n * typed as a `JSONObject`; but the actual expected type is: `IMainArea`.\n *\n * For fault tolerance, types are manually checked in deserialization.\n */\n export\n function deserializeMain(area: JSONObject, names: Map<string, Widget>): ApplicationShell.IMainArea | null {\n if (!area) {\n return null;\n }\n\n const name = (area as any).current || null;\n const dock = (area as any).dock || null;\n const mode = (area as any).mode || null;\n\n return {\n currentWidget: name && names.has(name) && names.get(name) || null,\n dock: dock ? { main: deserializeArea(dock, names) } : null,\n mode: mode === 'multiple-document' || mode === 'single-document' ? mode\n : null\n };\n }\n}\n"]}
package/lib/router.d.ts CHANGED
@@ -18,18 +18,35 @@ export interface IRouter {
18
18
  * The command registry used by the router.
19
19
  */
20
20
  readonly commands: CommandRegistry;
21
+ /**
22
+ * The parsed current URL of the application.
23
+ */
24
+ readonly current: IRouter.ILocation;
21
25
  /**
22
26
  * A signal emitted when the router routes a route.
23
27
  */
24
- readonly routed: ISignal<IRouter, IRouter.ICommandArgs>;
28
+ readonly routed: ISignal<IRouter, IRouter.ILocation>;
25
29
  /**
26
- * Register to route a path pattern to a command.
30
+ * If a matching rule's command resolves with the `stop` token during routing,
31
+ * no further matches will execute.
32
+ */
33
+ readonly stop: Token<void>;
34
+ /**
35
+ * Navigate to a new path within the application.
36
+ *
37
+ * @param path - The new path or empty string if redirecting to root.
38
+ *
39
+ * @param options - The navigation options.
40
+ */
41
+ navigate(path: string, options?: IRouter.INavOptions): void;
42
+ /**
43
+ * Register a rule that maps a path pattern to a command.
27
44
  *
28
45
  * @param options - The route registration options.
29
46
  *
30
- * @returns A disposable that removes the registered rul from the router.
47
+ * @returns A disposable that removes the registered rule from the router.
31
48
  */
32
- register(options: IRouter.IRegisterArgs): IDisposable;
49
+ register(options: IRouter.IRegisterOptions): IDisposable;
33
50
  /**
34
51
  * Route a specific path to an action.
35
52
  *
@@ -37,7 +54,7 @@ export interface IRouter {
37
54
  *
38
55
  * #### Notes
39
56
  * If a pattern is matched, its command will be invoked with arguments that
40
- * match the `IRouter.ICommandArgs` interface.
57
+ * match the `IRouter.ILocation` interface.
41
58
  */
42
59
  route(url: string): void;
43
60
  }
@@ -46,23 +63,43 @@ export interface IRouter {
46
63
  */
47
64
  export declare namespace IRouter {
48
65
  /**
49
- * The arguments passed into a command execution when a path is routed.
66
+ * The parsed location currently being routed.
50
67
  */
51
- interface ICommandArgs extends ReadonlyJSONObject {
68
+ interface ILocation extends ReadonlyJSONObject {
69
+ /**
70
+ * The location hash.
71
+ */
72
+ hash: string;
52
73
  /**
53
74
  * The path that matched a routing pattern.
54
75
  */
55
76
  path: string;
77
+ /**
78
+ * The request being routed with the router `base` omitted.
79
+ *
80
+ * #### Notes
81
+ * This field includes the query string and hash, if they exist.
82
+ */
83
+ request: string;
56
84
  /**
57
85
  * The search element, including leading question mark (`'?'`), if any,
58
86
  * of the path.
59
87
  */
60
88
  search: string;
61
89
  }
90
+ /**
91
+ * The options passed into a navigation request.
92
+ */
93
+ interface INavOptions {
94
+ /**
95
+ * Whether the navigation should be added to the browser's history.
96
+ */
97
+ silent?: boolean;
98
+ }
62
99
  /**
63
100
  * The specification for registering a route with the router.
64
101
  */
65
- interface IRegisterArgs {
102
+ interface IRegisterOptions {
66
103
  /**
67
104
  * The command string that will be invoked upon matching.
68
105
  */
@@ -94,28 +131,43 @@ export declare class Router implements IRouter {
94
131
  * The command registry used by the router.
95
132
  */
96
133
  readonly commands: CommandRegistry;
134
+ /**
135
+ * Returns the parsed current URL of the application.
136
+ */
137
+ readonly current: IRouter.ILocation;
97
138
  /**
98
139
  * A signal emitted when the router routes a route.
99
140
  */
100
- readonly routed: ISignal<this, IRouter.ICommandArgs>;
141
+ readonly routed: ISignal<this, IRouter.ILocation>;
142
+ /**
143
+ * If a matching rule's command resolves with the `stop` token during routing,
144
+ * no further matches will execute.
145
+ */
146
+ readonly stop: Token<void>;
147
+ /**
148
+ * Navigate to a new path within the application.
149
+ *
150
+ * @param path - The new path or empty string if redirecting to root.
151
+ *
152
+ * @param options - The navigation options.
153
+ */
154
+ navigate(path: string, options?: IRouter.INavOptions): void;
101
155
  /**
102
156
  * Register to route a path pattern to a command.
103
157
  *
104
158
  * @param options - The route registration options.
105
159
  *
106
- * @returns A disposable that removes the registered rul from the router.
160
+ * @returns A disposable that removes the registered rule from the router.
107
161
  */
108
- register(options: IRouter.IRegisterArgs): IDisposable;
162
+ register(options: IRouter.IRegisterOptions): IDisposable;
109
163
  /**
110
164
  * Route a specific path to an action.
111
165
  *
112
- * @param url - The URL string that will be routed.
113
- *
114
166
  * #### Notes
115
167
  * If a pattern is matched, its command will be invoked with arguments that
116
- * match the `IRouter.ICommandArgs` interface.
168
+ * match the `IRouter.ILocation` interface.
117
169
  */
118
- route(url: string): void;
170
+ route(): void;
119
171
  private _routed;
120
172
  private _rules;
121
173
  }
package/lib/router.js CHANGED
@@ -21,11 +21,31 @@ var Router = /** @class */ (function () {
21
21
  * Create a URL router.
22
22
  */
23
23
  function Router(options) {
24
+ /**
25
+ * If a matching rule's command resolves with the `stop` token during routing,
26
+ * no further matches will execute.
27
+ */
28
+ this.stop = new coreutils_2.Token('@jupyterlab/application:Router#stop');
24
29
  this._routed = new signaling_1.Signal(this);
25
30
  this._rules = new Map();
26
31
  this.base = options.base;
27
32
  this.commands = options.commands;
28
33
  }
34
+ Object.defineProperty(Router.prototype, "current", {
35
+ /**
36
+ * Returns the parsed current URL of the application.
37
+ */
38
+ get: function () {
39
+ var base = this.base;
40
+ var parsed = coreutils_1.URLExt.parse(window.location.href);
41
+ var search = parsed.search, hash = parsed.hash;
42
+ var path = parsed.pathname.replace(base, '');
43
+ var request = path + search + hash;
44
+ return { hash: hash, path: path, request: request, search: search };
45
+ },
46
+ enumerable: true,
47
+ configurable: true
48
+ });
29
49
  Object.defineProperty(Router.prototype, "routed", {
30
50
  /**
31
51
  * A signal emitted when the router routes a route.
@@ -36,12 +56,35 @@ var Router = /** @class */ (function () {
36
56
  enumerable: true,
37
57
  configurable: true
38
58
  });
59
+ /**
60
+ * Navigate to a new path within the application.
61
+ *
62
+ * @param path - The new path or empty string if redirecting to root.
63
+ *
64
+ * @param options - The navigation options.
65
+ */
66
+ Router.prototype.navigate = function (path, options) {
67
+ var _this = this;
68
+ if (options === void 0) { options = {}; }
69
+ var url = path ? coreutils_1.URLExt.join(this.base, path) : this.base;
70
+ var history = window.history;
71
+ var silent = options.silent;
72
+ if (silent) {
73
+ history.replaceState({}, '', url);
74
+ }
75
+ else {
76
+ history.pushState({}, '', url);
77
+ }
78
+ // Because a `route()` call may still be in the stack after having received
79
+ // a `stop` token, wait for the next stack frame before calling `route()`.
80
+ requestAnimationFrame(function () { _this.route(); });
81
+ };
39
82
  /**
40
83
  * Register to route a path pattern to a command.
41
84
  *
42
85
  * @param options - The route registration options.
43
86
  *
44
- * @returns A disposable that removes the registered rul from the router.
87
+ * @returns A disposable that removes the registered rule from the router.
45
88
  */
46
89
  Router.prototype.register = function (options) {
47
90
  var command = options.command, pattern = options.pattern;
@@ -53,31 +96,43 @@ var Router = /** @class */ (function () {
53
96
  /**
54
97
  * Route a specific path to an action.
55
98
  *
56
- * @param url - The URL string that will be routed.
57
- *
58
99
  * #### Notes
59
100
  * If a pattern is matched, its command will be invoked with arguments that
60
- * match the `IRouter.ICommandArgs` interface.
101
+ * match the `IRouter.ILocation` interface.
61
102
  */
62
- Router.prototype.route = function (url) {
63
- var _this = this;
64
- var parsed = coreutils_1.URLExt.parse(url.replace(this.base, ''));
65
- var args = { path: parsed.pathname, search: parsed.search };
103
+ Router.prototype.route = function () {
104
+ var _a = this, commands = _a.commands, current = _a.current, stop = _a.stop;
105
+ var request = current.request;
106
+ var routed = this._routed;
107
+ var rules = this._rules;
66
108
  var matches = [];
67
109
  // Collect all rules that match the URL.
68
- this._rules.forEach(function (rule, pattern) {
69
- if (parsed.pathname.match(pattern)) {
110
+ rules.forEach(function (rule, pattern) {
111
+ if (request.match(pattern)) {
70
112
  matches.push(rule);
71
113
  }
72
114
  });
73
- // Order the matching rules by rank and execute them.
74
- matches.sort(function (a, b) { return a.rank - b.rank; }).forEach(function (rule) {
75
- // Ignore the results of each executed promise.
76
- _this.commands.execute(rule.command, args).catch(function (reason) {
77
- console.warn("Routing " + url + " using " + rule.command + " failed:", reason);
115
+ // Order the matching rules by rank and enqueue them.
116
+ var queue = matches.sort(function (a, b) { return b.rank - a.rank; });
117
+ // Process each enqueued command sequentially and short-circuit if a promise
118
+ // resolves with the `stop` token.
119
+ (function next() {
120
+ if (!queue.length) {
121
+ routed.emit(current);
122
+ return;
123
+ }
124
+ var command = queue.pop().command;
125
+ commands.execute(command, current).then(function (result) {
126
+ if (result === stop) {
127
+ queue.length = 0;
128
+ console.log("Routing " + request + " was short-circuited by " + command);
129
+ }
130
+ next();
131
+ }).catch(function (reason) {
132
+ console.warn("Routing " + request + " to " + command + " failed", reason);
133
+ next();
78
134
  });
79
- });
80
- this._routed.emit(args);
135
+ })();
81
136
  };
82
137
  return Router;
83
138
  }());
package/lib/router.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../application/src/router.ts"],"names":[],"mappings":";AAAA;;;+EAG+E;;AAE/E,mDAE+B;AAM/B,iDAE6B;AAE7B,mDAE8B;AAE9B,iDAE6B;AAG7B,oBAAoB;AACpB;;GAEG;AAEG,QAAA,OAAO,GAAG,IAAI,iBAAK,CAAU,iCAAiC,CAAC,CAAC;AA4FtE;;GAEG;AACH;IAEE;;OAEG;IACH,gBAAY,OAAwB;QAuE5B,YAAO,GAAG,IAAI,kBAAM,CAA6B,IAAI,CAAC,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CAAC,CAAC,CAAC;gBACnC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,qDAAqD;QACrD,OAAO,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAf,CAAe,CAAC,CAAC,OAAO,CAAC,UAAA,IAAI;YAClD,+CAA+C;YAC/C,KAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,UAAA,MAAM;gBACpD,OAAO,CAAC,IAAI,CAAC,aAAW,GAAG,eAAU,IAAI,CAAC,OAAO,aAAU,EAAE,MAAM,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAIH,aAAC;AAAD,CAAC,AA9ED,IA8EC;AA7EK,wBAAM","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\n\nimport {\n URLExt\n} from '@jupyterlab/coreutils';\n\nimport {\n CommandRegistry\n} from '@phosphor/commands';\n\nimport {\n ReadonlyJSONObject, Token\n} from '@phosphor/coreutils';\n\nimport {\n DisposableDelegate, IDisposable\n} from '@phosphor/disposable';\n\nimport {\n ISignal, Signal\n} from '@phosphor/signaling';\n\n\n/* tslint:disable */\n/**\n * The URL Router token.\n */\nexport\nconst IRouter = new Token<IRouter>('@jupyterlab/application:IRouter');\n/* tslint:enable */\n\n\n/**\n * A static class that routes URLs within the application.\n */\nexport\ninterface IRouter {\n /**\n * The base URL for the router.\n */\n readonly base: string;\n\n /**\n * The command registry used by the router.\n */\n readonly commands: CommandRegistry;\n\n /**\n * A signal emitted when the router routes a route.\n */\n readonly routed: ISignal<IRouter, IRouter.ICommandArgs>;\n\n /**\n * Register to route a path pattern to a command.\n *\n * @param options - The route registration options.\n *\n * @returns A disposable that removes the registered rul from the router.\n */\n register(options: IRouter.IRegisterArgs): IDisposable;\n\n /**\n * Route a specific path to an action.\n *\n * @param url - The URL string that will be routed.\n *\n * #### Notes\n * If a pattern is matched, its command will be invoked with arguments that\n * match the `IRouter.ICommandArgs` interface.\n */\n route(url: string): void;\n}\n\n\n/**\n * A namespace for the `IRouter` specification.\n */\nexport\nnamespace IRouter {\n /**\n * The arguments passed into a command execution when a path is routed.\n */\n export\n interface ICommandArgs extends ReadonlyJSONObject {\n /**\n * The path that matched a routing pattern.\n */\n path: string;\n\n /**\n * The search element, including leading question mark (`'?'`), if any,\n * of the path.\n */\n search: string;\n }\n\n /**\n * The specification for registering a route with the router.\n */\n export\n interface IRegisterArgs {\n /**\n * The command string that will be invoked upon matching.\n */\n command: string;\n\n /**\n * The regular expression that will be matched against URLs.\n */\n pattern: RegExp;\n\n /**\n * The rank order of the registered rule. A lower rank denotes a higher\n * priority. The default rank is `100`.\n */\n rank?: number;\n }\n}\n\n\n/**\n * A static class that routes URLs within the application.\n */\nexport\nclass Router implements IRouter {\n /**\n * Create a URL router.\n */\n constructor(options: Router.IOptions) {\n this.base = options.base;\n this.commands = options.commands;\n }\n\n /**\n * The base URL for the router.\n */\n readonly base: string;\n\n /**\n * The command registry used by the router.\n */\n readonly commands: CommandRegistry;\n\n /**\n * A signal emitted when the router routes a route.\n */\n get routed(): ISignal<this, IRouter.ICommandArgs> {\n return this._routed;\n }\n\n /**\n * Register to route a path pattern to a command.\n *\n * @param options - The route registration options.\n *\n * @returns A disposable that removes the registered rul from the router.\n */\n register(options: IRouter.IRegisterArgs): IDisposable {\n const { command, pattern } = options;\n const rank = 'rank' in options ? options.rank : 100;\n const rules = this._rules;\n\n rules.set(pattern, { command, rank });\n\n return new DisposableDelegate(() => { rules.delete(pattern); });\n }\n\n /**\n * Route a specific path to an action.\n *\n * @param url - The URL string that will be routed.\n *\n * #### Notes\n * If a pattern is matched, its command will be invoked with arguments that\n * match the `IRouter.ICommandArgs` interface.\n */\n route(url: string): void {\n const parsed = URLExt.parse(url.replace(this.base, ''));\n const args = { path: parsed.pathname, search: parsed.search };\n const matches: Private.Rule[] = [];\n\n // Collect all rules that match the URL.\n this._rules.forEach((rule, pattern) => {\n if (parsed.pathname.match(pattern)) {\n matches.push(rule);\n }\n });\n\n // Order the matching rules by rank and execute them.\n matches.sort((a, b) => a.rank - b.rank).forEach(rule => {\n // Ignore the results of each executed promise.\n this.commands.execute(rule.command, args).catch(reason => {\n console.warn(`Routing ${url} using ${rule.command} failed:`, reason);\n });\n });\n\n this._routed.emit(args);\n }\n\n private _routed = new Signal<this, IRouter.ICommandArgs>(this);\n private _rules = new Map<RegExp, Private.Rule>();\n}\n\n\n/**\n * A namespace for `Router` class statics.\n */\nexport\nnamespace Router {\n /**\n * The options for instantiating a JupyterLab URL router.\n */\n export\n interface IOptions {\n /**\n * The fully qualified base URL for the router.\n */\n base: string;\n\n /**\n * The command registry used by the router.\n */\n commands: CommandRegistry;\n }\n}\n\n\n/**\n * A namespace for private module data.\n */\nnamespace Private {\n /**\n * The internal representation of a routing rule.\n */\n export\n type Rule = { command: string; rank: number };\n}\n"]}
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../application/src/router.ts"],"names":[],"mappings":";AAAA;;;+EAG+E;;AAE/E,mDAE+B;AAM/B,iDAE6B;AAE7B,mDAE8B;AAE9B,iDAE6B;AAG7B,oBAAoB;AACpB;;GAEG;AAEG,QAAA,OAAO,GAAG,IAAI,iBAAK,CAAU,iCAAiC,CAAC,CAAC;AAwItE;;GAEG;AACH;IAEE;;OAEG;IACH,gBAAY,OAAwB;QAmCpC;;;WAGG;QACM,SAAI,GAAG,IAAI,iBAAK,CAAO,qCAAqC,CAAC,CAAC;QAyF/D,YAAO,GAAG,IAAI,kBAAM,CAA0B,IAAI,CAAC,CAAC;QACpD,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A,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAf,CAAe,CAAC,CAAC;QAEtD,4EAA4E;QAC5E,kCAAkC;QAClC,CAAC;YACC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrB,MAAM,CAAC;YACT,CAAC;YAEO,IAAA,6BAAO,CAAiB;YAEhC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,UAAA,MAAM;gBAC5C,EAAE,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC;oBACpB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;oBACjB,OAAO,CAAC,GAAG,CAAC,aAAW,OAAO,gCAA2B,OAAS,CAAC,CAAC;gBACtE,CAAC;gBACD,IAAI,EAAE,CAAC;YACT,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,MAAM;gBACb,OAAO,CAAC,IAAI,CAAC,aAAW,OAAO,YAAO,OAAO,YAAS,EAAE,MAAM,CAAC,CAAC;gBAChE,IAAI,EAAE,CAAC;YACT,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IAIH,aAAC;AAAD,CAAC,AAvID,IAuIC;AAtIK,wBAAM","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\n\nimport {\n URLExt\n} from '@jupyterlab/coreutils';\n\nimport {\n CommandRegistry\n} from '@phosphor/commands';\n\nimport {\n ReadonlyJSONObject, Token\n} from '@phosphor/coreutils';\n\nimport {\n DisposableDelegate, IDisposable\n} from '@phosphor/disposable';\n\nimport {\n ISignal, Signal\n} from '@phosphor/signaling';\n\n\n/* tslint:disable */\n/**\n * The URL Router token.\n */\nexport\nconst IRouter = new Token<IRouter>('@jupyterlab/application:IRouter');\n/* tslint:enable */\n\n\n/**\n * A static class that routes URLs within the application.\n */\nexport\ninterface IRouter {\n /**\n * The base URL for the router.\n */\n readonly base: string;\n\n /**\n * The command registry used by the router.\n */\n readonly commands: CommandRegistry;\n\n /**\n * The parsed current URL of the application.\n */\n readonly current: IRouter.ILocation;\n\n /**\n * A signal emitted when the router routes a route.\n */\n readonly routed: ISignal<IRouter, IRouter.ILocation>;\n\n /**\n * If a matching rule's command resolves with the `stop` token during routing,\n * no further matches will execute.\n */\n readonly stop: Token<void>;\n\n /**\n * Navigate to a new path within the application.\n *\n * @param path - The new path or empty string if redirecting to root.\n *\n * @param options - The navigation options.\n */\n navigate(path: string, options?: IRouter.INavOptions): void;\n\n /**\n * Register a rule that maps a path pattern to a command.\n *\n * @param options - The route registration options.\n *\n * @returns A disposable that removes the registered rule from the router.\n */\n register(options: IRouter.IRegisterOptions): IDisposable;\n\n /**\n * Route a specific path to an action.\n *\n * @param url - The URL string that will be routed.\n *\n * #### Notes\n * If a pattern is matched, its command will be invoked with arguments that\n * match the `IRouter.ILocation` interface.\n */\n route(url: string): void;\n}\n\n\n/**\n * A namespace for the `IRouter` specification.\n */\nexport\nnamespace IRouter {\n /**\n * The parsed location currently being routed.\n */\n export\n interface ILocation extends ReadonlyJSONObject {\n /**\n * The location hash.\n */\n hash: string;\n\n /**\n * The path that matched a routing pattern.\n */\n path: string;\n\n /**\n * The request being routed with the router `base` omitted.\n *\n * #### Notes\n * This field includes the query string and hash, if they exist.\n */\n request: string;\n\n /**\n * The search element, including leading question mark (`'?'`), if any,\n * of the path.\n */\n search: string;\n }\n\n /**\n * The options passed into a navigation request.\n */\n export\n interface INavOptions {\n /**\n * Whether the navigation should be added to the browser's history.\n */\n silent?: boolean;\n }\n\n /**\n * The specification for registering a route with the router.\n */\n export\n interface IRegisterOptions {\n /**\n * The command string that will be invoked upon matching.\n */\n command: string;\n\n /**\n * The regular expression that will be matched against URLs.\n */\n pattern: RegExp;\n\n /**\n * The rank order of the registered rule. A lower rank denotes a higher\n * priority. The default rank is `100`.\n */\n rank?: number;\n }\n}\n\n\n/**\n * A static class that routes URLs within the application.\n */\nexport\nclass Router implements IRouter {\n /**\n * Create a URL router.\n */\n constructor(options: Router.IOptions) {\n this.base = options.base;\n this.commands = options.commands;\n }\n\n /**\n * The base URL for the router.\n */\n readonly base: string;\n\n /**\n * The command registry used by the router.\n */\n readonly commands: CommandRegistry;\n\n /**\n * Returns the parsed current URL of the application.\n */\n get current(): IRouter.ILocation {\n const { base } = this;\n const parsed = URLExt.parse(window.location.href);\n const { search, hash } = parsed;\n const path = parsed.pathname.replace(base, '');\n const request = path + search + hash;\n\n return { hash, path, request, search };\n }\n\n /**\n * A signal emitted when the router routes a route.\n */\n get routed(): ISignal<this, IRouter.ILocation> {\n return this._routed;\n }\n\n /**\n * If a matching rule's command resolves with the `stop` token during routing,\n * no further matches will execute.\n */\n readonly stop = new Token<void>('@jupyterlab/application:Router#stop');\n\n /**\n * Navigate to a new path within the application.\n *\n * @param path - The new path or empty string if redirecting to root.\n *\n * @param options - The navigation options.\n */\n navigate(path: string, options: IRouter.INavOptions = { }): void {\n const url = path ? URLExt.join(this.base, path) : this.base;\n const { history } = window;\n const { silent } = options;\n\n if (silent) {\n history.replaceState({ }, '', url);\n } else {\n history.pushState({ }, '', url);\n }\n\n // Because a `route()` call may still be in the stack after having received\n // a `stop` token, wait for the next stack frame before calling `route()`.\n requestAnimationFrame(() => { this.route(); });\n }\n\n /**\n * Register to route a path pattern to a command.\n *\n * @param options - The route registration options.\n *\n * @returns A disposable that removes the registered rule from the router.\n */\n register(options: IRouter.IRegisterOptions): IDisposable {\n const { command, pattern } = options;\n const rank = 'rank' in options ? options.rank : 100;\n const rules = this._rules;\n\n rules.set(pattern, { command, rank });\n\n return new DisposableDelegate(() => { rules.delete(pattern); });\n }\n\n /**\n * Route a specific path to an action.\n *\n * #### Notes\n * If a pattern is matched, its command will be invoked with arguments that\n * match the `IRouter.ILocation` interface.\n */\n route(): void {\n const { commands, current, stop } = this;\n const { request } = current;\n const routed = this._routed;\n const rules = this._rules;\n const matches: Private.Rule[] = [];\n\n // Collect all rules that match the URL.\n rules.forEach((rule, pattern) => {\n if (request.match(pattern)) {\n matches.push(rule);\n }\n });\n\n // Order the matching rules by rank and enqueue them.\n const queue = matches.sort((a, b) => b.rank - a.rank);\n\n // Process each enqueued command sequentially and short-circuit if a promise\n // resolves with the `stop` token.\n (function next() {\n if (!queue.length) {\n routed.emit(current);\n return;\n }\n\n const { command } = queue.pop();\n\n commands.execute(command, current).then(result => {\n if (result === stop) {\n queue.length = 0;\n console.log(`Routing ${request} was short-circuited by ${command}`);\n }\n next();\n }).catch(reason => {\n console.warn(`Routing ${request} to ${command} failed`, reason);\n next();\n });\n })();\n }\n\n private _routed = new Signal<this, IRouter.ILocation>(this);\n private _rules = new Map<RegExp, Private.Rule>();\n}\n\n\n/**\n * A namespace for `Router` class statics.\n */\nexport\nnamespace Router {\n /**\n * The options for instantiating a JupyterLab URL router.\n */\n export\n interface IOptions {\n /**\n * The fully qualified base URL for the router.\n */\n base: string;\n\n /**\n * The command registry used by the router.\n */\n commands: CommandRegistry;\n }\n}\n\n\n/**\n * A namespace for private module data.\n */\nnamespace Private {\n /**\n * The internal representation of a routing rule.\n */\n export\n type Rule = { command: string; rank: number };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/application",
3
- "version": "0.15.4",
3
+ "version": "0.16.3",
4
4
  "description": "JupyterLab - Application",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -31,12 +31,12 @@
31
31
  "watch": "tsc -w"
32
32
  },
33
33
  "dependencies": {
34
- "@jupyterlab/apputils": "^0.15.4",
35
- "@jupyterlab/coreutils": "^1.0.6",
36
- "@jupyterlab/docregistry": "^0.15.4",
37
- "@jupyterlab/rendermime": "^0.15.4",
38
- "@jupyterlab/rendermime-interfaces": "^1.0.6",
39
- "@jupyterlab/services": "^1.1.4",
34
+ "@jupyterlab/apputils": "^0.16.4",
35
+ "@jupyterlab/coreutils": "^1.1.3",
36
+ "@jupyterlab/docregistry": "^0.16.3",
37
+ "@jupyterlab/rendermime": "^0.16.3",
38
+ "@jupyterlab/rendermime-interfaces": "^1.0.10",
39
+ "@jupyterlab/services": "^2.0.3",
40
40
  "@phosphor/algorithm": "^1.1.2",
41
41
  "@phosphor/application": "^1.5.0",
42
42
  "@phosphor/commands": "^1.4.0",
package/style/icons.css CHANGED
@@ -233,6 +233,11 @@
233
233
  }
234
234
 
235
235
 
236
+ .jp-UndoIcon {
237
+ background-image: var(--jp-icon-undo);
238
+ }
239
+
240
+
236
241
  .jp-UploadIcon {
237
242
  background-image: var(--jp-icon-upload);
238
243
  }