UNPKG

2.86 kBTypeScriptView Raw
1import { Contents } from '@jupyterlab/services';
2import { IStateDB } from '@jupyterlab/statedb';
3import { ISignal } from '@lumino/signaling';
4import { IRecentsManager, RecentDocument } from './tokens';
5/**
6 * Manager for recently opened and closed documents.
7 */
8export declare class RecentsManager implements IRecentsManager {
9 constructor(options: RecentsManager.IOptions);
10 /**
11 * Whether the manager is disposed or not.
12 */
13 get isDisposed(): boolean;
14 /**
15 * List of recently opened items
16 */
17 get recentlyOpened(): RecentDocument[];
18 /**
19 * List of recently opened items
20 */
21 get recentlyClosed(): RecentDocument[];
22 /**
23 * Signal emitted when the recent list changes.
24 */
25 get changed(): ISignal<IRecentsManager, void>;
26 /**
27 * Maximal number of recent items to list.
28 */
29 get maximalRecentsLength(): number;
30 set maximalRecentsLength(value: number);
31 /**
32 * Dispose recent manager resources
33 */
34 dispose(): void;
35 /**
36 * Add a new path to the recent list.
37 */
38 addRecent(document: Omit<RecentDocument, 'root'>, event: 'opened' | 'closed'): void;
39 /**
40 * Clear the recents list
41 */
42 clearRecents(): void;
43 /**
44 * Remove the document from recents list.
45 */
46 removeRecent(document: RecentDocument, event: 'opened' | 'closed'): void;
47 /**
48 * Check if the recent item is valid, remove if it from both lists if it is not.
49 */
50 validate(recent: RecentDocument): Promise<boolean>;
51 /**
52 * Set server root dir.
53 *
54 * Note: protected to allow unit-testing.
55 */
56 protected updateRootDir(): void;
57 /**
58 * Remove a path from both lists (opened and closed).
59 */
60 private _removeRecent;
61 /**
62 * Check if the path of a given recent document exists.
63 */
64 private _isValid;
65 /**
66 * Set the recent list
67 * @param recents The new recent list
68 */
69 private _setRecents;
70 /**
71 * Load the recent items from the state.
72 */
73 private _loadRecents;
74 /**
75 * Get the list of invalid path in recents.
76 */
77 private _getInvalidPaths;
78 /**
79 * Save the recent items to the state.
80 */
81 private _save;
82 private _recentsChanged;
83 private _serverRoot;
84 private _stateDB;
85 private _contentsManager;
86 private _recents;
87 private _saveDebouncer;
88 private _isDisposed;
89 private _maxRecentsLength;
90}
91/**
92 * Namespace for RecentsManager statics.
93 */
94export declare namespace RecentsManager {
95 /**
96 * Initialization options for RecentsManager.
97 */
98 interface IOptions {
99 /**
100 * State database used to store the recent documents.
101 */
102 stateDB: IStateDB;
103 /**
104 * Contents manager used for path validation.
105 */
106 contents: Contents.IManager;
107 }
108}