1+ /**
2+ * Factory method that creates an unarchiver based on the byte signature found
3+ * in the arrayBuffer.
4+ * @param {ArrayBuffer } ab
5+ * @param {Function(string):Worker } createWorkerFn A function that creates a Worker from a script file.
6+ * @param {Object|string } options An optional object of options, or a string representing where
7+ * the path to the unarchiver script files.
8+ * @returns {Unarchiver }
9+ */
10+ export function getUnarchiverInternal ( ab : ArrayBuffer , createWorkerFn : any , options ?: any | string ) : Unarchiver ;
11+ export namespace UnarchiveEventType {
12+ const START : string ;
13+ const APPEND : string ;
14+ const PROGRESS : string ;
15+ const EXTRACT : string ;
16+ const FINISH : string ;
17+ const INFO : string ;
18+ const ERROR : string ;
19+ }
20+ /**
21+ * An unarchive event.
22+ */
23+ export class UnarchiveEvent {
24+ /**
25+ * @param {string } type The event type.
26+ */
27+ constructor ( type : string ) ;
28+ /**
29+ * The event type.
30+ * @type {string }
31+ */
32+ type : string ;
33+ }
34+ /**
35+ * Updates all Archiver listeners that an append has occurred.
36+ */
37+ export class UnarchiveAppendEvent extends UnarchiveEvent {
38+ /**
39+ * @param {number } numBytes The number of bytes appended.
40+ */
41+ constructor ( numBytes : number ) ;
42+ /**
43+ * The number of appended bytes.
44+ * @type {number }
45+ */
46+ numBytes : number ;
47+ }
48+ /**
49+ * Useful for passing info up to the client (for debugging).
50+ */
51+ export class UnarchiveInfoEvent extends UnarchiveEvent {
52+ /**
53+ * The information message.
54+ * @type {string }
55+ */
56+ msg : string ;
57+ }
58+ /**
59+ * An unrecoverable error has occured.
60+ */
61+ export class UnarchiveErrorEvent extends UnarchiveEvent {
62+ /**
63+ * The information message.
64+ * @type {string }
65+ */
66+ msg : string ;
67+ }
68+ /**
69+ * Start event.
70+ */
71+ export class UnarchiveStartEvent extends UnarchiveEvent {
72+ constructor ( ) ;
73+ }
74+ /**
75+ * Finish event.
76+ */
77+ export class UnarchiveFinishEvent extends UnarchiveEvent {
78+ /**
79+ * @param {Object } metadata A collection fo metadata about the archive file.
80+ */
81+ constructor ( metadata ?: any ) ;
82+ metadata : any ;
83+ }
84+ /**
85+ * Progress event.
86+ */
87+ export class UnarchiveProgressEvent extends UnarchiveEvent {
88+ /**
89+ * @param {string } currentFilename
90+ * @param {number } currentFileNumber
91+ * @param {number } currentBytesUnarchivedInFile
92+ * @param {number } currentBytesUnarchived
93+ * @param {number } totalUncompressedBytesInArchive
94+ * @param {number } totalFilesInArchive
95+ * @param {number } totalCompressedBytesRead
96+ */
97+ constructor ( currentFilename : string , currentFileNumber : number , currentBytesUnarchivedInFile : number , currentBytesUnarchived : number , totalUncompressedBytesInArchive : number , totalFilesInArchive : number , totalCompressedBytesRead : number ) ;
98+ currentFilename : string ;
99+ currentFileNumber : number ;
100+ currentBytesUnarchivedInFile : number ;
101+ totalFilesInArchive : number ;
102+ currentBytesUnarchived : number ;
103+ totalUncompressedBytesInArchive : number ;
104+ totalCompressedBytesRead : number ;
105+ }
106+ /**
107+ * Extract event.
108+ */
109+ export class UnarchiveExtractEvent extends UnarchiveEvent {
110+ /**
111+ * @param {UnarchivedFile } unarchivedFile
112+ */
113+ constructor ( unarchivedFile : UnarchivedFile ) ;
114+ /**
115+ * @type {UnarchivedFile }
116+ */
117+ unarchivedFile : UnarchivedFile ;
118+ }
119+ /**
120+ * Base class for all Unarchivers.
121+ * TODO: When EventTarget constructors are broadly supported, make this extend
122+ * EventTarget and remove event listener code.
123+ * https://caniuse.com/#feat=mdn-api_eventtarget_eventtarget
124+ */
125+ export class Unarchiver {
126+ /**
127+ * @param {ArrayBuffer } arrayBuffer The Array Buffer. Note that this ArrayBuffer must not be
128+ * referenced once it is sent to the Unarchiver, since it is marked as Transferable and sent
129+ * to the Worker.
130+ * @param {Function(string):Worker } createWorkerFn A function that creates a Worker from a script file.
131+ * @param {Object|string } options An optional object of options, or a string representing where
132+ * the BitJS files are located. The string version of this argument is deprecated.
133+ * Available options:
134+ * 'pathToBitJS': A string indicating where the BitJS files are located.
135+ * 'debug': A boolean where true indicates that the archivers should log debug output.
136+ */
137+ constructor ( arrayBuffer : ArrayBuffer , createWorkerFn : any , options ?: any | string ) ;
138+ /**
139+ * The ArrayBuffer object.
140+ * @type {ArrayBuffer }
141+ * @protected
142+ */
143+ protected ab : ArrayBuffer ;
144+ /**
145+ * A factory method that creates a Worker that does the unarchive work.
146+ * @type {Function(string): Worker }
147+ * @private
148+ */
149+ private createWorkerFn_ ;
150+ /**
151+ * The path to the BitJS files.
152+ * @type {string }
153+ * @private
154+ */
155+ private pathToBitJS_ ;
156+ /**
157+ * @orivate
158+ * @type {boolean }
159+ */
160+ debugMode_ : boolean ;
161+ /**
162+ * A map from event type to an array of listeners.
163+ * @private
164+ * @type {Map.<string, Array> }
165+ */
166+ private listeners_ ;
167+ /**
168+ * Private web worker initialized during start().
169+ * @private
170+ * @type {Worker }
171+ */
172+ private worker_ ;
173+ /**
174+ * This method must be overridden by the subclass to return the script filename.
175+ * @returns {string } The MIME type of the archive.
176+ * @protected .
177+ */
178+ protected getMIMEType ( ) : string ;
179+ /**
180+ * This method must be overridden by the subclass to return the script filename.
181+ * @returns {string } The script filename.
182+ * @protected .
183+ */
184+ protected getScriptFileName ( ) : string ;
185+ /**
186+ * Adds an event listener for UnarchiveEvents.
187+ *
188+ * @param {string } Event type.
189+ * @param {function } An event handler function.
190+ */
191+ addEventListener ( type : any , listener : any ) : void ;
192+ /**
193+ * Removes an event listener.
194+ *
195+ * @param {string } Event type.
196+ * @param {EventListener|function } An event listener or handler function.
197+ */
198+ removeEventListener ( type : any , listener : any ) : void ;
199+ /**
200+ * Create an UnarchiveEvent out of the object sent back from the Worker.
201+ * @param {Object } obj
202+ * @returns {UnarchiveEvent }
203+ * @private
204+ */
205+ private createUnarchiveEvent_ ;
206+ /**
207+ * Receive an event and pass it to the listener functions.
208+ *
209+ * @param {Object } obj
210+ * @private
211+ */
212+ private handleWorkerEvent_ ;
213+ /**
214+ * Starts the unarchive in a separate Web Worker thread and returns immediately.
215+ */
216+ start ( ) : void ;
217+ /**
218+ * Adds more bytes to the unarchiver's Worker thread.
219+ * @param {ArrayBuffer } ab The ArrayBuffer with more bytes in it. If opt_transferable is
220+ * set to true, this ArrayBuffer must not be referenced after calling update(), since it
221+ * is marked as Transferable and sent to the Worker.
222+ * @param {boolean= } opt_transferable Optional boolean whether to mark this ArrayBuffer
223+ * as a Tranferable object, which means it can no longer be referenced outside of
224+ * the Worker thread.
225+ */
226+ update ( ab : ArrayBuffer , opt_transferable ?: boolean | undefined ) : void ;
227+ /**
228+ * Terminates the Web Worker for this Unarchiver and returns immediately.
229+ */
230+ stop ( ) : void ;
231+ }
232+ export class UnzipperInternal extends Unarchiver {
233+ constructor ( arrayBuffer : any , createWorkerFn : any , options : any ) ;
234+ }
235+ export class UnrarrerInternal extends Unarchiver {
236+ constructor ( arrayBuffer : any , createWorkerFn : any , options : any ) ;
237+ }
238+ export class UntarrerInternal extends Unarchiver {
239+ constructor ( arrayBuffer : any , createWorkerFn : any , options : any ) ;
240+ }
241+ export type UnarchivedFile = {
242+ filename : string ;
243+ fileData : Uint8Array ;
244+ } ;
245+ //# sourceMappingURL=decompress-internal.d.ts.map
0 commit comments