22 * Factory method that creates an unarchiver based on the byte signature found
33 * in the arrayBuffer.
44 * @param {ArrayBuffer } ab
5- * @param {Function(string):Worker } createWorkerFn A function that creates a Worker from a script file .
5+ * @param {Function(string):Promise<*> } connectPortFn A function that connects the impl port .
66 * @param {Object|string } options An optional object of options, or a string representing where
77 * the path to the unarchiver script files.
88 * @returns {Unarchiver }
99 */
10- export function getUnarchiverInternal ( ab : ArrayBuffer , createWorkerFn : any , options ?: any | string ) : Unarchiver ;
10+ export function getUnarchiverInternal ( ab : ArrayBuffer , connectPortFn : any , options ?: any | string ) : Unarchiver ;
1111export namespace UnarchiveEventType {
1212 const START : string ;
1313 const APPEND : string ;
@@ -118,27 +118,39 @@ export class Unarchiver extends EventTarget {
118118 /**
119119 * @param {ArrayBuffer } arrayBuffer The Array Buffer. Note that this ArrayBuffer must not be
120120 * referenced once it is sent to the Unarchiver, since it is marked as Transferable and sent
121- * to the Worker.
122- * @param {Function(string):Worker } createWorkerFn A function that creates a Worker from a script file.
123- * @param {Object|string } options An optional object of options, or a string representing where
124- * the BitJS files are located. The string version of this argument is deprecated.
125- * Available options:
126- * 'pathToBitJS': A string indicating where the BitJS files are located.
127- * 'debug': A boolean where true indicates that the archivers should log debug output.
121+ * to the decompress implementation.
122+ * @param {Function(string, MessagePort):Promise<*> } connectPortFn A function that takes a path
123+ * to a JS decompression implementation (unzip.js) and connects it to a MessagePort.
124+ * @param {UnarchiverOptions|string } options An optional object of options, or a string
125+ * representing where the BitJS files are located. The string version of this argument is
126+ * deprecated.
128127 */
129- constructor ( arrayBuffer : ArrayBuffer , createWorkerFn : any , options ?: any | string ) ;
128+ constructor ( arrayBuffer : ArrayBuffer , connectPortFn : any , options ?: UnarchiverOptions | string ) ;
129+ /**
130+ * A handle to the decompressor implementation context.
131+ * @type {Worker|* }
132+ * @private
133+ */
134+ private implRef_ ;
135+ /**
136+ * The client-side port that sends messages to, and receives messages from the
137+ * decompressor implementation.
138+ * @type {MessagePort }
139+ * @private
140+ */
141+ private port_ ;
130142 /**
131143 * The ArrayBuffer object.
132144 * @type {ArrayBuffer }
133145 * @protected
134146 */
135147 protected ab : ArrayBuffer ;
136148 /**
137- * A factory method that creates a Worker that does the unarchive work .
138- * @type {Function(string ): Worker }
149+ * A factory method that connects a port to the decompress implementation .
150+ * @type {Function(MessagePort ): Promise<*> }
139151 * @private
140152 */
141- private createWorkerFn_ ;
153+ private connectPortFn_ ;
142154 /**
143155 * The path to the BitJS files.
144156 * @type {string }
@@ -150,12 +162,6 @@ export class Unarchiver extends EventTarget {
150162 * @type {boolean }
151163 */
152164 debugMode_ : boolean ;
153- /**
154- * Private web worker initialized during start().
155- * @private
156- * @type {Worker }
157- */
158- private worker_ ;
159165 /**
160166 * This method must be overridden by the subclass to return the script filename.
161167 * @returns {string } The MIME type of the archive.
@@ -169,7 +175,7 @@ export class Unarchiver extends EventTarget {
169175 */
170176 protected getScriptFileName ( ) : string ;
171177 /**
172- * Create an UnarchiveEvent out of the object sent back from the Worker .
178+ * Create an UnarchiveEvent out of the object sent back from the implementation .
173179 * @param {Object } obj
174180 * @returns {UnarchiveEvent }
175181 * @private
@@ -181,37 +187,47 @@ export class Unarchiver extends EventTarget {
181187 * @param {Object } obj
182188 * @private
183189 */
184- private handleWorkerEvent_ ;
190+ private handlePortEvent_ ;
185191 /**
186- * Starts the unarchive in a separate Web Worker thread and returns immediately .
192+ * Starts the unarchive by connecting the ports and sending the first ArrayBuffer .
187193 */
188194 start ( ) : void ;
189195 /**
190- * Adds more bytes to the unarchiver's Worker thread .
196+ * Adds more bytes to the unarchiver.
191197 * @param {ArrayBuffer } ab The ArrayBuffer with more bytes in it. If opt_transferable is
192198 * set to true, this ArrayBuffer must not be referenced after calling update(), since it
193- * is marked as Transferable and sent to the Worker .
199+ * is marked as Transferable and sent to the implementation .
194200 * @param {boolean= } opt_transferable Optional boolean whether to mark this ArrayBuffer
195201 * as a Tranferable object, which means it can no longer be referenced outside of
196- * the Worker thread .
202+ * the implementation context .
197203 */
198204 update ( ab : ArrayBuffer , opt_transferable ?: boolean | undefined ) : void ;
199205 /**
200- * Terminates the Web Worker for this Unarchiver and returns immediately .
206+ * Closes the port to the decompressor implementation and terminates it .
201207 */
202208 stop ( ) : void ;
203209}
204210export class UnzipperInternal extends Unarchiver {
205- constructor ( arrayBuffer : any , createWorkerFn : any , options : any ) ;
211+ constructor ( arrayBuffer : any , connectPortFn : any , options : any ) ;
206212}
207213export class UnrarrerInternal extends Unarchiver {
208- constructor ( arrayBuffer : any , createWorkerFn : any , options : any ) ;
214+ constructor ( arrayBuffer : any , connectPortFn : any , options : any ) ;
209215}
210216export class UntarrerInternal extends Unarchiver {
211- constructor ( arrayBuffer : any , createWorkerFn : any , options : any ) ;
217+ constructor ( arrayBuffer : any , connectPortFn : any , options : any ) ;
212218}
213219export type UnarchivedFile = {
214220 filename : string ;
215221 fileData : Uint8Array ;
216222} ;
223+ export type UnarchiverOptions = {
224+ /**
225+ * The path to the bitjs folder.
226+ */
227+ pathToBitJS : string ;
228+ /**
229+ * Set to true for verbose unarchiver logging.
230+ */
231+ debug ?: boolean | undefined ;
232+ } ;
217233//# sourceMappingURL=decompress-internal.d.ts.map
0 commit comments