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