jupyterlab-emrys
Version:
A computational environment for Jupyter. Powered by Emrys
165 lines (164 loc) • 4.64 kB
TypeScript
import { IContents, IKernel, IServiceManager, ISession } from 'jupyter-js-services';
import { IDisposable } from 'phosphor-disposable';
import { IChangedArgs } from 'phosphor-properties';
import { ISignal } from 'phosphor-signaling';
/**
* An implementation of a file browser model.
*
* #### Notes
* All paths parameters without a leading `'/'` are interpreted as relative to
* the current directory. Supports `'../'` syntax.
*/
export declare class FileBrowserModel implements IDisposable {
/**
* Construct a new file browser model.
*/
constructor(options: FileBrowserModel.IOptions);
/**
* A signal emitted when the path changes.
*/
pathChanged: ISignal<FileBrowserModel, IChangedArgs<string>>;
/**
* Get the refreshed signal.
*/
refreshed: ISignal<FileBrowserModel, void>;
/**
* Get the file path changed signal.
*/
fileChanged: ISignal<FileBrowserModel, IChangedArgs<string>>;
/**
* Get the current path.
*
* #### Notes
* This is a read-only property.
*/
path: string;
/**
* Get a read-only list of the items in the current path.
*/
items: IContents.IModel[];
/**
* Get whether the view model is disposed.
*/
isDisposed: boolean;
/**
* Get the session models for active notebooks.
*
* #### Notes
* This is a read-only property.
*/
sessions: ISession.IModel[];
/**
* Get the kernel specs.
*/
kernelspecs: IKernel.ISpecModels;
/**
* Dispose of the resources held by the view model.
*/
dispose(): void;
/**
* Change directory.
*
* @param path - The path to the file or directory.
*
* @returns A promise with the contents of the directory.
*/
cd(newValue?: string): Promise<void>;
/**
* Refresh the current directory.
*/
refresh(): Promise<void>;
/**
* Copy a file.
*
* @param fromFile - The path of the original file.
*
* @param toDir - The path to the target directory.
*
* @returns A promise which resolves to the contents of the file.
*/
copy(fromFile: string, toDir: string): Promise<IContents.IModel>;
/**
* Delete a file.
*
* @param: path - The path to the file to be deleted.
*
* @returns A promise which resolves when the file is deleted.
*/
deleteFile(path: string): Promise<void>;
/**
* Download a file.
*
* @param - path - The path of the file to be downloaded.
*
* @returns - A promise which resolves to the file contents.
*/
download(path: string): Promise<IContents.IModel>;
/**
* Create a new untitled file or directory in the current directory.
*
* @param type - The type of file object to create. One of
* `['file', 'notebook', 'directory']`.
*
* @param ext - Optional extension for `'file'` types (defaults to `'.txt'`).
*
* @returns A promise containing the new file contents model.
*/
newUntitled(options: IContents.ICreateOptions): Promise<IContents.IModel>;
/**
* Rename a file or directory.
*
* @param path - The path to the original file.
*
* @param newPath - The path to the new file.
*
* @returns A promise containing the new file contents model.
*/
rename(path: string, newPath: string): Promise<IContents.IModel>;
/**
* Upload a `File` object.
*
* @param file - The `File` object to upload.
*
* @param overwrite - Whether to overwrite an existing file.
*
* @returns A promise containing the new file contents model.
*
* #### Notes
* This will fail to upload files that are too big to be sent in one
* request to the server.
*/
upload(file: File, overwrite?: boolean): Promise<IContents.IModel>;
/**
* Shut down a session by session id.
*/
shutdown(id: string): Promise<void>;
/**
* Perform the actual upload.
*/
private _upload(file);
/**
* Handle a change to the running sessions.
*/
private _onRunningChanged(sender, models);
private _maxUploadSizeMb;
private _manager;
private _sessions;
private _model;
private _pendingPath;
private _pending;
}
/**
* The namespace for the `FileBrowserModel` class statics.
*/
export declare namespace FileBrowserModel {
/**
* An options object for initializing a file browser.
*/
interface IOptions {
/**
* A service manager instance.
*/
manager: IServiceManager;
}
}