1 | import { IChangedArgs } from '@jupyterlab/coreutils';
|
2 | import { IDocumentManager } from '@jupyterlab/docmanager';
|
3 | import { Contents, KernelSpec, Session } from '@jupyterlab/services';
|
4 | import { IStateDB } from '@jupyterlab/statedb';
|
5 | import { ITranslator } from '@jupyterlab/translation';
|
6 | import { IIterator, IterableOrArrayLike } from '@lumino/algorithm';
|
7 | import { IDisposable } from '@lumino/disposable';
|
8 | import { ISignal } from '@lumino/signaling';
|
9 |
|
10 |
|
11 |
|
12 | export declare const LARGE_FILE_SIZE: number;
|
13 |
|
14 |
|
15 |
|
16 | export declare const CHUNK_SIZE: number;
|
17 |
|
18 |
|
19 |
|
20 | export interface IUploadModel {
|
21 | path: string;
|
22 | |
23 |
|
24 |
|
25 | progress: number;
|
26 | }
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | export declare class FileBrowserModel implements IDisposable {
|
35 | |
36 |
|
37 |
|
38 | constructor(options: FileBrowserModel.IOptions);
|
39 | /**
|
40 | * The document manager instance used by the file browser model.
|
41 | */
|
42 | readonly manager: IDocumentManager;
|
43 | /**
|
44 | * A signal emitted when the file browser model loses connection.
|
45 | */
|
46 | get connectionFailure(): ISignal<this, Error>;
|
47 | /**
|
48 | * The drive name that gets prepended to the path.
|
49 | */
|
50 | get driveName(): string;
|
51 | /**
|
52 | * A promise that resolves when the model is first restored.
|
53 | */
|
54 | get restored(): Promise<void>;
|
55 | /**
|
56 | * Get the file path changed signal.
|
57 | */
|
58 | get fileChanged(): ISignal<this, Contents.IChangedArgs>;
|
59 | /**
|
60 | * Get the current path.
|
61 | */
|
62 | get path(): string;
|
63 | /**
|
64 | * Get the root path
|
65 | */
|
66 | get rootPath(): string;
|
67 | /**
|
68 | * A signal emitted when the path changes.
|
69 | */
|
70 | get pathChanged(): ISignal<this, IChangedArgs<string>>;
|
71 | /**
|
72 | * A signal emitted when the directory listing is refreshed.
|
73 | */
|
74 | get refreshed(): ISignal<this, void>;
|
75 | /**
|
76 | * Get the kernel spec models.
|
77 | */
|
78 | get specs(): KernelSpec.ISpecModels | null;
|
79 | /**
|
80 | * Get whether the model is disposed.
|
81 | */
|
82 | get isDisposed(): boolean;
|
83 | /**
|
84 | * A signal emitted when an upload progresses.
|
85 | */
|
86 | get uploadChanged(): ISignal<this, IChangedArgs<IUploadModel | null>>;
|
87 | /**
|
88 | * Create an iterator over the status of all in progress uploads.
|
89 | */
|
90 | uploads(): IIterator<IUploadModel>;
|
91 | /**
|
92 | * Dispose of the resources held by the model.
|
93 | */
|
94 | dispose(): void;
|
95 | /**
|
96 | * Create an iterator over the model's items.
|
97 | *
|
98 | * @returns A new iterator over the model's items.
|
99 | */
|
100 | items(): IIterator<Contents.IModel>;
|
101 | /**
|
102 | * Create an iterator over the active sessions in the directory.
|
103 | *
|
104 | * @returns A new iterator over the model's active sessions.
|
105 | */
|
106 | sessions(): IIterator<Session.IModel>;
|
107 | /**
|
108 | * Force a refresh of the directory contents.
|
109 | */
|
110 | refresh(): Promise<void>;
|
111 | /**
|
112 | * Change directory.
|
113 | *
|
114 | * @param path - The path to the file or directory.
|
115 | *
|
116 | * @returns A promise with the contents of the directory.
|
117 | */
|
118 | cd(newValue?: string): Promise<void>;
|
119 | /**
|
120 | * Download a file.
|
121 | *
|
122 | * @param path - The path of the file to be downloaded.
|
123 | *
|
124 | * @returns A promise which resolves when the file has begun
|
125 | * downloading.
|
126 | */
|
127 | download(path: string): Promise<void>;
|
128 | /**
|
129 | * Restore the state of the file browser.
|
130 | *
|
131 | * @param id - The unique ID that is used to construct a state database key.
|
132 | *
|
133 | * @param populate - If `false`, the restoration ID will be set but the file
|
134 | * browser state will not be fetched from the state database.
|
135 | *
|
136 | * @returns A promise when restoration is complete.
|
137 | *
|
138 | * #### Notes
|
139 | * This function will only restore the model *once*. If it is called multiple
|
140 | * times, all subsequent invocations are no-ops.
|
141 | */
|
142 | restore(id: string, populate?: boolean): Promise<void>;
|
143 | /**
|
144 | * Upload a `File` object.
|
145 | *
|
146 | * @param file - The `File` object to upload.
|
147 | *
|
148 | * @returns A promise containing the new file contents model.
|
149 | *
|
150 | * #### Notes
|
151 | * On Notebook version < 5.1.0, this will fail to upload files that are too
|
152 | * big to be sent in one request to the server. On newer versions, or on
|
153 | * Jupyter Server, it will ask for confirmation then upload the file in 1 MB
|
154 | * chunks.
|
155 | */
|
156 | upload(file: File): Promise<Contents.IModel>;
|
157 | private _shouldUploadLarge;
|
158 | /**
|
159 | * Perform the actual upload.
|
160 | */
|
161 | private _upload;
|
162 | private _uploadCheckDisposed;
|
163 | /**
|
164 | * Handle an updated contents model.
|
165 | */
|
166 | protected handleContents(contents: Contents.IModel): void;
|
167 | /**
|
168 | * Handle a change to the running sessions.
|
169 | */
|
170 | protected onRunningChanged(sender: Session.IManager, models: IterableOrArrayLike<Session.IModel>): void;
|
171 | /**
|
172 | * Handle a change on the contents manager.
|
173 | */
|
174 | protected onFileChanged(sender: Contents.IManager, change: Contents.IChangedArgs): void;
|
175 | /**
|
176 | * Populate the model's sessions collection.
|
177 | */
|
178 | private _populateSessions;
|
179 | protected translator: ITranslator;
|
180 | private _trans;
|
181 | private _connectionFailure;
|
182 | private _fileChanged;
|
183 | private _items;
|
184 | private _key;
|
185 | private _model;
|
186 | private _pathChanged;
|
187 | private _paths;
|
188 | private _pending;
|
189 | private _pendingPath;
|
190 | private _refreshed;
|
191 | private _sessions;
|
192 | private _state;
|
193 | private _driveName;
|
194 | private _isDisposed;
|
195 | private _restored;
|
196 | private _uploads;
|
197 | private _uploadChanged;
|
198 | private _unloadEventListener;
|
199 | private _poll;
|
200 | }
|
201 | /**
|
202 | * The namespace for the `FileBrowserModel` class statics.
|
203 | */
|
204 | export declare namespace FileBrowserModel {
|
205 | |
206 |
|
207 |
|
208 | interface IOptions {
|
209 | |
210 |
|
211 |
|
212 |
|
213 | auto?: boolean;
|
214 | |
215 |
|
216 |
|
217 |
|
218 |
|
219 | driveName?: string;
|
220 | |
221 |
|
222 |
|
223 | manager: IDocumentManager;
|
224 | |
225 |
|
226 |
|
227 | refreshInterval?: number;
|
228 | |
229 |
|
230 |
|
231 |
|
232 | state?: IStateDB;
|
233 | |
234 |
|
235 |
|
236 | translator?: ITranslator;
|
237 | }
|
238 | }
|
239 |
|
240 |
|
241 |
|
242 | export declare class TogglableHiddenFileBrowserModel extends FileBrowserModel {
|
243 | constructor(options: TogglableHiddenFileBrowserModel.IOptions);
|
244 | /**
|
245 | * Create an iterator over the model's items filtering hidden files out if necessary.
|
246 | *
|
247 | * @returns A new iterator over the model's items.
|
248 | */
|
249 | items(): IIterator<Contents.IModel>;
|
250 | /**
|
251 | * Set the inclusion of hidden files. Triggers a model refresh.
|
252 | */
|
253 | showHiddenFiles(value: boolean): void;
|
254 | private _includeHiddenFiles;
|
255 | }
|
256 | /**
|
257 | * Namespace for the togglable hidden file browser model
|
258 | */
|
259 | export declare namespace TogglableHiddenFileBrowserModel {
|
260 | |
261 |
|
262 |
|
263 | interface IOptions extends FileBrowserModel.IOptions {
|
264 | |
265 |
|
266 |
|
267 | includeHiddenFiles?: boolean;
|
268 | }
|
269 | }
|
270 |
|
271 |
|
272 |
|
273 | export declare class FilterFileBrowserModel extends TogglableHiddenFileBrowserModel {
|
274 | constructor(options: FilterFileBrowserModel.IOptions);
|
275 | /**
|
276 | * Create an iterator over the filtered model's items.
|
277 | *
|
278 | * @returns A new iterator over the model's items.
|
279 | */
|
280 | items(): IIterator<Contents.IModel>;
|
281 | setFilter(filter: (value: Contents.IModel) => boolean): void;
|
282 | private _filter;
|
283 | }
|
284 | /**
|
285 | * Namespace for the filtered file browser model
|
286 | */
|
287 | export declare namespace FilterFileBrowserModel {
|
288 | |
289 |
|
290 |
|
291 | interface IOptions extends TogglableHiddenFileBrowserModel.IOptions {
|
292 | |
293 |
|
294 |
|
295 | filter?: (value: Contents.IModel) => boolean;
|
296 | }
|
297 | }
|