1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-05 18:34:17 +02:00

For issue #44, remove the need for a pathToBitJS while unarchiving.

This commit is contained in:
Jeff Schiller 2023-12-12 17:18:42 -08:00
parent f71c893f63
commit d557383c9d
3 changed files with 13 additions and 17 deletions

View file

@ -9,6 +9,9 @@
* Copyright(c) 2021 Google Inc.
*/
// TODO(bitjs): Consider moving all this back into decompress.js to simplify the code now that
// the implementation isn't tied to Web Workers so heavily.
import { UnarchiveAppendEvent, UnarchiveErrorEvent, UnarchiveEvent, UnarchiveEventType,
UnarchiveExtractEvent, UnarchiveFinishEvent, UnarchiveInfoEvent,
UnarchiveProgressEvent, UnarchiveStartEvent } from './events.js';
@ -20,11 +23,12 @@ import { findMimeType } from '../file/sniffer.js';
* @property {Uint8Array} fileData
*/
// TODO: Remove pathToBitJS completely from this.
/**
* @typedef UnarchiverOptions
* @property {string} pathToBitJS The path to the bitjs folder.
* @property {boolean=} debug Set to true for verbose unarchiver logging.
* @property {ThreadingMode=} threadingMode The default is WEB_WORKER.
*/
/**
@ -72,13 +76,6 @@ export class Unarchiver extends EventTarget {
*/
this.connectPortFn_ = connectPortFn;
/**
* The path to the BitJS files.
* @type {string}
* @private
*/
this.pathToBitJS_ = options.pathToBitJS || '/';
/**
* @orivate
* @type {boolean}
@ -160,8 +157,7 @@ export class Unarchiver extends EventTarget {
const me = this;
const messageChannel = new MessageChannel();
this.port_ = messageChannel.port1;
this.connectPortFn_(this.pathToBitJS_,
this.getScriptFileName(), messageChannel.port2).then(() => {
this.connectPortFn_(this.getScriptFileName(), messageChannel.port2).then(() => {
this.port_.onerror = function (e) {
console.log('Impl error: message = ' + e.message);
throw e;