jupyterlab-emrys
Version:
A computational environment for Jupyter. Powered by Emrys
138 lines (137 loc) • 4.18 kB
TypeScript
import { IKernel, IServiceManager, ISession } from 'jupyter-js-services';
import { IDisposable } from 'phosphor-disposable';
import { Widget } from 'phosphor-widget';
import { IWidgetOpener } from '../filebrowser/browser';
import { DocumentRegistry, IDocumentModel, IDocumentContext } from '../docregistry';
/**
* The document manager.
*
* #### Notes
* The document manager is used to register model and widget creators,
* and the file browser uses the document manager to create widgets. The
* document manager maintains a context for each path and model type that is
* open, and a list of widgets for each context. The document manager is in
* control of the proper closing and disposal of the widgets and contexts.
*/
export declare class DocumentManager implements IDisposable {
/**
* Construct a new document manager.
*/
constructor(options: DocumentManager.IOptions);
/**
* Get the kernel spec models for the manager.
*
* #### Notes
* This is a read-only property.
*/
kernelspecs: IKernel.ISpecModels;
/**
* Get the registry used by the manager.
*
* #### Notes
* This is a read-only property.
*/
registry: DocumentRegistry;
/**
* Get whether the document manager has been disposed.
*/
isDisposed: boolean;
/**
* Dispose of the resources held by the document manager.
*/
dispose(): void;
/**
* Open a file and return the widget used to display the contents.
*
* @param path - The file path to open.
*
* @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
*
* @param kernel - An optional kernel name/id to override the default.
*/
open(path: string, widgetName?: string, kernel?: IKernel.IModel): Widget;
/**
* Create a new file of the given name.
*
* @param path - The file path to use.
*
* @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
*
* @param kernel - An optional kernel name/id to override the default.
*/
createNew(path: string, widgetName?: string, kernel?: IKernel.IModel): Widget;
/**
* List the running notebook sessions.
*/
listSessions(): Promise<ISession.IModel[]>;
/**
* Handle the renaming of an open document.
*
* @param oldPath - The previous path.
*
* @param newPath - The new path.
*/
handleRename(oldPath: string, newPath: string): void;
/**
* Handle a file deletion.
*/
handleDelete(path: string): void;
/**
* See if a widget already exists for the given path and widget name.
*
* @param path - The file path to use.
*
* @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
*
* #### Notes
* This can be used to use an existing widget instead of opening
* a new widget.
*/
findWidget(path: string, widgetName?: string): Widget;
/**
* Get the document context for a widget.
*/
contextForWidget(widget: Widget): IDocumentContext<IDocumentModel>;
/**
* Clone a widget.
*
* #### Notes
* This will create a new widget with the same model and context
* as this widget.
*/
clone(widget: Widget): Widget;
/**
* Close the widgets associated with a given path.
*/
closeFile(path: string): void;
/**
* Close all of the open documents.
*/
closeAll(): void;
private _serviceManager;
private _contextManager;
private _widgetManager;
private _registry;
}
/**
* A namespace for document manager statics.
*/
export declare namespace DocumentManager {
/**
* The options used to initialize a document manager.
*/
interface IOptions {
/**
* A document registry instance.
*/
registry: DocumentRegistry;
/**
* A service manager instance.
*/
manager: IServiceManager;
/**
* A widget opener for sibling widgets.
*/
opener: IWidgetOpener;
}
}