@@ -18,9 +18,17 @@ import { findMimeType } from '../file/sniffer.js';
1818 */
1919
2020/**
21- * @typedef DecompressorOptions
21+ * An enum for threading mode. Currently supporting only WebWorkers.
22+ */
23+ export const ThreadingMode = {
24+ WEB_WORKER : 'WEB_WORKER' ,
25+ }
26+
27+ /**
28+ * @typedef UnarchiverOptions
2229 * @property {string } pathToBitJS The path to the bitjs folder.
23- * @property {boolean= } debug Set to true for verbose decompressor logging.
30+ * @property {boolean= } debug Set to true for verbose unarchiver logging.
31+ * @property {ThreadingMode= } threadingMode The default is WEB_WORKER.
2432 */
2533
2634/**
@@ -172,14 +180,7 @@ export class UnarchiveExtractEvent extends UnarchiveEvent {
172180/**
173181 * Base class for all Unarchivers.
174182 */
175- export class Unarchiver extends EventTarget {
176- /**
177- * A handle to the decompressor implementation context.
178- * @type {Worker|* }
179- * @private
180- */
181- implRef_ ;
182-
183+ export class Unarchiver extends EventTarget {
183184 /**
184185 * The client-side port that sends messages to, and receives messages from the
185186 * decompressor implementation.
@@ -194,7 +195,7 @@ export class UnarchiveExtractEvent extends UnarchiveEvent {
194195 * to the decompress implementation.
195196 * @param {Function(string, MessagePort):Promise<*> } connectPortFn A function that takes a path
196197 * to a JS decompression implementation (unzip.js) and connects it to a MessagePort.
197- * @param {DecompressorOptions |string } options An optional object of options, or a string
198+ * @param {UnarchiverOptions |string } options An optional object of options, or a string
198199 * representing where the BitJS files are located. The string version of this argument is
199200 * deprecated.
200201 */
@@ -203,7 +204,7 @@ export class UnarchiveExtractEvent extends UnarchiveEvent {
203204
204205 if ( typeof options === 'string' ) {
205206 console . warn ( `Deprecated: Don't send a raw string to Unarchiver()` ) ;
206- console . warn ( ` send DecompressorOptions instead.` ) ;
207+ console . warn ( ` send UnarchiverOptions instead.` ) ;
207208 options = { 'pathToBitJS' : options } ;
208209 }
209210
@@ -310,10 +311,7 @@ export class UnarchiveExtractEvent extends UnarchiveEvent {
310311 const messageChannel = new MessageChannel ( ) ;
311312 this . port_ = messageChannel . port1 ;
312313 this . connectPortFn_ ( this . pathToBitJS_ ,
313- this . getScriptFileName ( ) ,
314- messageChannel . port2 ) . then ( ( implRef ) => {
315- this . implRef_ = implRef ;
316-
314+ this . getScriptFileName ( ) , messageChannel . port2 ) . then ( ( ) => {
317315 this . port_ . onerror = function ( e ) {
318316 console . log ( 'Impl error: message = ' + e . message ) ;
319317 throw e ;
@@ -368,12 +366,6 @@ export class UnarchiveExtractEvent extends UnarchiveEvent {
368366 this . port_ . close ( ) ;
369367 this . port_ = null ;
370368 }
371- if ( this . implRef_ ) {
372- if ( this . implRef_ instanceof Worker ) {
373- this . implRef_ . terminate ( ) ;
374- this . implRef_ = null ;
375- }
376- }
377369 }
378370}
379371
0 commit comments