import { Contents, Kernel, ServiceManager } from '@jupyterlab/services'; import { IDisposable } from '@phosphor/disposable'; import { ISignal } from '@phosphor/signaling'; import { Widget } from '@phosphor/widgets'; import { DocumentRegistry } from '../docregistry'; /** * An implementation of a document context. * * This class is typically instantiated by the document manger. */ export declare class Context implements DocumentRegistry.IContext { /** * Construct a new document context. */ constructor(options: Context.IOptions); /** * A signal emitted when the kernel changes. */ readonly kernelChanged: ISignal; /** * A signal emitted when the path changes. */ readonly pathChanged: ISignal; /** * A signal emitted when the model is saved or reverted. */ readonly fileChanged: ISignal; /** * A signal emitted when the context is disposed. */ readonly disposed: ISignal; /** * Get the model associated with the document. */ readonly model: T; /** * The current kernel associated with the document. */ readonly kernel: Kernel.IKernel; /** * The current path associated with the document. */ readonly path: string; /** * The current contents model associated with the document * * #### Notes * The model will have an empty `contents` field. */ readonly contentsModel: Contents.IModel; /** * Get the model factory name. * * #### Notes * This is not part of the `IContext` API. */ readonly factoryName: string; /** * Test whether the context is disposed. */ readonly isDisposed: boolean; /** * Dispose of the resources held by the context. */ dispose(): void; /** * The kernel spec models */ readonly specs: Kernel.ISpecModels; /** * Whether the context is ready. */ readonly isReady: boolean; /** * A promise that is fulfilled when the context is ready. */ readonly ready: Promise; /** * Start the default kernel for the context. * * @returns A promise that resolves with the new kernel. */ startDefaultKernel(): Promise; /** * Change the current kernel associated with the document. */ changeKernel(options: Kernel.IModel): Promise; /** * Save the document contents to disk. */ save(): Promise; /** * Save the document to a different path chosen by the user. */ saveAs(): Promise; /** * Revert the document contents to disk contents. */ revert(): Promise; /** * Create a checkpoint for the file. */ createCheckpoint(): Promise; /** * Delete a checkpoint for the file. */ deleteCheckpoint(checkpointId: string): Promise; /** * Restore the file to a known checkpoint state. */ restoreCheckpoint(checkpointId?: string): Promise; /** * List available checkpoints for a file. */ listCheckpoints(): Promise; /** * Resolve a relative url to a correct server path. */ resolveUrl(url: string): Promise; /** * Get the download url of a given absolute server path. */ getDownloadUrl(path: string): Promise; /** * Add a sibling widget to the document manager. */ addSibling(widget: Widget): IDisposable; /** * Handle a change on the contents manager. */ private _onFileChanged(sender, change); /** * Start a session and set up its signals. */ private _startSession(options); /** * Handle a change to a session path. */ private _onSessionPathChanged(sender, path); /** * Handle a change to the kernel. */ private _onKernelChanged(sender); /** * Update our contents model, without the content. */ private _updateContentsModel(model); /** * Handle a change to the running sessions. */ private _onSessionsChanged(sender, models); /** * Handle an initial population. */ private _populate(); private _manager; private _opener; private _model; private _path; private _session; private _factory; private _contentsModel; private _readyPromise; private _populatedPromise; private _isPopulated; private _isReady; private _kernelChanged; private _pathChanged; private _fileChanged; private _disposed; } /** * A namespace for `Context` statics. */ export declare namespace Context { /** * The options used to initialize a context. */ interface IOptions { /** * A service manager instance. */ manager: ServiceManager.IManager; /** * The model factory used to create the model. */ factory: DocumentRegistry.IModelFactory; /** * The initial path of the file. */ path: string; /** * An optional callback for opening sibling widgets. */ opener?: (widget: Widget) => void; } }