jupyterlab-emrys
Version:
A computational environment for Jupyter. Powered by Emrys
141 lines (140 loc) • 3.92 kB
TypeScript
import { IContents, IKernel, IServiceManager, ISession } from 'jupyter-js-services';
import { IDisposable } from 'phosphor-disposable';
import { Widget } from 'phosphor-widget';
import { IDocumentContext, IDocumentModel, IModelFactory } from '../docregistry';
/**
* An object which manages the active contexts.
*/
export declare class ContextManager implements IDisposable {
/**
* Construct a new context manager.
*/
constructor(options: ContextManager.IOptions);
/**
* Get whether the context manager has been disposed.
*/
isDisposed: boolean;
/**
* Dispose of the resources held by the document manager.
*/
dispose(): void;
/**
* Create a new context.
*/
createNew(path: string, model: IDocumentModel, factory: IModelFactory): string;
/**
* Get a context for a given path and model name.
*/
findContext(path: string, modelName: string): string;
/**
* Find a context by path.
*/
getIdsForPath(path: string): string[];
/**
* Get a context by id.
*/
getContext(id: string): IDocumentContext<IDocumentModel>;
/**
* Get the model associated with a context.
*/
getModel(id: string): IDocumentModel;
/**
* Remove a context.
*/
removeContext(id: string): void;
/**
* Get the current kernel associated with a document.
*/
getKernel(id: string): IKernel;
/**
* Get the current path associated with a document.
*/
getPath(id: string): string;
/**
* Get the current contents model associated with a document.
*/
getContentsModel(id: string): IContents.IModel;
/**
* Change the current kernel associated with the document.
*
* @param options - If given, change the kernel (starting a session
* if necessary). If falsey, shut down any existing session and return
* a void promise.
*/
changeKernel(id: string, options: IKernel.IModel): Promise<IKernel>;
/**
* Update the path of an open document.
*
* @param id - The id of the context.
*
* @param newPath - The new path.
*/
handleRename(oldPath: string, newPath: string): void;
/**
* Get the current kernelspec information.
*/
getKernelspecs(): IKernel.ISpecModels;
/**
* Save the document contents to disk.
*/
save(id: string): Promise<void>;
/**
* Save a document to a new file path chosen by the user.
*
* This results in a new session.
*/
saveAs(id: string): Promise<void>;
/**
* Revert the contents of a path.
*/
revert(id: string): Promise<void>;
/**
* Test whether the context is fully populated.
*/
isPopulated(id: string): boolean;
/**
* Finalize a context.
*/
finalize(id: string): void;
/**
* Get the list of running sessions.
*/
listSessions(): Promise<ISession.IModel[]>;
/**
* Resolve a relative url to a correct server path.
*/
resolveUrl(id: string, url: string): string;
/**
* Add a sibling widget to the document manager.
*/
addSibling(id: string, widget: Widget): IDisposable;
/**
* Start a session and set up its signals.
*/
private _startSession(id, options);
/**
* Copy the contents of a contents model, without the content.
*/
private _copyContentsModel(model);
private _manager;
private _contexts;
private _opener;
}
/**
* A namespace for ContextManager statics.
*/
export declare namespace ContextManager {
/**
* The options used to initialize a context manager.
*/
interface IOptions {
/**
* A service manager instance.
*/
manager: IServiceManager;
/**
* A callback for opening sibling widgets.
*/
opener: (id: string, widget: Widget) => IDisposable;
}
}