@jupyterlab/docmanager
Version: 
JupyterLab - Document Manager
109 lines (108 loc) • 2.86 kB
TypeScript
import { Contents } from '@jupyterlab/services';
import { IStateDB } from '@jupyterlab/statedb';
import { ISignal } from '@lumino/signaling';
import { IRecentsManager, RecentDocument } from './tokens';
/**
 * Manager for recently opened and closed documents.
 */
export declare class RecentsManager implements IRecentsManager {
    constructor(options: RecentsManager.IOptions);
    /**
     * Whether the manager is disposed or not.
     */
    get isDisposed(): boolean;
    /**
     * List of recently opened items
     */
    get recentlyOpened(): RecentDocument[];
    /**
     * List of recently opened items
     */
    get recentlyClosed(): RecentDocument[];
    /**
     * Signal emitted when the recent list changes.
     */
    get changed(): ISignal<IRecentsManager, void>;
    /**
     * Maximal number of recent items to list.
     */
    get maximalRecentsLength(): number;
    set maximalRecentsLength(value: number);
    /**
     * Dispose recent manager resources
     */
    dispose(): void;
    /**
     * Add a new path to the recent list.
     */
    addRecent(document: Omit<RecentDocument, 'root'>, event: 'opened' | 'closed'): void;
    /**
     * Clear the recents list
     */
    clearRecents(): void;
    /**
     * Remove the document from recents list.
     */
    removeRecent(document: RecentDocument, event: 'opened' | 'closed'): void;
    /**
     * Check if the recent item is valid, remove if it from both lists if it is not.
     */
    validate(recent: RecentDocument): Promise<boolean>;
    /**
     * Set server root dir.
     *
     * Note: protected to allow unit-testing.
     */
    protected updateRootDir(): void;
    /**
     * Remove a path from both lists (opened and closed).
     */
    private _removeRecent;
    /**
     * Check if the path of a given recent document exists.
     */
    private _isValid;
    /**
     * Set the recent list
     * @param recents The new recent list
     */
    private _setRecents;
    /**
     * Load the recent items from the state.
     */
    private _loadRecents;
    /**
     * Get the list of invalid path in recents.
     */
    private _getInvalidPaths;
    /**
     * Save the recent items to the state.
     */
    private _save;
    private _recentsChanged;
    private _serverRoot;
    private _stateDB;
    private _contentsManager;
    private _recents;
    private _saveDebouncer;
    private _isDisposed;
    private _maxRecentsLength;
}
/**
 * Namespace for RecentsManager statics.
 */
export declare namespace RecentsManager {
    /**
     * Initialization options for RecentsManager.
     */
    interface IOptions {
        /**
         * State database used to store the recent documents.
         */
        stateDB: IStateDB;
        /**
         * Contents manager used for path validation.
         */
        contents: Contents.IManager;
    }
}