|
3 | 3 | // Definitions by: Bazyli Brzóska <https://invent.life/>
|
4 | 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 | 5 |
|
6 |
| -declare module Resumable { |
| 6 | +export as namespace Resumable; |
| 7 | +export default Resumable; |
| 8 | + |
| 9 | +declare class Resumable { |
| 10 | + constructor(options: Resumable.ConfigurationHash); |
| 11 | + |
| 12 | + /** |
| 13 | + * A boolean value indicator whether or not Resumable.js is supported by the current browser. |
| 14 | + **/ |
| 15 | + support: boolean; |
| 16 | + /** |
| 17 | + * A hash object of the configuration of the Resumable.js instance. |
| 18 | + **/ |
| 19 | + opts: Resumable.ConfigurationHash; |
| 20 | + /** |
| 21 | + * An array of ResumableFile file objects added by the user (see full docs for this object type below). |
| 22 | + **/ |
| 23 | + files: Array<Resumable.ResumableFile>; |
| 24 | + |
| 25 | + events: Array<any>; |
| 26 | + version: number; |
| 27 | + |
| 28 | + /** |
| 29 | + * Assign a browse action to one or more DOM nodes. Pass in true to allow directories to be selected (Chrome only). |
| 30 | + **/ |
| 31 | + assignBrowse(domNode: Element | Array<Element>, isDirectory: boolean): void; |
| 32 | + /** |
| 33 | + * Assign one or more DOM nodes as a drop target. |
| 34 | + **/ |
| 35 | + assignDrop(domNode: Element | Array<Element>): void; |
| 36 | + unAssignDrop(domNode: Element | Array<Element>): void; |
| 37 | + /** |
| 38 | + * Start or resume uploading. |
| 39 | + **/ |
| 40 | + upload(): void; |
| 41 | + uploadNextChunk(): void; |
| 42 | + /** |
| 43 | + * Pause uploading. |
| 44 | + **/ |
| 45 | + pause(): void; |
| 46 | + /** |
| 47 | + * Cancel upload of all ResumableFile objects and remove them from the list. |
| 48 | + **/ |
| 49 | + cancel(): void; |
| 50 | + fire(): void; |
| 51 | + /** |
| 52 | + * Returns a float between 0 and 1 indicating the current upload progress of all files. |
| 53 | + **/ |
| 54 | + progress(): number; |
| 55 | + /** |
| 56 | + * Returns a boolean indicating whether or not the instance is currently uploading anything. |
| 57 | + **/ |
| 58 | + isUploading(): boolean; |
| 59 | + /** |
| 60 | + * Add a HTML5 File object to the list of files. |
| 61 | + **/ |
| 62 | + addFile(file: File): void; |
| 63 | + /** |
| 64 | + * Add an Array of HTML5 File objects to the list of files. |
| 65 | + **/ |
| 66 | + addFiles(files: Array<File>): void; |
| 67 | + /** |
| 68 | + * Cancel upload of a specific ResumableFile object on the list from the list. |
| 69 | + **/ |
| 70 | + removeFile(file: Resumable.ResumableFile): void; |
| 71 | + /** |
| 72 | + * Look up a ResumableFile object by its unique identifier. |
| 73 | + **/ |
| 74 | + getFromUniqueIdentifier(uniqueIdentifier: string): void; |
| 75 | + /** |
| 76 | + * Returns the total size of the upload in bytes. |
| 77 | + **/ |
| 78 | + getSize(): number; |
| 79 | + getOpt(o: string): any; |
| 80 | + |
| 81 | + // Events |
| 82 | + /** |
| 83 | + * Listen for event from Resumable.js (see below) |
| 84 | + **/ |
| 85 | + on(event: string, callback: Function): void; |
| 86 | + /** |
| 87 | + * A specific file was completed. |
| 88 | + **/ |
| 89 | + on(event: 'fileSuccess', callback: (file: Resumable.ResumableFile) => void); void; |
| 90 | + /** |
| 91 | + * Uploading progressed for a specific file. |
| 92 | + **/ |
| 93 | + on(event: 'fileProgress', callback: (file: Resumable.ResumableFile) => void): void; |
| 94 | + /** |
| 95 | + * A new file was added. Optionally, you can use the browser event object from when the file was added. |
| 96 | + **/ |
| 97 | + on(event: 'fileAdded', callback: (file: Resumable.ResumableFile, event: DragEvent) => void): void; |
| 98 | + /** |
| 99 | + * New files were added. |
| 100 | + **/ |
| 101 | + on(event: 'filesAdded', callback: (files: Array<Resumable.ResumableFile>) => void): void; |
| 102 | + /** |
| 103 | + * Something went wrong during upload of a specific file, uploading is being retried. |
| 104 | + **/ |
| 105 | + on(event: 'fileRetry', callback: (file: Resumable.ResumableFile) => void): void; |
| 106 | + /** |
| 107 | + * An error occurred during upload of a specific file. |
| 108 | + **/ |
| 109 | + on(event: 'fileError', callback: (file: Resumable.ResumableFile, message: string) => void): void; |
| 110 | + /** |
| 111 | + * Upload has been started on the Resumable object. |
| 112 | + **/ |
| 113 | + on(event: 'uploadStart', callback: () => void): void; |
| 114 | + /** |
| 115 | + * Uploading completed. |
| 116 | + **/ |
| 117 | + on(event: 'complete', callback: () => void): void; |
| 118 | + /** |
| 119 | + * Uploading progress. |
| 120 | + **/ |
| 121 | + on(event: 'progress', callback: () => void): void; |
| 122 | + /** |
| 123 | + * An error, including fileError, occurred. |
| 124 | + **/ |
| 125 | + on(event: 'error', callback: (message: string, file: Resumable.ResumableFile) => void): void; |
| 126 | + /** |
| 127 | + * Uploading was paused. |
| 128 | + **/ |
| 129 | + on(event: 'pause', callback: () => void): void; |
| 130 | + /** |
| 131 | + * Triggers before the items are cancelled allowing to do any processing on uploading files. |
| 132 | + **/ |
| 133 | + on(event: 'beforeCancel', callback: () => void): void; |
| 134 | + /** |
| 135 | + * Uploading was canceled. |
| 136 | + **/ |
| 137 | + on(event: 'cancel', callback: () => void): void; |
| 138 | + /** |
| 139 | + * Started preparing file for upload |
| 140 | + **/ |
| 141 | + on(event: 'chunkingStart', callback: (file: Resumable.ResumableFile) => void): void; |
| 142 | + /** |
| 143 | + * Show progress in file preparation |
| 144 | + **/ |
| 145 | + on(event: 'chunkingProgress', callback: (file: Resumable.ResumableFile, ratio) => void): void; |
| 146 | + /** |
| 147 | + * File is ready for upload |
| 148 | + **/ |
| 149 | + on(event: 'chunkingComplete', callback: (file: Resumable.ResumableFile) => void): void; |
| 150 | + /** |
| 151 | + * Listen to all the events listed above with the same callback function. |
| 152 | + **/ |
| 153 | + on(event: 'catchAll', callback: () => void); |
| 154 | +} |
| 155 | + |
| 156 | +declare namespace Resumable { |
7 | 157 | export interface ConfigurationHash {
|
8 | 158 | /**
|
9 | 159 | * The target URL for the multipart POST request. This can be a string or a function that allows you you to construct and return a value, based on supplied params. (Default: /)
|
@@ -166,153 +316,6 @@ declare module Resumable {
|
166 | 316 | permanentErrors?: number[]
|
167 | 317 | }
|
168 | 318 |
|
169 |
| - export class Resumable { |
170 |
| - constructor(options:ConfigurationHash); |
171 |
| - |
172 |
| - /** |
173 |
| - * A boolean value indicator whether or not Resumable.js is supported by the current browser. |
174 |
| - **/ |
175 |
| - support: boolean; |
176 |
| - /** |
177 |
| - * A hash object of the configuration of the Resumable.js instance. |
178 |
| - **/ |
179 |
| - opts: ConfigurationHash; |
180 |
| - /** |
181 |
| - * An array of ResumableFile file objects added by the user (see full docs for this object type below). |
182 |
| - **/ |
183 |
| - files: Array<ResumableFile>; |
184 |
| - |
185 |
| - events: Array<any>; |
186 |
| - version: number; |
187 |
| - |
188 |
| - /** |
189 |
| - * Assign a browse action to one or more DOM nodes. Pass in true to allow directories to be selected (Chrome only). |
190 |
| - **/ |
191 |
| - assignBrowse(domNode: Element | Array<Element>, isDirectory: boolean): void; |
192 |
| - /** |
193 |
| - * Assign one or more DOM nodes as a drop target. |
194 |
| - **/ |
195 |
| - assignDrop(domNode: Element | Array<Element>): void; |
196 |
| - unAssignDrop(domNode: Element | Array<Element>): void; |
197 |
| - /** |
198 |
| - * Start or resume uploading. |
199 |
| - **/ |
200 |
| - upload(): void; |
201 |
| - uploadNextChunk(): void; |
202 |
| - /** |
203 |
| - * Pause uploading. |
204 |
| - **/ |
205 |
| - pause(): void; |
206 |
| - /** |
207 |
| - * Cancel upload of all ResumableFile objects and remove them from the list. |
208 |
| - **/ |
209 |
| - cancel(): void; |
210 |
| - fire(): void; |
211 |
| - /** |
212 |
| - * Returns a float between 0 and 1 indicating the current upload progress of all files. |
213 |
| - **/ |
214 |
| - progress(): number; |
215 |
| - /** |
216 |
| - * Returns a boolean indicating whether or not the instance is currently uploading anything. |
217 |
| - **/ |
218 |
| - isUploading(): boolean; |
219 |
| - /** |
220 |
| - * Add a HTML5 File object to the list of files. |
221 |
| - **/ |
222 |
| - addFile(file: File): void; |
223 |
| - /** |
224 |
| - * Add an Array of HTML5 File objects to the list of files. |
225 |
| - **/ |
226 |
| - addFiles(files: Array<File>): void; |
227 |
| - /** |
228 |
| - * Cancel upload of a specific ResumableFile object on the list from the list. |
229 |
| - **/ |
230 |
| - removeFile(file: ResumableFile): void; |
231 |
| - /** |
232 |
| - * Look up a ResumableFile object by its unique identifier. |
233 |
| - **/ |
234 |
| - getFromUniqueIdentifier(uniqueIdentifier: string): void; |
235 |
| - /** |
236 |
| - * Returns the total size of the upload in bytes. |
237 |
| - **/ |
238 |
| - getSize(): number; |
239 |
| - getOpt(o: string): any; |
240 |
| - |
241 |
| - // Events |
242 |
| - /** |
243 |
| - * Listen for event from Resumable.js (see below) |
244 |
| - **/ |
245 |
| - on(event: string, callback: Function): void; |
246 |
| - /** |
247 |
| - * A specific file was completed. |
248 |
| - **/ |
249 |
| - on(event: 'fileSuccess', callback: (file: ResumableFile) => void); void; |
250 |
| - /** |
251 |
| - * Uploading progressed for a specific file. |
252 |
| - **/ |
253 |
| - on(event: 'fileProgress', callback: (file: ResumableFile) => void): void; |
254 |
| - /** |
255 |
| - * A new file was added. Optionally, you can use the browser event object from when the file was added. |
256 |
| - **/ |
257 |
| - on(event: 'fileAdded', callback: (file: ResumableFile, event: DragEvent) => void): void; |
258 |
| - /** |
259 |
| - * New files were added. |
260 |
| - **/ |
261 |
| - on(event: 'filesAdded', callback: (files: Array<ResumableFile>) => void): void; |
262 |
| - /** |
263 |
| - * Something went wrong during upload of a specific file, uploading is being retried. |
264 |
| - **/ |
265 |
| - on(event: 'fileRetry', callback: (file: ResumableFile) => void): void; |
266 |
| - /** |
267 |
| - * An error occurred during upload of a specific file. |
268 |
| - **/ |
269 |
| - on(event: 'fileError', callback: (file: ResumableFile, message: string) => void): void; |
270 |
| - /** |
271 |
| - * Upload has been started on the Resumable object. |
272 |
| - **/ |
273 |
| - on(event: 'uploadStart', callback: () => void): void; |
274 |
| - /** |
275 |
| - * Uploading completed. |
276 |
| - **/ |
277 |
| - on(event: 'complete', callback: () => void): void; |
278 |
| - /** |
279 |
| - * Uploading progress. |
280 |
| - **/ |
281 |
| - on(event: 'progress', callback: () => void): void; |
282 |
| - /** |
283 |
| - * An error, including fileError, occurred. |
284 |
| - **/ |
285 |
| - on(event: 'error', callback: (message: string, file: ResumableFile) => void): void; |
286 |
| - /** |
287 |
| - * Uploading was paused. |
288 |
| - **/ |
289 |
| - on(event: 'pause', callback: () => void): void; |
290 |
| - /** |
291 |
| - * Triggers before the items are cancelled allowing to do any processing on uploading files. |
292 |
| - **/ |
293 |
| - on(event: 'beforeCancel', callback: () => void): void; |
294 |
| - /** |
295 |
| - * Uploading was canceled. |
296 |
| - **/ |
297 |
| - on(event: 'cancel', callback: () => void): void; |
298 |
| - /** |
299 |
| - * Started preparing file for upload |
300 |
| - **/ |
301 |
| - on(event: 'chunkingStart', callback: (file: ResumableFile) => void): void; |
302 |
| - /** |
303 |
| - * Show progress in file preparation |
304 |
| - **/ |
305 |
| - on(event: 'chunkingProgress', callback: (file: ResumableFile, ratio) => void): void; |
306 |
| - /** |
307 |
| - * File is ready for upload |
308 |
| - **/ |
309 |
| - on(event: 'chunkingComplete', callback: (file: ResumableFile) => void): void; |
310 |
| - /** |
311 |
| - * Listen to all the events listed above with the same callback function. |
312 |
| - **/ |
313 |
| - on(event: 'catchAll', callback: () => void); |
314 |
| - } |
315 |
| - |
316 | 319 | export interface ResumableFile {
|
317 | 320 | /**
|
318 | 321 | * A back-reference to the parent Resumable object.
|
@@ -376,7 +379,3 @@ declare module Resumable {
|
376 | 379 |
|
377 | 380 | class ResumableChunk {}
|
378 | 381 | }
|
379 |
| - |
380 |
| -declare module 'resumablejs' { |
381 |
| - export = Resumable.Resumable; |
382 |
| -} |
0 commit comments